@copilotkit/core 2.0.0-rc.26 → 2.0.0-rc.28

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/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_viewport = require('./viewport-B0DGmyta.cjs');
2
+ const require_viewport = require('./viewport-GwjIosf7.cjs');
3
3
  const require_chat_configuration = require('./chat-configuration.cjs');
4
4
  let _tanstack_pacer = require("@tanstack/pacer");
5
5
  let _ag_ui_client = require("@ag-ui/client");
@@ -9598,12 +9598,15 @@ function toolCallKey(entry) {
9598
9598
  * Holds the renderers of one provider and tells subscribers when a list
9599
9599
  * changes.
9600
9600
  *
9601
- * Tool-call renderers come from two places. Prop renderers are the list the
9601
+ * Tool-call renderers come from three places. Prop renderers are the list the
9602
9602
  * provider was given (`setPropToolCalls`). Hook renderers are added one at a
9603
- * time (`addHookToolCall`), for example by `useRenderTool`. Each renderer has
9604
- * a key made of its `agentId` and `name`. A hook renderer replaces a prop
9605
- * renderer with the same key, and a later hook renderer replaces an earlier
9606
- * one with the same key, so the latest registration wins.
9603
+ * time (`addHookToolCall`), for example by `useRenderTool`. Built-in
9604
+ * renderers are added by CopilotKit features such as A2UI
9605
+ * (`addBuiltInToolCall`). Each renderer has a key made of its `agentId` and
9606
+ * `name`. A hook renderer replaces a prop renderer with the same key, and a
9607
+ * later hook renderer replaces an earlier one with the same key, so the
9608
+ * latest registration wins. A built-in renderer shows only when no prop or
9609
+ * hook renderer has its key, so an app can always replace it.
9607
9610
  *
9608
9611
  * Fields are TypeScript `private`, not `#private`, so the registry keeps
9609
9612
  * working behind a Vue reactive proxy.
@@ -9627,6 +9630,7 @@ function toolCallKey(entry) {
9627
9630
  var ɵRendererRegistry = class {
9628
9631
  _propToolCalls;
9629
9632
  _hookToolCalls = /* @__PURE__ */ new Map();
9633
+ _builtInToolCalls = /* @__PURE__ */ new Map();
9630
9634
  _mergedToolCalls = null;
9631
9635
  _activity;
9632
9636
  _custom;
@@ -9641,16 +9645,18 @@ var ɵRendererRegistry = class {
9641
9645
  return this._propToolCalls;
9642
9646
  }
9643
9647
  /**
9644
- * Every tool-call renderer: prop renderers, then hook renderers, with one
9645
- * entry per `agentId` + `name` key. A prop renderer that a hook renderer
9646
- * replaces keeps its position in the list.
9648
+ * Every tool-call renderer: prop renderers, then hook renderers, then
9649
+ * built-in renderers, with one entry per `agentId` + `name` key. A prop
9650
+ * renderer that a hook renderer replaces keeps its position in the list. A
9651
+ * built-in renderer is left out when a prop or hook renderer has its key.
9647
9652
  */
9648
9653
  get toolCalls() {
9649
- if (this._hookToolCalls.size === 0) return this._propToolCalls;
9654
+ if (this._hookToolCalls.size === 0 && this._builtInToolCalls.size === 0) return this._propToolCalls;
9650
9655
  if (this._mergedToolCalls) return this._mergedToolCalls;
9651
9656
  const merged = /* @__PURE__ */ new Map();
9652
9657
  for (const entry of this._propToolCalls) merged.set(toolCallKey(entry), entry);
9653
9658
  for (const [key, entry] of this._hookToolCalls) merged.set(key, entry);
9659
+ for (const [key, entry] of this._builtInToolCalls) if (!merged.has(key)) merged.set(key, entry);
9654
9660
  this._mergedToolCalls = [...merged.values()];
9655
9661
  return this._mergedToolCalls;
9656
9662
  }
@@ -9705,6 +9711,55 @@ var ɵRendererRegistry = class {
9705
9711
  this.emit("toolCalls");
9706
9712
  }
9707
9713
  /**
9714
+ * Remove the prop and hook renderers for `name` and `agentId`. Built-in
9715
+ * renderers stay. Does nothing when no such renderer exists.
9716
+ *
9717
+ * @param name - The tool name.
9718
+ * @param agentId - The agent the renderers belong to. Omit it for
9719
+ * renderers with no `agentId`.
9720
+ */
9721
+ removeToolCall(name, agentId) {
9722
+ const key = toolCallKey({
9723
+ name,
9724
+ agentId
9725
+ });
9726
+ const props = this._propToolCalls.filter((entry) => toolCallKey(entry) !== key);
9727
+ if (!this._hookToolCalls.delete(key) && props.length === this._propToolCalls.length) return;
9728
+ this._propToolCalls = props;
9729
+ this._mergedToolCalls = null;
9730
+ this.emit("toolCalls");
9731
+ }
9732
+ /**
9733
+ * Add a built-in renderer, for a tool that a CopilotKit feature owns (for
9734
+ * example the A2UI render tool). Prop and hook renderers with the same
9735
+ * `agentId` and `name` win over it, and setting the prop renderers never
9736
+ * removes it.
9737
+ *
9738
+ * @param entry - The renderer to add. It replaces an earlier built-in
9739
+ * renderer with the same key.
9740
+ * @returns A function that removes this renderer, if it is still the
9741
+ * built-in renderer for its key. Calling it more than once does nothing.
9742
+ *
9743
+ * @example
9744
+ * ```ts
9745
+ * const remove = registry.addBuiltInToolCall({ name: "render_a2ui", render: Nothing });
9746
+ * // when the feature turns off
9747
+ * remove();
9748
+ * ```
9749
+ */
9750
+ addBuiltInToolCall(entry) {
9751
+ const key = toolCallKey(entry);
9752
+ this._builtInToolCalls.set(key, entry);
9753
+ this._mergedToolCalls = null;
9754
+ this.emit("toolCalls");
9755
+ return () => {
9756
+ if (this._builtInToolCalls.get(key) !== entry) return;
9757
+ this._builtInToolCalls.delete(key);
9758
+ this._mergedToolCalls = null;
9759
+ this.emit("toolCalls");
9760
+ };
9761
+ }
9762
+ /**
9708
9763
  * Replace the activity message renderers.
9709
9764
  *
9710
9765
  * @param renderers - The renderers. The registry keeps a copy.
@@ -10616,6 +10671,229 @@ function ɵtoolRendererShapeChanged(previous, next) {
10616
10671
  for (const key of previousKeys) if (!nextKeys.has(key)) return true;
10617
10672
  return false;
10618
10673
  }
10674
+ function isToolRendererShape(value) {
10675
+ return typeof value === "object" && value !== null;
10676
+ }
10677
+ /**
10678
+ * @internal The warning for a provider array prop that changed after mount,
10679
+ * or `undefined` when the change is fine.
10680
+ *
10681
+ * `renderToolCalls` warns only when its shape changes (see
10682
+ * {@link ɵtoolRendererShapeChanged}), so new render closures for the same
10683
+ * tools are fine. Every other prop warns on a new array.
10684
+ *
10685
+ * @param prop - Which prop changed.
10686
+ * @param initial - The value at mount. `undefined` counts as an empty list.
10687
+ * @param next - The new value.
10688
+ *
10689
+ * @example
10690
+ * const warning = ɵstableArrayPropWarning("frontendTools", initial, next);
10691
+ * if (warning) console.error(warning);
10692
+ */
10693
+ function ɵstableArrayPropWarning(prop, initial, next) {
10694
+ if (next === initial) return void 0;
10695
+ if (prop === "renderToolCalls" && !ɵtoolRendererShapeChanged((initial ?? []).filter(isToolRendererShape), (next ?? []).filter(isToolRendererShape))) return;
10696
+ return ɵSTABLE_ARRAY_WARNINGS[prop];
10697
+ }
10698
+ /**
10699
+ * @internal Build the tool list and the tool-call renderer list of a
10700
+ * provider from its props.
10701
+ *
10702
+ * - Tools: `frontendTools`, then `builtInFrontendTools`, then one tool per
10703
+ * `humanInTheLoop` entry (see `ɵbuildHumanInTheLoopTool`).
10704
+ * - Renderers: `renderToolCalls`, then one renderer per frontend tool with a
10705
+ * `render`, then one per human-in-the-loop entry with a `render`. A tool
10706
+ * renderer keeps the tool's `agentId`. A frontend tool without
10707
+ * `parameters` gets a renderer only when it is the `"*"` wildcard, which
10708
+ * then accepts any arguments.
10709
+ *
10710
+ * @example
10711
+ * const { tools, renderToolCalls } = ɵassembleProviderRegistry({
10712
+ * renderToolCalls: props.renderToolCalls,
10713
+ * frontendTools: props.frontendTools,
10714
+ * humanInTheLoop: props.humanInTheLoop,
10715
+ * humanInTheLoopRegistry: () => core.ɵhumanInTheLoop,
10716
+ * wrapHumanInTheLoopRender: (Render, tool, registry) => (props) =>
10717
+ * <Render {...ɵhitlRenderProps(props, tool, registry())} />,
10718
+ * });
10719
+ */
10720
+ function ɵassembleProviderRegistry(input) {
10721
+ const humanInTheLoop = ɵassembleHumanInTheLoop(input);
10722
+ return {
10723
+ tools: ɵassembleProviderTools({
10724
+ ...input,
10725
+ humanInTheLoop
10726
+ }),
10727
+ renderToolCalls: ɵassembleProviderToolRenderers({
10728
+ ...input,
10729
+ humanInTheLoop
10730
+ })
10731
+ };
10732
+ }
10733
+ /**
10734
+ * @internal The human-in-the-loop part of {@link ɵassembleProviderRegistry}:
10735
+ * one tool per `humanInTheLoop` entry, and one renderer per entry with a
10736
+ * `render`.
10737
+ *
10738
+ * Each call wraps every render again, and a new wrapper is a new component
10739
+ * type to React and Vue, so the card remounts. Adapters memoize this result
10740
+ * on `humanInTheLoop` alone, and pass it to {@link ɵassembleProviderTools}
10741
+ * and {@link ɵassembleProviderToolRenderers}.
10742
+ */
10743
+ function ɵassembleHumanInTheLoop(input) {
10744
+ const registryInput = input.humanInTheLoopRegistry;
10745
+ const registry = typeof registryInput === "function" ? registryInput : () => registryInput;
10746
+ const tools = [];
10747
+ const renderToolCalls = [];
10748
+ for (const entry of input.humanInTheLoop ?? []) {
10749
+ const { render, ...config } = entry;
10750
+ tools.push(ɵbuildHumanInTheLoopTool(config, registry));
10751
+ if (!render) continue;
10752
+ renderToolCalls.push({
10753
+ name: entry.name,
10754
+ args: entry.parameters,
10755
+ render: input.wrapHumanInTheLoopRender(render, entry, registry),
10756
+ ...entry.agentId && { agentId: entry.agentId }
10757
+ });
10758
+ }
10759
+ return {
10760
+ tools,
10761
+ renderToolCalls
10762
+ };
10763
+ }
10764
+ /**
10765
+ * @internal The tool list of {@link ɵassembleProviderRegistry}:
10766
+ * `frontendTools`, then `builtInFrontendTools`, then the human-in-the-loop
10767
+ * tools. It does not read `renderToolCalls`.
10768
+ */
10769
+ function ɵassembleProviderTools(input) {
10770
+ return [
10771
+ ...input.frontendTools ?? [],
10772
+ ...input.builtInFrontendTools ?? [],
10773
+ ...input.humanInTheLoop.tools
10774
+ ];
10775
+ }
10776
+ /**
10777
+ * @internal The renderer list of {@link ɵassembleProviderRegistry}:
10778
+ * `renderToolCalls`, then one renderer per frontend tool with a `render`,
10779
+ * then the human-in-the-loop renderers, which keep their identity.
10780
+ */
10781
+ function ɵassembleProviderToolRenderers(input) {
10782
+ const renderToolCalls = [...input.renderToolCalls ?? []];
10783
+ for (const tool of [...input.frontendTools ?? [], ...input.builtInFrontendTools ?? []]) {
10784
+ if (!tool.render) continue;
10785
+ const args = tool.parameters ?? (tool.name === "*" ? _copilotkit_shared.ɵanySchema : void 0);
10786
+ if (!args) continue;
10787
+ renderToolCalls.push({
10788
+ name: tool.name,
10789
+ args,
10790
+ render: tool.render,
10791
+ ...tool.agentId && { agentId: tool.agentId }
10792
+ });
10793
+ }
10794
+ renderToolCalls.push(...input.humanInTheLoop.renderToolCalls);
10795
+ return renderToolCalls;
10796
+ }
10797
+ /**
10798
+ * @internal Whether the provider turns on A2UI: its built-in renderers and
10799
+ * its agent context.
10800
+ *
10801
+ * A2UI is active when the runtime enables it or the provider has a catalog.
10802
+ * With `requireCatalog`, only a catalog turns it on. `missingCatalog` is
10803
+ * true when the runtime enables A2UI but `requireCatalog` keeps it off;
10804
+ * the provider should tell the developer to configure a catalog.
10805
+ *
10806
+ * @example
10807
+ * ɵresolveA2UIActivation({ runtimeEnabled: true, hasCatalog: false });
10808
+ * // { active: true, missingCatalog: false }
10809
+ * ɵresolveA2UIActivation({ runtimeEnabled: true, hasCatalog: false, requireCatalog: true });
10810
+ * // { active: false, missingCatalog: true }
10811
+ */
10812
+ function ɵresolveA2UIActivation({ runtimeEnabled, hasCatalog, requireCatalog = false }) {
10813
+ if (requireCatalog) return {
10814
+ active: hasCatalog,
10815
+ missingCatalog: runtimeEnabled && !hasCatalog
10816
+ };
10817
+ return {
10818
+ active: runtimeEnabled || hasCatalog,
10819
+ missingCatalog: false
10820
+ };
10821
+ }
10822
+ /**
10823
+ * @internal The provider's activity renderer list: the app's renderers, then
10824
+ * the A2UI renderer, then the other built-in renderers. Missing entries are
10825
+ * left out.
10826
+ *
10827
+ * @example
10828
+ * ɵassembleActivityRenderers({
10829
+ * app: props.renderActivityMessages,
10830
+ * a2ui: a2uiActive ? a2uiRenderer : undefined,
10831
+ * builtIns: [mcpAppsRenderer, openGenUIActive && openGenUIRenderer],
10832
+ * });
10833
+ */
10834
+ function ɵassembleActivityRenderers({ app = [], a2ui, builtIns = [] }) {
10835
+ const renderers = [...app];
10836
+ if (a2ui) renderers.push(a2ui);
10837
+ for (const renderer of builtIns) if (renderer) renderers.push(renderer);
10838
+ return renderers;
10839
+ }
10840
+
10841
+ //#endregion
10842
+ //#region src/core/frontend-tool-registration.ts
10843
+ function toolKey(tool) {
10844
+ return `${tool.agentId ?? ""}:${tool.name}`;
10845
+ }
10846
+ /**
10847
+ * @internal Register frontend tools from a hook (`useFrontendTool`,
10848
+ * `useFrontendTools`) and their renderers.
10849
+ *
10850
+ * - Tools with the same `name` and `agentId` in `tools` collapse to the last
10851
+ * one, with a warning.
10852
+ * - A tool that hides an already registered tool (a provider tool or another
10853
+ * hook) logs a warning. Core runs the newest registration until it is
10854
+ * removed, and then the hidden tool runs again.
10855
+ * - A tool with a `render` gets a renderer through `addRenderer`, also when
10856
+ * it has no `parameters` (for example a confirm dialog). The returned
10857
+ * function does not remove renderers, so past calls still render in the
10858
+ * chat history.
10859
+ *
10860
+ * @param core - The core to register the tools with.
10861
+ * @param tools - The tools, in order.
10862
+ * @param addRenderer - Adds a hook renderer in the framework's registry.
10863
+ * @returns A function that removes exactly the tools this call registered.
10864
+ *
10865
+ * @example
10866
+ * const unregister = ɵregisterFrontendTools(core, [tool], (renderer) =>
10867
+ * core.addHookRenderToolCall(renderer),
10868
+ * );
10869
+ * // on unmount
10870
+ * unregister();
10871
+ */
10872
+ function ɵregisterFrontendTools(core, tools, addRenderer) {
10873
+ const deduped = /* @__PURE__ */ new Map();
10874
+ for (const tool of tools) {
10875
+ const key = toolKey(tool);
10876
+ if (deduped.has(key)) console.warn(`Tool '${tool.name}' is listed more than once for agent '${tool.agentId || "global"}' in the same useFrontendTools call. Using the last entry.`);
10877
+ deduped.set(key, tool);
10878
+ }
10879
+ const unregisters = [];
10880
+ for (const tool of deduped.values()) {
10881
+ if (core.getTool({
10882
+ toolName: tool.name,
10883
+ agentId: tool.agentId
10884
+ })) console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
10885
+ unregisters.push(core.addTool(tool));
10886
+ if (tool.render) addRenderer({
10887
+ name: tool.name,
10888
+ args: tool.parameters,
10889
+ agentId: tool.agentId,
10890
+ render: tool.render
10891
+ });
10892
+ }
10893
+ return () => {
10894
+ for (const unregister of unregisters) unregister();
10895
+ };
10896
+ }
10619
10897
 
10620
10898
  //#endregion
10621
10899
  //#region src/utils/markdown/complete-partial-markdown.ts
@@ -10841,10 +11119,11 @@ const threadDomainEvents = createActionGroup("Thread Domain", {
10841
11119
  threadDeleted: props()
10842
11120
  });
10843
11121
  function sortThreadsByRecency(threads) {
10844
- return [...threads].sort((left, right) => {
10845
- const leftKey = left.lastRunAt ?? left.updatedAt ?? left.createdAt;
10846
- return (right.lastRunAt ?? right.updatedAt ?? right.createdAt).localeCompare(leftKey);
10847
- });
11122
+ return [...threads].sort((left, right) => recencyOf(right) - recencyOf(left));
11123
+ }
11124
+ function recencyOf(thread) {
11125
+ const time = Date.parse(thread.lastRunAt ?? thread.updatedAt ?? thread.createdAt);
11126
+ return Number.isNaN(time) ? Number.NEGATIVE_INFINITY : time;
10848
11127
  }
10849
11128
  function upsertThread(threads, thread) {
10850
11129
  const existingIndex = threads.findIndex((item) => item.id === thread.id);
@@ -14163,6 +14442,31 @@ function ɵresolveCustomMessageRenderContext(renderers, chatAgentId) {
14163
14442
  renderers: ɵresolveCustomMessageRenderers(renderers, agentId)
14164
14443
  };
14165
14444
  }
14445
+ /** The run that produced a message, else the thread's latest run. */
14446
+ function resolveMessageRunId(core, agentId, threadId, messageId) {
14447
+ return core.getRunIdForMessage(agentId, threadId, messageId) ?? core.getRunIdsForThread(agentId, threadId).at(-1);
14448
+ }
14449
+ /**
14450
+ * The agent state of the run that produced a message: the same value as
14451
+ * {@link ɵgetCustomMessageRenderProps}'s `stateSnapshot`, without the work of
14452
+ * placing the message in its run. Adapters use it to tell when a custom
14453
+ * message renderer must draw again.
14454
+ *
14455
+ * It clones the run state on each call. With no run at all it returns
14456
+ * `undefined`.
14457
+ *
14458
+ * @example
14459
+ * ```ts
14460
+ * const snapshot = ɵgetMessageRunStateSnapshot(core, {
14461
+ * agentId, threadId, messageId: message.id,
14462
+ * });
14463
+ * ```
14464
+ */
14465
+ function ɵgetMessageRunStateSnapshot(core, params) {
14466
+ const { agentId, threadId, messageId } = params;
14467
+ const runId = resolveMessageRunId(core, agentId, threadId, messageId);
14468
+ return runId === void 0 ? void 0 : core.getStateByRun(agentId, threadId, runId);
14469
+ }
14166
14470
  /**
14167
14471
  * The props a custom message renderer gets for one message: the run that
14168
14472
  * produced it, its place in the conversation and in the run, and the agent
@@ -14191,7 +14495,7 @@ function ɵresolveCustomMessageRenderContext(renderers, chatAgentId) {
14191
14495
  */
14192
14496
  function ɵgetCustomMessageRenderProps(core, params) {
14193
14497
  const { agentId, threadId, agent, message, position } = params;
14194
- const resolvedRunId = core.getRunIdForMessage(agentId, threadId, message.id) ?? core.getRunIdsForThread(agentId, threadId).at(-1);
14498
+ const resolvedRunId = resolveMessageRunId(core, agentId, threadId, message.id);
14195
14499
  const messages = agent?.messages ?? [];
14196
14500
  const messageIdsInRun = resolvedRunId === void 0 ? [message.id] : messages.filter((candidate) => core.getRunIdForMessage(agentId, threadId, candidate.id) === resolvedRunId).map((candidate) => candidate.id);
14197
14501
  const messageIndex = Math.max(0, messages.findIndex((candidate) => candidate.id === message.id));
@@ -14302,7 +14606,7 @@ function ɵbuildToolCallRenderProps(toolCall, toolMessage, options) {
14302
14606
  if (toolMessage !== void 0) return {
14303
14607
  ...base,
14304
14608
  status: ToolCallStatus.Complete,
14305
- result: (0, _ag_ui_core.contentToText)(toolMessage.content)
14609
+ result: toolResultText(toolMessage)
14306
14610
  };
14307
14611
  if (status === ToolCallStatus.Executing) return {
14308
14612
  ...base,
@@ -14315,6 +14619,35 @@ function ɵbuildToolCallRenderProps(toolCall, toolMessage, options) {
14315
14619
  result: void 0
14316
14620
  };
14317
14621
  }
14622
+ const warnedToolMessages = /* @__PURE__ */ new WeakSet();
14623
+ /**
14624
+ * The tool result as renderers take it, `result: string`. AG-UI 1.0 lets a
14625
+ * tool result carry content parts: renderers get the text parts, and the
14626
+ * message keeps the media.
14627
+ *
14628
+ * Other content only comes from a producer that skipped validation: restored
14629
+ * thread history, a non-SSE transport, or app code casting on `addMessage`.
14630
+ * It is serialized as JSON, not dropped, because an empty string is a
14631
+ * legitimate tool result and a dropped one would look the same. `null` gives
14632
+ * `""`. It warns once per message outside production, and never throws, also
14633
+ * not on circular content.
14634
+ */
14635
+ function toolResultText(toolMessage) {
14636
+ const content = toolMessage.content;
14637
+ if (typeof content === "string") return content;
14638
+ if (Array.isArray(content) && content.every(isContentPart)) return (0, _ag_ui_core.contentToText)(content);
14639
+ let serialized = "";
14640
+ if (content !== null && content !== void 0) try {
14641
+ serialized = JSON.stringify(content) ?? Object.prototype.toString.call(content);
14642
+ } catch {
14643
+ serialized = Object.prototype.toString.call(content);
14644
+ }
14645
+ if (process.env.NODE_ENV !== "production" && !warnedToolMessages.has(toolMessage)) {
14646
+ warnedToolMessages.add(toolMessage);
14647
+ console.warn(`[CopilotChat] Tool message for tool call "${toolMessage.toolCallId}" had content outside the AG-UI protocol (${content === null ? "null" : typeof content}), but renderers receive \`result: string\`. Rendering a serialized form instead of dropping it: ${serialized === "" ? "<empty>" : serialized}`);
14648
+ }
14649
+ return serialized;
14650
+ }
14318
14651
  /**
14319
14652
  * The agent to look up tool-call renderers for: the chat's agent, else the
14320
14653
  * agent that wrote the message, else the default agent.
@@ -14407,6 +14740,41 @@ function ɵcomponentToolDescription(name, description) {
14407
14740
  const prefix = `Use this tool to display the "${name}" component in the chat. This tool renders a visual UI component for the user.`;
14408
14741
  return description ? `${prefix}\n\n${description}` : prefix;
14409
14742
  }
14743
+ const warnedUnknownStatuses = /* @__PURE__ */ new Set();
14744
+ /**
14745
+ * The status the default tool-call renderer shows. A status this version
14746
+ * does not know (a newer runtime could send one) reads `"inProgress"`, and
14747
+ * logs one warning per distinct value.
14748
+ *
14749
+ * @param status - A `ToolCallStatus`, or any framework's spelling of one.
14750
+ */
14751
+ function ɵtoDefaultToolCallStatus(status) {
14752
+ const key = String(status);
14753
+ const normalized = ɵnormalizeToolCallStatus(key);
14754
+ if (normalized !== "unknown") return normalized;
14755
+ if (!warnedUnknownStatuses.has(key)) {
14756
+ warnedUnknownStatuses.add(key);
14757
+ console.warn(`[CopilotKit] Unknown ToolCallStatus "${key}" in default tool-call renderer; falling back to "inProgress".`);
14758
+ }
14759
+ return "inProgress";
14760
+ }
14761
+ /**
14762
+ * Turns the props a `"*"` renderer is called with into the documented
14763
+ * {@link ɵDefaultToolCallRenderProps}: `args` becomes `parameters`, and the
14764
+ * status goes through {@link ɵtoDefaultToolCallStatus}. Props already in the
14765
+ * documented shape stay as they are.
14766
+ *
14767
+ * @param raw - The props the renderer was called with.
14768
+ */
14769
+ function ɵadaptDefaultToolCallRenderProps(raw) {
14770
+ return {
14771
+ name: raw.name,
14772
+ toolCallId: raw.toolCallId,
14773
+ parameters: raw.parameters !== void 0 ? raw.parameters : raw.args,
14774
+ status: ɵtoDefaultToolCallStatus(raw.status),
14775
+ result: raw.result
14776
+ };
14777
+ }
14410
14778
 
14411
14779
  //#endregion
14412
14780
  //#region src/chat/tool-call-layout.ts
@@ -15301,7 +15669,7 @@ var ɵAttachmentQueue = class {
15301
15669
  value: await (0, _copilotkit_shared.readFileAsBase64)(file),
15302
15670
  mimeType: file.type
15303
15671
  };
15304
- const thumbnail = placeholder.type === "video" ? await (0, _copilotkit_shared.generateVideoThumbnail)(file) : void 0;
15672
+ const thumbnail = placeholder.type === "video" ? await (0, _copilotkit_shared.generateVideoThumbnail)(file).catch(() => {}) : void 0;
15305
15673
  const isStillQueued = this.attachments.some((attachment) => attachment.id === placeholder.id);
15306
15674
  if (this.disposed || !isStillQueued) return;
15307
15675
  this.update(this.attachments.map((attachment) => attachment.id === placeholder.id ? {
@@ -16029,6 +16397,287 @@ var ɵThreadSwitchCoordinator = class {
16029
16397
  }
16030
16398
  };
16031
16399
 
16400
+ //#endregion
16401
+ //#region src/chat/chat-connection.ts
16402
+ /**
16403
+ * Calls `handler` for every core error that belongs to `agentId`, and for
16404
+ * errors that name no agent. Core awaits its subscribers, so the handler's
16405
+ * promise is not awaited: a slow handler must not hold up the run that
16406
+ * reported the error. Returns the unsubscribe.
16407
+ */
16408
+ function ɵsubscribeToAgentErrors(core, agentId, handler) {
16409
+ const subscription = core.subscribe({ onError: (event) => {
16410
+ const eventAgentId = event.context.agentId;
16411
+ if (eventAgentId && eventAgentId !== agentId) return;
16412
+ handler({
16413
+ error: event.error,
16414
+ code: event.code,
16415
+ context: event.context
16416
+ });
16417
+ } });
16418
+ return () => subscription.unsubscribe();
16419
+ }
16420
+ /**
16421
+ * The thread a chat shows when no caller picked one: a locally minted id.
16422
+ * The id stays the same while no thread is provided, and a new one is minted
16423
+ * each time a provided thread goes away, so removing a thread starts a fresh
16424
+ * one instead of returning to an older fresh thread.
16425
+ *
16426
+ * {@link resolve} returns the same id for the same input, so a framework can
16427
+ * call it while it renders.
16428
+ */
16429
+ var ɵFreshThreadId = class {
16430
+ generated = (0, _copilotkit_shared.randomUUID)();
16431
+ lastProvided;
16432
+ /** `providedThreadId` when set, else the fresh thread's id. */
16433
+ resolve(providedThreadId) {
16434
+ if (providedThreadId) {
16435
+ this.lastProvided = providedThreadId;
16436
+ return providedThreadId;
16437
+ }
16438
+ if (this.lastProvided !== void 0) {
16439
+ this.lastProvided = void 0;
16440
+ this.generated = (0, _copilotkit_shared.randomUUID)();
16441
+ }
16442
+ return this.generated;
16443
+ }
16444
+ };
16445
+ /**
16446
+ * Whether `agent` can load a thread from its backend: it overrides AG-UI's
16447
+ * `connect` or `connectAgent`. The base versions only throw
16448
+ * `AGUIConnectNotImplementedError`.
16449
+ */
16450
+ function ɵimplementsConnect(agent) {
16451
+ const base = _ag_ui_client.AbstractAgent.prototype;
16452
+ return Reflect.get(agent, "connect") !== Reflect.get(base, "connect") || Reflect.get(agent, "connectAgent") !== Reflect.get(base, "connectAgent");
16453
+ }
16454
+ function defaultAfterPaint(callback) {
16455
+ if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => callback());
16456
+ else setTimeout(callback, 16);
16457
+ }
16458
+ /**
16459
+ * The connect side of a chat: keeps the agent on the thread the chat shows
16460
+ * and loads that thread from the backend. Owns the rules all three
16461
+ * frameworks share:
16462
+ *
16463
+ * - Only a thread a caller picked (explicit) is connected. A locally minted
16464
+ * thread has never reached the backend, so `/connect` would 404.
16465
+ * - A connect waits for the previous thread's teardown, and a send waits for
16466
+ * the connect ({@link threads}).
16467
+ * - An `HttpAgent` connect gets its own `AbortController`, aborted when the
16468
+ * chat leaves the thread before the connect settles.
16469
+ * - Leaving a thread detaches the agent's run only while that run is the
16470
+ * connect's own. A run the user started after the connect keeps running.
16471
+ * - An agent that does not implement connect is not connected, and its
16472
+ * thread counts as loaded at once. On the agent's first thread its
16473
+ * messages stay, so a message sent right after mount survives. A move
16474
+ * from another thread detaches the old thread's run and empties the agent,
16475
+ * as a connect would. An `AGUIConnectNotImplementedError` from a connect
16476
+ * is not an error.
16477
+ * - A failed connect of an Inspector override ends the override.
16478
+ * - The chat shows "connecting" for an explicit thread until its connect has
16479
+ * settled and painted ({@link isConnecting}).
16480
+ *
16481
+ * @example
16482
+ * ```ts
16483
+ * const connection = new ɵChatConnection({ core, onInspectorOverrideFailed });
16484
+ * const handle = connection.open({ agent, threadId, explicit: true });
16485
+ * connection.isConnecting({ threadId, explicit: true }); // true until settled
16486
+ * // cleanup:
16487
+ * handle.release();
16488
+ * ```
16489
+ */
16490
+ var ɵChatConnection = class {
16491
+ /** The thread coordinator; a chat submitter waits on its connections. */
16492
+ threads;
16493
+ snapshot = { connectedThreadId: null };
16494
+ listeners = /* @__PURE__ */ new Set();
16495
+ afterPaint;
16496
+ /** The thread each agent showed last, to tell a thread switch from a first open. */
16497
+ openedThreads = /* @__PURE__ */ new WeakMap();
16498
+ constructor(options) {
16499
+ this.options = options;
16500
+ this.threads = new ɵThreadSwitchCoordinator(options.core);
16501
+ this.afterPaint = options.afterPaint ?? defaultAfterPaint;
16502
+ }
16503
+ /** The last connected thread. Keeps its identity until it changes. */
16504
+ getSnapshot() {
16505
+ return this.snapshot;
16506
+ }
16507
+ /** Calls `listener` after every snapshot change. Returns the unsubscribe. */
16508
+ subscribe(listener) {
16509
+ this.listeners.add(listener);
16510
+ return () => {
16511
+ this.listeners.delete(listener);
16512
+ };
16513
+ }
16514
+ /**
16515
+ * Whether the chat waits for `threadId` to load: an explicit thread whose
16516
+ * connect has not settled yet. Pure, so a framework can call it while it
16517
+ * renders, before {@link open} has run for a new thread.
16518
+ */
16519
+ isConnecting({ threadId, explicit }) {
16520
+ return explicit && this.snapshot.connectedThreadId !== threadId;
16521
+ }
16522
+ /**
16523
+ * Shows a thread: selects it on the coordinator (pinning `agent.threadId`)
16524
+ * and, for an explicit thread, connects it. Release the handle when the
16525
+ * chat moves on or unmounts.
16526
+ */
16527
+ open(input, hooks = {}) {
16528
+ const previousThreadId = this.openedThreads.get(input.agent);
16529
+ const selection = this.threads.select(input);
16530
+ this.openedThreads.set(selection.agent, selection.threadId);
16531
+ if (!selection.shouldConnect) return {
16532
+ selection,
16533
+ release: () => selection.release()
16534
+ };
16535
+ if (!ɵimplementsConnect(selection.agent)) {
16536
+ if (previousThreadId !== void 0 && previousThreadId !== input.threadId) this.clearSwitchedThread(selection);
16537
+ this.setConnectedThreadId(selection.threadId);
16538
+ return {
16539
+ selection,
16540
+ release: () => selection.release()
16541
+ };
16542
+ }
16543
+ return this.connect(selection, hooks);
16544
+ }
16545
+ /**
16546
+ * Runs `connect` as a connection of the current thread, so a send waits for
16547
+ * it. With no current thread it just runs, and a failure is logged.
16548
+ */
16549
+ track(connect) {
16550
+ const selection = this.threads.current;
16551
+ if (selection) return this.threads.trackConnection(selection, connect);
16552
+ return connect().then(() => {}).catch((error) => {
16553
+ console.error("CopilotChat: connection failed", error);
16554
+ });
16555
+ }
16556
+ /** Releases the current thread and drops the listeners. */
16557
+ dispose() {
16558
+ this.threads.dispose();
16559
+ this.listeners.clear();
16560
+ }
16561
+ /**
16562
+ * What a connect does when an agent without `connect` moves to another
16563
+ * thread: detaches the old thread's run and empties the agent. The reset
16564
+ * runs again once the detach and every earlier teardown finished, and a
16565
+ * send waits for it, so nothing of the old thread lands on the new one.
16566
+ */
16567
+ clearSwitchedThread(selection) {
16568
+ const { agent, threadId } = selection;
16569
+ const reset = () => {
16570
+ if (selection.isCurrent) ɵresetAgentThreadBaseline(agent, { cursorThreadId: threadId });
16571
+ };
16572
+ this.threads.detach(agent);
16573
+ reset();
16574
+ this.threads.trackConnection(selection, async () => {
16575
+ await this.threads.whenTornDown();
16576
+ reset();
16577
+ });
16578
+ }
16579
+ setConnectedThreadId(threadId) {
16580
+ if (this.snapshot.connectedThreadId === threadId) return;
16581
+ this.snapshot = { connectedThreadId: threadId };
16582
+ for (const listener of this.listeners) listener();
16583
+ }
16584
+ connect(selection, hooks) {
16585
+ const { core, onInspectorOverrideFailed } = this.options;
16586
+ const { agent, threadId, inspectorRequestId } = selection;
16587
+ const controller = new AbortController();
16588
+ let ownership;
16589
+ let released = false;
16590
+ let settled = false;
16591
+ const failInspectorOverride = () => {
16592
+ if (inspectorRequestId) onInspectorOverrideFailed?.(inspectorRequestId);
16593
+ };
16594
+ const inspectorErrors = inspectorRequestId ? core.subscribe({ onError: (event) => {
16595
+ if (event.code === CopilotKitCoreErrorCode.AGENT_CONNECT_FAILED && event.context.agentId === agent.agentId && event.context.threadId === threadId && !released) failInspectorOverride();
16596
+ } }) : void 0;
16597
+ hooks.onStart?.();
16598
+ this.threads.trackConnection(selection, async () => {
16599
+ try {
16600
+ await this.threads.whenTornDown();
16601
+ if (released) return;
16602
+ if (ɵisHttpAgent(agent)) agent.abortController = controller;
16603
+ ownership = new ConnectOwnership(agent);
16604
+ await core.connectAgent({ agent });
16605
+ } catch (error) {
16606
+ if (released || error instanceof _ag_ui_client.AGUIConnectNotImplementedError) return;
16607
+ failInspectorOverride();
16608
+ throw error;
16609
+ }
16610
+ }).finally(() => {
16611
+ settled = true;
16612
+ ownership?.stopWatching();
16613
+ if (released) selection.clearDiscardedBaseline();
16614
+ else this.afterPaint(() => {
16615
+ if (!released) this.setConnectedThreadId(threadId);
16616
+ });
16617
+ hooks.onSettled?.(!released);
16618
+ });
16619
+ return {
16620
+ selection,
16621
+ release: () => {
16622
+ if (released) return;
16623
+ released = true;
16624
+ selection.release();
16625
+ inspectorErrors?.unsubscribe();
16626
+ const ownsRun = !settled && ownership?.ownsActiveRun() === true;
16627
+ if (ownership?.replaced !== true && (!settled || ɵisHttpAgent(agent) && agent.abortController !== controller)) controller.abort();
16628
+ ownership?.stopWatching();
16629
+ if (ownsRun) this.threads.detach(agent);
16630
+ }
16631
+ };
16632
+ }
16633
+ };
16634
+ /**
16635
+ * Tells whether the agent's active run is still the pipeline a connect
16636
+ * started, or whether another run replaced it. It watches from the moment it
16637
+ * is created, and takes the first run that initializes after that for the
16638
+ * connect's own, so create it right before the connect starts.
16639
+ */
16640
+ var ConnectOwnership = class {
16641
+ /** Set when another run initialized on the agent after the connect's own. */
16642
+ replaced = false;
16643
+ initialized;
16644
+ completion;
16645
+ refresh;
16646
+ subscription;
16647
+ constructor(agent) {
16648
+ this.agent = agent;
16649
+ this.subscription = agent.subscribe({
16650
+ onRunInitialized: ({ input }) => {
16651
+ if (this.initialized && input !== this.initialized) {
16652
+ this.replaced = true;
16653
+ return;
16654
+ }
16655
+ this.initialized = input;
16656
+ this.refresh = setTimeout(() => this.isOwnPipeline(), 0);
16657
+ },
16658
+ onRunStartedEvent: () => {
16659
+ this.isOwnPipeline();
16660
+ }
16661
+ });
16662
+ }
16663
+ /** Whether detaching the agent stops only the connect's own run. */
16664
+ ownsActiveRun() {
16665
+ return this.isOwnPipeline() || !this.initialized;
16666
+ }
16667
+ stopWatching() {
16668
+ clearTimeout(this.refresh);
16669
+ this.subscription.unsubscribe();
16670
+ }
16671
+ isOwnPipeline() {
16672
+ if (!this.initialized || this.replaced) return false;
16673
+ const candidate = this.agent;
16674
+ const current = isRunCompletionAware(candidate) ? candidate.activeRunCompletionPromise : void 0;
16675
+ if (!current) return false;
16676
+ this.completion ??= current;
16677
+ return current === this.completion;
16678
+ }
16679
+ };
16680
+
16032
16681
  //#endregion
16033
16682
  //#region src/chat/message-view.ts
16034
16683
  const NO_LAYOUTS = /* @__PURE__ */ new Map();
@@ -16323,7 +16972,7 @@ function ɵcomposerButtonState(input) {
16323
16972
  * This handles Enter only. Keys for the slash-command menu stay in each
16324
16973
  * framework, and the framework handles them before it calls this function.
16325
16974
  *
16326
- * Results:
16975
+ * `action`:
16327
16976
  * - `"send"`: send the trimmed text.
16328
16977
  * - `"stop"`: stop the run. This happens for Enter in an empty input while
16329
16978
  * the agent runs. Text in the input always means send, not stop.
@@ -16332,9 +16981,9 @@ function ɵcomposerButtonState(input) {
16332
16981
  * is disabled, for keys other than Enter, and for an Enter that has
16333
16982
  * nothing to send or stop.
16334
16983
  *
16335
- * Call `preventDefault()` for every Enter without Shift that is not part of
16336
- * IME composition, including when the result is `"none"`. This stops Enter
16337
- * from adding a line break that the user cannot send.
16984
+ * `preventDefault` is `true` for every Enter without Shift that is not part
16985
+ * of IME composition, also when `action` is `"none"`: Enter never adds a line
16986
+ * break that the user cannot send.
16338
16987
  *
16339
16988
  * @param event - The keyboard event, or an object with the same fields.
16340
16989
  * @param input - The current state of the chat input.
@@ -16342,18 +16991,35 @@ function ɵcomposerButtonState(input) {
16342
16991
  * @example
16343
16992
  * ```ts
16344
16993
  * function onKeyDown(event: KeyboardEvent) {
16345
- * if (event.isComposing || event.keyCode === 229) return;
16346
16994
  * // ...slash-command menu keys...
16347
- * const result = ɵresolveComposerKey(event, composerInput);
16348
- * if (event.key === "Enter" && !event.shiftKey) event.preventDefault();
16349
- * if (result === "send") sendMessage(composerInput.value.trim());
16350
- * if (result === "stop") stopRun();
16995
+ * const { action, preventDefault } = ɵresolveComposerKey(event, composerInput);
16996
+ * if (preventDefault) event.preventDefault();
16997
+ * if (action === "send") sendMessage(composerInput.value.trim());
16998
+ * if (action === "stop") stopRun();
16351
16999
  * }
16352
17000
  * ```
16353
17001
  */
16354
17002
  function ɵresolveComposerKey(event, input) {
16355
- if (event.isComposing || event.keyCode === 229 || input.disabled === true || event.key !== "Enter") return "none";
16356
- if (event.shiftKey) return "newline";
17003
+ if (isImeComposition(event) || event.key !== "Enter") return {
17004
+ action: "none",
17005
+ preventDefault: false
17006
+ };
17007
+ if (event.shiftKey) return {
17008
+ action: "newline",
17009
+ preventDefault: false
17010
+ };
17011
+ return {
17012
+ action: resolveEnter(input),
17013
+ preventDefault: true
17014
+ };
17015
+ }
17016
+ /** `true` while the key is part of IME composition (for example CJK input). */
17017
+ function isImeComposition(event) {
17018
+ return event.isComposing || event.keyCode === 229;
17019
+ }
17020
+ /** What Enter without Shift does. */
17021
+ function resolveEnter(input) {
17022
+ if (input.disabled === true) return "none";
16357
17023
  const button = ɵcomposerButtonState(input);
16358
17024
  const isEmpty = input.value.trim().length === 0;
16359
17025
  if (button.isProcessing && isEmpty) return input.canStop ? "stop" : "none";
@@ -16508,6 +17174,255 @@ function ɵresolveSlashKey(event, state) {
16508
17174
  default: return none;
16509
17175
  }
16510
17176
  }
17177
+ /**
17178
+ * The tools menu the "+" button opens: the default "Add file" item first,
17179
+ * then the app's items. A separator goes between the two parts. Separators
17180
+ * next to each other become one, and separators at the start or end are
17181
+ * dropped. Nested groups stay as they are.
17182
+ *
17183
+ * @param toolsMenu - The app's items. `"-"` is a separator.
17184
+ * @param addFileItem - The default "Add file" item, or `undefined` when the
17185
+ * chat takes no files.
17186
+ *
17187
+ * @example
17188
+ * ```ts
17189
+ * ɵnormalizeToolsMenu(["-", search, "-", "-", summarize, "-"], addFile);
17190
+ * // → [addFile, "-", search, "-", summarize]
17191
+ * ```
17192
+ */
17193
+ function ɵnormalizeToolsMenu(toolsMenu, addFileItem) {
17194
+ const items = [];
17195
+ if (addFileItem !== void 0) items.push(addFileItem, "-");
17196
+ for (const item of toolsMenu ?? []) if (!(item === "-" && (items.length === 0 || items[items.length - 1] === "-"))) items.push(item);
17197
+ while (items[items.length - 1] === "-") items.pop();
17198
+ return items;
17199
+ }
17200
+ /**
17201
+ * The tools menu as a flat list of rows, for a menu that draws groups inline
17202
+ * instead of as submenus. A group becomes a label row followed by its items
17203
+ * one level deeper. Leaf items without an `action` are dropped. Each row has
17204
+ * a `key` that stays the same while the menu does.
17205
+ *
17206
+ * @param menu - The menu from {@link ɵnormalizeToolsMenu}.
17207
+ */
17208
+ function ɵflattenToolsMenuForDisplay(menu) {
17209
+ const walk = (items, depth, prefix) => items.flatMap((item, index) => {
17210
+ const key = `${prefix}-${index}`;
17211
+ if (item === "-") return [{
17212
+ type: "separator",
17213
+ key: `sep-${key}`
17214
+ }];
17215
+ if (item.items && item.items.length > 0) return [{
17216
+ type: "label",
17217
+ key: `label-${key}`,
17218
+ label: item.label,
17219
+ depth
17220
+ }, ...walk(item.items, depth + 1, key)];
17221
+ if (!item.action) return [];
17222
+ return [{
17223
+ type: "item",
17224
+ key: `item-${key}`,
17225
+ label: item.label,
17226
+ depth,
17227
+ action: item.action
17228
+ }];
17229
+ });
17230
+ return walk(menu, 0, "root");
17231
+ }
17232
+ /**
17233
+ * Make the recorder follow the chat input's mode: it starts recording when
17234
+ * the mode is `"transcribe"` and it is idle, and it stops when the mode
17235
+ * changes while it records. Call it when the mode or the recorder changes.
17236
+ * Errors are logged, not thrown.
17237
+ *
17238
+ * @param recorder - The recorder, or `null` before it renders.
17239
+ * @param mode - The chat input's mode.
17240
+ */
17241
+ async function ɵsyncRecorderToMode(recorder, mode) {
17242
+ if (!recorder) return;
17243
+ try {
17244
+ if (mode === "transcribe") {
17245
+ if (recorder.state === "idle") await recorder.start();
17246
+ } else if (recorder.state === "recording") await recorder.stop();
17247
+ } catch (error) {
17248
+ console.error(error);
17249
+ }
17250
+ }
17251
+ /**
17252
+ * Whether the chat input shows its disclaimer: as `showDisclaimer` says, or,
17253
+ * when it is not set, only when the input is pinned with absolute
17254
+ * positioning.
17255
+ */
17256
+ function ɵshowsComposerDisclaimer(options) {
17257
+ return options.showDisclaimer ?? options.positioning === "absolute";
17258
+ }
17259
+ /**
17260
+ * The text and slash-command menu of one chat input.
17261
+ *
17262
+ * - The text is the app's `value` when it sets one (controlled), else the
17263
+ * controller keeps it. Every change calls `onChange`, in both cases.
17264
+ * - The slash menu opens while the text starts with `/` in input mode and
17265
+ * the menu has commands. Escape, running a command, and leaving input mode
17266
+ * close it until the text changes.
17267
+ * - The highlight goes to the first row when the query changes and stays on
17268
+ * a row that exists when the list changes.
17269
+ *
17270
+ * Frameworks render from `getSnapshot()` and re-render when `subscribe()`
17271
+ * notifies. Call `setInputs()` whenever the app's value, the mode, or the
17272
+ * tools menu changes.
17273
+ *
17274
+ * @example
17275
+ * ```ts
17276
+ * const composer = new ɵComposerController({ onChange: emitChange });
17277
+ * composer.setInputs({ value: undefined, mode: "input", menu });
17278
+ * textarea.oninput = () => composer.setValue(textarea.value);
17279
+ * textarea.onkeydown = (event) => {
17280
+ * const { preventDefault, action } = composer.keyDown(event, composerInput);
17281
+ * if (preventDefault) event.preventDefault();
17282
+ * if (action === "send") composer.submit(sendMessage);
17283
+ * };
17284
+ * ```
17285
+ */
17286
+ var ɵComposerController = class {
17287
+ #listeners = /* @__PURE__ */ new Set();
17288
+ #onChange;
17289
+ #internalValue;
17290
+ #controlledValue;
17291
+ #mode = "input";
17292
+ #menu = [];
17293
+ #commands = [];
17294
+ #closedFor = null;
17295
+ #state;
17296
+ constructor({ initialValue = "", onChange } = {}) {
17297
+ this.#internalValue = initialValue;
17298
+ this.#onChange = onChange;
17299
+ this.#state = {
17300
+ value: initialValue,
17301
+ slashQuery: null,
17302
+ slashCommands: [],
17303
+ slashHighlightIndex: 0
17304
+ };
17305
+ }
17306
+ /** The current state. The same object until something changes. */
17307
+ getSnapshot = () => this.#state;
17308
+ /** Calls `listener` when the state changes. Returns the unsubscribe function. */
17309
+ subscribe = (listener) => {
17310
+ this.#listeners.add(listener);
17311
+ return () => {
17312
+ this.#listeners.delete(listener);
17313
+ };
17314
+ };
17315
+ /** Takes the app's value, the mode, and the tools menu. */
17316
+ setInputs = ({ value, mode, menu }) => {
17317
+ this.#controlledValue = value;
17318
+ if (menu !== this.#menu) {
17319
+ this.#menu = menu;
17320
+ this.#commands = ɵflattenCommandItems(menu);
17321
+ }
17322
+ if (mode !== this.#mode) {
17323
+ this.#mode = mode;
17324
+ if (mode !== "input") this.#closedFor = this.#value();
17325
+ }
17326
+ this.#refresh();
17327
+ };
17328
+ /** The user changed the text. */
17329
+ setValue = (value) => {
17330
+ if (this.#controlledValue === void 0) this.#internalValue = value;
17331
+ this.#onChange?.(value);
17332
+ this.#refresh();
17333
+ };
17334
+ /** Highlights row `index` of the slash menu, for example on hover. */
17335
+ highlight = (index) => {
17336
+ this.#refresh(index);
17337
+ };
17338
+ /** Closes the slash menu and keeps the text. */
17339
+ closeSlashMenu = () => {
17340
+ this.#closedFor = this.#value();
17341
+ this.#refresh();
17342
+ };
17343
+ /** Clears the text, closes the slash menu, and runs `command`. */
17344
+ runCommand = (command) => {
17345
+ this.#closedFor = this.#value();
17346
+ this.setValue("");
17347
+ command.action?.();
17348
+ };
17349
+ /**
17350
+ * Sends the trimmed text with `send` and then clears the input. Does
17351
+ * nothing for text that is only whitespace.
17352
+ *
17353
+ * @param send - Receives the trimmed text.
17354
+ * @param options.value - The text to send, when the framework has a newer
17355
+ * one than the snapshot (a controlled value can lag a tick).
17356
+ * @param options.clear - Clear the input after sending. Default: `true`.
17357
+ * @returns Whether `send` was called.
17358
+ */
17359
+ submit = (send, { value = this.#value(), clear = true } = {}) => {
17360
+ const trimmed = value.trim();
17361
+ if (!trimmed) return false;
17362
+ send(trimmed);
17363
+ if (clear) this.setValue("");
17364
+ return true;
17365
+ };
17366
+ /**
17367
+ * Handles a key press in the text box: the slash-menu keys first, then
17368
+ * Enter as {@link ɵresolveComposerKey} decides.
17369
+ *
17370
+ * @param event - The keyboard event, or an object with the same fields.
17371
+ * @param input - The chat input's state for the send or stop decision.
17372
+ */
17373
+ keyDown = (event, input) => {
17374
+ if (isImeComposition(event)) return {
17375
+ preventDefault: false,
17376
+ action: "none"
17377
+ };
17378
+ const slash = ɵresolveSlashKey(event, {
17379
+ query: this.#state.slashQuery,
17380
+ commands: this.#state.slashCommands,
17381
+ highlightIndex: this.#state.slashHighlightIndex
17382
+ });
17383
+ switch (slash.type) {
17384
+ case "highlight":
17385
+ this.highlight(slash.index);
17386
+ return {
17387
+ preventDefault: true,
17388
+ action: "none"
17389
+ };
17390
+ case "run":
17391
+ this.runCommand(slash.command);
17392
+ return {
17393
+ preventDefault: true,
17394
+ action: "command"
17395
+ };
17396
+ case "close":
17397
+ this.closeSlashMenu();
17398
+ return {
17399
+ preventDefault: true,
17400
+ action: "none"
17401
+ };
17402
+ case "none": return ɵresolveComposerKey(event, input);
17403
+ }
17404
+ };
17405
+ #value() {
17406
+ return this.#controlledValue ?? this.#internalValue;
17407
+ }
17408
+ #refresh(highlight = this.#state.slashHighlightIndex) {
17409
+ const value = this.#value();
17410
+ if (this.#closedFor !== null && this.#closedFor !== value) this.#closedFor = null;
17411
+ const slashQuery = this.#mode === "input" && this.#closedFor === null ? ɵparseSlashQuery(value, this.#commands.length > 0) : null;
17412
+ const slashCommands = ɵfilterCommands(this.#commands, slashQuery);
17413
+ const queryChanged = slashQuery !== this.#state.slashQuery;
17414
+ const slashHighlightIndex = slashQuery === null || queryChanged && slashCommands.length > 0 ? 0 : ɵclampSlashIndex(highlight, slashCommands.length);
17415
+ const previous = this.#state;
17416
+ if (value === previous.value && slashQuery === previous.slashQuery && slashHighlightIndex === previous.slashHighlightIndex && slashCommands.length === previous.slashCommands.length && slashCommands.every((command, i) => command === previous.slashCommands[i])) return;
17417
+ this.#state = {
17418
+ value,
17419
+ slashQuery,
17420
+ slashCommands,
17421
+ slashHighlightIndex
17422
+ };
17423
+ for (const listener of this.#listeners) listener();
17424
+ }
17425
+ };
16511
17426
 
16512
17427
  //#endregion
16513
17428
  //#region src/chat/composer-layout.ts
@@ -17098,375 +18013,6 @@ function ɵcreateWaveformRenderer(canvas, recorder) {
17098
18013
  } };
17099
18014
  }
17100
18015
 
17101
- //#endregion
17102
- //#region src/chat/dom.ts
17103
- /**
17104
- * Turn a width or height prop into a CSS value.
17105
- *
17106
- * @param value - A number of pixels, or a CSS length such as `"30rem"`.
17107
- * @param fallback - The pixels to use when `value` is missing, not finite,
17108
- * or an empty string.
17109
- *
17110
- * @example
17111
- * ```ts
17112
- * ɵdimensionToCss(420, 480); // "420px"
17113
- * ɵdimensionToCss(" 30rem ", 480); // "30rem"
17114
- * ɵdimensionToCss(undefined, 480); // "480px"
17115
- * ```
17116
- */
17117
- function ɵdimensionToCss(value, fallback) {
17118
- if (typeof value === "number" && Number.isFinite(value)) return `${value}px`;
17119
- if (typeof value === "string" && value.trim().length > 0) return value.trim();
17120
- return `${fallback}px`;
17121
- }
17122
- const ONLY_ONE_DOCKED_SIDEBAR = "[CopilotKit] Only one docked CopilotSidebar may be open per document.";
17123
- /**
17124
- * Gives one docked sidebar at a time the page's inline margin on its side,
17125
- * and puts back the margins the page had before when it lets go.
17126
- *
17127
- * Get the registry of a document with {@link ɵdockedSidebarRegistryFor}.
17128
- */
17129
- var ɵDockedSidebarRegistry = class {
17130
- owner;
17131
- original = {
17132
- start: "",
17133
- end: "",
17134
- transition: ""
17135
- };
17136
- restoreTimer;
17137
- warned = /* @__PURE__ */ new Set();
17138
- constructor(document) {
17139
- this.document = document;
17140
- }
17141
- /**
17142
- * Take the page margins for `owner`.
17143
- *
17144
- * @returns `true` when `owner` now has them. `false`, with a warning, when
17145
- * another sidebar has them.
17146
- */
17147
- acquire(owner) {
17148
- if (this.owner === owner) return true;
17149
- if (this.owner !== void 0) {
17150
- if (!this.warned.has(owner)) {
17151
- this.warned.add(owner);
17152
- console.warn(ONLY_ONE_DOCKED_SIDEBAR);
17153
- }
17154
- return false;
17155
- }
17156
- const style = this.document.body.style;
17157
- const transition = this.restoreTimer === void 0 ? style.transition : this.original.transition;
17158
- this.original = {
17159
- start: style.marginInlineStart,
17160
- end: style.marginInlineEnd,
17161
- transition
17162
- };
17163
- this.cancelRestore();
17164
- this.owner = owner;
17165
- return true;
17166
- }
17167
- /** Set the margin on the sidebar's side. Does nothing unless `owner` has it. */
17168
- update(owner, placement, options = {}) {
17169
- if (this.owner !== owner) return;
17170
- const style = this.document.body.style;
17171
- this.applyTransition(options.transitionMs);
17172
- style.marginInlineStart = placement.position === "left" ? placement.width : this.original.start;
17173
- style.marginInlineEnd = placement.position === "right" ? placement.width : this.original.end;
17174
- }
17175
- /**
17176
- * Put back the page's own margins and let go. Does nothing unless `owner`
17177
- * has the margins.
17178
- */
17179
- release(owner, options = {}) {
17180
- this.warned.delete(owner);
17181
- if (this.owner !== owner) return;
17182
- const style = this.document.body.style;
17183
- this.applyTransition(options.transitionMs);
17184
- style.marginInlineStart = this.original.start;
17185
- style.marginInlineEnd = this.original.end;
17186
- this.owner = void 0;
17187
- if (options.transitionMs === void 0) return;
17188
- this.restoreTimer = setTimeout(() => {
17189
- this.restoreTimer = void 0;
17190
- if (this.owner === void 0) style.transition = this.original.transition;
17191
- }, options.transitionMs);
17192
- }
17193
- applyTransition(transitionMs) {
17194
- const style = this.document.body.style;
17195
- this.cancelRestore();
17196
- style.transition = transitionMs === void 0 ? this.original.transition : `margin-inline-start ${transitionMs}ms ease, margin-inline-end ${transitionMs}ms ease`;
17197
- }
17198
- cancelRestore() {
17199
- if (this.restoreTimer === void 0) return;
17200
- clearTimeout(this.restoreTimer);
17201
- this.restoreTimer = void 0;
17202
- }
17203
- };
17204
- const registries = /* @__PURE__ */ new WeakMap();
17205
- /** The one {@link ɵDockedSidebarRegistry} of `document`. */
17206
- function ɵdockedSidebarRegistryFor(document) {
17207
- let registry = registries.get(document);
17208
- if (!registry) {
17209
- registry = new ɵDockedSidebarRegistry(document);
17210
- registries.set(document, registry);
17211
- }
17212
- return registry;
17213
- }
17214
- /**
17215
- * Makes room on the page for an open sidebar, on desktop viewports only
17216
- * (wider than 767px). It follows viewport changes, animates every change
17217
- * after the first, and gives the page its margins back on `dispose()`.
17218
- *
17219
- * Create it with {@link ɵcreateDockedSidebar}.
17220
- */
17221
- var ɵDockedSidebar = class {
17222
- owner = Symbol("copilot-sidebar");
17223
- registry;
17224
- media;
17225
- state;
17226
- owns = false;
17227
- hasApplied = false;
17228
- constructor(document, transitionMs) {
17229
- this.transitionMs = transitionMs;
17230
- this.registry = ɵdockedSidebarRegistryFor(document);
17231
- this.media = document.defaultView?.matchMedia?.(require_viewport.ɵMOBILE_MAX_WIDTH_QUERY);
17232
- this.media?.addEventListener("change", this.apply);
17233
- }
17234
- /** Apply the sidebar's open state, side, and width. */
17235
- set(state) {
17236
- this.state = state;
17237
- this.apply();
17238
- }
17239
- /** Give the margins back at once and stop following the viewport. */
17240
- dispose() {
17241
- this.media?.removeEventListener("change", this.apply);
17242
- this.registry.release(this.owner);
17243
- this.owns = false;
17244
- }
17245
- apply = () => {
17246
- const state = this.state;
17247
- if (!state) return;
17248
- const transition = this.hasApplied ? { transitionMs: this.transitionMs } : {};
17249
- this.hasApplied = true;
17250
- if (!(state.open && !this.media?.matches)) {
17251
- if (this.owns) this.registry.release(this.owner, transition);
17252
- this.owns = false;
17253
- return;
17254
- }
17255
- this.owns = this.owns || this.registry.acquire(this.owner);
17256
- if (this.owns) this.registry.update(this.owner, state, transition);
17257
- };
17258
- };
17259
- /**
17260
- * Create the controller that reserves the page margin for a docked sidebar.
17261
- *
17262
- * @param document - The page.
17263
- * @param options - `transitionMs`: how long margin changes animate.
17264
- *
17265
- * @example
17266
- * ```ts
17267
- * const dock = ɵcreateDockedSidebar(document, { transitionMs: 260 });
17268
- * dock.set({ open: true, position: "right", width: "480px" });
17269
- * dock.dispose(); // on unmount
17270
- * ```
17271
- */
17272
- function ɵcreateDockedSidebar(document, options) {
17273
- return new ɵDockedSidebar(document, options.transitionMs);
17274
- }
17275
- /** How long the popup's open animation runs, in ms. */
17276
- const ɵPOPUP_ANIMATION_MS = 200;
17277
- /**
17278
- * Close an open popup on Escape and, when asked, on a pointer down outside
17279
- * it, and move focus into it once its open animation ends.
17280
- *
17281
- * A pointer down on the chat toggle button, or in a chat popover (which
17282
- * renders in a portal, outside the panel), does not close the popup. Focus
17283
- * moves to the panel only when nothing inside it has focus yet.
17284
- *
17285
- * Call it when the popup opens, and call the returned function when it
17286
- * closes or unmounts.
17287
- *
17288
- * @param options - The panel, the close callback, and whether a click
17289
- * outside closes.
17290
- */
17291
- function ɵbindPopupDismiss(options) {
17292
- if (typeof window === "undefined") return () => {};
17293
- const handleKeyDown = (event) => {
17294
- if (event.key !== "Escape") return;
17295
- event.preventDefault();
17296
- options.onDismiss();
17297
- };
17298
- const handlePointerDown = (event) => {
17299
- const target = event.target;
17300
- if (!(target instanceof Node)) return;
17301
- if (options.getContainer()?.contains(target)) return;
17302
- if ((target instanceof Element ? target : target.parentElement)?.closest("[data-slot='chat-toggle-button'], [data-copilotkit-popover]")) return;
17303
- options.onDismiss();
17304
- };
17305
- const focusTimer = setTimeout(() => {
17306
- const container = options.getContainer();
17307
- if (container && !container.contains(container.ownerDocument.activeElement)) container.focus({ preventScroll: true });
17308
- }, ɵPOPUP_ANIMATION_MS);
17309
- window.addEventListener("keydown", handleKeyDown);
17310
- if (options.clickOutsideToClose) document.addEventListener("pointerdown", handlePointerDown);
17311
- return () => {
17312
- clearTimeout(focusTimer);
17313
- window.removeEventListener("keydown", handleKeyDown);
17314
- document.removeEventListener("pointerdown", handlePointerDown);
17315
- };
17316
- }
17317
- /**
17318
- * Open or close a lightbox with the View Transition API, so the thumbnail
17319
- * morphs into the preview and back.
17320
- *
17321
- * `view-transition-name` must be on one element at a time: on the
17322
- * thumbnail before the change and on the preview after it. Bind `name` to
17323
- * the preview element. Without the API, or without a thumbnail, `apply`
17324
- * runs with no animation.
17325
- *
17326
- * @param thumbnail - The element the preview grows from.
17327
- * @param name - A `view-transition-name`, unique on the page.
17328
- * @param apply - Renders the change. It must finish the DOM update before
17329
- * it returns or resolves (React: `flushSync`; Vue: `await nextTick()`).
17330
- * @param direction - `"open"` or `"close"`.
17331
- */
17332
- function ɵmorphViewTransition(thumbnail, name, apply, direction) {
17333
- const doc = typeof document === "undefined" ? void 0 : document;
17334
- if (!(!!thumbnail && typeof doc?.startViewTransition === "function") || !thumbnail || !doc) {
17335
- apply();
17336
- return;
17337
- }
17338
- if (direction === "open") {
17339
- thumbnail.style.viewTransitionName = name;
17340
- doc.startViewTransition(async () => {
17341
- thumbnail.style.viewTransitionName = "";
17342
- await apply();
17343
- });
17344
- return;
17345
- }
17346
- const transition = doc.startViewTransition(async () => {
17347
- await apply();
17348
- thumbnail.style.viewTransitionName = name;
17349
- });
17350
- const clear = () => {
17351
- thumbnail.style.viewTransitionName = "";
17352
- };
17353
- transition.finished.then(clear, clear);
17354
- }
17355
- const FOCUSABLE = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), audio[controls], video[controls], iframe, [tabindex]:not([tabindex=\"-1\"])";
17356
- /**
17357
- * Make `root` behave as a modal dialog for keyboard users: focus moves into
17358
- * it, Tab and Shift+Tab wrap inside it, and focus goes back to the opener
17359
- * when the returned function runs.
17360
- *
17361
- * @param root - The dialog element.
17362
- * @param options - Where focus goes on open and on close.
17363
- * @returns A function that removes the trap and returns focus.
17364
- */
17365
- function ɵbindDialogFocus(root, options = {}) {
17366
- const doc = root.ownerDocument;
17367
- const active = doc.activeElement;
17368
- const opener = active instanceof HTMLElement ? active : null;
17369
- const focusables = () => Array.from(root.querySelectorAll(FOCUSABLE));
17370
- const handleKeyDown = (event) => {
17371
- if (event.key !== "Tab") return;
17372
- const elements = focusables();
17373
- const first = elements[0];
17374
- const last = elements[elements.length - 1];
17375
- if (!first || !last) {
17376
- event.preventDefault();
17377
- return;
17378
- }
17379
- const current = doc.activeElement;
17380
- const isOutside = !root.contains(current);
17381
- if (event.shiftKey && (current === first || isOutside)) {
17382
- event.preventDefault();
17383
- last.focus();
17384
- } else if (!event.shiftKey && (current === last || isOutside)) {
17385
- event.preventDefault();
17386
- first.focus();
17387
- }
17388
- };
17389
- root.addEventListener("keydown", handleKeyDown);
17390
- (options.initialFocus ?? focusables()[0])?.focus();
17391
- return () => {
17392
- root.removeEventListener("keydown", handleKeyDown);
17393
- const target = options.returnFocusTo ?? opener;
17394
- if (target?.isConnected) target.focus();
17395
- };
17396
- }
17397
- /**
17398
- * Which in-browser preview a document gets.
17399
- *
17400
- * @param mimeType - The document's MIME type.
17401
- * @returns `"pdf"`, `"text"` (for `text/*`), or `null` when the browser
17402
- * cannot preview it.
17403
- */
17404
- function ɵcanPreviewDocument(mimeType) {
17405
- if (!mimeType) return null;
17406
- if (mimeType.includes("pdf")) return "pdf";
17407
- if (mimeType.startsWith("text/")) return "text";
17408
- return null;
17409
- }
17410
- function decodeBase64(value) {
17411
- const binary = atob(value);
17412
- const bytes = new Uint8Array(binary.length);
17413
- for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
17414
- return bytes;
17415
- }
17416
- /**
17417
- * A URL a browser can show in an `<iframe>` for an attachment's source.
17418
- *
17419
- * Browsers block `data:` URLs for PDFs in frames, so base64 data becomes a
17420
- * `blob:` URL. Call `revoke()` when the preview closes.
17421
- *
17422
- * @param source - The attachment's source.
17423
- * @returns `{ url, revoke }`, or `null` when the data is not valid base64.
17424
- */
17425
- function ɵcreateObjectUrlFromSource(source) {
17426
- if (source.type === "url") return {
17427
- url: source.value,
17428
- revoke: () => {}
17429
- };
17430
- try {
17431
- const blob = new Blob([decodeBase64(source.value)], { type: source.mimeType || "application/octet-stream" });
17432
- const url = URL.createObjectURL(blob);
17433
- return {
17434
- url,
17435
- revoke: () => URL.revokeObjectURL(url)
17436
- };
17437
- } catch (error) {
17438
- console.error("[CopilotKit] Failed to decode attachment data:", error);
17439
- return null;
17440
- }
17441
- }
17442
- /**
17443
- * The text of a text attachment, for a `<pre>` preview.
17444
- *
17445
- * @param source - The attachment's source.
17446
- * @returns The base64 data decoded as UTF-8, the raw value when it is not
17447
- * valid base64, or `null` for a URL source (show it in a frame instead).
17448
- */
17449
- function ɵdecodeTextSource(source) {
17450
- if (source.type !== "data") return null;
17451
- try {
17452
- return new TextDecoder().decode(decodeBase64(source.value));
17453
- } catch {
17454
- return source.value;
17455
- }
17456
- }
17457
- /** How close to the end, in pixels, still counts as scrolled to the bottom. */
17458
- const ɵSCROLL_BOTTOM_THRESHOLD_PX = 12;
17459
- /**
17460
- * Whether a scroll container shows the end of its content.
17461
- *
17462
- * @param element - The scroll container.
17463
- * @param threshold - The pixels from the end that still count. Default:
17464
- * {@link ɵSCROLL_BOTTOM_THRESHOLD_PX}.
17465
- */
17466
- function ɵisScrolledToBottom(element, threshold = ɵSCROLL_BOTTOM_THRESHOLD_PX) {
17467
- return element.scrollHeight - element.scrollTop - element.clientHeight <= threshold;
17468
- }
17469
-
17470
18016
  //#endregion
17471
18017
  //#region src/chat/license.ts
17472
18018
  /**
@@ -18185,6 +18731,19 @@ function ɵgetMessageFeedbackControls(scope, message) {
18185
18731
  }
18186
18732
  };
18187
18733
  }
18734
+ /** Selects a thumb of a rated message by its rating. */
18735
+ const thumbSelector = (rating) => `[data-copilotkit-rating="${rating}"]`;
18736
+ const HIDDEN_TOO = {
18737
+ checkVisibilityCSS: true,
18738
+ visibilityProperty: true
18739
+ };
18740
+ /**
18741
+ * Whether `target` is a thumb of message `messageId`. A click on one decides
18742
+ * itself what happens to the comment, so the popover ignores it.
18743
+ */
18744
+ function ɵisOwnFeedbackThumb(target, messageId) {
18745
+ return (target instanceof Element ? target.closest("[data-copilotkit-rating]") : null)?.closest("[data-message-id]")?.getAttribute("data-message-id") === messageId;
18746
+ }
18188
18747
  /**
18189
18748
  * Drives the comment popover of a rated message.
18190
18749
  *
@@ -18195,6 +18754,12 @@ function ɵgetMessageFeedbackControls(scope, message) {
18195
18754
  * Escape. Closing saves a changed comment; Escape, a click on a thumb, and
18196
18755
  * removing the rating discard it.
18197
18756
  *
18757
+ * The thumbs are toggles (see `rate()`), and `thumb()` gives each thumb its
18758
+ * attributes and handlers. The popover lives in a portal, so it keeps the
18759
+ * keyboard order by hand (see `popoverKeyDown()` and `popoverEscape()`):
18760
+ * Shift+Tab from its start returns to the thumb, Tab from its end moves on
18761
+ * to the control after the thumb, and Enter or Escape returns to the thumb.
18762
+ *
18198
18763
  * Frameworks render from `getSnapshot()` and re-render when `subscribe()`
18199
18764
  * notifies. Call `dispose()` on unmount: it keeps an unsaved edit, for a
18200
18765
  * message that scrolls out of a virtual list. The controller stays usable
@@ -18211,13 +18776,16 @@ function ɵgetMessageFeedbackControls(scope, message) {
18211
18776
  */
18212
18777
  var ɵFeedbackCommentController = class {
18213
18778
  #getControls;
18779
+ #getInput;
18214
18780
  #closeDelayMs;
18215
18781
  #listeners = /* @__PURE__ */ new Set();
18216
18782
  #state = {
18217
18783
  open: false,
18218
18784
  draft: "",
18219
- focusRequest: 0
18785
+ focusRequest: 0,
18786
+ anchor: null
18220
18787
  };
18788
+ #commentRating;
18221
18789
  #timer;
18222
18790
  #editing = false;
18223
18791
  #focusWaiting = false;
@@ -18225,6 +18793,8 @@ var ɵFeedbackCommentController = class {
18225
18793
  #returning = false;
18226
18794
  constructor(options) {
18227
18795
  this.#getControls = options.getControls;
18796
+ this.#getInput = options.getInput ?? (() => null);
18797
+ this.#commentRating = options.getControls()?.feedback?.rating;
18228
18798
  this.#closeDelayMs = options.closeDelayMs ?? ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS;
18229
18799
  }
18230
18800
  /** The current state. The same object until something changes. */
@@ -18302,6 +18872,157 @@ var ɵFeedbackCommentController = class {
18302
18872
  this.#returning = false;
18303
18873
  }
18304
18874
  };
18875
+ /**
18876
+ * A click on thumb `value`. Thumbs are toggles: a new rating is saved and
18877
+ * opens its comment, and clicking the chosen thumb again removes the
18878
+ * rating. A keyboard click moves focus into the comment, as there is no
18879
+ * pointer.
18880
+ *
18881
+ * @param options.target - The clicked thumb, if the click gave one.
18882
+ * @param options.keyboard - The click came from the keyboard (`detail` 0).
18883
+ * @returns Whether the app's handler should run: true for a new rating and
18884
+ * whenever this chat does not record ratings, false when one is removed.
18885
+ */
18886
+ rate = (value, options = {}) => {
18887
+ const controls = this.#getControls();
18888
+ if (!controls) return true;
18889
+ if (controls.feedback?.rating === value) {
18890
+ this.close({ save: false });
18891
+ controls.clear();
18892
+ return false;
18893
+ }
18894
+ controls.rate(value);
18895
+ this.#commentRating = value;
18896
+ this.#update({ anchor: options.target ?? null });
18897
+ this.show({
18898
+ comment: "",
18899
+ focus: options.keyboard === true
18900
+ });
18901
+ return true;
18902
+ };
18903
+ /**
18904
+ * The attributes and handlers of thumb `value`, or `null` while this chat
18905
+ * records no ratings. The chosen thumb opens its comment when the pointer
18906
+ * or keyboard focus reaches it, and Tab from it moves into the comment.
18907
+ */
18908
+ thumb = (value) => {
18909
+ const controls = this.#getControls();
18910
+ if (!controls) return null;
18911
+ if (controls.feedback?.rating !== value) return {
18912
+ attributes: {
18913
+ "data-copilotkit-rating": value,
18914
+ "aria-pressed": false
18915
+ },
18916
+ handlers: null
18917
+ };
18918
+ const enter = (target, via) => {
18919
+ if (!this.#state.open) this.#commentRating = value;
18920
+ if (target instanceof HTMLElement) this.#update({ anchor: target });
18921
+ this.enter(via);
18922
+ };
18923
+ return {
18924
+ attributes: {
18925
+ "data-copilotkit-rating": value,
18926
+ "aria-pressed": true,
18927
+ "aria-haspopup": "dialog",
18928
+ "aria-expanded": this.#state.open
18929
+ },
18930
+ handlers: {
18931
+ pointerEnter: (event) => {
18932
+ if (event.pointerType !== "touch") enter(event.currentTarget, "pointer");
18933
+ },
18934
+ pointerLeave: (event) => {
18935
+ if (event.pointerType !== "touch") this.leave("pointer");
18936
+ },
18937
+ focus: (event) => {
18938
+ const target = event.currentTarget;
18939
+ if (target instanceof Element && require_viewport.ɵisFocusVisible(target)) enter(target, "focus");
18940
+ },
18941
+ blur: () => this.leave(),
18942
+ keyDown: (event) => {
18943
+ const input = this.#getInput();
18944
+ const visible = input?.checkVisibility?.(HIDDEN_TOO) !== false;
18945
+ if (event.key === "Tab" && !event.shiftKey && this.#state.open && input && visible) {
18946
+ event.preventDefault();
18947
+ input.focus();
18948
+ }
18949
+ }
18950
+ }
18951
+ };
18952
+ };
18953
+ /**
18954
+ * Points the popover at the chosen thumb inside `root` when no thumb was
18955
+ * given: a custom thumb can call its click handler without an event. Call
18956
+ * it after each render.
18957
+ */
18958
+ findAnchor = (root) => {
18959
+ const rating = this.#getControls()?.feedback?.rating;
18960
+ if (!this.#state.open || this.#state.anchor?.isConnected || !rating) return;
18961
+ const anchor = root?.querySelector(thumbSelector(rating)) ?? root?.querySelector("button[aria-pressed=\"true\"]") ?? null;
18962
+ this.#update({ anchor });
18963
+ };
18964
+ /**
18965
+ * Closes a comment that no longer fits: discards it when the rating was
18966
+ * changed or removed elsewhere, and saves it when the toolbar hides. Call
18967
+ * it when the rating or `showsToolbar` changes.
18968
+ */
18969
+ sync = ({ showsToolbar }) => {
18970
+ if (!this.#state.open) return;
18971
+ if (this.#getControls()?.feedback?.rating !== this.#commentRating) this.close({ save: false });
18972
+ else if (!showsToolbar) this.close();
18973
+ };
18974
+ /** Moves focus into the comment field when a keyboard rating asked for it. */
18975
+ focusField = () => {
18976
+ const input = this.#getInput();
18977
+ if (input && this.takeFocusRequest()) input.focus();
18978
+ };
18979
+ /** Saves the comment, closes, and moves focus back to the thumb. */
18980
+ submit = () => {
18981
+ this.close();
18982
+ this.returnFocus(this.#state.anchor);
18983
+ };
18984
+ /**
18985
+ * Escape in the popover: closes without saving, and moves focus back to
18986
+ * the thumb when it was in the popover.
18987
+ *
18988
+ * @param content - The popover element.
18989
+ * @returns Whether focus was in the popover. Then stop the event, so it
18990
+ * does not also close a chat popup around the message.
18991
+ */
18992
+ popoverEscape = (content) => {
18993
+ const focusInside = content?.contains(content.ownerDocument.activeElement);
18994
+ this.close({ save: false });
18995
+ if (focusInside) this.returnFocus(this.#state.anchor);
18996
+ return focusInside === true;
18997
+ };
18998
+ /**
18999
+ * A key press in the popover: Tab past its last control or Shift+Tab past
19000
+ * its first one leaves it, as if it sat right after the thumb.
19001
+ *
19002
+ * @param content - The popover element.
19003
+ */
19004
+ popoverKeyDown = (event, content) => {
19005
+ if (event.key !== "Tab" || !content) return;
19006
+ const anchor = this.#state.anchor;
19007
+ const stops = Array.from(content.querySelectorAll(require_viewport.ɵTAB_STOP_SELECTOR));
19008
+ const active = content.ownerDocument.activeElement;
19009
+ if (!(event.shiftKey ? active === stops[0] : active === stops[stops.length - 1]) || !anchor?.isConnected) return;
19010
+ event.preventDefault();
19011
+ const target = event.shiftKey ? anchor : require_viewport.ɵnextTabStop(anchor, content) ?? anchor;
19012
+ this.close();
19013
+ if (target === anchor) this.returnFocus(target);
19014
+ else target.focus();
19015
+ };
19016
+ /**
19017
+ * Focus left the comment form for `next`. Moving within the popover or to
19018
+ * a thumb of the message, where the pointer still is, keeps it open.
19019
+ *
19020
+ * @param content - The popover element.
19021
+ */
19022
+ popoverFocusLeave = (next, content, messageId) => {
19023
+ if (next && (content?.contains(next) || ɵisOwnFeedbackThumb(next, messageId))) return;
19024
+ this.leave();
19025
+ };
18305
19026
  /** Stops the close timer and saves a changed comment that is still open. */
18306
19027
  dispose = () => {
18307
19028
  this.#cancelClose();
@@ -18325,7 +19046,7 @@ var ɵFeedbackCommentController = class {
18325
19046
  ...this.#state,
18326
19047
  ...patch
18327
19048
  };
18328
- if (next.open === this.#state.open && next.draft === this.#state.draft && next.focusRequest === this.#state.focusRequest) return;
19049
+ if (next.open === this.#state.open && next.draft === this.#state.draft && next.focusRequest === this.#state.focusRequest && next.anchor === this.#state.anchor) return;
18329
19050
  this.#state = next;
18330
19051
  for (const listener of this.#listeners) listener();
18331
19052
  }
@@ -18356,6 +19077,119 @@ function ɵformatReasoningDurationLabel(seconds, labels) {
18356
19077
  }
18357
19078
  }
18358
19079
  /**
19080
+ * The header text of a reasoning message: `labels.reasoningMessageThinkingLabel`
19081
+ * while the model reasons, then `labels.reasoningMessageThoughtForLabel`
19082
+ * ("Thought for 4 seconds").
19083
+ *
19084
+ * @param state - Whether the model still reasons, and for how long it did.
19085
+ * @param labels - The chat labels.
19086
+ */
19087
+ function ɵgetReasoningHeaderLabel(state, labels) {
19088
+ if (state.isStreaming) return labels.reasoningMessageThinkingLabel;
19089
+ return ɵformatLabel(labels.reasoningMessageThoughtForLabel, { duration: ɵformatReasoningDurationLabel(state.elapsedSeconds, labels) });
19090
+ }
19091
+ /**
19092
+ * The open state and reasoning timer of one reasoning message.
19093
+ *
19094
+ * - It opens when streaming starts and closes by itself when it ends,
19095
+ * unless the user toggled it during that stream: then their choice stays.
19096
+ * Each new stream starts open again and forgets the earlier toggle.
19097
+ * - The elapsed time counts from the first stream start and updates every
19098
+ * tick while streaming. When streaming ends it takes the final time.
19099
+ *
19100
+ * Frameworks render from `getSnapshot()` and re-render when `subscribe()`
19101
+ * notifies. Call `setStreaming()` whenever the streaming state may have
19102
+ * changed, including once after mount. Call `dispose()` on unmount. The
19103
+ * controller stays usable after `dispose()`, so a remount (React Strict
19104
+ * Mode) can keep it: the next `setStreaming(true)` starts the timer again.
19105
+ *
19106
+ * @example
19107
+ * ```ts
19108
+ * const disclosure = new ɵReasoningDisclosure({ isStreaming });
19109
+ * disclosure.subscribe(() => render(disclosure.getSnapshot()));
19110
+ * disclosure.setStreaming(isStreaming);
19111
+ * // Header click, when the message has text:
19112
+ * disclosure.toggle();
19113
+ * ```
19114
+ */
19115
+ var ɵReasoningDisclosure = class {
19116
+ #listeners = /* @__PURE__ */ new Set();
19117
+ #tickMs;
19118
+ #state;
19119
+ #startedAt = null;
19120
+ #userToggled = false;
19121
+ #timer;
19122
+ constructor({ isStreaming = false, tickMs = 1e3 } = {}) {
19123
+ this.#tickMs = tickMs;
19124
+ this.#state = {
19125
+ isStreaming: false,
19126
+ isOpen: isStreaming,
19127
+ elapsedSeconds: 0
19128
+ };
19129
+ }
19130
+ /** The current state. The same object until something changes. */
19131
+ getSnapshot = () => this.#state;
19132
+ /** Calls `listener` when the state changes. Returns the unsubscribe function. */
19133
+ subscribe = (listener) => {
19134
+ this.#listeners.add(listener);
19135
+ return () => {
19136
+ this.#listeners.delete(listener);
19137
+ };
19138
+ };
19139
+ /** Tells the controller whether the model reasons in this message now. */
19140
+ setStreaming = (isStreaming) => {
19141
+ if (isStreaming) {
19142
+ if (this.#timer === void 0) this.#startTimer();
19143
+ if (this.#state.isStreaming) return;
19144
+ this.#startedAt ??= Date.now();
19145
+ this.#userToggled = false;
19146
+ this.#update({
19147
+ isStreaming: true,
19148
+ isOpen: true
19149
+ });
19150
+ return;
19151
+ }
19152
+ if (!this.#state.isStreaming) return;
19153
+ this.#stopTimer();
19154
+ this.#update({
19155
+ isStreaming: false,
19156
+ elapsedSeconds: this.#elapsed(),
19157
+ isOpen: this.#userToggled ? this.#state.isOpen : false
19158
+ });
19159
+ };
19160
+ /** Opens or closes the reasoning text, and keeps that after the stream. */
19161
+ toggle = () => {
19162
+ this.#userToggled = true;
19163
+ this.#update({ isOpen: !this.#state.isOpen });
19164
+ };
19165
+ /** Stops the timer. */
19166
+ dispose = () => {
19167
+ this.#stopTimer();
19168
+ };
19169
+ #elapsed() {
19170
+ return this.#startedAt === null ? 0 : (Date.now() - this.#startedAt) / 1e3;
19171
+ }
19172
+ #startTimer() {
19173
+ this.#timer = setInterval(() => {
19174
+ this.#update({ elapsedSeconds: this.#elapsed() });
19175
+ }, this.#tickMs);
19176
+ }
19177
+ #stopTimer() {
19178
+ if (this.#timer === void 0) return;
19179
+ clearInterval(this.#timer);
19180
+ this.#timer = void 0;
19181
+ }
19182
+ #update(patch) {
19183
+ const next = {
19184
+ ...this.#state,
19185
+ ...patch
19186
+ };
19187
+ if (next.isStreaming === this.#state.isStreaming && next.isOpen === this.#state.isOpen && next.elapsedSeconds === this.#state.elapsedSeconds) return;
19188
+ this.#state = next;
19189
+ for (const listener of this.#listeners) listener();
19190
+ }
19191
+ };
19192
+ /**
18359
19193
  * The text of the work summary line at the top of a reply in the `"turn"`
18360
19194
  * tool-call display.
18361
19195
  *
@@ -18398,18 +19232,18 @@ function ɵgetWorkSummaryText({ isWorking, calls, elapsedMs, workingSince, now,
18398
19232
  }
18399
19233
  /**
18400
19234
  * The text of a user message: the string content, or its text parts joined
18401
- * by newlines. Parts that are not text, and malformed parts from untyped
18402
- * data, add nothing.
19235
+ * by newlines. Parts that are not text, and malformed parts or content
19236
+ * that is not a list from untyped data, add nothing.
18403
19237
  */
18404
19238
  function ɵflattenUserMessageContent(content) {
18405
- if (!content) return "";
18406
19239
  if (typeof content === "string") return content;
19240
+ if (!Array.isArray(content)) return "";
18407
19241
  return content.map((part) => part?.type === "text" && typeof part.text === "string" ? part.text : "").filter((text) => text.length > 0).join("\n");
18408
19242
  }
18409
19243
  const isMediaPart = (part) => part?.type === "image" || part?.type === "audio" || part?.type === "video" || part?.type === "document";
18410
19244
  /** The image, audio, video, and document parts of a user message. */
18411
19245
  function ɵgetUserMessageMediaParts(content) {
18412
- if (!content || typeof content === "string") return [];
19246
+ if (!Array.isArray(content)) return [];
18413
19247
  return content.filter(isMediaPart);
18414
19248
  }
18415
19249
  /** The file name stored in an attachment's `metadata.filename`, if any. */
@@ -19310,6 +20144,25 @@ function buildOpenGenerativeUIContexts({ designSkill, sandboxFunctions }) {
19310
20144
  });
19311
20145
  return entries;
19312
20146
  }
20147
+ /**
20148
+ * Add the Open Generative UI agent context entries (see
20149
+ * {@link buildOpenGenerativeUIContexts}) to a core.
20150
+ *
20151
+ * @returns A function that removes the entries this call added.
20152
+ *
20153
+ * @example
20154
+ * ```ts
20155
+ * const remove = ɵaddOpenGenerativeUIContexts(core, { designSkill, sandboxFunctions });
20156
+ * // when the feature turns off or the options change
20157
+ * remove();
20158
+ * ```
20159
+ */
20160
+ function addOpenGenerativeUIContexts(core, options) {
20161
+ const ids = buildOpenGenerativeUIContexts(options).map((entry) => core.addContext(entry));
20162
+ return () => {
20163
+ for (const id of ids) core.removeContext(id);
20164
+ };
20165
+ }
19313
20166
 
19314
20167
  //#endregion
19315
20168
  //#region src/open-generative-ui/placeholder.ts
@@ -19724,13 +20577,17 @@ exports.ɵCOPILOT_CLOUD_PUBLIC_API_KEY_HEADER = ɵCOPILOT_CLOUD_PUBLIC_API_KEY_H
19724
20577
  exports.ɵCOPILOT_CLOUD_RUNTIME_URL = ɵCOPILOT_CLOUD_RUNTIME_URL;
19725
20578
  exports.ɵCOPY_FEEDBACK_RESET_MS = ɵCOPY_FEEDBACK_RESET_MS;
19726
20579
  exports.ɵChatConfigurationStore = require_chat_configuration.ɵChatConfigurationStore;
20580
+ exports.ɵChatConnection = ɵChatConnection;
19727
20581
  exports.ɵChatSubmitter = ɵChatSubmitter;
19728
20582
  exports.ɵComposerAutosize = ɵComposerAutosize;
20583
+ exports.ɵComposerController = ɵComposerController;
19729
20584
  exports.ɵCopyFeedback = ɵCopyFeedback;
19730
- exports.ɵDockedSidebar = ɵDockedSidebar;
19731
- exports.ɵDockedSidebarRegistry = ɵDockedSidebarRegistry;
20585
+ exports.ɵDockedSidebar = require_viewport.ɵDockedSidebar;
20586
+ exports.ɵDockedSidebarRegistry = require_viewport.ɵDockedSidebarRegistry;
20587
+ exports.ɵExitPresence = require_viewport.ɵExitPresence;
19732
20588
  exports.ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS = ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS;
19733
20589
  exports.ɵFeedbackCommentController = ɵFeedbackCommentController;
20590
+ exports.ɵFreshThreadId = ɵFreshThreadId;
19734
20591
  exports.ɵGENERATE_SANDBOXED_UI_ARGS_SCHEMA = GENERATE_SANDBOXED_UI_ARGS_SCHEMA;
19735
20592
  exports.ɵHITL_ABORTED_MESSAGE = ɵHITL_ABORTED_MESSAGE;
19736
20593
  exports.ɵHOVER_MENU_CLOSE_DELAY_MS = ɵHOVER_MENU_CLOSE_DELAY_MS;
@@ -19755,14 +20612,22 @@ exports.ɵOPEN_GENERATIVE_UI_DESIGN_CONTEXT_DESCRIPTION = OPEN_GENERATIVE_UI_DES
19755
20612
  exports.ɵOPEN_GENERATIVE_UI_SANDBOX_FUNCTIONS_CONTEXT_DESCRIPTION = OPEN_GENERATIVE_UI_SANDBOX_FUNCTIONS_CONTEXT_DESCRIPTION;
19756
20613
  exports.ɵOpenGenerativeUIController = OpenGenerativeUIController;
19757
20614
  exports.ɵPLACEHOLDER_CYCLE_MS = PLACEHOLDER_CYCLE_MS;
19758
- exports.ɵPOPUP_ANIMATION_MS = ɵPOPUP_ANIMATION_MS;
20615
+ exports.ɵPOPUP_ANIMATION_MS = require_viewport.ɵPOPUP_ANIMATION_MS;
20616
+ exports.ɵPOPUP_DEFAULT_HEIGHT = require_viewport.ɵPOPUP_DEFAULT_HEIGHT;
20617
+ exports.ɵPOPUP_DEFAULT_WIDTH = require_viewport.ɵPOPUP_DEFAULT_WIDTH;
19759
20618
  exports.ɵPlaceholderCycler = PlaceholderCycler;
19760
20619
  exports.ɵRENDER_A2UI_TOOL_NAME = RENDER_A2UI_TOOL_NAME;
20620
+ exports.ɵRESIZE_SETTLE_MS = require_viewport.ɵRESIZE_SETTLE_MS;
19761
20621
  exports.ɵRUNTIME_PROBE_TIMEOUT_MS = ɵRUNTIME_PROBE_TIMEOUT_MS;
20622
+ exports.ɵReasoningDisclosure = ɵReasoningDisclosure;
19762
20623
  exports.ɵRendererRegistry = ɵRendererRegistry;
19763
20624
  exports.ɵRuntimeInfoStore = ɵRuntimeInfoStore;
19764
- exports.ɵSCROLL_BOTTOM_THRESHOLD_PX = ɵSCROLL_BOTTOM_THRESHOLD_PX;
20625
+ exports.ɵSCROLL_BOTTOM_THRESHOLD_PX = require_viewport.ɵSCROLL_BOTTOM_THRESHOLD_PX;
20626
+ exports.ɵSIDEBAR_DEFAULT_WIDTH = require_viewport.ɵSIDEBAR_DEFAULT_WIDTH;
20627
+ exports.ɵSIDEBAR_TRANSITION_MS = require_viewport.ɵSIDEBAR_TRANSITION_MS;
19765
20628
  exports.ɵSTABLE_ARRAY_WARNINGS = ɵSTABLE_ARRAY_WARNINGS;
20629
+ exports.ɵStickToBottom = require_viewport.ɵStickToBottom;
20630
+ exports.ɵTAB_STOP_SELECTOR = require_viewport.ɵTAB_STOP_SELECTOR;
19766
20631
  exports.ɵTHREAD_REQUEST_TIMEOUT_MS = ɵTHREAD_REQUEST_TIMEOUT_MS;
19767
20632
  exports.ɵTOOL_CALL_STATUS_ICONS = TOOL_CALL_STATUS_ICONS;
19768
20633
  exports.ɵTOOL_CALL_STATUS_LABEL_KEYS = TOOL_CALL_STATUS_LABEL_KEYS;
@@ -19770,10 +20635,17 @@ exports.ɵTRANSCRIPTION_ERROR_TIMEOUT_MS = ɵTRANSCRIPTION_ERROR_TIMEOUT_MS;
19770
20635
  exports.ɵThreadSelection = ɵThreadSelection;
19771
20636
  exports.ɵThreadSwitchCoordinator = ɵThreadSwitchCoordinator;
19772
20637
  exports.ɵThreadsController = ɵThreadsController;
20638
+ exports.ɵadaptDefaultToolCallRenderProps = ɵadaptDefaultToolCallRenderProps;
20639
+ exports.ɵaddOpenGenerativeUIContexts = addOpenGenerativeUIContexts;
19773
20640
  exports.ɵagentUpdateHandlers = ɵagentUpdateHandlers;
19774
20641
  exports.ɵappendTranscript = ɵappendTranscript;
19775
- exports.ɵbindDialogFocus = ɵbindDialogFocus;
19776
- exports.ɵbindPopupDismiss = ɵbindPopupDismiss;
20642
+ exports.ɵassembleActivityRenderers = ɵassembleActivityRenderers;
20643
+ exports.ɵassembleHumanInTheLoop = ɵassembleHumanInTheLoop;
20644
+ exports.ɵassembleProviderRegistry = ɵassembleProviderRegistry;
20645
+ exports.ɵassembleProviderToolRenderers = ɵassembleProviderToolRenderers;
20646
+ exports.ɵassembleProviderTools = ɵassembleProviderTools;
20647
+ exports.ɵbindDialogFocus = require_viewport.ɵbindDialogFocus;
20648
+ exports.ɵbindPopupDismiss = require_viewport.ɵbindPopupDismiss;
19777
20649
  exports.ɵbindSuggestionsConfig = ɵbindSuggestionsConfig;
19778
20650
  exports.ɵbuildHumanInTheLoopTool = ɵbuildHumanInTheLoopTool;
19779
20651
  exports.ɵbuildLearnFromUserActionPayload = ɵbuildLearnFromUserActionPayload;
@@ -19781,7 +20653,7 @@ exports.ɵbuildOpenGenerativeUIContexts = buildOpenGenerativeUIContexts;
19781
20653
  exports.ɵbuildToolCallRenderProps = ɵbuildToolCallRenderProps;
19782
20654
  exports.ɵbuildUserMessage = ɵbuildUserMessage;
19783
20655
  exports.ɵbuildUserMessageContent = ɵbuildUserMessageContent;
19784
- exports.ɵcanPreviewDocument = ɵcanPreviewDocument;
20656
+ exports.ɵcanPreviewDocument = require_viewport.ɵcanPreviewDocument;
19785
20657
  exports.ɵclampSlashIndex = ɵclampSlashIndex;
19786
20658
  exports.ɵclearAgentInterruptState = ɵclearAgentInterruptState;
19787
20659
  exports.ɵclearAgentThreadCursors = ɵclearAgentThreadCursors;
@@ -19793,25 +20665,27 @@ exports.ɵcopilotIcons = ɵcopilotIcons;
19793
20665
  exports.ɵcountFailedToolCalls = countFailedToolCalls;
19794
20666
  exports.ɵcreateChatSubmitter = ɵcreateChatSubmitter;
19795
20667
  exports.ɵcreateComposerAutosize = ɵcreateComposerAutosize;
19796
- exports.ɵcreateDockedSidebar = ɵcreateDockedSidebar;
20668
+ exports.ɵcreateDockedSidebar = require_viewport.ɵcreateDockedSidebar;
20669
+ exports.ɵcreateExitPresence = require_viewport.ɵcreateExitPresence;
19797
20670
  exports.ɵcreateLastUserMessageTracker = ɵcreateLastUserMessageTracker;
19798
20671
  exports.ɵcreateMemoryStore = createMemoryStore;
19799
20672
  exports.ɵcreateMessageViewModel = ɵcreateMessageViewModel;
19800
- exports.ɵcreateObjectUrlFromSource = ɵcreateObjectUrlFromSource;
20673
+ exports.ɵcreateObjectUrlFromSource = require_viewport.ɵcreateObjectUrlFromSource;
19801
20674
  exports.ɵcreateOpenGenerativeUITool = createOpenGenerativeUITool;
20675
+ exports.ɵcreateStickToBottom = require_viewport.ɵcreateStickToBottom;
19802
20676
  exports.ɵcreateThreadSelectors = ɵcreateThreadSelectors;
19803
20677
  exports.ɵcreateThreadStore = createThreadStore;
19804
20678
  exports.ɵcreateThreadsDrawerActions = ɵcreateThreadsDrawerActions;
19805
20679
  exports.ɵcreateWaveformRenderer = ɵcreateWaveformRenderer;
19806
- exports.ɵdecodeTextSource = ɵdecodeTextSource;
20680
+ exports.ɵdecodeTextSource = require_viewport.ɵdecodeTextSource;
19807
20681
  exports.ɵdeduplicateMessages = ɵdeduplicateMessages;
19808
20682
  exports.ɵdescribeActivityRendererFailure = ɵdescribeActivityRendererFailure;
19809
20683
  exports.ɵdescribeUnrenderedToolCalls = ɵdescribeUnrenderedToolCalls;
19810
20684
  exports.ɵdiagnoseMissingSurface = diagnoseMissingSurface;
19811
20685
  exports.ɵdiagnoseUnpaintedSurface = diagnoseUnpaintedSurface;
19812
20686
  exports.ɵdiagnoseUnresolvedRoot = diagnoseUnresolvedRoot;
19813
- exports.ɵdimensionToCss = ɵdimensionToCss;
19814
- exports.ɵdockedSidebarRegistryFor = ɵdockedSidebarRegistryFor;
20687
+ exports.ɵdimensionToCss = require_viewport.ɵdimensionToCss;
20688
+ exports.ɵdockedSidebarRegistryFor = require_viewport.ɵdockedSidebarRegistryFor;
19815
20689
  exports.ɵduplicateMessagesWarning = ɵduplicateMessagesWarning;
19816
20690
  exports.ɵextractCompleteStyles = extractCompleteStyles;
19817
20691
  exports.ɵfilterCommands = ɵfilterCommands;
@@ -19820,6 +20694,7 @@ exports.ɵfindChatInput = ɵfindChatInput;
19820
20694
  exports.ɵfindToolMessage = ɵfindToolMessage;
19821
20695
  exports.ɵfitTextareaHeight = ɵfitTextareaHeight;
19822
20696
  exports.ɵflattenCommandItems = ɵflattenCommandItems;
20697
+ exports.ɵflattenToolsMenuForDisplay = ɵflattenToolsMenuForDisplay;
19823
20698
  exports.ɵflattenUserMessageContent = ɵflattenUserMessageContent;
19824
20699
  exports.ɵformatA2UIDebugPayload = formatA2UIDebugPayload;
19825
20700
  exports.ɵformatA2UIRetryLabel = formatA2UIRetryLabel;
@@ -19845,6 +20720,8 @@ exports.ɵgetLatestTurnKey = getLatestTurnKey;
19845
20720
  exports.ɵgetLicenseBannerSpec = ɵgetLicenseBannerSpec;
19846
20721
  exports.ɵgetMessageFeedback = ɵgetMessageFeedback;
19847
20722
  exports.ɵgetMessageFeedbackControls = ɵgetMessageFeedbackControls;
20723
+ exports.ɵgetMessageRunStateSnapshot = ɵgetMessageRunStateSnapshot;
20724
+ exports.ɵgetReasoningHeaderLabel = ɵgetReasoningHeaderLabel;
19848
20725
  exports.ɵgetThreadsDrawerElementProps = ɵgetThreadsDrawerElementProps;
19849
20726
  exports.ɵgetToolCallBadge = ɵgetToolCallBadge;
19850
20727
  exports.ɵgetToolCallGroupState = getToolCallGroupState;
@@ -19862,17 +20739,22 @@ exports.ɵgetWorkSummaryText = ɵgetWorkSummaryText;
19862
20739
  exports.ɵgroupA2UIOperationsBySurface = groupA2UIOperationsBySurface;
19863
20740
  exports.ɵhasAssistantMessageText = ɵhasAssistantMessageText;
19864
20741
  exports.ɵhitlRenderProps = ɵhitlRenderProps;
20742
+ exports.ɵimplementsConnect = ɵimplementsConnect;
19865
20743
  exports.ɵinitialKeyboardState = require_viewport.ɵinitialKeyboardState;
19866
20744
  exports.ɵinspectorKiteFill = ɵinspectorKiteFill;
19867
20745
  exports.ɵinspectorKiteIcon = ɵinspectorKiteIcon;
19868
20746
  exports.ɵinspectorShortcuts = ɵinspectorShortcuts;
20747
+ exports.ɵisContentPart = isContentPart;
20748
+ exports.ɵisContentScrolledToBottom = require_viewport.ɵisContentScrolledToBottom;
19869
20749
  exports.ɵisCopilotKitFeature = ɵisCopilotKitFeature;
20750
+ exports.ɵisFocusVisible = require_viewport.ɵisFocusVisible;
19870
20751
  exports.ɵisHttpAgent = ɵisHttpAgent;
19871
20752
  exports.ɵisLearningFeedbackEnabled = ɵisLearningFeedbackEnabled;
19872
20753
  exports.ɵisMobileViewport = require_viewport.ɵisMobileViewport;
19873
20754
  exports.ɵisOpenGenerativeUIActive = isOpenGenerativeUIActive;
20755
+ exports.ɵisOwnFeedbackThumb = ɵisOwnFeedbackThumb;
19874
20756
  exports.ɵisRetryableMemoryStatus = isRetryableStatus;
19875
- exports.ɵisScrolledToBottom = ɵisScrolledToBottom;
20757
+ exports.ɵisScrolledToBottom = require_viewport.ɵisScrolledToBottom;
19876
20758
  exports.ɵisTurnWorkOpen = isTurnWorkOpen;
19877
20759
  exports.ɵisTurnWorking = isTurnWorking;
19878
20760
  exports.ɵjoinPhoenixChannel$ = ɵjoinPhoenixChannel$;
@@ -19885,10 +20767,12 @@ exports.ɵmemoryDomainEvents = ɵmemoryDomainEvents;
19885
20767
  exports.ɵmemoryReducer = ɵmemoryReducer;
19886
20768
  exports.ɵmemoryRestEvents = ɵmemoryRestEvents;
19887
20769
  exports.ɵmessagesFingerprint = ɵmessagesFingerprint;
19888
- exports.ɵmorphViewTransition = ɵmorphViewTransition;
20770
+ exports.ɵmorphViewTransition = require_viewport.ɵmorphViewTransition;
19889
20771
  exports.ɵnextSlashIndex = ɵnextSlashIndex;
20772
+ exports.ɵnextTabStop = require_viewport.ɵnextTabStop;
19890
20773
  exports.ɵnormalizeAutoScroll = require_viewport.ɵnormalizeAutoScroll;
19891
20774
  exports.ɵnormalizeToolCallStatus = ɵnormalizeToolCallStatus;
20775
+ exports.ɵnormalizeToolsMenu = ɵnormalizeToolsMenu;
19892
20776
  exports.ɵobservePhoenixEvent$ = ɵobservePhoenixEvent$;
19893
20777
  exports.ɵobservePhoenixJoinOutcome$ = ɵobservePhoenixJoinOutcome$;
19894
20778
  exports.ɵobservePhoenixSocketHealth$ = ɵobservePhoenixSocketHealth$;
@@ -19906,10 +20790,12 @@ exports.ɵreadA2UILifecycle = readA2UILifecycle;
19906
20790
  exports.ɵreadKeyboardState = require_viewport.ɵreadKeyboardState;
19907
20791
  exports.ɵrecordAnnotation = ɵrecordAnnotation;
19908
20792
  exports.ɵrecordWorkTime = recordWorkTime;
20793
+ exports.ɵregisterFrontendTools = ɵregisterFrontendTools;
19909
20794
  exports.ɵreportProviderConfigDiagnostics = ɵreportProviderConfigDiagnostics;
19910
20795
  exports.ɵreserveLicenseBannerOffset = ɵreserveLicenseBannerOffset;
19911
20796
  exports.ɵresetAgentThreadBaseline = ɵresetAgentThreadBaseline;
19912
20797
  exports.ɵresetMessageFeedbackCache = ɵresetMessageFeedbackCache;
20798
+ exports.ɵresolveA2UIActivation = ɵresolveA2UIActivation;
19913
20799
  exports.ɵresolveA2UIDebugExposure = resolveA2UIDebugExposure;
19914
20800
  exports.ɵresolveActivityRenderer = ɵresolveActivityRenderer;
19915
20801
  exports.ɵresolveAgentId = ɵresolveAgentId;
@@ -19944,17 +20830,22 @@ exports.ɵsetMessageFeedback = ɵsetMessageFeedback;
19944
20830
  exports.ɵshallowEqualRecord = shallowEqualRecord;
19945
20831
  exports.ɵshouldShowAssistantToolbar = ɵshouldShowAssistantToolbar;
19946
20832
  exports.ɵshouldShowMessageCursor = ɵshouldShowMessageCursor;
20833
+ exports.ɵshowsComposerDisclaimer = ɵshowsComposerDisclaimer;
19947
20834
  exports.ɵsnapshotAgentState = ɵsnapshotAgentState;
20835
+ exports.ɵstableArrayPropWarning = ɵstableArrayPropWarning;
19948
20836
  exports.ɵstopAgentWithFallback = ɵstopAgentWithFallback;
19949
20837
  exports.ɵstringifyToolCallAttr = stringifyToolCallAttr;
19950
20838
  exports.ɵstringifyToolCallPayload = stringifyToolCallPayload;
20839
+ exports.ɵsubscribeToAgentErrors = ɵsubscribeToAgentErrors;
19951
20840
  exports.ɵsubscribeToAgentSuggestions = ɵsubscribeToAgentSuggestions;
19952
20841
  exports.ɵsubscribeToAgentUpdates = ɵsubscribeToAgentUpdates;
19953
20842
  exports.ɵsubscribeToLearningFeedbackEnabled = ɵsubscribeToLearningFeedbackEnabled;
19954
20843
  exports.ɵsubscribeToMessageFeedback = ɵsubscribeToMessageFeedback;
19955
20844
  exports.ɵsurfaceHasRenderableContent = surfaceHasRenderableContent;
20845
+ exports.ɵsyncRecorderToMode = ɵsyncRecorderToMode;
19956
20846
  exports.ɵthreadAdapterEvents = ɵthreadAdapterEvents;
19957
20847
  exports.ɵtoA2UIClientEvent = toA2UIClientEvent;
20848
+ exports.ɵtoDefaultToolCallStatus = ɵtoDefaultToolCallStatus;
19958
20849
  exports.ɵtoDrawerThread = ɵtoDrawerThread;
19959
20850
  exports.ɵtoLearningConfig = ɵtoLearningConfig;
19960
20851
  exports.ɵtoolCallAppearance = toolCallAppearance;
@@ -19964,6 +20855,8 @@ exports.ɵtranscriptionErrorMessageKey = ɵtranscriptionErrorMessageKey;
19964
20855
  exports.ɵtranscriptionErrorNotice = ɵtranscriptionErrorNotice;
19965
20856
  exports.ɵvalidateAgentBinding = ɵvalidateAgentBinding;
19966
20857
  exports.ɵwaitForActiveRun = ɵwaitForActiveRun;
20858
+ exports.ɵwatchElementHeight = require_viewport.ɵwatchElementHeight;
20859
+ exports.ɵwatchElementWidth = require_viewport.ɵwatchElementWidth;
19967
20860
  exports.ɵwatchKeyboardState = require_viewport.ɵwatchKeyboardState;
19968
20861
  exports.ɵwatchMobileViewport = require_viewport.ɵwatchMobileViewport;
19969
20862
  exports.ɵwithHeaderDefaults = ɵwithHeaderDefaults;