@copilotkit/react-core 2.0.0-rc.7 → 2.0.0-rc.8
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/{MarkdownRendererContext-B4Us6mwL.d.cts → MarkdownRendererContext-DAuVISwv.d.cts} +14 -30
- package/dist/MarkdownRendererContext-DAuVISwv.d.cts.map +1 -0
- package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-XWC2OXD5.d.mts} +15 -31
- package/dist/MarkdownRendererContext-XWC2OXD5.d.mts.map +1 -0
- package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-BXaxgpm_.mjs} +91 -74
- package/dist/MarkdownSurfaces-BXaxgpm_.mjs.map +1 -0
- package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-DQZM4lSI.cjs} +96 -73
- package/dist/MarkdownSurfaces-DQZM4lSI.cjs.map +1 -0
- package/dist/context.cjs +20 -17
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +38 -98
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +38 -98
- package/dist/context.d.mts.map +1 -1
- package/dist/context.mjs +20 -17
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui.cjs +35 -15
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +9 -9
- package/dist/generative-ui.d.mts +9 -9
- package/dist/generative-ui.mjs +35 -15
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +50 -76
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +78 -253
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +56 -202
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +43 -74
- package/dist/headless.mjs.map +1 -1
- package/dist/index.cjs +664 -958
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -472
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +168 -472
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +443 -949
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +754 -1029
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -10
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
- package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { A as GenerativeUIError, B as renderSlot, C as issueKey, D as getMarkdownSurfaceSource, E as containsDynamicValue, F as toJsonSchema, G as
|
|
4
|
-
import { A2UI_FENCE_LANGUAGE, AgentRegistry, AgentThreadLockedError, ContextStore, CopilotKitCore, CopilotKitCore as CopilotKitCore$1, CopilotKitCoreErrorCode, CopilotKitCoreErrorCode as CopilotKitCoreErrorCode$1, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreRuntimeConnectionStatus as CopilotKitCoreRuntimeConnectionStatus$1, CopilotKitHeaderResolutionError, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, IntelligenceAgent, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgent as ProxiedCopilotRuntimeAgent$1, RunHandler, StateManager, SuggestionEngine, ToolCallStatus, ToolCallStatus as ToolCallStatus$1, WebMCPRegistry, classifySurfaceCards, completePartialMarkdown, createActionGroup, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, emitInspectorActiveThread, emitInspectorActiveThread as emitInspectorActiveThread$1, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, emitInspectorViewThreadResult as emitInspectorViewThreadResult$1, empty, ensureObjectArgs, extractCompleteArrayItems, extractFenceOperations, extractStringField, flattenInformationalCards, getMarkdownOperationSurfaceId, getWebMCPModelContext, isAbortError, isInspectorThreadBridgeEnabled, isInspectorThreadBridgeEnabled as isInspectorThreadBridgeEnabled$1, isRunCompletionAware, isRunCompletionAware as isRunCompletionAware$1, ofType, on, onInspectorActiveThread, onInspectorStopViewing, onInspectorStopViewing as onInspectorStopViewing$1, onInspectorViewThread, onInspectorViewThread as onInspectorViewThread$1, onInspectorViewThreadResult,
|
|
3
|
+
import { A as GenerativeUIError, B as renderSlot, C as issueKey, D as getMarkdownSurfaceSource, E as containsDynamicValue, F as toJsonSchema, G as CopilotIcon, H as CopilotChatConfigurationProvider, I as defineToolCallRenderer, J as StreamingMarkdownDefaultRenderer, L as MarkdownRendererProvider, M as catalogIdsOf, N as componentCatalogIds, O as BASIC_FUNCTIONS, R as useMarkdownRenderer, S as isAsyncIssue, T as withoutRejectedNulls, U as useCopilotChatConfiguration, V as ControlledModalOpenScope, W as useShallowStableRef, a as GenerativeUIToolCallRenderer, i as GenerativeUIChatSlotContext, j as isRecord, k as ExpressionError, o as createGenerativeUIActivityRenderer, q as cn, s as createGenerativeUIFunctionCallActivityRenderer, t as MarkdownSurfaces, v as GenerativeUIRuntimeContext, w as validateSchemaSync, x as formatIssues, y as useGenerativeUIRuntime, z as isReactComponentType } from "./MarkdownSurfaces-BXaxgpm_.mjs";
|
|
4
|
+
import { A2UI_FENCE_LANGUAGE, AgentRegistry, AgentThreadLockedError, ContextStore, CopilotChatDefaultLabels, CopilotChatDefaultLabels as CopilotChatDefaultLabels$1, CopilotKitCore, CopilotKitCore as CopilotKitCore$1, CopilotKitCoreErrorCode, CopilotKitCoreErrorCode as CopilotKitCoreErrorCode$1, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreRuntimeConnectionStatus as CopilotKitCoreRuntimeConnectionStatus$1, CopilotKitHeaderResolutionError, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, INTERRUPT_EVENT_NAME, IntelligenceAgent, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgent as ProxiedCopilotRuntimeAgent$1, RunHandler, StateManager, SuggestionEngine, ToolCallStatus, ToolCallStatus as ToolCallStatus$1, TranscriptionError, TranscriptionError as TranscriptionError$1, TranscriptionErrorCode, WebMCPRegistry, classifySurfaceCards, completePartialMarkdown, createActionGroup, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, emitInspectorActiveThread, emitInspectorActiveThread as emitInspectorActiveThread$1, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, emitInspectorViewThreadResult as emitInspectorViewThreadResult$1, empty, ensureObjectArgs, extractCompleteArrayItems, extractFenceOperations, extractStringField, flattenInformationalCards, getMarkdownOperationSurfaceId, getWebMCPModelContext, isAbortError, isInspectorThreadBridgeEnabled, isInspectorThreadBridgeEnabled as isInspectorThreadBridgeEnabled$1, isRunCompletionAware, isRunCompletionAware as isRunCompletionAware$1, ofType, on, onInspectorActiveThread, onInspectorStopViewing, onInspectorStopViewing as onInspectorStopViewing$1, onInspectorViewThread, onInspectorViewThread as onInspectorViewThread$1, onInspectorViewThreadResult, parseToolArguments, prepareSurfaceOperations, props, segmentSurfaceProse, select, splitA2UIMarkdown, ɵCOPILOTKIT_FEATURES, ɵInterruptState, ɵInterruptState as ɵInterruptState$1, ɵMAX_SOCKET_RETRIES, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵTHREAD_REQUEST_TIMEOUT_MS, ɵclearAgentInterruptState, ɵclearAgentInterruptState as ɵclearAgentInterruptState$1, ɵcomposerButtonState, ɵcomposerButtonState as ɵcomposerButtonState$1, ɵcopilotIconSvgAttributes, ɵcopilotIcons, ɵcountFailedToolCalls, ɵcountFailedToolCalls as ɵcountFailedToolCalls$1, ɵcreateMemoryStore, ɵcreateThreadSelectors, ɵcreateThreadStore, ɵcreateThreadStore as ɵcreateThreadStore$1, ɵdeduplicateMessages, ɵdeduplicateMessages as ɵdeduplicateMessages$1, ɵformatCountLabel, ɵformatCountLabel as ɵformatCountLabel$1, ɵformatLabel, ɵformatLabel as ɵformatLabel$1, ɵformatReasoningDuration, ɵformatReasoningDuration as ɵformatReasoningDuration$1, ɵformatToolNames, ɵformatToolNames as ɵformatToolNames$1, ɵformatWorkDuration, ɵformatWorkDuration as ɵformatWorkDuration$1, ɵgetAgentInterruptState, ɵgetAgentInterruptState as ɵgetAgentInterruptState$1, ɵgetArgumentPreview, ɵgetArgumentPreview as ɵgetArgumentPreview$1, ɵgetLatestTurnKey, ɵgetLatestTurnKey as ɵgetLatestTurnKey$1, ɵgetToolCallLayouts, ɵgetToolCallLayouts as ɵgetToolCallLayouts$1, ɵgetToolCallPreview, ɵgetToolCallPreview as ɵgetToolCallPreview$1, ɵgetToolCallRendererNames, ɵgetToolCallRendererNames as ɵgetToolCallRendererNames$1, ɵgetToolCallRowStatus, ɵgetToolCallRowStatus as ɵgetToolCallRowStatus$1, ɵgetToolResults, ɵgetTurnWork, ɵgetTurnWork as ɵgetTurnWork$1, ɵgetWorkOpenState, ɵgetWorkOpenState as ɵgetWorkOpenState$1, ɵisCopilotKitFeature, ɵisHttpAgent, ɵisHttpAgent as ɵisHttpAgent$1, ɵisRetryableMemoryStatus, ɵisTurnWorkOpen, ɵisTurnWorkOpen as ɵisTurnWorkOpen$1, ɵisTurnWorking, ɵisTurnWorking as ɵisTurnWorking$1, ɵjoinPhoenixChannel$, ɵmapMemoryMetadataEvent, ɵmemoryAdapterEvents, ɵmemoryDomainEvents, ɵmemoryReducer, ɵmemoryRestEvents, ɵmessagesFingerprint, ɵmessagesFingerprint as ɵmessagesFingerprint$1, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵpluralize, ɵrecordWorkTime, ɵrecordWorkTime as ɵrecordWorkTime$1, ɵresolveActivityRenderer, ɵresolveActivityRenderer as ɵresolveActivityRenderer$1, ɵresolveComposerKey, ɵresolveComposerKey as ɵresolveComposerKey$1, ɵresolveCustomMessageRenderers, ɵresolveCustomMessageRenderers as ɵresolveCustomMessageRenderers$1, ɵresolveLicenseState, ɵresolveLicenseState as ɵresolveLicenseState$1, ɵresolveThreadsLicense, ɵresolveToolCallRenderer, ɵresolveToolCallRenderer as ɵresolveToolCallRenderer$1, ɵselectFetchMoreError, ɵselectFetchMoreError as ɵselectFetchMoreError$1, ɵselectHasNextPage, ɵselectHasNextPage as ɵselectHasNextPage$1, ɵselectIsFetchingNextPage, ɵselectIsFetchingNextPage as ɵselectIsFetchingNextPage$1, ɵselectIsMutating, ɵselectIsMutating as ɵselectIsMutating$1, ɵselectMemories, ɵselectMemories as ɵselectMemories$1, ɵselectMemoriesAvailable, ɵselectMemoriesAvailable as ɵselectMemoriesAvailable$1, ɵselectMemoriesError, ɵselectMemoriesError as ɵselectMemoriesError$1, ɵselectMemoriesIsLoading, ɵselectMemoriesIsLoading as ɵselectMemoriesIsLoading$1, ɵselectMemoriesIsMutating, ɵselectMemoriesRealtimeStatus, ɵselectMemoriesRealtimeStatus as ɵselectMemoriesRealtimeStatus$1, ɵselectThreads, ɵselectThreads as ɵselectThreads$1, ɵselectThreadsError, ɵselectThreadsError as ɵselectThreadsError$1, ɵselectThreadsIsLoading, ɵselectThreadsIsLoading as ɵselectThreadsIsLoading$1, ɵstringifyToolCallPayload, ɵstringifyToolCallPayload as ɵstringifyToolCallPayload$1, ɵthreadAdapterEvents, ɵtranscribeAudio, ɵtranscribeAudio as ɵtranscribeAudio$1, ɵtranscriptionErrorMessageKey, ɵtranscriptionErrorMessageKey as ɵtranscriptionErrorMessageKey$1, ɵwithHeaderDefaults, ɵwithHeaderDefaults as ɵwithHeaderDefaults$1 } from "@copilotkit/core";
|
|
5
5
|
import { ACTIVITY_HISTORY_METADATA, AGUIConnectNotImplementedError, AGUIError, AGUI_METADATA_KEY, AbstractAgent, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, BackwardCompatibility_0_0_57, CompatibilityBoundary, DebugLogger, EventType, FilterToolCallsMiddleware, FunctionMiddleware, HttpAgent, Middleware, PROTOCOL_VERSION, aggregateTokenUsage, authoritativeActivityTypes, buildResumeArray, compactEvents, contentHasMedia, contentToText, convertToLegacyEvents, createDebugLogger, defaultApplyEvents, enforceEvents, enforceOutgoingInput, getRunOutcome, isInterruptExpired, isRecognizedEvent, mergeMetadata, omitOptionalNulls, parseProtoStream, parseSSEStream, randomUUID, randomUUID as randomUUID$1, resolveAgentDebugConfig, resolveDebugLogger, runHttpRequest, structuredClone_, tokenUsageFromAiSdkUsage, tokenUsageFromLangChainMetadata, transformChunks, transformHttpEventStream, verifyEvents, withAuthoritativeActivityTypes } from "@ag-ui/client";
|
|
6
6
|
import { ActivityDeltaEventSchema, ActivityMessageSchema, ActivitySnapshotEventSchema, AddOperationSchema, AgentCapabilitiesSchema, AssistantMessageSchema, AttributableSchema, AudioInputContentSchema, AudioInputPartSchema, AudioPartSchema, BaseEventSchema, BaseMessageSchema, ContentPartSchema, ContextSchema, CopyOperationSchema, CustomEventSchema, DataSourceSchema, DeveloperMessageSchema, DocumentInputContentSchema, DocumentInputPartSchema, DocumentPartSchema, EventSchema, EventSchemas, EventTypeSchema, ExecutionCapabilitiesSchema, FileSourceSchema, FunctionCallSchema, HumanInTheLoopCapabilitiesSchema, IdentityCapabilitiesSchema, ImageInputContentSchema, ImageInputPartSchema, ImagePartSchema, InputContentDataSourceSchema, InputContentSchema, InputContentSourceSchema, InputContentUrlSourceSchema, InterruptSchema, JsonPatchOperationSchema, JsonPatchSchema, JsonPointerSchema, MessageSchema, MessagesSnapshotEventSchema, MetadataSchema, MoveOperationSchema, MultiAgentCapabilitiesSchema, MultimodalCapabilitiesSchema, MultimodalInputCapabilitiesSchema, MultimodalOutputCapabilitiesSchema, OptionalMetadataSchema, OutputCapabilitiesSchema, PartSourceSchema, RawEventSchema, ReasoningCapabilitiesSchema, ReasoningEncryptedValueEventSchema, ReasoningEncryptedValueSubtypeSchema, ReasoningEndEventSchema, ReasoningMessageChunkEventSchema, ReasoningMessageContentEventSchema, ReasoningMessageEndEventSchema, ReasoningMessageSchema, ReasoningMessageStartEventSchema, ReasoningStartEventSchema, RemoveOperationSchema, ReplaceOperationSchema, ResumeEntrySchema, RoleSchema, RunAgentInputSchema, RunErrorEventSchema, RunFinishedCancelledOutcomeSchema, RunFinishedEventSchema, RunFinishedInterruptOutcomeSchema, RunFinishedOutcomeSchema, RunFinishedSuccessOutcomeSchema, RunStartedEventSchema, StateCapabilitiesSchema, StateDeltaEventSchema, StateSchema, StateSnapshotEventSchema, StepFinishedEventSchema, StepStartedEventSchema, SubagentErrorEventSchema, SubagentFinishedEventSchema, SubagentFinishedOutcomeSchema, SubagentFinishedSuccessOutcomeSchema, SubagentFinishedSuspendedOutcomeSchema, SubagentInfoSchema, SubagentRunIdSchema, SubagentStartedEventSchema, SystemMessageSchema, TestOperationSchema, TextInputContentSchema, TextMessageChunkEventSchema, TextMessageContentEventSchema, TextMessageEndEventSchema, TextMessageRoleSchema, TextMessageStartEventSchema, TextPartSchema, TokenUsageSchema, ToolCallArgsEventSchema, ToolCallChunkEventSchema, ToolCallEndEventSchema, ToolCallResultEventSchema, ToolCallSchema, ToolCallStartEventSchema, ToolMessageSchema, ToolSchema, ToolsCapabilitiesSchema, TransportCapabilitiesSchema, UrlSourceSchema, UserMessageSchema, VideoInputContentSchema, VideoInputPartSchema, VideoPartSchema } from "@ag-ui/core/schemas";
|
|
7
7
|
import * as React$1 from "react";
|
|
8
8
|
import React, { Fragment, createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, version } from "react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import {
|
|
11
|
-
import { A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, A2UI_VERSION, COPILOTKIT_FORWARDED_PROPS_KEY, COPILOTKIT_UI_ENVELOPE_FORMAT, DEFAULT_AGENT_ID, GENERATE_SANDBOXED_UI_DESCRIPTION, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_AGENT_FUNCTION_CALLS, GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION, GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION, GENERATIVE_UI_MAX_REJECTION_LENGTH, GENERATIVE_UI_MAX_SUMMARY_REJECTIONS, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, buildGenerativeUIMarkdownGuidelines, buildGenerativeUIPrompt, callerProblem, childRefKind, commitRowKeyStore, copyToClipboard, createAttachmentContent, createLicenseContextValue, createRowKeyStore, envelopeToManifest, exceedsMaxSize, formatFileSize, functionCallers, generateVideoThumbnail, generativeUIGuideFeatures, getDocumentIcon, getModalityFromMimeType, getOperationKind, getOperationSurfaceId, getSourceUrl, matchesAcceptFilter, partialJSONParse, randomUUID as randomUUID$2, readFileAsBase64, resolveRowRenderKeysById, schemaToJsonSchema, shouldEnableInspector, toA2UIActionMessage, validateOperation } from "@copilotkit/shared";
|
|
10
|
+
import { A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, A2UI_VERSION, COPILOTKIT_FORWARDED_PROPS_KEY, COPILOTKIT_UI_ENVELOPE_FORMAT, DEFAULT_AGENT_ID, GENERATE_SANDBOXED_UI_DESCRIPTION, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_AGENT_FUNCTION_CALLS, GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION, GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION, GENERATIVE_UI_MAX_REJECTION_LENGTH, GENERATIVE_UI_MAX_SUMMARY_REJECTIONS, buildGenerativeUIMarkdownGuidelines, buildGenerativeUIPrompt, callerProblem, childRefKind, commitRowKeyStore, copyToClipboard, createAttachmentContent, createRowKeyStore, envelopeToManifest, exceedsMaxSize, formatFileSize, functionCallers, generateVideoThumbnail, generativeUIGuideFeatures, getDocumentIcon, getModalityFromMimeType, getOperationKind, getOperationSurfaceId, getSourceUrl, matchesAcceptFilter, partialJSONParse, randomUUID as randomUUID$2, readFileAsBase64, resolveRowRenderKeysById, schemaToJsonSchema, shouldEnableInspector, toA2UIActionMessage, validateOperation, ɵanySchema } from "@copilotkit/shared";
|
|
12
11
|
import { CopilotKitAgentIdContext, CopilotKitContext, LicenseContext, useCopilotKit, useCopilotKit as useCopilotKit$1, useDefaultAgentId, useLicenseContext, useLicenseContext as useLicenseContext$1 } from "@copilotkit/react-core/context";
|
|
13
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
14
12
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
15
13
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
16
14
|
import { contentToText as contentToText$1 } from "@ag-ui/core";
|
|
17
|
-
import { z } from "zod";
|
|
18
15
|
import { MCPAppsActivityContentSchema, MCPAppsActivityType, ɵrunMcpFollowUp } from "@copilotkit/mcp-apps-renderer/activity";
|
|
16
|
+
import { z } from "zod";
|
|
19
17
|
import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, ROOT_COMPONENT_ID, buildCatalogContextValue, defaultTheme as a2uiDefaultTheme, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
|
|
20
18
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
21
19
|
import { Catalog as Catalog$1, ComponentModel, DataModel, SurfaceModel } from "@a2ui/web_core/v0_9";
|
|
@@ -26,111 +24,6 @@ import { useVirtualizer } from "@tanstack/react-virtual";
|
|
|
26
24
|
import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
|
|
27
25
|
import { COPILOTKIT_THREADS_DRAWER_TAG, defineCopilotKitThreadsDrawer } from "@copilotkit/web-components/threads-drawer";
|
|
28
26
|
|
|
29
|
-
//#region src/components/chat/BasicMarkdownRenderer.tsx
|
|
30
|
-
const SAFE_HREF = /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i;
|
|
31
|
-
const SAFE_IMG_SRC = /^(https?:|data:image\/(?!svg)|\/|\.\/|\.\.\/)/i;
|
|
32
|
-
function sanitizeHref(href) {
|
|
33
|
-
if (!href) return void 0;
|
|
34
|
-
return SAFE_HREF.test(href.trim()) ? href : void 0;
|
|
35
|
-
}
|
|
36
|
-
function sanitizeImgSrc(src) {
|
|
37
|
-
if (!src) return void 0;
|
|
38
|
-
return SAFE_IMG_SRC.test(src.trim()) ? src : void 0;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Dependency-light built-in markdown renderer (basic GFM). Walks the
|
|
42
|
-
* framework-agnostic token tree from `@copilotkit/core` into React elements.
|
|
43
|
-
* No syntax highlighting, no math, no table/image action buttons — plug in a
|
|
44
|
-
* custom renderer via `CopilotKitProvider markdownRenderer={...}` for those.
|
|
45
|
-
*/
|
|
46
|
-
function BasicMarkdownRenderer({ content, className }) {
|
|
47
|
-
const tokens = React.useMemo(() => parseMarkdown$1(content ?? ""), [content]);
|
|
48
|
-
if (!tokens.length) return null;
|
|
49
|
-
return /* @__PURE__ */ jsx("div", {
|
|
50
|
-
className,
|
|
51
|
-
children: tokens.map((t, i) => /* @__PURE__ */ jsx(BlockToken, { token: t }, i))
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function renderInline(tokens) {
|
|
55
|
-
if (!tokens) return null;
|
|
56
|
-
return tokens.map((token, i) => {
|
|
57
|
-
switch (token.type) {
|
|
58
|
-
case "text": return "tokens" in token && token.tokens ? renderInline(token.tokens) : token.text;
|
|
59
|
-
case "strong": return /* @__PURE__ */ jsx("strong", { children: renderInline(token.tokens) }, i);
|
|
60
|
-
case "em": return /* @__PURE__ */ jsx("em", { children: renderInline(token.tokens) }, i);
|
|
61
|
-
case "del": return /* @__PURE__ */ jsx("del", { children: renderInline(token.tokens) }, i);
|
|
62
|
-
case "codespan": return /* @__PURE__ */ jsx("code", {
|
|
63
|
-
className: "cpk-markdown-inline-code",
|
|
64
|
-
children: token.text
|
|
65
|
-
}, i);
|
|
66
|
-
case "br": return /* @__PURE__ */ jsx("br", {}, i);
|
|
67
|
-
case "link": {
|
|
68
|
-
const l = token;
|
|
69
|
-
return /* @__PURE__ */ jsx("a", {
|
|
70
|
-
href: sanitizeHref(l.href),
|
|
71
|
-
target: "_blank",
|
|
72
|
-
rel: "noopener noreferrer",
|
|
73
|
-
children: l.tokens ? renderInline(l.tokens) : l.text
|
|
74
|
-
}, i);
|
|
75
|
-
}
|
|
76
|
-
case "image": {
|
|
77
|
-
const img = token;
|
|
78
|
-
return /* @__PURE__ */ jsx("img", {
|
|
79
|
-
src: sanitizeImgSrc(img.href),
|
|
80
|
-
alt: img.text,
|
|
81
|
-
className: "cpk-markdown-image"
|
|
82
|
-
}, i);
|
|
83
|
-
}
|
|
84
|
-
case "escape": return token.text;
|
|
85
|
-
default: return "text" in token ? token.text : null;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function BlockToken({ token }) {
|
|
90
|
-
switch (token.type) {
|
|
91
|
-
case "space": return null;
|
|
92
|
-
case "heading": {
|
|
93
|
-
const h = token;
|
|
94
|
-
return /* @__PURE__ */ jsx(`h${Math.min(Math.max(h.depth, 1), 6)}`, { children: renderInline(h.tokens) });
|
|
95
|
-
}
|
|
96
|
-
case "paragraph": return /* @__PURE__ */ jsx("p", { children: renderInline(token.tokens ?? []) });
|
|
97
|
-
case "blockquote": return /* @__PURE__ */ jsx("blockquote", { children: (token.tokens ?? []).map((t, i) => /* @__PURE__ */ jsx(BlockToken, { token: t }, i)) });
|
|
98
|
-
case "code": {
|
|
99
|
-
const c = token;
|
|
100
|
-
return /* @__PURE__ */ jsx("pre", {
|
|
101
|
-
className: "cpk-markdown-code-block",
|
|
102
|
-
children: /* @__PURE__ */ jsx("code", {
|
|
103
|
-
"data-language": c.lang || void 0,
|
|
104
|
-
children: c.text
|
|
105
|
-
})
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
case "hr": return /* @__PURE__ */ jsx("hr", {});
|
|
109
|
-
case "list": {
|
|
110
|
-
const list = token;
|
|
111
|
-
const items = list.items.map((item, i) => /* @__PURE__ */ jsx("li", { children: (item.tokens ?? []).map((t, j) => /* @__PURE__ */ jsx(BlockToken, { token: t }, j)) }, i));
|
|
112
|
-
return list.ordered ? /* @__PURE__ */ jsx("ol", {
|
|
113
|
-
start: typeof list.start === "number" ? list.start : void 0,
|
|
114
|
-
children: items
|
|
115
|
-
}) : /* @__PURE__ */ jsx("ul", { children: items });
|
|
116
|
-
}
|
|
117
|
-
case "table": {
|
|
118
|
-
const tbl = token;
|
|
119
|
-
return /* @__PURE__ */ jsx("div", {
|
|
120
|
-
className: "cpk-markdown-table-container",
|
|
121
|
-
children: /* @__PURE__ */ jsxs("table", { children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: tbl.header.map((cell, i) => /* @__PURE__ */ jsx("th", { children: renderInline(cell.tokens) }, i)) }) }), /* @__PURE__ */ jsx("tbody", { children: tbl.rows.map((row, i) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, j) => /* @__PURE__ */ jsx("td", { children: renderInline(cell.tokens) }, j)) }, i)) })] })
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
case "text": {
|
|
125
|
-
const t = token;
|
|
126
|
-
return /* @__PURE__ */ jsx("p", { children: t.tokens ? renderInline(t.tokens) : t.text });
|
|
127
|
-
}
|
|
128
|
-
default: return "text" in token ? /* @__PURE__ */ jsx("span", { children: token.text }) : null;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
BasicMarkdownRenderer.displayName = "BasicMarkdownRenderer";
|
|
132
|
-
|
|
133
|
-
//#endregion
|
|
134
27
|
//#region src/components/ui/button.tsx
|
|
135
28
|
const variantClasses = {
|
|
136
29
|
default: "cpk-button-default",
|
|
@@ -158,8 +51,8 @@ const sizeClasses = {
|
|
|
158
51
|
function buttonVariants({ variant, size, className, class: classProp } = {}) {
|
|
159
52
|
return cn("cpk-button", variant !== null && variantClasses[variant ?? "default"], size !== null && sizeClasses[size ?? "default"], classProp, className);
|
|
160
53
|
}
|
|
161
|
-
const Button = React$1.forwardRef(function Button({ className, variant, size,
|
|
162
|
-
return /* @__PURE__ */ jsx(
|
|
54
|
+
const Button = React$1.forwardRef(function Button({ className, variant, size, ...props }, ref) {
|
|
55
|
+
return /* @__PURE__ */ jsx("button", {
|
|
163
56
|
ref,
|
|
164
57
|
"data-slot": "button",
|
|
165
58
|
className: buttonVariants({
|
|
@@ -264,7 +157,10 @@ function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
|
|
|
264
157
|
"data-inset": inset,
|
|
265
158
|
className: cn("cpk-dropdown-menu-sub-trigger", className),
|
|
266
159
|
...props,
|
|
267
|
-
children: [children, /* @__PURE__ */ jsx(
|
|
160
|
+
children: [children, /* @__PURE__ */ jsx(CopilotIcon, {
|
|
161
|
+
name: "ChevronRight",
|
|
162
|
+
className: "cpk-dropdown-menu-sub-trigger-icon"
|
|
163
|
+
})]
|
|
268
164
|
});
|
|
269
165
|
}
|
|
270
166
|
function DropdownMenuSubContent({ className, ...props }) {
|
|
@@ -504,7 +400,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
504
400
|
const audioRecorderRef = useRef(null);
|
|
505
401
|
const slashMenuRef = useRef(null);
|
|
506
402
|
const config = useCopilotChatConfiguration();
|
|
507
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
403
|
+
const labels = config?.labels ?? CopilotChatDefaultLabels$1;
|
|
508
404
|
const previousModalStateRef = useRef(void 0);
|
|
509
405
|
const measurementCanvasRef = useRef(null);
|
|
510
406
|
const measurementsRef = useRef({
|
|
@@ -625,6 +521,14 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
625
521
|
inputRef.current?.focus();
|
|
626
522
|
});
|
|
627
523
|
}, [clearInputValue]);
|
|
524
|
+
const composerInput = {
|
|
525
|
+
mode,
|
|
526
|
+
isRunning,
|
|
527
|
+
value: resolvedValue,
|
|
528
|
+
canSubmit: !!onSubmitMessage,
|
|
529
|
+
canStop: !!onStop
|
|
530
|
+
};
|
|
531
|
+
const { isProcessing, action: buttonAction, disabled: buttonDisabled } = ɵcomposerButtonState$1(composerInput);
|
|
628
532
|
const handleKeyDown = (e) => {
|
|
629
533
|
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
630
534
|
if (commandQuery !== null && mode === "input") {
|
|
@@ -663,11 +567,15 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
663
567
|
return;
|
|
664
568
|
}
|
|
665
569
|
}
|
|
666
|
-
if (e.key === "Enter" && !e.shiftKey)
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
570
|
+
if (e.key === "Enter" && !e.shiftKey) e.preventDefault();
|
|
571
|
+
const action = ɵresolveComposerKey$1({
|
|
572
|
+
key: e.key,
|
|
573
|
+
shiftKey: e.shiftKey,
|
|
574
|
+
isComposing: e.nativeEvent.isComposing,
|
|
575
|
+
keyCode: e.keyCode
|
|
576
|
+
}, composerInput);
|
|
577
|
+
if (action === "stop") onStop?.();
|
|
578
|
+
else if (action === "send") send();
|
|
671
579
|
};
|
|
672
580
|
const send = () => {
|
|
673
581
|
if (!onSubmitMessage) return;
|
|
@@ -692,9 +600,6 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
692
600
|
autoFocus,
|
|
693
601
|
className: isExpanded ? "cpk-chat-input-textarea-expanded" : "cpk-chat-input-textarea-compact"
|
|
694
602
|
});
|
|
695
|
-
const isProcessing = mode !== "transcribe" && isRunning;
|
|
696
|
-
const canSend = resolvedValue.trim().length > 0 && !!onSubmitMessage;
|
|
697
|
-
const canStop = !!onStop;
|
|
698
603
|
const handleSendButtonClick = () => {
|
|
699
604
|
if (isProcessing) {
|
|
700
605
|
onStop?.();
|
|
@@ -703,12 +608,15 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
703
608
|
send();
|
|
704
609
|
};
|
|
705
610
|
const BoundAudioRecorder = renderSlot(audioRecorder, CopilotChatAudioRecorder, { ref: audioRecorderRef });
|
|
706
|
-
const showsStop =
|
|
611
|
+
const showsStop = buttonAction === "stop";
|
|
707
612
|
const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {
|
|
708
613
|
onClick: handleSendButtonClick,
|
|
709
|
-
disabled:
|
|
614
|
+
disabled: buttonDisabled,
|
|
710
615
|
"aria-label": showsStop ? labels.chatInputToolbarStopButtonLabel : labels.chatInputToolbarSendButtonLabel,
|
|
711
|
-
children: showsStop ? /* @__PURE__ */ jsx(
|
|
616
|
+
children: showsStop ? /* @__PURE__ */ jsx(CopilotIcon, {
|
|
617
|
+
name: "Square",
|
|
618
|
+
className: "cpk-chat-input-stop-icon"
|
|
619
|
+
}) : void 0
|
|
712
620
|
});
|
|
713
621
|
const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, { onClick: onStartTranscribe });
|
|
714
622
|
const BoundCancelTranscribeButton = renderSlot(cancelTranscribeButton, CopilotChatInput.CancelTranscribeButton, { onClick: onCancelTranscribe });
|
|
@@ -965,7 +873,10 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
965
873
|
className: "cpk-chat-input-field",
|
|
966
874
|
children: mode === "transcribe" ? BoundAudioRecorder : mode === "processing" ? /* @__PURE__ */ jsx("div", {
|
|
967
875
|
className: "cpk-chat-input-processing",
|
|
968
|
-
children: /* @__PURE__ */ jsx(
|
|
876
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
877
|
+
name: "Loader2",
|
|
878
|
+
className: "cpk-chat-input-processing-spinner"
|
|
879
|
+
})
|
|
969
880
|
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [BoundTextArea, slashMenu] })
|
|
970
881
|
}),
|
|
971
882
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -1025,7 +936,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1025
936
|
}
|
|
1026
937
|
(function(_CopilotChatInput) {
|
|
1027
938
|
_CopilotChatInput.SendButton = ({ className, children, ...props }) => {
|
|
1028
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
939
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
1029
940
|
return /* @__PURE__ */ jsx("div", {
|
|
1030
941
|
className: "cpk-chat-input-send",
|
|
1031
942
|
children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -1036,12 +947,15 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1036
947
|
className: cn("cpk-chat-input-send-button", className),
|
|
1037
948
|
"aria-label": labels.chatInputToolbarSendButtonLabel,
|
|
1038
949
|
...props,
|
|
1039
|
-
children: children ?? /* @__PURE__ */ jsx(
|
|
950
|
+
children: children ?? /* @__PURE__ */ jsx(CopilotIcon, {
|
|
951
|
+
name: "ArrowUp",
|
|
952
|
+
className: "cpk-chat-input-send-icon"
|
|
953
|
+
})
|
|
1040
954
|
})
|
|
1041
955
|
});
|
|
1042
956
|
};
|
|
1043
957
|
const ToolbarButton = _CopilotChatInput.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
|
|
1044
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
958
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
1045
959
|
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
1046
960
|
asChild: true,
|
|
1047
961
|
children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -1060,27 +974,36 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1060
974
|
};
|
|
1061
975
|
_CopilotChatInput.StartTranscribeButton = (props) => /* @__PURE__ */ jsx(ToolbarButton, {
|
|
1062
976
|
"data-testid": "copilot-start-transcribe-button",
|
|
1063
|
-
icon: /* @__PURE__ */ jsx(
|
|
977
|
+
icon: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
978
|
+
name: "Mic",
|
|
979
|
+
className: "cpk-chat-input-toolbar-icon"
|
|
980
|
+
}),
|
|
1064
981
|
labelKey: "chatInputToolbarStartTranscribeButtonLabel",
|
|
1065
982
|
defaultClassName: "cpk-chat-input-start-transcribe-button",
|
|
1066
983
|
...props
|
|
1067
984
|
});
|
|
1068
985
|
_CopilotChatInput.CancelTranscribeButton = (props) => /* @__PURE__ */ jsx(ToolbarButton, {
|
|
1069
986
|
"data-testid": "copilot-cancel-transcribe-button",
|
|
1070
|
-
icon: /* @__PURE__ */ jsx(
|
|
987
|
+
icon: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
988
|
+
name: "X",
|
|
989
|
+
className: "cpk-chat-input-toolbar-icon"
|
|
990
|
+
}),
|
|
1071
991
|
labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
|
|
1072
992
|
defaultClassName: "cpk-chat-input-cancel-transcribe-button",
|
|
1073
993
|
...props
|
|
1074
994
|
});
|
|
1075
995
|
_CopilotChatInput.FinishTranscribeButton = (props) => /* @__PURE__ */ jsx(ToolbarButton, {
|
|
1076
996
|
"data-testid": "copilot-finish-transcribe-button",
|
|
1077
|
-
icon: /* @__PURE__ */ jsx(
|
|
997
|
+
icon: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
998
|
+
name: "Check",
|
|
999
|
+
className: "cpk-chat-input-toolbar-icon"
|
|
1000
|
+
}),
|
|
1078
1001
|
labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
|
|
1079
1002
|
defaultClassName: "cpk-chat-input-finish-transcribe-button",
|
|
1080
1003
|
...props
|
|
1081
1004
|
});
|
|
1082
1005
|
_CopilotChatInput.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
|
|
1083
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1006
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
1084
1007
|
const [mounted, setMounted] = useState(false);
|
|
1085
1008
|
useEffect(() => setMounted(true), []);
|
|
1086
1009
|
const menuItems = useMemo(() => {
|
|
@@ -1122,7 +1045,10 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1122
1045
|
disabled: isDisabled,
|
|
1123
1046
|
"aria-label": labels.chatInputToolbarAddButtonLabel,
|
|
1124
1047
|
...props,
|
|
1125
|
-
children: /* @__PURE__ */ jsx(
|
|
1048
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
1049
|
+
name: "Plus",
|
|
1050
|
+
className: "cpk-chat-input-add-menu-icon"
|
|
1051
|
+
})
|
|
1126
1052
|
});
|
|
1127
1053
|
if (!mounted) return button;
|
|
1128
1054
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
@@ -1148,7 +1074,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1148
1074
|
};
|
|
1149
1075
|
_CopilotChatInput.TextArea = forwardRef(function TextArea({ style, className, autoFocus, placeholder, ...props }, ref) {
|
|
1150
1076
|
const internalTextareaRef = useRef(null);
|
|
1151
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1077
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
1152
1078
|
useImperativeHandle(ref, () => internalTextareaRef.current);
|
|
1153
1079
|
useEffect(() => {
|
|
1154
1080
|
if (autoFocus) internalTextareaRef.current?.focus({ preventScroll: true });
|
|
@@ -1169,7 +1095,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1169
1095
|
});
|
|
1170
1096
|
_CopilotChatInput.AudioRecorder = CopilotChatAudioRecorder;
|
|
1171
1097
|
_CopilotChatInput.Disclaimer = ({ className, ...props }) => {
|
|
1172
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1098
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
1173
1099
|
return /* @__PURE__ */ jsx("div", {
|
|
1174
1100
|
className: cn("cpk-chat-input-disclaimer", className),
|
|
1175
1101
|
...props,
|
|
@@ -1265,16 +1191,7 @@ function useToolCallRenderers() {
|
|
|
1265
1191
|
*/
|
|
1266
1192
|
function useToolCallRendererNames() {
|
|
1267
1193
|
const renderers = useToolCallRenderers();
|
|
1268
|
-
return useMemo(() =>
|
|
1269
|
-
const named = renderers.filter((rc) => rc.name !== "*");
|
|
1270
|
-
const wildcards = renderers.filter((rc) => rc.name === "*");
|
|
1271
|
-
return {
|
|
1272
|
-
named: new Set(named.map((rc) => rc.name)),
|
|
1273
|
-
groupedNames: new Set(named.filter((rc) => rc.group).map((rc) => rc.name)),
|
|
1274
|
-
wildcard: wildcards.length > 0,
|
|
1275
|
-
wildcardGroups: wildcards.some((rc) => rc.group)
|
|
1276
|
-
};
|
|
1277
|
-
}, [renderers]);
|
|
1194
|
+
return useMemo(() => ɵgetToolCallRendererNames$1(renderers), [renderers]);
|
|
1278
1195
|
}
|
|
1279
1196
|
/**
|
|
1280
1197
|
* Hook that returns a function to render tool calls based on the render functions
|
|
@@ -1289,18 +1206,17 @@ function useRenderToolCall() {
|
|
|
1289
1206
|
const warnedToolNames = useRef(/* @__PURE__ */ new Set());
|
|
1290
1207
|
const renderToolCalls = useToolCallRenderers();
|
|
1291
1208
|
const renderToolCall = useCallback(({ toolCall, toolMessage }) => {
|
|
1292
|
-
const
|
|
1293
|
-
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
1209
|
+
const renderConfig = ɵresolveToolCallRenderer$1(renderToolCalls, toolCall.function.name, agentId);
|
|
1294
1210
|
if (!renderConfig) {
|
|
1295
1211
|
if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
|
|
1296
1212
|
return null;
|
|
1297
1213
|
}
|
|
1298
|
-
const
|
|
1214
|
+
const isExecuting = executingToolCallIds.has(toolCall.id);
|
|
1299
1215
|
return /* @__PURE__ */ jsx(ToolCallRenderer, {
|
|
1300
1216
|
toolCall,
|
|
1301
1217
|
toolMessage,
|
|
1302
|
-
RenderComponent,
|
|
1303
|
-
isExecuting
|
|
1218
|
+
RenderComponent: renderConfig.render,
|
|
1219
|
+
isExecuting
|
|
1304
1220
|
}, toolCall.id);
|
|
1305
1221
|
}, [
|
|
1306
1222
|
renderToolCalls,
|
|
@@ -1322,7 +1238,7 @@ function useRenderToolCall() {
|
|
|
1322
1238
|
|
|
1323
1239
|
//#endregion
|
|
1324
1240
|
//#region package.json
|
|
1325
|
-
var version$1 = "2.0.0-rc.
|
|
1241
|
+
var version$1 = "2.0.0-rc.8";
|
|
1326
1242
|
|
|
1327
1243
|
//#endregion
|
|
1328
1244
|
//#region src/components/CopilotKitInspector.tsx
|
|
@@ -1393,6 +1309,15 @@ function useCopilotKitInspector() {
|
|
|
1393
1309
|
|
|
1394
1310
|
//#endregion
|
|
1395
1311
|
//#region src/components/license-warning-banner.tsx
|
|
1312
|
+
const labels = CopilotChatDefaultLabels$1;
|
|
1313
|
+
/**
|
|
1314
|
+
* The "expires soon" banner text. Without a day count it says "soon", never
|
|
1315
|
+
* "in undefined days".
|
|
1316
|
+
*/
|
|
1317
|
+
function expiringMessage(graceRemaining) {
|
|
1318
|
+
if (graceRemaining === void 0) return labels.licenseExpiringText;
|
|
1319
|
+
return ɵformatLabel$1(graceRemaining === 1 ? labels.licenseExpiringInDaysOne : labels.licenseExpiringInDaysOther, { days: graceRemaining });
|
|
1320
|
+
}
|
|
1396
1321
|
const LICENSE_BANNER_OFFSET_PX = 52;
|
|
1397
1322
|
const LICENSE_BANNER_OFFSET_VAR = "--copilotkit-license-banner-offset";
|
|
1398
1323
|
const BANNER_STYLES = {
|
|
@@ -1483,36 +1408,36 @@ function LicenseWarningBanner({ type, featureName, expiryDate, graceRemaining, o
|
|
|
1483
1408
|
switch (type) {
|
|
1484
1409
|
case "no_license": return /* @__PURE__ */ jsx(BannerShell, {
|
|
1485
1410
|
severity: "info",
|
|
1486
|
-
message:
|
|
1487
|
-
actionLabel:
|
|
1411
|
+
message: labels.licensePoweredByText,
|
|
1412
|
+
actionLabel: labels.licenseGetLicenseLabel,
|
|
1488
1413
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
1489
1414
|
onDismiss
|
|
1490
1415
|
});
|
|
1491
1416
|
case "feature_unlicensed": return /* @__PURE__ */ jsx(BannerShell, {
|
|
1492
1417
|
severity: "warning",
|
|
1493
|
-
message:
|
|
1494
|
-
actionLabel:
|
|
1418
|
+
message: ɵformatLabel$1(labels.licenseFeatureUnlicensedText, { feature: featureName ?? "" }),
|
|
1419
|
+
actionLabel: labels.licenseGetLicenseLabel,
|
|
1495
1420
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
1496
1421
|
onDismiss
|
|
1497
1422
|
});
|
|
1498
1423
|
case "expiring": return /* @__PURE__ */ jsx(BannerShell, {
|
|
1499
1424
|
severity: "warning",
|
|
1500
|
-
message:
|
|
1501
|
-
actionLabel:
|
|
1425
|
+
message: expiringMessage(graceRemaining),
|
|
1426
|
+
actionLabel: labels.licenseRenewLabel,
|
|
1502
1427
|
actionUrl: "https://dashboard.operations.copilotkit.ai",
|
|
1503
1428
|
onDismiss
|
|
1504
1429
|
});
|
|
1505
1430
|
case "expired": return /* @__PURE__ */ jsx(BannerShell, {
|
|
1506
1431
|
severity: "critical",
|
|
1507
|
-
message:
|
|
1508
|
-
actionLabel:
|
|
1432
|
+
message: expiryDate ? ɵformatLabel$1(labels.licenseExpiredOnDateText, { date: expiryDate }) : labels.licenseExpiredText,
|
|
1433
|
+
actionLabel: labels.licenseRenewNowLabel,
|
|
1509
1434
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
1510
1435
|
onDismiss
|
|
1511
1436
|
});
|
|
1512
1437
|
case "invalid": return /* @__PURE__ */ jsx(BannerShell, {
|
|
1513
1438
|
severity: "critical",
|
|
1514
|
-
message:
|
|
1515
|
-
actionLabel:
|
|
1439
|
+
message: labels.licenseInvalidText,
|
|
1440
|
+
actionLabel: labels.licenseGetLicenseLabel,
|
|
1516
1441
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
1517
1442
|
onDismiss
|
|
1518
1443
|
});
|
|
@@ -1531,9 +1456,7 @@ function InlineFeatureWarning({ featureName }) {
|
|
|
1531
1456
|
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif"
|
|
1532
1457
|
},
|
|
1533
1458
|
children: [
|
|
1534
|
-
|
|
1535
|
-
featureName,
|
|
1536
|
-
"\" feature requires a CopilotKit license.",
|
|
1459
|
+
ɵformatLabel$1(labels.licenseFeatureUnlicensedText, { feature: featureName }),
|
|
1537
1460
|
" ",
|
|
1538
1461
|
/* @__PURE__ */ jsx("a", {
|
|
1539
1462
|
href: "https://copilotkit.ai/pricing",
|
|
@@ -4764,9 +4687,28 @@ function useGenerativeUIRoot(copilotkit, config) {
|
|
|
4764
4687
|
|
|
4765
4688
|
//#endregion
|
|
4766
4689
|
//#region src/lib/react-core.ts
|
|
4690
|
+
/**
|
|
4691
|
+
* Wait for pending React state updates before the follow-up agent run.
|
|
4692
|
+
*
|
|
4693
|
+
* When a frontend tool handler calls setState(), React 18 batches the update
|
|
4694
|
+
* and schedules a commit via its internal scheduler (MessageChannel). The
|
|
4695
|
+
* useAgentContext hook registers context via useLayoutEffect, which runs
|
|
4696
|
+
* synchronously after React commits that batch.
|
|
4697
|
+
*
|
|
4698
|
+
* Awaiting a zero-delay timeout yields to the macrotask queue. React's
|
|
4699
|
+
* MessageChannel task runs first, committing the pending state and running
|
|
4700
|
+
* useLayoutEffect (which updates the context store). The follow-up runAgent
|
|
4701
|
+
* call then reads fresh context.
|
|
4702
|
+
*/
|
|
4703
|
+
function waitForReactCommit() {
|
|
4704
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
4705
|
+
}
|
|
4767
4706
|
var CopilotKitCoreReact = class extends CopilotKitCore$1 {
|
|
4768
4707
|
constructor(config) {
|
|
4769
|
-
super(
|
|
4708
|
+
super({
|
|
4709
|
+
...config,
|
|
4710
|
+
ɵwaitForFrameworkUpdates: waitForReactCommit
|
|
4711
|
+
});
|
|
4770
4712
|
this._renderToolCalls = [];
|
|
4771
4713
|
this._hookRenderToolCalls = /* @__PURE__ */ new Map();
|
|
4772
4714
|
this._cachedMergedRenderToolCalls = null;
|
|
@@ -4840,22 +4782,6 @@ var CopilotKitCoreReact = class extends CopilotKitCore$1 {
|
|
|
4840
4782
|
subscribe(subscriber) {
|
|
4841
4783
|
return super.subscribe(subscriber);
|
|
4842
4784
|
}
|
|
4843
|
-
/**
|
|
4844
|
-
* Wait for pending React state updates before the follow-up agent run.
|
|
4845
|
-
*
|
|
4846
|
-
* When a frontend tool handler calls setState(), React 18 batches the update
|
|
4847
|
-
* and schedules a commit via its internal scheduler (MessageChannel). The
|
|
4848
|
-
* useAgentContext hook registers context via useLayoutEffect, which runs
|
|
4849
|
-
* synchronously after React commits that batch.
|
|
4850
|
-
*
|
|
4851
|
-
* Awaiting a zero-delay timeout yields to the macrotask queue. React's
|
|
4852
|
-
* MessageChannel task runs first, committing the pending state and running
|
|
4853
|
-
* useLayoutEffect (which updates the context store). The follow-up runAgent
|
|
4854
|
-
* call then reads fresh context.
|
|
4855
|
-
*/
|
|
4856
|
-
async waitForPendingFrameworkUpdates() {
|
|
4857
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
4858
|
-
}
|
|
4859
4785
|
};
|
|
4860
4786
|
|
|
4861
4787
|
//#endregion
|
|
@@ -5153,7 +5079,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
5153
5079
|
const combined = [...renderToolCallsList];
|
|
5154
5080
|
[...frontendToolsList, ...builtInFrontendTools].forEach((tool) => {
|
|
5155
5081
|
if (tool.render) {
|
|
5156
|
-
const args = tool.parameters || (tool.name === "*" ?
|
|
5082
|
+
const args = tool.parameters || (tool.name === "*" ? ɵanySchema : void 0);
|
|
5157
5083
|
if (args) combined.push({
|
|
5158
5084
|
name: tool.name,
|
|
5159
5085
|
args,
|
|
@@ -5400,26 +5326,17 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
5400
5326
|
executingToolCallIds,
|
|
5401
5327
|
showIntelligenceIndicator
|
|
5402
5328
|
]);
|
|
5403
|
-
const
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
if (!terminalRuntimeEntitlementFailure) return runtimeLicenseContext;
|
|
5411
|
-
return {
|
|
5412
|
-
...runtimeLicenseContext,
|
|
5413
|
-
checkFeature: () => false,
|
|
5414
|
-
getLimit: () => null
|
|
5415
|
-
};
|
|
5416
|
-
}, [
|
|
5417
|
-
terminalRuntimeEntitlementFailure,
|
|
5418
|
-
runtimeEntitlementRetryInProgress,
|
|
5329
|
+
const licenseState = useMemo(() => ɵresolveLicenseState$1({
|
|
5330
|
+
status: runtimeLicenseStatus,
|
|
5331
|
+
entitlements: runtimeEntitlements,
|
|
5332
|
+
retryPending: runtimeEntitlementRetryPending,
|
|
5333
|
+
publicKey: resolvedPublicKey
|
|
5334
|
+
}), [
|
|
5335
|
+
runtimeLicenseStatus,
|
|
5419
5336
|
runtimeEntitlements,
|
|
5420
|
-
|
|
5337
|
+
runtimeEntitlementRetryPending,
|
|
5338
|
+
resolvedPublicKey
|
|
5421
5339
|
]);
|
|
5422
|
-
const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
|
|
5423
5340
|
return /* @__PURE__ */ jsx(CopilotStyleOptionsProvider, {
|
|
5424
5341
|
value: useMemo(() => ({
|
|
5425
5342
|
nonce,
|
|
@@ -5430,7 +5347,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
5430
5347
|
children: /* @__PURE__ */ jsx(CopilotKitContext.Provider, {
|
|
5431
5348
|
value: contextValue,
|
|
5432
5349
|
children: /* @__PURE__ */ jsxs(LicenseContext.Provider, {
|
|
5433
|
-
value:
|
|
5350
|
+
value: licenseState.context,
|
|
5434
5351
|
children: [
|
|
5435
5352
|
a2uiActive && /* @__PURE__ */ jsx(A2UIBuiltInToolCallRenderer, {}),
|
|
5436
5353
|
generativeUIActive && /* @__PURE__ */ jsx(GenerativeUIToolCallRenderer, {}),
|
|
@@ -5455,10 +5372,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
5455
5372
|
}) : null]
|
|
5456
5373
|
})
|
|
5457
5374
|
}),
|
|
5458
|
-
|
|
5459
|
-
runtimeLicenseWarningStatus === "expired" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expired" }),
|
|
5460
|
-
runtimeLicenseWarningStatus === "invalid" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "invalid" }),
|
|
5461
|
-
runtimeLicenseWarningStatus === "expiring" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expiring" })
|
|
5375
|
+
licenseState.bannerType && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: licenseState.bannerType })
|
|
5462
5376
|
]
|
|
5463
5377
|
})
|
|
5464
5378
|
})
|
|
@@ -5473,11 +5387,7 @@ function useRenderCustomMessages() {
|
|
|
5473
5387
|
const config = useCopilotChatConfiguration();
|
|
5474
5388
|
if (!config) return null;
|
|
5475
5389
|
const { agentId, threadId } = config;
|
|
5476
|
-
const customMessageRenderers = copilotkit.renderCustomMessages
|
|
5477
|
-
const aHasAgent = a.agentId !== void 0;
|
|
5478
|
-
if (aHasAgent === (b.agentId !== void 0)) return 0;
|
|
5479
|
-
return aHasAgent ? -1 : 1;
|
|
5480
|
-
});
|
|
5390
|
+
const customMessageRenderers = ɵresolveCustomMessageRenderers$1(copilotkit.renderCustomMessages, agentId);
|
|
5481
5391
|
if (!customMessageRenderers.length) return null;
|
|
5482
5392
|
return function(params) {
|
|
5483
5393
|
const { message, position } = params;
|
|
@@ -5513,6 +5423,18 @@ function useRenderCustomMessages() {
|
|
|
5513
5423
|
|
|
5514
5424
|
//#endregion
|
|
5515
5425
|
//#region src/hooks/use-render-activity-message.tsx
|
|
5426
|
+
/**
|
|
5427
|
+
* Explain why an activity message that has a renderer drew nothing: its
|
|
5428
|
+
* content validates asynchronously, or it fails the renderer's schema.
|
|
5429
|
+
*/
|
|
5430
|
+
function warnAboutRejectedContent(renderer, message) {
|
|
5431
|
+
const result = renderer.content["~standard"].validate(message.content);
|
|
5432
|
+
if (result instanceof Promise) {
|
|
5433
|
+
console.warn(`Async content validation is not supported for activity message '${message.activityType}'`);
|
|
5434
|
+
return;
|
|
5435
|
+
}
|
|
5436
|
+
if (result.issues) console.warn(`Failed to parse content for activity message '${message.activityType}':`, result.issues);
|
|
5437
|
+
}
|
|
5516
5438
|
function useRenderActivityMessage() {
|
|
5517
5439
|
const { copilotkit } = useCopilotKit();
|
|
5518
5440
|
const agentId = useCopilotChatConfiguration()?.agentId ?? DEFAULT_AGENT_ID;
|
|
@@ -5523,29 +5445,29 @@ function useRenderActivityMessage() {
|
|
|
5523
5445
|
return matches.find((candidate) => candidate.agentId === agentId) ?? matches.find((candidate) => candidate.agentId === void 0) ?? renderers.find((candidate) => candidate.activityType === "*") ?? null;
|
|
5524
5446
|
}, [agentId, renderers]);
|
|
5525
5447
|
const renderActivityMessage = useCallback((message) => {
|
|
5526
|
-
const
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
console.warn(`Failed to parse content for activity message '${message.activityType}':`, parseResult.issues);
|
|
5448
|
+
const match = ɵresolveActivityRenderer$1(renderers, {
|
|
5449
|
+
activityType: message.activityType,
|
|
5450
|
+
agentId,
|
|
5451
|
+
content: message.content
|
|
5452
|
+
});
|
|
5453
|
+
if (!match) {
|
|
5454
|
+
const renderer = findRenderer(message.activityType);
|
|
5455
|
+
if (renderer) warnAboutRejectedContent(renderer, message);
|
|
5535
5456
|
return null;
|
|
5536
5457
|
}
|
|
5537
|
-
const Component = renderer.render;
|
|
5458
|
+
const Component = match.renderer.render;
|
|
5538
5459
|
const agent = copilotkit.getAgent(agentId);
|
|
5539
5460
|
return /* @__PURE__ */ jsx(Component, {
|
|
5540
5461
|
activityType: message.activityType,
|
|
5541
|
-
content:
|
|
5462
|
+
content: match.content,
|
|
5542
5463
|
message,
|
|
5543
5464
|
agent
|
|
5544
5465
|
}, message.id);
|
|
5545
5466
|
}, [
|
|
5546
5467
|
agentId,
|
|
5547
5468
|
copilotkit,
|
|
5548
|
-
findRenderer
|
|
5469
|
+
findRenderer,
|
|
5470
|
+
renderers
|
|
5549
5471
|
]);
|
|
5550
5472
|
return useMemo(() => ({
|
|
5551
5473
|
renderActivityMessage,
|
|
@@ -5630,6 +5552,30 @@ function useDepsVersion(deps) {
|
|
|
5630
5552
|
|
|
5631
5553
|
//#endregion
|
|
5632
5554
|
//#region src/hooks/use-frontend-tool.tsx
|
|
5555
|
+
/**
|
|
5556
|
+
* Register a frontend tool while the component is mounted. The agent can
|
|
5557
|
+
* call it, and its `render` component draws the call in the chat.
|
|
5558
|
+
*
|
|
5559
|
+
* A tool with the same name and agentId as a tool that is already registered
|
|
5560
|
+
* (for example one from the provider's `tools`) overrides it while this
|
|
5561
|
+
* component is mounted. When the component unmounts, the overridden tool is
|
|
5562
|
+
* active again. The renderer stays registered after unmount, so past tool
|
|
5563
|
+
* calls still render in the chat history.
|
|
5564
|
+
*
|
|
5565
|
+
* @param tool - The tool to register.
|
|
5566
|
+
* @param deps - Extra values that re-register the tool when they change. Use
|
|
5567
|
+
* it when the handler closes over a value that is not part of the tool.
|
|
5568
|
+
*
|
|
5569
|
+
* @example
|
|
5570
|
+
* ```tsx
|
|
5571
|
+
* useFrontendTool({
|
|
5572
|
+
* name: "showWeather",
|
|
5573
|
+
* description: "Show the weather for a city",
|
|
5574
|
+
* parameters: z.object({ city: z.string() }),
|
|
5575
|
+
* handler: async ({ city }) => `Sunny in ${city}`,
|
|
5576
|
+
* });
|
|
5577
|
+
* ```
|
|
5578
|
+
*/
|
|
5633
5579
|
function useFrontendTool(tool, deps) {
|
|
5634
5580
|
const { copilotkit } = useCopilotKit$1();
|
|
5635
5581
|
const depsVersion = useDepsVersion(deps);
|
|
@@ -5638,11 +5584,8 @@ function useFrontendTool(tool, deps) {
|
|
|
5638
5584
|
if (copilotkit.getTool({
|
|
5639
5585
|
toolName: name,
|
|
5640
5586
|
agentId: tool.agentId
|
|
5641
|
-
})) {
|
|
5642
|
-
|
|
5643
|
-
copilotkit.removeTool(name, tool.agentId);
|
|
5644
|
-
}
|
|
5645
|
-
copilotkit.addTool(tool);
|
|
5587
|
+
})) console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
|
|
5588
|
+
const unregister = copilotkit.addTool(tool);
|
|
5646
5589
|
if (tool.render) copilotkit.addHookRenderToolCall({
|
|
5647
5590
|
name,
|
|
5648
5591
|
args: tool.parameters,
|
|
@@ -5650,7 +5593,7 @@ function useFrontendTool(tool, deps) {
|
|
|
5650
5593
|
render: tool.render
|
|
5651
5594
|
});
|
|
5652
5595
|
return () => {
|
|
5653
|
-
|
|
5596
|
+
unregister();
|
|
5654
5597
|
};
|
|
5655
5598
|
}, [
|
|
5656
5599
|
tool.name,
|
|
@@ -5675,8 +5618,10 @@ const EMPTY_TOOLS = [];
|
|
|
5675
5618
|
*
|
|
5676
5619
|
* Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
|
|
5677
5620
|
* tool that disappears from the array is unregistered on the next render, and
|
|
5678
|
-
* every tool is unregistered on unmount.
|
|
5679
|
-
*
|
|
5621
|
+
* every tool is unregistered on unmount. A listed tool hides a tool with the
|
|
5622
|
+
* same name and agentId (for example one from the provider's `tools`) until it
|
|
5623
|
+
* is unregistered, and then the hidden tool is active again. Renderers stay
|
|
5624
|
+
* registered after unmount so past tool calls still render in the chat history.
|
|
5680
5625
|
*
|
|
5681
5626
|
* @param tools - The tools to register. May be empty and may change length.
|
|
5682
5627
|
* @param deps - Extra dependencies that force re-registration, compared by
|
|
@@ -5726,15 +5671,13 @@ function useFrontendTools(tools, deps) {
|
|
|
5726
5671
|
deduped.set(key, tool);
|
|
5727
5672
|
}
|
|
5728
5673
|
const registered = [...deduped.values()];
|
|
5674
|
+
const unregisters = [];
|
|
5729
5675
|
for (const tool of registered) {
|
|
5730
5676
|
if (copilotkit.getTool({
|
|
5731
5677
|
toolName: tool.name,
|
|
5732
5678
|
agentId: tool.agentId
|
|
5733
|
-
})) {
|
|
5734
|
-
|
|
5735
|
-
copilotkit.removeTool(tool.name, tool.agentId);
|
|
5736
|
-
}
|
|
5737
|
-
copilotkit.addTool(tool);
|
|
5679
|
+
})) console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
|
|
5680
|
+
unregisters.push(copilotkit.addTool(tool));
|
|
5738
5681
|
if (tool.render) copilotkit.addHookRenderToolCall({
|
|
5739
5682
|
name: tool.name,
|
|
5740
5683
|
args: tool.parameters,
|
|
@@ -5743,7 +5686,7 @@ function useFrontendTools(tools, deps) {
|
|
|
5743
5686
|
});
|
|
5744
5687
|
}
|
|
5745
5688
|
return () => {
|
|
5746
|
-
for (const
|
|
5689
|
+
for (const unregister of unregisters) unregister();
|
|
5747
5690
|
};
|
|
5748
5691
|
}, [
|
|
5749
5692
|
JSON.stringify(toolList.map((tool) => [
|
|
@@ -5918,34 +5861,24 @@ function useRenderTool(config, deps) {
|
|
|
5918
5861
|
* @internal
|
|
5919
5862
|
*/
|
|
5920
5863
|
const ToolCallGroupContext = createContext(null);
|
|
5921
|
-
/**
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
const statusLabels = {
|
|
5928
|
-
running: "Running",
|
|
5929
|
-
done: "Done",
|
|
5930
|
-
failed: "Failed",
|
|
5931
|
-
stopped: "Stopped"
|
|
5864
|
+
/** The label key for each call status. */
|
|
5865
|
+
const STATUS_LABEL_KEYS = {
|
|
5866
|
+
running: "toolCallStatusRunningLabel",
|
|
5867
|
+
done: "toolCallStatusDoneLabel",
|
|
5868
|
+
failed: "toolCallStatusFailedLabel",
|
|
5869
|
+
stopped: "toolCallStatusStoppedLabel"
|
|
5932
5870
|
};
|
|
5933
|
-
/** The
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
const name = toolCall.function.name;
|
|
5944
|
-
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
5945
|
-
}
|
|
5946
|
-
return [...counts].map(([name, count]) => count > 1 ? `${name} ×${count}` : name).join(", ");
|
|
5871
|
+
/** The icon for each call status. */
|
|
5872
|
+
const STATUS_ICONS = {
|
|
5873
|
+
running: "Loader2",
|
|
5874
|
+
done: "Check",
|
|
5875
|
+
failed: "X",
|
|
5876
|
+
stopped: "Circle"
|
|
5877
|
+
};
|
|
5878
|
+
/** The chat labels from the nearest chat configuration, or the defaults. */
|
|
5879
|
+
function useLabels$1() {
|
|
5880
|
+
return useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
5947
5881
|
}
|
|
5948
|
-
const pluralize = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
5949
5882
|
/**
|
|
5950
5883
|
* Height transition between closed and its content's height. Closed content
|
|
5951
5884
|
* stays mounted (so its state survives) but is inert.
|
|
@@ -5968,55 +5901,35 @@ function Collapsible({ open, id, className, children }) {
|
|
|
5968
5901
|
});
|
|
5969
5902
|
}
|
|
5970
5903
|
function StatusIcon({ status, className }) {
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
done: Check,
|
|
5974
|
-
failed: X,
|
|
5975
|
-
stopped: Circle
|
|
5976
|
-
}[status];
|
|
5977
|
-
return /* @__PURE__ */ jsx(Icon, {
|
|
5904
|
+
return /* @__PURE__ */ jsx(CopilotIcon, {
|
|
5905
|
+
name: STATUS_ICONS[status],
|
|
5978
5906
|
"aria-hidden": "true",
|
|
5979
5907
|
className: cn("cpk-tool-call-status-icon", status === "running" && "cpk-tool-call-status-icon-running", status === "failed" && "cpk-tool-call-status-icon-failed", className)
|
|
5980
5908
|
});
|
|
5981
5909
|
}
|
|
5982
5910
|
function Chevron({ open, className }) {
|
|
5983
|
-
return /* @__PURE__ */ jsx(
|
|
5911
|
+
return /* @__PURE__ */ jsx(CopilotIcon, {
|
|
5912
|
+
name: "ChevronRight",
|
|
5984
5913
|
"aria-hidden": "true",
|
|
5985
5914
|
className: cn("cpk-tool-call-chevron", open && "cpk-tool-call-chevron-open", className)
|
|
5986
5915
|
});
|
|
5987
5916
|
}
|
|
5988
5917
|
function FailedCount({ calls }) {
|
|
5989
|
-
const
|
|
5918
|
+
const labels = useLabels$1();
|
|
5919
|
+
const failed = ɵcountFailedToolCalls$1(calls);
|
|
5990
5920
|
if (!failed) return null;
|
|
5991
|
-
return /* @__PURE__ */
|
|
5921
|
+
return /* @__PURE__ */ jsx("span", {
|
|
5992
5922
|
className: "cpk-tool-call-failed-count",
|
|
5993
|
-
children:
|
|
5923
|
+
children: ɵformatLabel$1(labels.toolCallFailedCountLabel, { count: failed })
|
|
5994
5924
|
});
|
|
5995
5925
|
}
|
|
5996
|
-
/**
|
|
5997
|
-
* Guarded JSON.stringify for the payload blocks. A circular reference would
|
|
5998
|
-
* otherwise crash the entire React tree on render.
|
|
5999
|
-
*/
|
|
6000
|
-
function stringifyPayload(value) {
|
|
6001
|
-
if (typeof value === "string") return value;
|
|
6002
|
-
try {
|
|
6003
|
-
return JSON.stringify(value, null, 2);
|
|
6004
|
-
} catch (err) {
|
|
6005
|
-
console.warn("[CopilotKit] Failed to JSON.stringify tool-call payload; falling back to String():", err);
|
|
6006
|
-
try {
|
|
6007
|
-
return String(value);
|
|
6008
|
-
} catch {
|
|
6009
|
-
return "[unserializable]";
|
|
6010
|
-
}
|
|
6011
|
-
}
|
|
6012
|
-
}
|
|
6013
5926
|
function Payload({ label, value }) {
|
|
6014
5927
|
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
6015
5928
|
className: "cpk-tool-call-payload-label",
|
|
6016
5929
|
children: label
|
|
6017
5930
|
}), /* @__PURE__ */ jsx("pre", {
|
|
6018
5931
|
className: "cpk-tool-call-payload-code",
|
|
6019
|
-
children:
|
|
5932
|
+
children: ɵstringifyToolCallPayload$1(value)
|
|
6020
5933
|
})] });
|
|
6021
5934
|
}
|
|
6022
5935
|
/**
|
|
@@ -6024,13 +5937,14 @@ function Payload({ label, value }) {
|
|
|
6024
5937
|
* @internal
|
|
6025
5938
|
*/
|
|
6026
5939
|
function ToolCallPayloads({ parameters, result, className }) {
|
|
5940
|
+
const labels = useLabels$1();
|
|
6027
5941
|
return /* @__PURE__ */ jsxs("div", {
|
|
6028
5942
|
className: cn("cpk-tool-call-payloads", className),
|
|
6029
5943
|
children: [/* @__PURE__ */ jsx(Payload, {
|
|
6030
|
-
label:
|
|
5944
|
+
label: labels.toolCallArgumentsLabel,
|
|
6031
5945
|
value: parameters ?? {}
|
|
6032
5946
|
}), result !== void 0 && /* @__PURE__ */ jsx(Payload, {
|
|
6033
|
-
label:
|
|
5947
|
+
label: labels.toolCallResultLabel,
|
|
6034
5948
|
value: result
|
|
6035
5949
|
})]
|
|
6036
5950
|
});
|
|
@@ -6041,9 +5955,10 @@ function ToolCallPayloads({ parameters, result, className }) {
|
|
|
6041
5955
|
* @internal
|
|
6042
5956
|
*/
|
|
6043
5957
|
function ToolCallRow({ name, parameters, result, status, appearance, className, ...props }) {
|
|
5958
|
+
const labels = useLabels$1();
|
|
6044
5959
|
const [open, setOpen] = useState(false);
|
|
6045
5960
|
const detailsId = useId();
|
|
6046
|
-
const preview =
|
|
5961
|
+
const preview = ɵgetArgumentPreview$1(parameters);
|
|
6047
5962
|
return /* @__PURE__ */ jsxs("div", {
|
|
6048
5963
|
"data-copilotkit": true,
|
|
6049
5964
|
className: cn("cpk-tool-call-row", `cpk-tool-call-row-${appearance}`, className),
|
|
@@ -6068,7 +5983,7 @@ function ToolCallRow({ name, parameters, result, status, appearance, className,
|
|
|
6068
5983
|
/* @__PURE__ */ jsx("span", {
|
|
6069
5984
|
"data-testid": "copilot-tool-render-status",
|
|
6070
5985
|
className: "cpk-tool-call-row-status",
|
|
6071
|
-
children:
|
|
5986
|
+
children: labels[STATUS_LABEL_KEYS[status]]
|
|
6072
5987
|
}),
|
|
6073
5988
|
/* @__PURE__ */ jsx(Chevron, {
|
|
6074
5989
|
open,
|
|
@@ -6097,14 +6012,15 @@ function ToolCallRow({ name, parameters, result, status, appearance, className,
|
|
|
6097
6012
|
* draws.
|
|
6098
6013
|
*/
|
|
6099
6014
|
function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isActive = false, className, ...props }) {
|
|
6015
|
+
const labels = useLabels$1();
|
|
6100
6016
|
const [open, setOpen] = useState(false);
|
|
6101
6017
|
const bodyId = useId();
|
|
6102
6018
|
const latest = calls[calls.length - 1];
|
|
6103
6019
|
if (!latest) return null;
|
|
6104
6020
|
const current = isActive ? calls.find((call) => !call.toolMessage) ?? latest : void 0;
|
|
6105
|
-
const preview = current ?
|
|
6021
|
+
const preview = current ? ɵgetToolCallPreview$1(current) : void 0;
|
|
6106
6022
|
const done = calls.filter((call) => call.toolMessage).length;
|
|
6107
|
-
const statuses = calls.map((call) =>
|
|
6023
|
+
const statuses = calls.map((call) => ɵgetToolCallRowStatus$1(call, isActive));
|
|
6108
6024
|
const failedIds = new Set(calls.filter((_, index) => statuses[index] === "failed").map((call) => call.toolCall.id));
|
|
6109
6025
|
const status = current ? "running" : failedIds.size > 0 ? "failed" : statuses.includes("stopped") ? "stopped" : "done";
|
|
6110
6026
|
const rows = (rowAppearance) => /* @__PURE__ */ jsx(ToolCallGroupContext.Provider, {
|
|
@@ -6122,9 +6038,9 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6122
6038
|
"data-state": status,
|
|
6123
6039
|
...props
|
|
6124
6040
|
};
|
|
6125
|
-
const runningLabel = current && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */
|
|
6041
|
+
const runningLabel = current && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
6126
6042
|
className: "cpk-tool-call-group-running cpk-shimmer",
|
|
6127
|
-
children:
|
|
6043
|
+
children: ɵformatLabel$1(labels.toolCallRunningLabel, { name: current.toolCall.function.name })
|
|
6128
6044
|
}), preview && /* @__PURE__ */ jsx("span", {
|
|
6129
6045
|
className: "cpk-tool-call-group-preview",
|
|
6130
6046
|
children: preview
|
|
@@ -6152,13 +6068,16 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6152
6068
|
onClick: () => setOpen((value) => !value),
|
|
6153
6069
|
className: "cpk-tool-call-group-line-toggle",
|
|
6154
6070
|
children: [runningLabel || /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
6155
|
-
/* @__PURE__ */
|
|
6071
|
+
/* @__PURE__ */ jsx("span", {
|
|
6156
6072
|
className: "cpk-tool-call-group-line-summary",
|
|
6157
|
-
children:
|
|
6073
|
+
children: ɵformatCountLabel$1(calls.length, {
|
|
6074
|
+
one: labels.toolCallUsedToolsOne,
|
|
6075
|
+
other: labels.toolCallUsedToolsOther
|
|
6076
|
+
})
|
|
6158
6077
|
}),
|
|
6159
6078
|
/* @__PURE__ */ jsx("span", {
|
|
6160
6079
|
className: "cpk-tool-call-group-line-names",
|
|
6161
|
-
children:
|
|
6080
|
+
children: ɵformatToolNames$1(calls)
|
|
6162
6081
|
}),
|
|
6163
6082
|
/* @__PURE__ */ jsx(FailedCount, { calls })
|
|
6164
6083
|
] }), /* @__PURE__ */ jsx(Chevron, { open })]
|
|
@@ -6175,8 +6094,8 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6175
6094
|
if (appearance === "stack") {
|
|
6176
6095
|
const behind = open ? 0 : Math.min(calls.length - 1, 2);
|
|
6177
6096
|
const layer = "cpk-tool-call-group-stack-layer";
|
|
6178
|
-
const latestStatus =
|
|
6179
|
-
const latestPreview =
|
|
6097
|
+
const latestStatus = ɵgetToolCallRowStatus$1(latest, isActive);
|
|
6098
|
+
const latestPreview = ɵgetToolCallPreview$1(latest);
|
|
6180
6099
|
return /* @__PURE__ */ jsxs("div", {
|
|
6181
6100
|
...groupProps,
|
|
6182
6101
|
className: cn("cpk-tool-call-group cpk-tool-call-group-stack", className),
|
|
@@ -6203,11 +6122,14 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6203
6122
|
onClick: () => setOpen((value) => !value),
|
|
6204
6123
|
className: cn("cpk-tool-call-group-stack-toggle", open ? "cpk-tool-call-group-stack-toggle-open" : [layer, "cpk-tool-call-group-stack-toggle-closed"]),
|
|
6205
6124
|
children: open ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
6206
|
-
|
|
6125
|
+
ɵformatCountLabel$1(calls.length, {
|
|
6126
|
+
one: labels.toolCallToolCallCountOne,
|
|
6127
|
+
other: labels.toolCallToolCallCountOther
|
|
6128
|
+
}),
|
|
6207
6129
|
/* @__PURE__ */ jsx(FailedCount, { calls }),
|
|
6208
6130
|
/* @__PURE__ */ jsxs("span", {
|
|
6209
6131
|
className: "cpk-tool-call-group-stack-collapse",
|
|
6210
|
-
children: [
|
|
6132
|
+
children: [labels.toolCallCollapseLabel, /* @__PURE__ */ jsx(Chevron, {
|
|
6211
6133
|
open: true,
|
|
6212
6134
|
className: "cpk-tool-call-group-stack-collapse-icon"
|
|
6213
6135
|
})]
|
|
@@ -6226,7 +6148,7 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6226
6148
|
}),
|
|
6227
6149
|
/* @__PURE__ */ jsx("span", {
|
|
6228
6150
|
className: "cpk-tool-call-group-stack-status",
|
|
6229
|
-
children:
|
|
6151
|
+
children: labels[STATUS_LABEL_KEYS[latestStatus]]
|
|
6230
6152
|
})
|
|
6231
6153
|
]
|
|
6232
6154
|
}, latest.toolCall.id), /* @__PURE__ */ jsxs("span", {
|
|
@@ -6235,7 +6157,10 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6235
6157
|
/* @__PURE__ */ jsx(FailedCount, { calls }),
|
|
6236
6158
|
/* @__PURE__ */ jsx("span", {
|
|
6237
6159
|
className: "cpk-tool-call-group-stack-count",
|
|
6238
|
-
children:
|
|
6160
|
+
children: ɵformatCountLabel$1(calls.length, {
|
|
6161
|
+
one: labels.toolCallCallCountOne,
|
|
6162
|
+
other: labels.toolCallCallCountOther
|
|
6163
|
+
})
|
|
6239
6164
|
}),
|
|
6240
6165
|
/* @__PURE__ */ jsx(Chevron, {
|
|
6241
6166
|
open: false,
|
|
@@ -6247,7 +6172,7 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6247
6172
|
/* @__PURE__ */ jsx("span", {
|
|
6248
6173
|
"aria-live": "polite",
|
|
6249
6174
|
className: "cpk-tool-call-group-stack-live",
|
|
6250
|
-
children: open ? "" : `${latest.toolCall.function.name}: ${
|
|
6175
|
+
children: open ? "" : `${latest.toolCall.function.name}: ${labels[STATUS_LABEL_KEYS[latestStatus]]}`
|
|
6251
6176
|
})
|
|
6252
6177
|
]
|
|
6253
6178
|
}), open && /* @__PURE__ */ jsx("div", {
|
|
@@ -6279,18 +6204,21 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
|
|
|
6279
6204
|
className: "cpk-tool-call-group-card-toggle",
|
|
6280
6205
|
children: [
|
|
6281
6206
|
/* @__PURE__ */ jsx(StatusIcon, { status }),
|
|
6282
|
-
runningLabel || /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */
|
|
6207
|
+
runningLabel || /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
6283
6208
|
className: "cpk-tool-call-group-card-summary",
|
|
6284
|
-
children:
|
|
6209
|
+
children: ɵformatCountLabel$1(calls.length, {
|
|
6210
|
+
one: labels.toolCallUsedToolsOne,
|
|
6211
|
+
other: labels.toolCallUsedToolsOther
|
|
6212
|
+
})
|
|
6285
6213
|
}), /* @__PURE__ */ jsx("span", {
|
|
6286
6214
|
className: "cpk-tool-call-group-card-names",
|
|
6287
|
-
children:
|
|
6215
|
+
children: ɵformatToolNames$1(calls)
|
|
6288
6216
|
})] }),
|
|
6289
6217
|
/* @__PURE__ */ jsxs("span", {
|
|
6290
6218
|
className: "cpk-tool-call-group-card-meta",
|
|
6291
6219
|
children: [status === "failed" ? /* @__PURE__ */ jsx(FailedCount, { calls }) : /* @__PURE__ */ jsx("span", {
|
|
6292
6220
|
className: "cpk-tool-call-group-card-status",
|
|
6293
|
-
children: status !== "running" ?
|
|
6221
|
+
children: status !== "running" ? labels[STATUS_LABEL_KEYS[status]] : done > 0 && ɵformatLabel$1(labels.toolCallDoneCountLabel, { count: done })
|
|
6294
6222
|
}), /* @__PURE__ */ jsx(Chevron, { open })]
|
|
6295
6223
|
})
|
|
6296
6224
|
]
|
|
@@ -7057,11 +6985,6 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
7057
6985
|
}));
|
|
7058
6986
|
}
|
|
7059
6987
|
|
|
7060
|
-
//#endregion
|
|
7061
|
-
//#region src/types/interrupt.ts
|
|
7062
|
-
/** Name of the legacy custom event agents emit to signal an interrupt. */
|
|
7063
|
-
const INTERRUPT_EVENT_NAME = "on_interrupt";
|
|
7064
|
-
|
|
7065
6988
|
//#endregion
|
|
7066
6989
|
//#region src/hooks/use-interrupt.tsx
|
|
7067
6990
|
/** Recognize thenables returned by interrupt preprocessing handlers. */
|
|
@@ -7978,297 +7901,11 @@ function useAttachments({ config }) {
|
|
|
7978
7901
|
};
|
|
7979
7902
|
}
|
|
7980
7903
|
|
|
7981
|
-
//#endregion
|
|
7982
|
-
//#region src/hooks/use-learning-containers.tsx
|
|
7983
|
-
/** The default learning containers value. Matches the backend default. */
|
|
7984
|
-
const DEFAULT_CONTAINERS = ["project"];
|
|
7985
|
-
/**
|
|
7986
|
-
* Legacy compatibility hook that keeps a thread's plural learning-container
|
|
7987
|
-
* annotation in sync by emitting
|
|
7988
|
-
* `set_learning_containers` annotations via the CopilotKit runtime annotate
|
|
7989
|
-
* endpoint (`POST ${runtimeUrl}/annotate`).
|
|
7990
|
-
*
|
|
7991
|
-
* **Emit rules:**
|
|
7992
|
-
* - On mount with `["project"]` (the backend default) → does NOT emit.
|
|
7993
|
-
* Absence of an annotation equals the default, so the round-trip is skipped.
|
|
7994
|
-
* - On mount with any other value → emits immediately.
|
|
7995
|
-
* - On any subsequent content change (including a switch back to
|
|
7996
|
-
* `["project"]`) → emits (a deliberate switch is always recorded).
|
|
7997
|
-
* - On unmount or threadId change → emits a reset to `["project"]`
|
|
7998
|
-
* so the backend is left in a clean state for the next consumer.
|
|
7999
|
-
* Changing `learningContainers` within the same thread does NOT reset the
|
|
8000
|
-
* thread; only the new value is emitted.
|
|
8001
|
-
*
|
|
8002
|
-
* Content-equality is evaluated via `JSON.stringify` so a fresh array literal
|
|
8003
|
-
* with the same items does NOT trigger a redundant emit.
|
|
8004
|
-
*
|
|
8005
|
-
* If `runtimeUrl` is absent, all emits are silently skipped.
|
|
8006
|
-
*
|
|
8007
|
-
* @example
|
|
8008
|
-
* ```tsx
|
|
8009
|
-
* function ThreadPane({ threadId, userScope }: Props) {
|
|
8010
|
-
* useLearningContainers({
|
|
8011
|
-
* threadId,
|
|
8012
|
-
* learningContainers: [userScope],
|
|
8013
|
-
* });
|
|
8014
|
-
* // ...
|
|
8015
|
-
* }
|
|
8016
|
-
* ```
|
|
8017
|
-
*
|
|
8018
|
-
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
8019
|
-
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
8020
|
-
* Intelligence runtimes.
|
|
8021
|
-
*/
|
|
8022
|
-
function useLearningContainers({ threadId, learningContainers }) {
|
|
8023
|
-
const { copilotkit } = useCopilotKit$1();
|
|
8024
|
-
/**
|
|
8025
|
-
* Tracks the last-synced container list so content-identical rerenders
|
|
8026
|
-
* (fresh array, same values) do not fire a redundant emit.
|
|
8027
|
-
* `null` = nothing synced yet (initial state or after a threadId reset).
|
|
8028
|
-
*/
|
|
8029
|
-
const lastSyncedRef = useRef(null);
|
|
8030
|
-
/** Guards the missing-runtimeUrl warning so it fires at most once per hook instance. */
|
|
8031
|
-
const warnedMissingUrlRef = useRef(false);
|
|
8032
|
-
const runtimeUrlRef = useRef(copilotkit.runtimeUrl);
|
|
8033
|
-
const runtimeFetchRef = useRef(copilotkit.ɵruntimeFetch);
|
|
8034
|
-
runtimeUrlRef.current = copilotkit.runtimeUrl;
|
|
8035
|
-
runtimeFetchRef.current = copilotkit.ɵruntimeFetch;
|
|
8036
|
-
const key = JSON.stringify(learningContainers);
|
|
8037
|
-
const defaultKey = JSON.stringify(DEFAULT_CONTAINERS);
|
|
8038
|
-
useEffect(() => {
|
|
8039
|
-
const runtimeUrl = copilotkit.runtimeUrl;
|
|
8040
|
-
/**
|
|
8041
|
-
* Fire-and-forget emit; errors must not surface in render.
|
|
8042
|
-
* Failures are logged as warnings so they are diagnosable without
|
|
8043
|
-
* propagating into the React render cycle.
|
|
8044
|
-
*/
|
|
8045
|
-
const emit = (containers) => {
|
|
8046
|
-
if (!runtimeUrl) {
|
|
8047
|
-
if (!warnedMissingUrlRef.current) {
|
|
8048
|
-
warnedMissingUrlRef.current = true;
|
|
8049
|
-
console.warn("useLearningContainers: runtimeUrl not configured; learning-container sync disabled");
|
|
8050
|
-
}
|
|
8051
|
-
return;
|
|
8052
|
-
}
|
|
8053
|
-
recordAnnotation({
|
|
8054
|
-
fetch: copilotkit.ɵruntimeFetch,
|
|
8055
|
-
runtimeUrl,
|
|
8056
|
-
headers: {},
|
|
8057
|
-
type: "set_learning_containers",
|
|
8058
|
-
payload: { containers },
|
|
8059
|
-
threadId
|
|
8060
|
-
}).catch((err) => {
|
|
8061
|
-
console.warn("useLearningContainers: failed to record set_learning_containers", err);
|
|
8062
|
-
});
|
|
8063
|
-
};
|
|
8064
|
-
if (lastSyncedRef.current === null) {
|
|
8065
|
-
if (key === defaultKey) {
|
|
8066
|
-
lastSyncedRef.current = learningContainers;
|
|
8067
|
-
return;
|
|
8068
|
-
}
|
|
8069
|
-
emit(learningContainers);
|
|
8070
|
-
lastSyncedRef.current = learningContainers;
|
|
8071
|
-
} else if (key !== JSON.stringify(lastSyncedRef.current)) {
|
|
8072
|
-
emit(learningContainers);
|
|
8073
|
-
lastSyncedRef.current = learningContainers;
|
|
8074
|
-
}
|
|
8075
|
-
}, [threadId, key]);
|
|
8076
|
-
useEffect(() => {
|
|
8077
|
-
const capturedThreadId = threadId;
|
|
8078
|
-
return () => {
|
|
8079
|
-
const capturedRuntimeUrl = runtimeUrlRef.current;
|
|
8080
|
-
if (capturedRuntimeUrl) recordAnnotation({
|
|
8081
|
-
fetch: runtimeFetchRef.current,
|
|
8082
|
-
runtimeUrl: capturedRuntimeUrl,
|
|
8083
|
-
headers: {},
|
|
8084
|
-
type: "set_learning_containers",
|
|
8085
|
-
payload: { containers: DEFAULT_CONTAINERS },
|
|
8086
|
-
threadId: capturedThreadId
|
|
8087
|
-
}).catch((err) => {
|
|
8088
|
-
console.warn("useLearningContainers: failed to record set_learning_containers", err);
|
|
8089
|
-
});
|
|
8090
|
-
lastSyncedRef.current = null;
|
|
8091
|
-
};
|
|
8092
|
-
}, [threadId]);
|
|
8093
|
-
}
|
|
8094
|
-
|
|
8095
|
-
//#endregion
|
|
8096
|
-
//#region src/hooks/use-learning-containers-in-current-thread.tsx
|
|
8097
|
-
/**
|
|
8098
|
-
* Legacy compatibility hook that keeps the **current chat thread's** plural
|
|
8099
|
-
* learning-container annotation in sync. The `threadId` is sourced from the surrounding
|
|
8100
|
-
* `<CopilotChatConfigurationProvider>` (the same provider `<CopilotChat>`,
|
|
8101
|
-
* `<CopilotSidebar>`, and friends set up), so callers in a chat-aware
|
|
8102
|
-
* subtree don't need to thread an id through manually.
|
|
8103
|
-
*
|
|
8104
|
-
* **Throws on render** when there is no chat-config provider in scope or
|
|
8105
|
-
* when the provider does not yet have an active `threadId`. Mount the hook
|
|
8106
|
-
* inside a subtree that is guaranteed to have a thread context.
|
|
8107
|
-
*
|
|
8108
|
-
* If you need to manage an explicit thread, use {@link useLearningContainers}
|
|
8109
|
-
* directly — two hooks, two crisp contracts, no mode confusion.
|
|
8110
|
-
*
|
|
8111
|
-
* @throws When no `CopilotChatConfigurationProvider` is in scope or when the
|
|
8112
|
-
* active `threadId` is absent/empty.
|
|
8113
|
-
*
|
|
8114
|
-
* @example
|
|
8115
|
-
* ```tsx
|
|
8116
|
-
* function ThreadPanel({ scope }: Props) {
|
|
8117
|
-
* useLearningContainersInCurrentThread({
|
|
8118
|
-
* learningContainers: [scope],
|
|
8119
|
-
* });
|
|
8120
|
-
* // ...
|
|
8121
|
-
* }
|
|
8122
|
-
* ```
|
|
8123
|
-
*
|
|
8124
|
-
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
8125
|
-
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
8126
|
-
* Intelligence runtimes.
|
|
8127
|
-
*/
|
|
8128
|
-
function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
8129
|
-
const threadId = useCopilotChatConfiguration()?.threadId;
|
|
8130
|
-
if (!threadId) throw new Error("useLearningContainersInCurrentThread must be used within a thread context (no active threadId). Wrap the component in <CopilotChat>, <CopilotSidebar>, or <CopilotChatConfigurationProvider>, or use `useLearningContainers()` and pass `threadId` explicitly.");
|
|
8131
|
-
useLearningContainers({
|
|
8132
|
-
threadId,
|
|
8133
|
-
learningContainers
|
|
8134
|
-
});
|
|
8135
|
-
}
|
|
8136
|
-
|
|
8137
7904
|
//#endregion
|
|
8138
7905
|
//#region src/components/chat/tool-call-display-context.ts
|
|
8139
7906
|
/** @internal */
|
|
8140
7907
|
const ToolCallDisplayContext = createContext(null);
|
|
8141
7908
|
|
|
8142
|
-
//#endregion
|
|
8143
|
-
//#region src/components/chat/tool-call-layout.ts
|
|
8144
|
-
function contentLength(content) {
|
|
8145
|
-
return typeof content === "string" ? content.length : JSON.stringify(content ?? "").length;
|
|
8146
|
-
}
|
|
8147
|
-
const entrySignature = ({ toolCall, toolMessage }) => [
|
|
8148
|
-
toolCall.id,
|
|
8149
|
-
toolCall.function.name,
|
|
8150
|
-
toolCall.function.arguments.length,
|
|
8151
|
-
toolMessage ? `${contentLength(toolMessage.content)}${toolMessage.error ? "!" : ""}` : "-"
|
|
8152
|
-
].join(":");
|
|
8153
|
-
function signatureOf(segments) {
|
|
8154
|
-
return segments.map((segment) => segment.kind === "call" ? `c(${entrySignature(segment.call)})` : `g${segment.trailing ? "*" : ""}(${segment.calls.map(entrySignature).join(",")})`).join("|");
|
|
8155
|
-
}
|
|
8156
|
-
/** Index of tool results by the call they answer. */
|
|
8157
|
-
function getToolResults(messages) {
|
|
8158
|
-
const results = /* @__PURE__ */ new Map();
|
|
8159
|
-
for (const message of messages) if (message.role === "tool") results.set(message.toolCallId, message);
|
|
8160
|
-
return results;
|
|
8161
|
-
}
|
|
8162
|
-
/**
|
|
8163
|
-
* Lays out the tool calls of every assistant message in `rendered`.
|
|
8164
|
-
*
|
|
8165
|
-
* Calls drawn by a renderer that opted into grouping join the group that's
|
|
8166
|
-
* open; anything else that shows between them closes it: assistant text, a
|
|
8167
|
-
* user, reasoning or activity message, or a call drawn by any other renderer. A group belongs to
|
|
8168
|
-
* the message where it starts, so later messages whose calls joined it render
|
|
8169
|
-
* no tool calls themselves.
|
|
8170
|
-
*
|
|
8171
|
-
* @param rendered - The messages as the chat renders them, in order.
|
|
8172
|
-
* @param all - Every message, for finding tool results (a transform may hide them).
|
|
8173
|
-
* @param renderers - The registered renderers.
|
|
8174
|
-
*/
|
|
8175
|
-
function getToolCallLayouts(rendered, all, renderers) {
|
|
8176
|
-
const results = getToolResults(all);
|
|
8177
|
-
const layouts = /* @__PURE__ */ new Map();
|
|
8178
|
-
let open;
|
|
8179
|
-
for (const message of rendered) {
|
|
8180
|
-
if (message.role === "tool") continue;
|
|
8181
|
-
if (message.role !== "assistant") {
|
|
8182
|
-
open = void 0;
|
|
8183
|
-
continue;
|
|
8184
|
-
}
|
|
8185
|
-
if (typeof message.content === "string" && message.content.trim()) open = void 0;
|
|
8186
|
-
const segments = [];
|
|
8187
|
-
layouts.set(message.id, segments);
|
|
8188
|
-
const toolCalls = /* @__PURE__ */ new Map();
|
|
8189
|
-
for (const toolCall of message.toolCalls ?? []) toolCalls.set(toolCall.id, toolCall);
|
|
8190
|
-
for (const toolCall of toolCalls.values()) {
|
|
8191
|
-
const entry = {
|
|
8192
|
-
toolCall,
|
|
8193
|
-
toolMessage: results.get(toolCall.id)
|
|
8194
|
-
};
|
|
8195
|
-
const name = toolCall.function.name;
|
|
8196
|
-
const named = renderers.named.has(name);
|
|
8197
|
-
const rendered = named || renderers.wildcard;
|
|
8198
|
-
const groups = named ? renderers.groupedNames.has(name) : renderers.wildcardGroups;
|
|
8199
|
-
if (!rendered || !groups) {
|
|
8200
|
-
if (rendered) open = void 0;
|
|
8201
|
-
segments.push({
|
|
8202
|
-
kind: "call",
|
|
8203
|
-
id: toolCall.id,
|
|
8204
|
-
call: entry,
|
|
8205
|
-
rendered
|
|
8206
|
-
});
|
|
8207
|
-
} else if (open) open.calls.push(entry);
|
|
8208
|
-
else {
|
|
8209
|
-
open = {
|
|
8210
|
-
kind: "group",
|
|
8211
|
-
id: toolCall.id,
|
|
8212
|
-
calls: [entry],
|
|
8213
|
-
trailing: false
|
|
8214
|
-
};
|
|
8215
|
-
segments.push(open);
|
|
8216
|
-
}
|
|
8217
|
-
}
|
|
8218
|
-
}
|
|
8219
|
-
if (open) open.trailing = true;
|
|
8220
|
-
const layout = /* @__PURE__ */ new Map();
|
|
8221
|
-
for (const [id, segments] of layouts) layout.set(id, {
|
|
8222
|
-
segments,
|
|
8223
|
-
signature: signatureOf(segments)
|
|
8224
|
-
});
|
|
8225
|
-
return layout;
|
|
8226
|
-
}
|
|
8227
|
-
/**
|
|
8228
|
-
* Finds the working phase of every reply in `rendered`: its messages up to the
|
|
8229
|
-
* last one that calls a tool. Text in there was narration; what follows is the
|
|
8230
|
-
* reply itself. Replies that called no tools are omitted, except the latest,
|
|
8231
|
-
* which may be about to.
|
|
8232
|
-
*/
|
|
8233
|
-
function getTurnWork(rendered, layouts) {
|
|
8234
|
-
const turns = /* @__PURE__ */ new Map();
|
|
8235
|
-
let start = 0;
|
|
8236
|
-
while (start < rendered.length) {
|
|
8237
|
-
let end = start;
|
|
8238
|
-
while (end < rendered.length && rendered[end].role !== "user") end++;
|
|
8239
|
-
const key = start > 0 ? rendered[start - 1].id : "start";
|
|
8240
|
-
const visible = rendered.slice(start, end).filter((message) => message.role !== "tool");
|
|
8241
|
-
const isLatest = end === rendered.length;
|
|
8242
|
-
const calls = [];
|
|
8243
|
-
for (const message of visible) for (const segment of layouts.get(message.id)?.segments ?? []) if (segment.kind === "group") calls.push(...segment.calls);
|
|
8244
|
-
else if (segment.rendered) calls.push(segment.call);
|
|
8245
|
-
const shown = new Set(calls.map((entry) => entry.toolCall.id));
|
|
8246
|
-
let lastWork = -1;
|
|
8247
|
-
visible.forEach((message, index) => {
|
|
8248
|
-
if (message.role === "assistant" && message.toolCalls?.some((call) => shown.has(call.id))) lastWork = index;
|
|
8249
|
-
});
|
|
8250
|
-
const first = visible[0];
|
|
8251
|
-
if (first && (calls.length > 0 || isLatest)) {
|
|
8252
|
-
let lastAssistant = -1;
|
|
8253
|
-
visible.forEach((message, index) => {
|
|
8254
|
-
if (message.role === "assistant") lastAssistant = index;
|
|
8255
|
-
});
|
|
8256
|
-
const replyText = visible[lastAssistant]?.content;
|
|
8257
|
-
const endsWithWork = lastAssistant >= 0 && lastAssistant <= lastWork && typeof replyText === "string" && replyText.trim().length > 0;
|
|
8258
|
-
turns.set(key, {
|
|
8259
|
-
key,
|
|
8260
|
-
firstMessageId: first.id,
|
|
8261
|
-
workMessageIds: new Set(visible.slice(0, lastWork + 1).map((message) => message.id)),
|
|
8262
|
-
replyTextMessageId: endsWithWork ? visible[lastAssistant].id : void 0,
|
|
8263
|
-
calls,
|
|
8264
|
-
isLatest
|
|
8265
|
-
});
|
|
8266
|
-
}
|
|
8267
|
-
start = end + 1;
|
|
8268
|
-
}
|
|
8269
|
-
return turns;
|
|
8270
|
-
}
|
|
8271
|
-
|
|
8272
7909
|
//#endregion
|
|
8273
7910
|
//#region src/components/chat/CopilotChatToolCallsView.tsx
|
|
8274
7911
|
const appearances = {
|
|
@@ -8288,7 +7925,7 @@ function CopilotChatToolCallsView({ message, messages = [], display: displayProp
|
|
|
8288
7925
|
const viewLayout = context?.layouts.get(message.id);
|
|
8289
7926
|
const layout = useMemo(() => {
|
|
8290
7927
|
if (display === "separate") return void 0;
|
|
8291
|
-
return viewLayout ??
|
|
7928
|
+
return viewLayout ?? ɵgetToolCallLayouts$1([message], messages, rendererNames).get(message.id);
|
|
8292
7929
|
}, [
|
|
8293
7930
|
display,
|
|
8294
7931
|
viewLayout,
|
|
@@ -8478,7 +8115,7 @@ function InspectorKiteIcon({ className, ...props }) {
|
|
|
8478
8115
|
});
|
|
8479
8116
|
}
|
|
8480
8117
|
function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
|
|
8481
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
8118
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
8482
8119
|
const { isInspectorEnabled } = useCopilotKitInspector();
|
|
8483
8120
|
const hidden = useInspectorShortcutsHidden();
|
|
8484
8121
|
const [open, setOpen] = useState(false);
|
|
@@ -8547,7 +8184,8 @@ function CopilotChatInspectorButton({ title, className, onClick, onPointerDown,
|
|
|
8547
8184
|
event.currentTarget.click();
|
|
8548
8185
|
}
|
|
8549
8186
|
},
|
|
8550
|
-
children: /* @__PURE__ */ jsx(
|
|
8187
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
8188
|
+
name: "Wrench",
|
|
8551
8189
|
"aria-hidden": "true",
|
|
8552
8190
|
className: "cpk-inspector-button-icon",
|
|
8553
8191
|
"data-testid": "copilot-inspector-icon"
|
|
@@ -8614,7 +8252,8 @@ function CopilotChatInspectorButton({ title, className, onClick, onPointerDown,
|
|
|
8614
8252
|
/* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
8615
8253
|
onSelect: hideShortcuts,
|
|
8616
8254
|
className: "cpk-inspector-button-menu-item cpk-inspector-button-hide-item",
|
|
8617
|
-
children: [/* @__PURE__ */ jsx(
|
|
8255
|
+
children: [/* @__PURE__ */ jsx(CopilotIcon, {
|
|
8256
|
+
name: "EyeOff",
|
|
8618
8257
|
"aria-hidden": "true",
|
|
8619
8258
|
className: "cpk-inspector-button-menu-item-icon"
|
|
8620
8259
|
}), /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -9008,7 +8647,7 @@ function nextFocusable(element, skip) {
|
|
|
9008
8647
|
* control after the thumb, and Enter or Escape inside it returns to the thumb.
|
|
9009
8648
|
*/
|
|
9010
8649
|
function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
|
|
9011
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
8650
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9012
8651
|
const contentRef = useRef(null);
|
|
9013
8652
|
const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
|
|
9014
8653
|
const { focusRequest, takeFocusRequest, inputRef } = comment;
|
|
@@ -9312,7 +8951,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
9312
8951
|
});
|
|
9313
8952
|
};
|
|
9314
8953
|
_CopilotChatAssistantMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
9315
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
8954
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9316
8955
|
const [copied, setCopied] = useState(false);
|
|
9317
8956
|
const timerRef = useRef(null);
|
|
9318
8957
|
useEffect(() => {
|
|
@@ -9338,36 +8977,44 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
9338
8977
|
onClick: handleClick,
|
|
9339
8978
|
className,
|
|
9340
8979
|
...props,
|
|
9341
|
-
children: copied ? /* @__PURE__ */ jsx(
|
|
8980
|
+
children: copied ? /* @__PURE__ */ jsx(CopilotIcon, {
|
|
8981
|
+
name: "Check",
|
|
8982
|
+
className: "cpk-assistant-message-toolbar-icon"
|
|
8983
|
+
}) : /* @__PURE__ */ jsx(CopilotIcon, {
|
|
8984
|
+
name: "Copy",
|
|
8985
|
+
className: "cpk-assistant-message-toolbar-icon"
|
|
8986
|
+
})
|
|
9342
8987
|
});
|
|
9343
8988
|
};
|
|
9344
8989
|
_CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
|
|
9345
8990
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
9346
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
8991
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9347
8992
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
9348
8993
|
"data-testid": "copilot-thumbs-up-button",
|
|
9349
8994
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
9350
8995
|
...props,
|
|
9351
|
-
children: /* @__PURE__ */ jsx(
|
|
8996
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
8997
|
+
name: "ThumbsUp",
|
|
9352
8998
|
className: "cpk-assistant-message-toolbar-icon",
|
|
9353
8999
|
fill: props["aria-pressed"] === true ? "currentColor" : "none"
|
|
9354
9000
|
})
|
|
9355
9001
|
});
|
|
9356
9002
|
};
|
|
9357
9003
|
_CopilotChatAssistantMessage.ThumbsDownButton = ({ title, ...props }) => {
|
|
9358
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9004
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9359
9005
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
9360
9006
|
"data-testid": "copilot-thumbs-down-button",
|
|
9361
9007
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
9362
9008
|
...props,
|
|
9363
|
-
children: /* @__PURE__ */ jsx(
|
|
9009
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9010
|
+
name: "ThumbsDown",
|
|
9364
9011
|
className: "cpk-assistant-message-toolbar-icon",
|
|
9365
9012
|
fill: props["aria-pressed"] === true ? "currentColor" : "none"
|
|
9366
9013
|
})
|
|
9367
9014
|
});
|
|
9368
9015
|
};
|
|
9369
9016
|
_CopilotChatAssistantMessage.FeedbackComment = ({ value, savedComment, inputRef, onChange, onSubmit, onEditingChange, onLeave, className }) => {
|
|
9370
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9017
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9371
9018
|
const changed = value.trim() !== savedComment;
|
|
9372
9019
|
return /* @__PURE__ */ jsxs("form", {
|
|
9373
9020
|
"data-testid": "copilot-feedback-comment",
|
|
@@ -9397,26 +9044,35 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
9397
9044
|
variant: "assistantMessageToolbarButton",
|
|
9398
9045
|
"aria-label": labels.assistantMessageFeedbackCommentSubmitLabel,
|
|
9399
9046
|
title: labels.assistantMessageFeedbackCommentSubmitLabel,
|
|
9400
|
-
children: /* @__PURE__ */ jsx(
|
|
9047
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9048
|
+
name: "ArrowUp",
|
|
9049
|
+
className: "cpk-assistant-message-feedback-comment-submit-icon"
|
|
9050
|
+
})
|
|
9401
9051
|
})]
|
|
9402
9052
|
});
|
|
9403
9053
|
};
|
|
9404
9054
|
_CopilotChatAssistantMessage.ReadAloudButton = ({ title, ...props }) => {
|
|
9405
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9055
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9406
9056
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
9407
9057
|
"data-testid": "copilot-read-aloud-button",
|
|
9408
9058
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
9409
9059
|
...props,
|
|
9410
|
-
children: /* @__PURE__ */ jsx(
|
|
9060
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9061
|
+
name: "Volume2",
|
|
9062
|
+
className: "cpk-assistant-message-read-aloud-icon"
|
|
9063
|
+
})
|
|
9411
9064
|
});
|
|
9412
9065
|
};
|
|
9413
9066
|
_CopilotChatAssistantMessage.RegenerateButton = ({ title, ...props }) => {
|
|
9414
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9067
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9415
9068
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
9416
9069
|
"data-testid": "copilot-regenerate-button",
|
|
9417
9070
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
9418
9071
|
...props,
|
|
9419
|
-
children: /* @__PURE__ */ jsx(
|
|
9072
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9073
|
+
name: "RefreshCw",
|
|
9074
|
+
className: "cpk-assistant-message-toolbar-icon"
|
|
9075
|
+
})
|
|
9420
9076
|
});
|
|
9421
9077
|
};
|
|
9422
9078
|
})(CopilotChatAssistantMessage || (CopilotChatAssistantMessage = {}));
|
|
@@ -9439,7 +9095,7 @@ var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
|
9439
9095
|
* `labels.attachmentPreviewCloseButtonLabel`.
|
|
9440
9096
|
*/
|
|
9441
9097
|
function Lightbox({ onClose, children }) {
|
|
9442
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9098
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9443
9099
|
useEffect(() => {
|
|
9444
9100
|
const handleKey = (e) => {
|
|
9445
9101
|
if (e.key === "Escape") onClose();
|
|
@@ -9455,7 +9111,10 @@ function Lightbox({ onClose, children }) {
|
|
|
9455
9111
|
onClick: onClose,
|
|
9456
9112
|
className: "cpk-attachment-lightbox-close-button",
|
|
9457
9113
|
"aria-label": labels.attachmentPreviewCloseButtonLabel,
|
|
9458
|
-
children: /* @__PURE__ */ jsx(
|
|
9114
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9115
|
+
name: "X",
|
|
9116
|
+
className: "cpk-attachment-lightbox-close-icon"
|
|
9117
|
+
})
|
|
9459
9118
|
}), /* @__PURE__ */ jsx("div", {
|
|
9460
9119
|
onClick: (e) => e.stopPropagation(),
|
|
9461
9120
|
children
|
|
@@ -9509,17 +9168,22 @@ function useLightbox() {
|
|
|
9509
9168
|
|
|
9510
9169
|
//#endregion
|
|
9511
9170
|
//#region src/components/chat/CopilotChatAttachmentRenderer.tsx
|
|
9171
|
+
/** The chat labels from the nearest chat configuration, or the defaults. */
|
|
9172
|
+
function useLabels() {
|
|
9173
|
+
return useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9174
|
+
}
|
|
9512
9175
|
const ImageAttachment = memo(function ImageAttachment({ src, className }) {
|
|
9176
|
+
const labels = useLabels();
|
|
9513
9177
|
const [error, setError] = useState(false);
|
|
9514
9178
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
9515
9179
|
if (error) return /* @__PURE__ */ jsx("div", {
|
|
9516
9180
|
className: cn("cpk-attachment-renderer cpk-attachment-renderer-image-error", className),
|
|
9517
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9181
|
+
children: /* @__PURE__ */ jsx("span", { children: labels.attachmentImageLoadErrorText })
|
|
9518
9182
|
});
|
|
9519
9183
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("img", {
|
|
9520
9184
|
ref: thumbnailRef,
|
|
9521
9185
|
src,
|
|
9522
|
-
alt:
|
|
9186
|
+
alt: labels.attachmentImageAltText,
|
|
9523
9187
|
className: cn("cpk-attachment-renderer cpk-attachment-renderer-image", className),
|
|
9524
9188
|
onClick: openLightbox,
|
|
9525
9189
|
onError: () => setError(true)
|
|
@@ -9528,7 +9192,7 @@ const ImageAttachment = memo(function ImageAttachment({ src, className }) {
|
|
|
9528
9192
|
children: /* @__PURE__ */ jsx("img", {
|
|
9529
9193
|
style: { viewTransitionName: vtName },
|
|
9530
9194
|
src,
|
|
9531
|
-
alt:
|
|
9195
|
+
alt: labels.attachmentImageAltText,
|
|
9532
9196
|
className: "cpk-attachment-renderer-lightbox-image"
|
|
9533
9197
|
})
|
|
9534
9198
|
})] });
|
|
@@ -9556,7 +9220,8 @@ const VideoAttachment = memo(function VideoAttachment({ src, className }) {
|
|
|
9556
9220
|
});
|
|
9557
9221
|
});
|
|
9558
9222
|
const DocumentAttachment = memo(function DocumentAttachment({ src, source, filename, className }) {
|
|
9559
|
-
const
|
|
9223
|
+
const labels = useLabels();
|
|
9224
|
+
const label = filename || source.mimeType || labels.attachmentDocumentAltText;
|
|
9560
9225
|
return /* @__PURE__ */ jsxs("a", {
|
|
9561
9226
|
href: src,
|
|
9562
9227
|
download: filename ?? "",
|
|
@@ -9569,7 +9234,7 @@ const DocumentAttachment = memo(function DocumentAttachment({ src, source, filen
|
|
|
9569
9234
|
children: getDocumentIcon(source.mimeType ?? "")
|
|
9570
9235
|
}), /* @__PURE__ */ jsx("span", {
|
|
9571
9236
|
className: "cpk-attachment-renderer-document-name",
|
|
9572
|
-
children: filename || source.mimeType ||
|
|
9237
|
+
children: filename || source.mimeType || labels.attachmentUnknownTypeText
|
|
9573
9238
|
})]
|
|
9574
9239
|
});
|
|
9575
9240
|
});
|
|
@@ -9708,7 +9373,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
9708
9373
|
})] });
|
|
9709
9374
|
};
|
|
9710
9375
|
_CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
9711
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9376
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9712
9377
|
const [copied, setCopied] = useState(false);
|
|
9713
9378
|
const handleClick = async (event) => {
|
|
9714
9379
|
let success = false;
|
|
@@ -9724,21 +9389,30 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
9724
9389
|
onClick: handleClick,
|
|
9725
9390
|
className,
|
|
9726
9391
|
...props,
|
|
9727
|
-
children: copied ? /* @__PURE__ */ jsx(
|
|
9392
|
+
children: copied ? /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9393
|
+
name: "Check",
|
|
9394
|
+
className: "cpk-user-message-toolbar-icon"
|
|
9395
|
+
}) : /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9396
|
+
name: "Copy",
|
|
9397
|
+
className: "cpk-user-message-toolbar-icon"
|
|
9398
|
+
})
|
|
9728
9399
|
});
|
|
9729
9400
|
};
|
|
9730
9401
|
_CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
|
|
9731
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9402
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9732
9403
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
9733
9404
|
"data-testid": "copilot-edit-button",
|
|
9734
9405
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
9735
9406
|
className,
|
|
9736
9407
|
...props,
|
|
9737
|
-
children: /* @__PURE__ */ jsx(
|
|
9408
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9409
|
+
name: "Edit",
|
|
9410
|
+
className: "cpk-user-message-toolbar-icon"
|
|
9411
|
+
})
|
|
9738
9412
|
});
|
|
9739
9413
|
};
|
|
9740
9414
|
_CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
|
|
9741
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9415
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9742
9416
|
if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) return null;
|
|
9743
9417
|
const canGoPrev = currentBranch > 0;
|
|
9744
9418
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
@@ -9758,7 +9432,10 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
9758
9432
|
disabled: !canGoPrev,
|
|
9759
9433
|
className: "cpk-user-message-branch-button",
|
|
9760
9434
|
"aria-label": labels.userMessageToolbarPreviousBranchLabel,
|
|
9761
|
-
children: /* @__PURE__ */ jsx(
|
|
9435
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9436
|
+
name: "ChevronLeft",
|
|
9437
|
+
className: "cpk-user-message-branch-icon"
|
|
9438
|
+
})
|
|
9762
9439
|
}),
|
|
9763
9440
|
/* @__PURE__ */ jsxs("span", {
|
|
9764
9441
|
className: "cpk-user-message-branch-counter",
|
|
@@ -9779,7 +9456,10 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
9779
9456
|
disabled: !canGoNext,
|
|
9780
9457
|
className: "cpk-user-message-branch-button",
|
|
9781
9458
|
"aria-label": labels.userMessageToolbarNextBranchLabel,
|
|
9782
|
-
children: /* @__PURE__ */ jsx(
|
|
9459
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9460
|
+
name: "ChevronRight",
|
|
9461
|
+
className: "cpk-user-message-branch-icon"
|
|
9462
|
+
})
|
|
9783
9463
|
})
|
|
9784
9464
|
]
|
|
9785
9465
|
});
|
|
@@ -9797,24 +9477,35 @@ var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
|
9797
9477
|
//#endregion
|
|
9798
9478
|
//#region src/components/chat/CopilotChatReasoningMessage.tsx
|
|
9799
9479
|
/**
|
|
9800
|
-
*
|
|
9480
|
+
* The reasoning time as label text, such as "4 seconds" or "1m 5s".
|
|
9481
|
+
*
|
|
9482
|
+
* @param seconds - The elapsed time in seconds. It may have a fraction.
|
|
9483
|
+
* @param labels - The chat labels that hold the duration texts.
|
|
9801
9484
|
*/
|
|
9802
|
-
function formatDuration
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9485
|
+
function formatDuration(seconds, labels) {
|
|
9486
|
+
const duration = ɵformatReasoningDuration$1(seconds);
|
|
9487
|
+
switch (duration.unit) {
|
|
9488
|
+
case "fewSeconds": return labels.reasoningMessageDurationFewSeconds;
|
|
9489
|
+
case "seconds": return ɵformatLabel$1(labels.reasoningMessageDurationSeconds, { count: duration.seconds });
|
|
9490
|
+
case "minutes": return ɵformatCountLabel$1(duration.minutes, {
|
|
9491
|
+
one: labels.reasoningMessageDurationMinutesOne,
|
|
9492
|
+
other: labels.reasoningMessageDurationMinutesOther
|
|
9493
|
+
});
|
|
9494
|
+
case "minutesSeconds": return ɵformatLabel$1(labels.reasoningMessageDurationMinutesSeconds, {
|
|
9495
|
+
minutes: duration.minutes,
|
|
9496
|
+
seconds: duration.seconds
|
|
9497
|
+
});
|
|
9498
|
+
}
|
|
9809
9499
|
}
|
|
9810
9500
|
/**
|
|
9811
9501
|
* A reasoning message as a collapsible block. While the model reasons it is
|
|
9812
9502
|
* open and the header shows `labels.reasoningMessageThinkingLabel`; when
|
|
9813
|
-
* streaming ends it collapses and the header reads
|
|
9503
|
+
* streaming ends it collapses and the header reads
|
|
9504
|
+
* `labels.reasoningMessageThoughtForLabel` ("Thought for 4 seconds"). The
|
|
9814
9505
|
* `header` slot also receives `elapsedSeconds`.
|
|
9815
9506
|
*/
|
|
9816
9507
|
function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: isLatestProp, header, contentView, toggle, children, className, ...props }) {
|
|
9817
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
9508
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
9818
9509
|
const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
|
|
9819
9510
|
const isStreaming = !!(isRunning && isLatest);
|
|
9820
9511
|
const hasContent = !!(message.content && message.content.length > 0);
|
|
@@ -9844,7 +9535,7 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: i
|
|
|
9844
9535
|
userToggledRef.current = true;
|
|
9845
9536
|
setIsOpen((prev) => !prev);
|
|
9846
9537
|
} : void 0;
|
|
9847
|
-
const label = isStreaming ? labels.reasoningMessageThinkingLabel :
|
|
9538
|
+
const label = isStreaming ? labels.reasoningMessageThinkingLabel : ɵformatLabel$1(labels.reasoningMessageThoughtForLabel, { duration: formatDuration(elapsed, labels) });
|
|
9848
9539
|
const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
|
|
9849
9540
|
isOpen,
|
|
9850
9541
|
label,
|
|
@@ -9899,7 +9590,10 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: i
|
|
|
9899
9590
|
children: /* @__PURE__ */ jsx("span", { className: "cpk-reasoning-message-indicator-dot" })
|
|
9900
9591
|
}),
|
|
9901
9592
|
headerChildren,
|
|
9902
|
-
isExpandable && /* @__PURE__ */ jsx(
|
|
9593
|
+
isExpandable && /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9594
|
+
name: "ChevronRight",
|
|
9595
|
+
className: cn("cpk-reasoning-message-chevron", isOpen && "cpk-reasoning-message-chevron-open")
|
|
9596
|
+
})
|
|
9903
9597
|
]
|
|
9904
9598
|
});
|
|
9905
9599
|
};
|
|
@@ -9953,7 +9647,8 @@ const CopilotChatSuggestionPill = React.forwardRef(function CopilotChatSuggestio
|
|
|
9953
9647
|
...props,
|
|
9954
9648
|
children: [isLoading ? /* @__PURE__ */ jsx("span", {
|
|
9955
9649
|
className: "cpk-suggestion-pill-icon",
|
|
9956
|
-
children: /* @__PURE__ */ jsx(
|
|
9650
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9651
|
+
name: "Loader2",
|
|
9957
9652
|
className: "cpk-suggestion-pill-spinner",
|
|
9958
9653
|
"aria-hidden": "true"
|
|
9959
9654
|
})
|
|
@@ -10070,14 +9765,6 @@ const ScrollPinnedContext = React.createContext(false);
|
|
|
10070
9765
|
|
|
10071
9766
|
//#endregion
|
|
10072
9767
|
//#region src/components/chat/CopilotChatWorkSummary.tsx
|
|
10073
|
-
/** "45s", "1m 5s", "2m". Used for the live timer and the final duration. */
|
|
10074
|
-
function formatDuration(ms) {
|
|
10075
|
-
const seconds = Math.max(0, Math.floor(ms / 1e3));
|
|
10076
|
-
if (seconds < 60) return `${seconds}s`;
|
|
10077
|
-
const minutes = Math.floor(seconds / 60);
|
|
10078
|
-
const rest = seconds % 60;
|
|
10079
|
-
return rest ? `${minutes}m ${rest}s` : `${minutes}m`;
|
|
10080
|
-
}
|
|
10081
9768
|
/** Re-renders every second while `active`, returning the current time. */
|
|
10082
9769
|
function useNow(active) {
|
|
10083
9770
|
const [now, setNow] = useState(() => Date.now());
|
|
@@ -10091,14 +9778,20 @@ function useNow(active) {
|
|
|
10091
9778
|
}
|
|
10092
9779
|
/**
|
|
10093
9780
|
* The line at the top of a reply in the `"turn"` tool-call display. While the
|
|
10094
|
-
* agent works it reads "Working 4s"
|
|
10095
|
-
* for 9s
|
|
9781
|
+
* agent works it reads "Working 4s". Once the reply is done it reads "Worked
|
|
9782
|
+
* for 9s" and "7 tools", and toggles the work it folded away. The text comes
|
|
9783
|
+
* from the `workSummary...` and `toolCall...` chat labels.
|
|
10096
9784
|
*/
|
|
10097
9785
|
function CopilotChatWorkSummary({ isWorking, isOpen, calls, elapsedMs, workingSince, className, ...props }) {
|
|
9786
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
10098
9787
|
const now = useNow(isWorking);
|
|
10099
|
-
const failed = calls
|
|
9788
|
+
const failed = ɵcountFailedToolCalls$1(calls);
|
|
9789
|
+
const toolCount = ɵformatCountLabel$1(calls.length, {
|
|
9790
|
+
one: labels.toolCallToolCountOne,
|
|
9791
|
+
other: labels.toolCallToolCountOther
|
|
9792
|
+
});
|
|
10100
9793
|
const liveMs = elapsedMs !== void 0 && workingSince !== void 0 ? elapsedMs + Math.max(0, now - workingSince) : void 0;
|
|
10101
|
-
const duration = elapsedMs !== void 0 ?
|
|
9794
|
+
const duration = elapsedMs !== void 0 ? ɵformatWorkDuration$1(Math.max(1e3, elapsedMs)) : void 0;
|
|
10102
9795
|
return /* @__PURE__ */ jsxs("button", {
|
|
10103
9796
|
type: "button",
|
|
10104
9797
|
"data-copilotkit": true,
|
|
@@ -10109,24 +9802,28 @@ function CopilotChatWorkSummary({ isWorking, isOpen, calls, elapsedMs, workingSi
|
|
|
10109
9802
|
...props,
|
|
10110
9803
|
children: [isWorking ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
10111
9804
|
className: "cpk-work-summary-label cpk-shimmer",
|
|
10112
|
-
children:
|
|
9805
|
+
children: labels.workSummaryWorkingLabel
|
|
10113
9806
|
}), liveMs !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
10114
9807
|
className: "cpk-work-summary-detail cpk-work-summary-timer",
|
|
10115
|
-
children:
|
|
9808
|
+
children: ɵformatWorkDuration$1(liveMs)
|
|
10116
9809
|
})] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
10117
9810
|
/* @__PURE__ */ jsx("span", {
|
|
10118
9811
|
className: "cpk-work-summary-label",
|
|
10119
|
-
children: duration ?
|
|
9812
|
+
children: duration ? ɵformatLabel$1(labels.workSummaryWorkedForLabel, { duration }) : ɵformatCountLabel$1(calls.length, {
|
|
9813
|
+
one: labels.toolCallUsedToolsOne,
|
|
9814
|
+
other: labels.toolCallUsedToolsOther
|
|
9815
|
+
})
|
|
10120
9816
|
}),
|
|
10121
9817
|
duration && /* @__PURE__ */ jsx("span", {
|
|
10122
9818
|
className: "cpk-work-summary-detail",
|
|
10123
|
-
children:
|
|
9819
|
+
children: toolCount
|
|
10124
9820
|
}),
|
|
10125
|
-
failed > 0 && /* @__PURE__ */
|
|
9821
|
+
failed > 0 && /* @__PURE__ */ jsx("span", {
|
|
10126
9822
|
className: "cpk-work-summary-failed",
|
|
10127
|
-
children:
|
|
9823
|
+
children: ɵformatLabel$1(labels.toolCallFailedCountLabel, { count: failed })
|
|
10128
9824
|
})
|
|
10129
|
-
] }), /* @__PURE__ */ jsx(
|
|
9825
|
+
] }), /* @__PURE__ */ jsx(CopilotIcon, {
|
|
9826
|
+
name: "ChevronRight",
|
|
10130
9827
|
"aria-hidden": "true",
|
|
10131
9828
|
className: cn("cpk-work-summary-chevron", isOpen && "cpk-work-summary-chevron-open")
|
|
10132
9829
|
})]
|
|
@@ -10541,68 +10238,6 @@ const MemoizedCustomMessage = React.memo(function MemoizedCustomMessage({ messag
|
|
|
10541
10238
|
if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
|
|
10542
10239
|
return true;
|
|
10543
10240
|
});
|
|
10544
|
-
/**
|
|
10545
|
-
* Deduplicates messages by ID. For assistant messages, merges occurrences:
|
|
10546
|
-
* recovers non-empty content from any earlier occurrence if the latest wiped it
|
|
10547
|
-
* (empty string means the streaming update cleared the field, not blank text),
|
|
10548
|
-
* and similarly recovers toolCalls from earlier occurrences if the latest is
|
|
10549
|
-
* undefined (an empty array [] is treated as intentional and kept as-is).
|
|
10550
|
-
* For all other roles, keeps the last entry.
|
|
10551
|
-
*
|
|
10552
|
-
* @internal Exported for unit testing only — not part of the public API.
|
|
10553
|
-
*/
|
|
10554
|
-
/**
|
|
10555
|
-
* Collapse tool calls that share an id, keeping first-seen order.
|
|
10556
|
-
*
|
|
10557
|
-
* AG-UI's TOOL_CALL_START handler appends to the parent message's `toolCalls`
|
|
10558
|
-
* without checking whether that id is already present. So whenever a start
|
|
10559
|
-
* event is applied twice — which the human-in-the-loop flow triggers when the
|
|
10560
|
-
* run syncs after `respond()` — the message ends up carrying the same call
|
|
10561
|
-
* twice. The second copy has EMPTY `arguments`, because a start event carries
|
|
10562
|
-
* none; the args arrive later as TOOL_CALL_ARGS deltas addressed to the first
|
|
10563
|
-
* copy.
|
|
10564
|
-
*
|
|
10565
|
-
* Left alone that renders the same tool call twice: once populated and once
|
|
10566
|
-
* blank (an approval card with no transaction id, offering live buttons for an
|
|
10567
|
-
* action already taken), and React warns "Encountered two children with the
|
|
10568
|
-
* same key" because the call id is the render key.
|
|
10569
|
-
*
|
|
10570
|
-
* The empty copy is the redundant one, so prefer whichever entry actually
|
|
10571
|
-
* carries arguments rather than blindly taking the first.
|
|
10572
|
-
*/
|
|
10573
|
-
function dedupeToolCalls(toolCalls) {
|
|
10574
|
-
const byId = /* @__PURE__ */ new Map();
|
|
10575
|
-
for (const toolCall of toolCalls) {
|
|
10576
|
-
const existing = byId.get(toolCall.id);
|
|
10577
|
-
if (!existing) {
|
|
10578
|
-
byId.set(toolCall.id, toolCall);
|
|
10579
|
-
continue;
|
|
10580
|
-
}
|
|
10581
|
-
if (!existing.function?.arguments && toolCall.function?.arguments) byId.set(toolCall.id, toolCall);
|
|
10582
|
-
}
|
|
10583
|
-
return byId.size === toolCalls.length ? toolCalls : [...byId.values()];
|
|
10584
|
-
}
|
|
10585
|
-
function deduplicateMessages(messages) {
|
|
10586
|
-
const acc = /* @__PURE__ */ new Map();
|
|
10587
|
-
for (const message of messages) {
|
|
10588
|
-
const existing = acc.get(message.id);
|
|
10589
|
-
if (existing && message.role === "assistant" && existing.role === "assistant") {
|
|
10590
|
-
const content = message.content || existing.content;
|
|
10591
|
-
const toolCalls = message.toolCalls ?? existing.toolCalls;
|
|
10592
|
-
acc.set(message.id, {
|
|
10593
|
-
...existing,
|
|
10594
|
-
...message,
|
|
10595
|
-
content,
|
|
10596
|
-
toolCalls: toolCalls ? dedupeToolCalls(toolCalls) : toolCalls
|
|
10597
|
-
});
|
|
10598
|
-
} else if (message.role === "assistant" && message.toolCalls) acc.set(message.id, {
|
|
10599
|
-
...message,
|
|
10600
|
-
toolCalls: dedupeToolCalls(message.toolCalls)
|
|
10601
|
-
});
|
|
10602
|
-
else acc.set(message.id, message);
|
|
10603
|
-
}
|
|
10604
|
-
return [...acc.values()];
|
|
10605
|
-
}
|
|
10606
10241
|
/** A row holding a single message, rendered as it would be ungrouped. */
|
|
10607
10242
|
function messageRow(message) {
|
|
10608
10243
|
return {
|
|
@@ -10651,7 +10286,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
10651
10286
|
if (!resolvedRunId) return void 0;
|
|
10652
10287
|
return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
|
|
10653
10288
|
};
|
|
10654
|
-
const deduplicatedMessages = useMemo(() =>
|
|
10289
|
+
const deduplicatedMessages = useMemo(() => ɵdeduplicateMessages$1(messages), [messages]);
|
|
10655
10290
|
const transformedMessages = useMemo(() => transformMessages ? transformMessages(deduplicatedMessages) : deduplicatedMessages, [deduplicatedMessages, transformMessages]);
|
|
10656
10291
|
const rows = useMemo(() => groupMessages ? groupMessages(transformedMessages) : transformedMessages.map(messageRow), [transformedMessages, groupMessages]);
|
|
10657
10292
|
const renderedMessages = useMemo(() => groupMessages ? rows.flatMap((row) => row.type === "group" ? row.messages : [row.message]) : transformedMessages, [
|
|
@@ -10661,13 +10296,13 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
10661
10296
|
]);
|
|
10662
10297
|
const latestRenderedId = renderedMessages[renderedMessages.length - 1]?.id;
|
|
10663
10298
|
const rendererNames = useToolCallRendererNames();
|
|
10664
|
-
const toolCallLayouts = useMemo(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() :
|
|
10299
|
+
const toolCallLayouts = useMemo(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() : ɵgetToolCallLayouts$1(renderedMessages, messages, rendererNames), [
|
|
10665
10300
|
toolCallDisplay,
|
|
10666
10301
|
renderedMessages,
|
|
10667
10302
|
messages,
|
|
10668
10303
|
rendererNames
|
|
10669
10304
|
]);
|
|
10670
|
-
const turnWork = useMemo(() => toolCallDisplay === "turn" ?
|
|
10305
|
+
const turnWork = useMemo(() => toolCallDisplay === "turn" ? ɵgetTurnWork$1(renderedMessages, toolCallLayouts) : void 0, [
|
|
10671
10306
|
toolCallDisplay,
|
|
10672
10307
|
renderedMessages,
|
|
10673
10308
|
toolCallLayouts
|
|
@@ -10677,46 +10312,25 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
10677
10312
|
for (const turn of turnWork?.values() ?? []) byFirst.set(turn.firstMessageId, turn);
|
|
10678
10313
|
return byFirst;
|
|
10679
10314
|
}, [turnWork]);
|
|
10680
|
-
|
|
10681
|
-
for (let i = renderedMessages.length - 1; i >= 0; i--) if (renderedMessages[i].role === "user") {
|
|
10682
|
-
latestTurnKey = renderedMessages[i].id;
|
|
10683
|
-
break;
|
|
10684
|
-
}
|
|
10685
|
-
const isWorkingOn = (turnKey) => isRunning && turnKey === latestTurnKey;
|
|
10315
|
+
const latestTurnKey = ɵgetLatestTurnKey$1(renderedMessages);
|
|
10686
10316
|
const [toggledTurns, setToggledTurns] = useState(() => /* @__PURE__ */ new Map());
|
|
10687
|
-
const
|
|
10317
|
+
const turnState = {
|
|
10318
|
+
toggledTurns,
|
|
10319
|
+
isRunning,
|
|
10320
|
+
latestTurnKey
|
|
10321
|
+
};
|
|
10688
10322
|
const workTimesRef = useRef(/* @__PURE__ */ new Map());
|
|
10689
|
-
if (toolCallDisplay === "turn") {
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
if (times.workingSince === void 0) continue;
|
|
10701
|
-
times.elapsedMs += now - times.workingSince;
|
|
10702
|
-
times.workingSince = void 0;
|
|
10703
|
-
}
|
|
10704
|
-
}
|
|
10705
|
-
const { workOpen, workTextOpen } = useMemo(() => {
|
|
10706
|
-
const open = /* @__PURE__ */ new Map();
|
|
10707
|
-
const textOpen = /* @__PURE__ */ new Map();
|
|
10708
|
-
for (const turn of turnWork?.values() ?? []) {
|
|
10709
|
-
const turnOpen = toggledTurns.get(turn.key) ?? (isRunning && turn.key === latestTurnKey);
|
|
10710
|
-
for (const id of turn.workMessageIds) {
|
|
10711
|
-
open.set(id, turnOpen);
|
|
10712
|
-
if (id !== turn.replyTextMessageId) textOpen.set(id, turnOpen);
|
|
10713
|
-
}
|
|
10714
|
-
}
|
|
10715
|
-
return {
|
|
10716
|
-
workOpen: open,
|
|
10717
|
-
workTextOpen: textOpen
|
|
10718
|
-
};
|
|
10719
|
-
}, [
|
|
10323
|
+
if (toolCallDisplay === "turn") ɵrecordWorkTime$1(workTimesRef.current, {
|
|
10324
|
+
isRunning,
|
|
10325
|
+
latestTurnKey,
|
|
10326
|
+
lastMessageRole: renderedMessages[renderedMessages.length - 1]?.role,
|
|
10327
|
+
now: Date.now()
|
|
10328
|
+
});
|
|
10329
|
+
const { workOpen, workTextOpen } = useMemo(() => ɵgetWorkOpenState$1(turnWork?.values() ?? [], {
|
|
10330
|
+
toggledTurns,
|
|
10331
|
+
isRunning,
|
|
10332
|
+
latestTurnKey
|
|
10333
|
+
}), [
|
|
10720
10334
|
turnWork,
|
|
10721
10335
|
toggledTurns,
|
|
10722
10336
|
isRunning,
|
|
@@ -10736,8 +10350,8 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
10736
10350
|
workTextOpen
|
|
10737
10351
|
]);
|
|
10738
10352
|
const renderWorkSummary = (turnKey, calls) => {
|
|
10739
|
-
const working =
|
|
10740
|
-
const open =
|
|
10353
|
+
const working = ɵisTurnWorking$1(turnKey, turnState);
|
|
10354
|
+
const open = ɵisTurnWorkOpen$1(turnKey, turnState);
|
|
10741
10355
|
const times = workTimesRef.current.get(turnKey);
|
|
10742
10356
|
return /* @__PURE__ */ jsx(Collapsible, {
|
|
10743
10357
|
open: working || calls.length > 0,
|
|
@@ -11164,7 +10778,7 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
11164
10778
|
* button named by `labels.attachmentRemoveButtonLabel`.
|
|
11165
10779
|
*/
|
|
11166
10780
|
const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
|
|
11167
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
10781
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
11168
10782
|
if (attachments.length === 0) return null;
|
|
11169
10783
|
return /* @__PURE__ */ jsx("div", {
|
|
11170
10784
|
"data-testid": "copilot-attachment-queue",
|
|
@@ -11240,7 +10854,7 @@ function AudioPreview({ attachment }) {
|
|
|
11240
10854
|
* lightbox.
|
|
11241
10855
|
*/
|
|
11242
10856
|
function VideoPreview({ attachment }) {
|
|
11243
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
10857
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
11244
10858
|
const src = getSourceUrl(attachment.source);
|
|
11245
10859
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
11246
10860
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -11264,7 +10878,10 @@ function VideoPreview({ attachment }) {
|
|
|
11264
10878
|
"aria-label": labels.attachmentPlayVideoButtonLabel,
|
|
11265
10879
|
children: /* @__PURE__ */ jsx("div", {
|
|
11266
10880
|
className: "cpk-attachment-queue-video-play-badge",
|
|
11267
|
-
children: /* @__PURE__ */ jsx(
|
|
10881
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
10882
|
+
name: "Play",
|
|
10883
|
+
className: "cpk-attachment-queue-video-play-icon"
|
|
10884
|
+
})
|
|
11268
10885
|
})
|
|
11269
10886
|
}),
|
|
11270
10887
|
open && /* @__PURE__ */ jsx(Lightbox, {
|
|
@@ -11317,6 +10934,7 @@ function useBlobUrl(attachment) {
|
|
|
11317
10934
|
return url;
|
|
11318
10935
|
}
|
|
11319
10936
|
function DocumentLightboxContent({ attachment, vtName }) {
|
|
10937
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
11320
10938
|
const mimeType = attachment.source.mimeType;
|
|
11321
10939
|
const blobUrl = useBlobUrl(attachment);
|
|
11322
10940
|
if (isPdf(mimeType)) {
|
|
@@ -11364,20 +10982,21 @@ function DocumentLightboxContent({ attachment, vtName }) {
|
|
|
11364
10982
|
className: "cpk-attachment-queue-document-card-details",
|
|
11365
10983
|
children: [/* @__PURE__ */ jsx("div", {
|
|
11366
10984
|
className: "cpk-attachment-queue-document-card-name",
|
|
11367
|
-
children: attachment.filename ||
|
|
10985
|
+
children: attachment.filename || labels.attachmentDocumentLabel
|
|
11368
10986
|
}), /* @__PURE__ */ jsxs("div", {
|
|
11369
10987
|
className: "cpk-attachment-queue-document-card-meta",
|
|
11370
|
-
children: [mimeType ||
|
|
10988
|
+
children: [mimeType || labels.attachmentUnknownTypeText, attachment.size != null && ` · ${formatFileSize(attachment.size)}`]
|
|
11371
10989
|
})]
|
|
11372
10990
|
}),
|
|
11373
10991
|
/* @__PURE__ */ jsx("div", {
|
|
11374
10992
|
className: "cpk-attachment-queue-document-card-note",
|
|
11375
|
-
children:
|
|
10993
|
+
children: labels.attachmentNoPreviewText
|
|
11376
10994
|
})
|
|
11377
10995
|
]
|
|
11378
10996
|
});
|
|
11379
10997
|
}
|
|
11380
10998
|
function DocumentPreview({ attachment }) {
|
|
10999
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
11381
11000
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
11382
11001
|
const mimeType = attachment.source.mimeType;
|
|
11383
11002
|
const previewable = canPreviewInBrowser(mimeType);
|
|
@@ -11392,7 +11011,7 @@ function DocumentPreview({ attachment }) {
|
|
|
11392
11011
|
className: "cpk-attachment-queue-document-info",
|
|
11393
11012
|
children: [/* @__PURE__ */ jsx("span", {
|
|
11394
11013
|
className: "cpk-attachment-queue-document-name",
|
|
11395
|
-
children: attachment.filename ||
|
|
11014
|
+
children: attachment.filename || labels.attachmentDocumentLabel
|
|
11396
11015
|
}), attachment.size != null && /* @__PURE__ */ jsx("span", {
|
|
11397
11016
|
className: "cpk-attachment-queue-document-size",
|
|
11398
11017
|
children: formatFileSize(attachment.size)
|
|
@@ -11529,13 +11148,17 @@ function computeOffsetTop(el, stopAt) {
|
|
|
11529
11148
|
//#region src/components/chat/CopilotChatView.tsx
|
|
11530
11149
|
const SCROLL_BUTTON_OFFSET = 16;
|
|
11531
11150
|
function DropOverlay() {
|
|
11151
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
11532
11152
|
return /* @__PURE__ */ jsx("div", {
|
|
11533
11153
|
className: "cpk-chat-view-drop-overlay",
|
|
11534
11154
|
children: /* @__PURE__ */ jsxs("div", {
|
|
11535
11155
|
className: "cpk-chat-view-drop-overlay-content",
|
|
11536
|
-
children: [/* @__PURE__ */ jsx(
|
|
11156
|
+
children: [/* @__PURE__ */ jsx(CopilotIcon, {
|
|
11157
|
+
name: "Upload",
|
|
11158
|
+
className: "cpk-chat-view-drop-overlay-icon"
|
|
11159
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
11537
11160
|
className: "cpk-chat-view-drop-overlay-label",
|
|
11538
|
-
children:
|
|
11161
|
+
children: labels.chatDropFilesLabel
|
|
11539
11162
|
})]
|
|
11540
11163
|
})
|
|
11541
11164
|
});
|
|
@@ -11975,7 +11598,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
11975
11598
|
});
|
|
11976
11599
|
};
|
|
11977
11600
|
_CopilotChatView.ScrollToBottomButton = ({ className, ...props }) => {
|
|
11978
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
11601
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
11979
11602
|
return /* @__PURE__ */ jsx(Button, {
|
|
11980
11603
|
"data-testid": "copilot-scroll-to-bottom",
|
|
11981
11604
|
variant: "outline",
|
|
@@ -11983,7 +11606,10 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
11983
11606
|
className: cn("cpk-chat-view-scroll-to-bottom-button", className),
|
|
11984
11607
|
"aria-label": labels.chatScrollToBottomLabel,
|
|
11985
11608
|
...props,
|
|
11986
|
-
children: /* @__PURE__ */ jsx(
|
|
11609
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
11610
|
+
name: "ChevronDown",
|
|
11611
|
+
className: "cpk-chat-view-scroll-to-bottom-icon"
|
|
11612
|
+
})
|
|
11987
11613
|
});
|
|
11988
11614
|
};
|
|
11989
11615
|
_CopilotChatView.Feather = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
@@ -11991,7 +11617,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
11991
11617
|
...props
|
|
11992
11618
|
});
|
|
11993
11619
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|
|
11994
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
11620
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
11995
11621
|
return /* @__PURE__ */ jsx("h1", {
|
|
11996
11622
|
className: cn("cpk-chat-view-welcome-message", className),
|
|
11997
11623
|
...props,
|
|
@@ -12037,119 +11663,6 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
12037
11663
|
})(CopilotChatView || (CopilotChatView = {}));
|
|
12038
11664
|
var CopilotChatView_default = CopilotChatView;
|
|
12039
11665
|
|
|
12040
|
-
//#endregion
|
|
12041
|
-
//#region src/lib/transcription-client.ts
|
|
12042
|
-
/**
|
|
12043
|
-
* Convert a Blob to a base64 string
|
|
12044
|
-
*/
|
|
12045
|
-
async function blobToBase64(blob) {
|
|
12046
|
-
return new Promise((resolve, reject) => {
|
|
12047
|
-
const reader = new FileReader();
|
|
12048
|
-
reader.onloadend = () => {
|
|
12049
|
-
const base64 = reader.result.split(",")[1];
|
|
12050
|
-
resolve(base64 ?? "");
|
|
12051
|
-
};
|
|
12052
|
-
reader.onerror = () => reject(/* @__PURE__ */ new Error("Failed to read audio data"));
|
|
12053
|
-
reader.readAsDataURL(blob);
|
|
12054
|
-
});
|
|
12055
|
-
}
|
|
12056
|
-
/**
|
|
12057
|
-
* Check if an error response matches our expected format
|
|
12058
|
-
*/
|
|
12059
|
-
function isTranscriptionErrorResponse(data) {
|
|
12060
|
-
return typeof data === "object" && data !== null && "error" in data && "message" in data && typeof data.error === "string" && typeof data.message === "string";
|
|
12061
|
-
}
|
|
12062
|
-
/**
|
|
12063
|
-
* Parse error info from a transcription error response
|
|
12064
|
-
*/
|
|
12065
|
-
function parseTranscriptionError(response) {
|
|
12066
|
-
return {
|
|
12067
|
-
code: response.error,
|
|
12068
|
-
message: response.message,
|
|
12069
|
-
retryable: response.retryable ?? false
|
|
12070
|
-
};
|
|
12071
|
-
}
|
|
12072
|
-
/**
|
|
12073
|
-
* Custom error type for transcription failures.
|
|
12074
|
-
* Extends Error with transcription-specific info for contextual error handling.
|
|
12075
|
-
*/
|
|
12076
|
-
var TranscriptionError = class extends Error {
|
|
12077
|
-
constructor(info) {
|
|
12078
|
-
super(info.message);
|
|
12079
|
-
this.name = "TranscriptionError";
|
|
12080
|
-
this.info = info;
|
|
12081
|
-
}
|
|
12082
|
-
};
|
|
12083
|
-
/**
|
|
12084
|
-
* Transcribe an audio blob using the CopilotKit runtime
|
|
12085
|
-
*
|
|
12086
|
-
* Supports both REST mode (multipart/form-data) and single-endpoint mode (base64 JSON)
|
|
12087
|
-
*
|
|
12088
|
-
* @throws {TranscriptionError} When transcription fails with typed error information
|
|
12089
|
-
*/
|
|
12090
|
-
async function transcribeAudio(core, audioBlob, filename = "recording.webm") {
|
|
12091
|
-
const runtimeUrl = core.runtimeUrl;
|
|
12092
|
-
if (!runtimeUrl) throw new TranscriptionError({
|
|
12093
|
-
code: TranscriptionErrorCode$1.INVALID_REQUEST,
|
|
12094
|
-
message: "Runtime URL is not configured",
|
|
12095
|
-
retryable: false
|
|
12096
|
-
});
|
|
12097
|
-
const headers = { ...await core.resolveHeaders() };
|
|
12098
|
-
let response;
|
|
12099
|
-
try {
|
|
12100
|
-
if (core.runtimeTransport === "single") {
|
|
12101
|
-
const base64Audio = await blobToBase64(audioBlob);
|
|
12102
|
-
headers["Content-Type"] = "application/json";
|
|
12103
|
-
response = await fetch(runtimeUrl, {
|
|
12104
|
-
method: "POST",
|
|
12105
|
-
headers,
|
|
12106
|
-
body: JSON.stringify({
|
|
12107
|
-
method: "transcribe",
|
|
12108
|
-
body: {
|
|
12109
|
-
audio: base64Audio,
|
|
12110
|
-
mimeType: audioBlob.type || "audio/webm",
|
|
12111
|
-
filename
|
|
12112
|
-
}
|
|
12113
|
-
})
|
|
12114
|
-
});
|
|
12115
|
-
} else {
|
|
12116
|
-
delete headers["Content-Type"];
|
|
12117
|
-
const formData = new FormData();
|
|
12118
|
-
formData.append("audio", audioBlob, filename);
|
|
12119
|
-
response = await fetch(`${runtimeUrl}/transcribe`, {
|
|
12120
|
-
method: "POST",
|
|
12121
|
-
headers,
|
|
12122
|
-
body: formData
|
|
12123
|
-
});
|
|
12124
|
-
}
|
|
12125
|
-
} catch (error) {
|
|
12126
|
-
throw new TranscriptionError({
|
|
12127
|
-
code: TranscriptionErrorCode$1.NETWORK_ERROR,
|
|
12128
|
-
message: error instanceof Error ? error.message : "Network request failed",
|
|
12129
|
-
retryable: true
|
|
12130
|
-
});
|
|
12131
|
-
}
|
|
12132
|
-
if (!response.ok) {
|
|
12133
|
-
let errorData;
|
|
12134
|
-
try {
|
|
12135
|
-
errorData = await response.json();
|
|
12136
|
-
} catch {
|
|
12137
|
-
throw new TranscriptionError({
|
|
12138
|
-
code: TranscriptionErrorCode$1.PROVIDER_ERROR,
|
|
12139
|
-
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
12140
|
-
retryable: response.status >= 500
|
|
12141
|
-
});
|
|
12142
|
-
}
|
|
12143
|
-
if (isTranscriptionErrorResponse(errorData)) throw new TranscriptionError(parseTranscriptionError(errorData));
|
|
12144
|
-
throw new TranscriptionError({
|
|
12145
|
-
code: TranscriptionErrorCode$1.PROVIDER_ERROR,
|
|
12146
|
-
message: typeof errorData === "object" && errorData !== null && "message" in errorData ? String(errorData.message) : "Transcription failed",
|
|
12147
|
-
retryable: response.status >= 500
|
|
12148
|
-
});
|
|
12149
|
-
}
|
|
12150
|
-
return await response.json();
|
|
12151
|
-
}
|
|
12152
|
-
|
|
12153
11666
|
//#endregion
|
|
12154
11667
|
//#region src/providers/use-inspector-thread-override.ts
|
|
12155
11668
|
function useInspectorThreadOverride(args) {
|
|
@@ -12631,7 +12144,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12631
12144
|
}
|
|
12632
12145
|
if (!isCurrentSelection()) return false;
|
|
12633
12146
|
if (failedConnectionsRef.current.has(agent)) {
|
|
12634
|
-
setTranscriptionError(
|
|
12147
|
+
setTranscriptionError({ labelKey: "threadLoadErrorText" });
|
|
12635
12148
|
return "failed";
|
|
12636
12149
|
}
|
|
12637
12150
|
const maybeAware = agent;
|
|
@@ -12656,7 +12169,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12656
12169
|
const onSubmitInput = useCallback(async (value) => {
|
|
12657
12170
|
if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
|
|
12658
12171
|
console.error("[CopilotKit] Cannot send while attachments are uploading (pre-await guard)");
|
|
12659
|
-
setTranscriptionError(
|
|
12172
|
+
setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
|
|
12660
12173
|
return;
|
|
12661
12174
|
}
|
|
12662
12175
|
setInputValue("");
|
|
@@ -12668,7 +12181,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12668
12181
|
}
|
|
12669
12182
|
if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
|
|
12670
12183
|
console.error("[CopilotKit] Cannot send while attachments are uploading (post-await re-check)");
|
|
12671
|
-
setTranscriptionError(
|
|
12184
|
+
setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
|
|
12672
12185
|
setInputValue(value);
|
|
12673
12186
|
return;
|
|
12674
12187
|
}
|
|
@@ -12786,7 +12299,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12786
12299
|
setIsTranscribing(true);
|
|
12787
12300
|
try {
|
|
12788
12301
|
setTranscriptionError(null);
|
|
12789
|
-
const result = await
|
|
12302
|
+
const result = await ɵtranscribeAudio$1(copilotkit, audioBlob);
|
|
12790
12303
|
setInputValue((prev) => {
|
|
12791
12304
|
const trimmedPrev = prev.trim();
|
|
12792
12305
|
if (trimmedPrev) return `${trimmedPrev} ${result.text}`;
|
|
@@ -12794,33 +12307,10 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12794
12307
|
});
|
|
12795
12308
|
} catch (error) {
|
|
12796
12309
|
console.error("CopilotChat: Transcription failed", error);
|
|
12797
|
-
if (error instanceof TranscriptionError) {
|
|
12798
|
-
const
|
|
12799
|
-
|
|
12800
|
-
|
|
12801
|
-
setTranscriptionError("Too many requests. Please wait a moment.");
|
|
12802
|
-
break;
|
|
12803
|
-
case TranscriptionErrorCode.AUTH_FAILED:
|
|
12804
|
-
setTranscriptionError("Authentication error. Please check your configuration.");
|
|
12805
|
-
break;
|
|
12806
|
-
case TranscriptionErrorCode.AUDIO_TOO_LONG:
|
|
12807
|
-
setTranscriptionError("Recording is too long. Please try a shorter recording.");
|
|
12808
|
-
break;
|
|
12809
|
-
case TranscriptionErrorCode.AUDIO_TOO_SHORT:
|
|
12810
|
-
setTranscriptionError("Recording is too short. Please try again.");
|
|
12811
|
-
break;
|
|
12812
|
-
case TranscriptionErrorCode.INVALID_AUDIO_FORMAT:
|
|
12813
|
-
setTranscriptionError("Audio format not supported.");
|
|
12814
|
-
break;
|
|
12815
|
-
case TranscriptionErrorCode.SERVICE_NOT_CONFIGURED:
|
|
12816
|
-
setTranscriptionError("Transcription service is not available.");
|
|
12817
|
-
break;
|
|
12818
|
-
case TranscriptionErrorCode.NETWORK_ERROR:
|
|
12819
|
-
setTranscriptionError("Network error. Please check your connection.");
|
|
12820
|
-
break;
|
|
12821
|
-
default: setTranscriptionError(retryable ? "Transcription failed. Please try again." : message);
|
|
12822
|
-
}
|
|
12823
|
-
} else setTranscriptionError("Transcription failed. Please try again.");
|
|
12310
|
+
if (error instanceof TranscriptionError$1) {
|
|
12311
|
+
const labelKey = ɵtranscriptionErrorMessageKey$1(error.info);
|
|
12312
|
+
setTranscriptionError(labelKey ? { labelKey } : { text: error.info.message });
|
|
12313
|
+
} else setTranscriptionError({ labelKey: "transcriptionErrorGenericText" });
|
|
12824
12314
|
} finally {
|
|
12825
12315
|
setIsTranscribing(false);
|
|
12826
12316
|
}
|
|
@@ -12852,11 +12342,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12852
12342
|
const effectiveStopHandler = agent.isRunning && hasMessages ? providedStopHandler ?? stopCurrentRun : providedStopHandler;
|
|
12853
12343
|
const showTranscription = isTranscriptionEnabled && isMediaRecorderSupported;
|
|
12854
12344
|
const effectiveMode = isTranscribing ? "processing" : transcribeMode;
|
|
12855
|
-
const messages = useMemo(() => [...agent.messages], [agent.messages
|
|
12856
|
-
const contentKey = typeof m.content === "string" ? m.content.length : Array.isArray(m.content) ? m.content.length : m.content && typeof m.content === "object" ? JSON.stringify(m.content) : 0;
|
|
12857
|
-
const toolCallsKey = "toolCalls" in m && Array.isArray(m.toolCalls) ? m.toolCalls.map((tc) => `${tc.id}:${tc.function?.arguments?.length ?? 0}`).join(";") : "";
|
|
12858
|
-
return `${m.id}:${m.role}:${contentKey}:${toolCallsKey}`;
|
|
12859
|
-
}).join(",")]);
|
|
12345
|
+
const messages = useMemo(() => [...agent.messages], [ɵmessagesFingerprint$1(agent.messages)]);
|
|
12860
12346
|
const lastUserMessageId = useMemo(() => {
|
|
12861
12347
|
for (let i = messages.length - 1; i >= 0; i--) if (messages[i].role === "user") return messages[i].id;
|
|
12862
12348
|
return null;
|
|
@@ -12928,7 +12414,11 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12928
12414
|
fontSize: "14px",
|
|
12929
12415
|
zIndex: 50
|
|
12930
12416
|
},
|
|
12931
|
-
children: transcriptionError
|
|
12417
|
+
children: "labelKey" in transcriptionError ? {
|
|
12418
|
+
...CopilotChatDefaultLabels$1,
|
|
12419
|
+
...existingConfig?.labels,
|
|
12420
|
+
...labels
|
|
12421
|
+
}[transcriptionError.labelKey] : transcriptionError.text
|
|
12932
12422
|
}),
|
|
12933
12423
|
/* @__PURE__ */ jsx(LastUserMessageContext.Provider, {
|
|
12934
12424
|
value: lastUserMessageState,
|
|
@@ -12951,16 +12441,18 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
12951
12441
|
//#endregion
|
|
12952
12442
|
//#region src/components/chat/CopilotChatToggleButton.tsx
|
|
12953
12443
|
const ICON_CLASS = "cpk-chat-toggle-button-icon";
|
|
12954
|
-
const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
12444
|
+
const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(CopilotIcon, {
|
|
12955
12445
|
className: className ?? ICON_CLASS,
|
|
12956
12446
|
strokeWidth: 1.75,
|
|
12957
12447
|
fill: "currentColor",
|
|
12958
|
-
...props
|
|
12448
|
+
...props,
|
|
12449
|
+
name: "MessageCircle"
|
|
12959
12450
|
});
|
|
12960
|
-
const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
12451
|
+
const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(CopilotIcon, {
|
|
12961
12452
|
className: className ?? ICON_CLASS,
|
|
12962
12453
|
strokeWidth: 1.75,
|
|
12963
|
-
...props
|
|
12454
|
+
...props,
|
|
12455
|
+
name: "X"
|
|
12964
12456
|
});
|
|
12965
12457
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
12966
12458
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
@@ -12969,7 +12461,7 @@ const ICON_WRAPPER_CLASS = "cpk-chat-toggle-button-icon-wrapper";
|
|
|
12969
12461
|
const CopilotChatToggleButton = React.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
12970
12462
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
12971
12463
|
const configuration = useCopilotChatConfiguration();
|
|
12972
|
-
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
12464
|
+
const labels = configuration?.labels ?? CopilotChatDefaultLabels$1;
|
|
12973
12465
|
const [fallbackOpen, setFallbackOpen] = useState(false);
|
|
12974
12466
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
12975
12467
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
@@ -13086,7 +12578,7 @@ function useIsMobileViewport() {
|
|
|
13086
12578
|
}
|
|
13087
12579
|
function CopilotModalHeader({ title, titleContent, closeButton, drawerLauncher, children, className, ...rest }) {
|
|
13088
12580
|
const configuration = useCopilotChatConfiguration();
|
|
13089
|
-
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
12581
|
+
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels$1.modalHeaderTitle;
|
|
13090
12582
|
const resolvedTitle = title ?? fallbackTitle;
|
|
13091
12583
|
const isMobile = useIsMobileViewport();
|
|
13092
12584
|
const drawerRegistered = (configuration?.drawerRegistered ?? false) && isMobile;
|
|
@@ -13142,28 +12634,30 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
13142
12634
|
children
|
|
13143
12635
|
});
|
|
13144
12636
|
_CopilotModalHeader.CloseButton = ({ className, ...props }) => {
|
|
13145
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12637
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
13146
12638
|
return /* @__PURE__ */ jsx("button", {
|
|
13147
12639
|
type: "button",
|
|
13148
12640
|
"data-testid": "copilot-close-button",
|
|
13149
12641
|
className: cn("cpk-modal-header-close-button", className),
|
|
13150
12642
|
"aria-label": labels.modalHeaderCloseButtonLabel,
|
|
13151
12643
|
...props,
|
|
13152
|
-
children: /* @__PURE__ */ jsx(
|
|
12644
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
12645
|
+
name: "X",
|
|
13153
12646
|
className: "cpk-modal-header-close-icon",
|
|
13154
12647
|
"aria-hidden": "true"
|
|
13155
12648
|
})
|
|
13156
12649
|
});
|
|
13157
12650
|
};
|
|
13158
12651
|
_CopilotModalHeader.DrawerLauncher = ({ className, ...props }) => {
|
|
13159
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12652
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels$1;
|
|
13160
12653
|
return /* @__PURE__ */ jsx("button", {
|
|
13161
12654
|
type: "button",
|
|
13162
12655
|
"data-testid": "copilot-threads-drawer-launcher",
|
|
13163
12656
|
className: cn("cpk-modal-header-drawer-launcher", className),
|
|
13164
12657
|
"aria-label": labels.modalHeaderThreadsButtonLabel,
|
|
13165
12658
|
...props,
|
|
13166
|
-
children: /* @__PURE__ */ jsx(
|
|
12659
|
+
children: /* @__PURE__ */ jsx(CopilotIcon, {
|
|
12660
|
+
name: "PanelLeftOpen",
|
|
13167
12661
|
className: "cpk-modal-header-drawer-launcher-icon",
|
|
13168
12662
|
"aria-hidden": "true"
|
|
13169
12663
|
})
|
|
@@ -13268,7 +12762,7 @@ function CopilotSidebarViewInternal({ header, toggleButton, width, position = "r
|
|
|
13268
12762
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
13269
12763
|
},
|
|
13270
12764
|
"aria-hidden": !isSidebarOpen,
|
|
13271
|
-
"aria-label": configuration?.labels.sidebarLabel ?? CopilotChatDefaultLabels.sidebarLabel,
|
|
12765
|
+
"aria-label": configuration?.labels.sidebarLabel ?? CopilotChatDefaultLabels$1.sidebarLabel,
|
|
13272
12766
|
role: "complementary",
|
|
13273
12767
|
children: /* @__PURE__ */ jsxs("div", {
|
|
13274
12768
|
className: "cpk-sidebar-view-panel",
|
|
@@ -13349,7 +12843,7 @@ function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOu
|
|
|
13349
12843
|
const configuration = useCopilotChatConfiguration();
|
|
13350
12844
|
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
13351
12845
|
const setModalOpen = configuration?.setModalOpen;
|
|
13352
|
-
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
12846
|
+
const labels = configuration?.labels ?? CopilotChatDefaultLabels$1;
|
|
13353
12847
|
const containerRef = useRef(null);
|
|
13354
12848
|
const [isRendered, setIsRendered] = useState(isPopupOpen);
|
|
13355
12849
|
const [isAnimatingOut, setIsAnimatingOut] = useState(false);
|
|
@@ -13917,5 +13411,5 @@ const WildcardToolCallRender = defineToolCallRenderer({
|
|
|
13917
13411
|
});
|
|
13918
13412
|
|
|
13919
13413
|
//#endregion
|
|
13920
|
-
export { A2UI_FENCE_LANGUAGE, ACTIVITY_HISTORY_METADATA, AGUIConnectNotImplementedError, AGUIError, AGUI_METADATA_KEY, AbstractAgent, ActivityDeltaEventSchema, ActivityMessageSchema, ActivitySnapshotEventSchema, AddOperationSchema, AgentCapabilitiesSchema, AgentRegistry, AgentThreadLockedError, AssistantMessageSchema, AttributableSchema, AudioInputContentSchema, AudioInputPartSchema, AudioPartSchema, AudioRecorderError, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, BackwardCompatibility_0_0_57, BaseEventSchema, BaseMessageSchema,
|
|
13414
|
+
export { A2UI_FENCE_LANGUAGE, ACTIVITY_HISTORY_METADATA, AGUIConnectNotImplementedError, AGUIError, AGUI_METADATA_KEY, AbstractAgent, ActivityDeltaEventSchema, ActivityMessageSchema, ActivitySnapshotEventSchema, AddOperationSchema, AgentCapabilitiesSchema, AgentRegistry, AgentThreadLockedError, AssistantMessageSchema, AttributableSchema, AudioInputContentSchema, AudioInputPartSchema, AudioPartSchema, AudioRecorderError, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, BackwardCompatibility_0_0_57, BaseEventSchema, BaseMessageSchema, CompatibilityBoundary, ContentPartSchema, ContextSchema, ContextStore, CopilotChat, CopilotChatAssistantMessage_default as CopilotChatAssistantMessage, CopilotChatAttachmentQueue, CopilotChatAttachmentRenderer, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatDefaultLabels, CopilotChatInput_default as CopilotChatInput, CopilotChatMessageView, CopilotChatReasoningMessage_default as CopilotChatReasoningMessage, CopilotChatSuggestionPill, CopilotChatSuggestionView, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToolCallGroup, CopilotChatToolCallsView, CopilotChatUserMessage_default as CopilotChatUserMessage, CopilotChatView_default as CopilotChatView, CopilotChatWorkSummary, CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreReact, CopilotKitCoreRuntimeConnectionStatus, CopilotKitHeaderResolutionError, CopilotKitInspector, CopilotKitProvider, CopilotKitStyles, CopilotModalHeader, CopilotPopup, CopilotPopupView, CopilotSidebar, CopilotSidebarView, CopilotThreadsDrawer, CopyOperationSchema, CustomEventSchema, DataSourceSchema, DebugLogger, DeveloperMessageSchema, DocumentInputContentSchema, DocumentInputPartSchema, DocumentPartSchema, EventSchema, EventSchemas, EventType, EventTypeSchema, ExecutionCapabilitiesSchema, FileSourceSchema, FilterToolCallsMiddleware, FunctionCallSchema, FunctionMiddleware, GenerateSandboxedUiArgsSchema, HttpAgent, HumanInTheLoopCapabilitiesSchema, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, INTELLIGENCE_TURN_HEAD, INTERRUPT_EVENT_NAME, IdentityCapabilitiesSchema, ImageInputContentSchema, ImageInputPartSchema, ImagePartSchema, InputContentDataSourceSchema, InputContentSchema, InputContentSourceSchema, InputContentUrlSourceSchema, IntelligenceAgent, IntelligenceIndicator, IntelligenceIndicatorView, InterruptSchema, JsonPatchOperationSchema, JsonPatchSchema, JsonPointerSchema, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, MEMORY_ERROR_REGISTRY, MarkdownRendererProvider, MemoryError, MessageSchema, MessagesSnapshotEventSchema, MetadataSchema, Middleware, MoveOperationSchema, MultiAgentCapabilitiesSchema, MultimodalCapabilitiesSchema, MultimodalInputCapabilitiesSchema, MultimodalOutputCapabilitiesSchema, OpenGenerativeUIActivityRenderer, OpenGenerativeUIActivityType, OpenGenerativeUIContentSchema, OpenGenerativeUIToolRenderer, OptionalMetadataSchema, OutputCapabilitiesSchema, PROTOCOL_VERSION, PartSourceSchema, ProxiedCopilotRuntimeAgent, RawEventSchema, ReasoningCapabilitiesSchema, ReasoningEncryptedValueEventSchema, ReasoningEncryptedValueSubtypeSchema, ReasoningEndEventSchema, ReasoningMessageChunkEventSchema, ReasoningMessageContentEventSchema, ReasoningMessageEndEventSchema, ReasoningMessageSchema, ReasoningMessageStartEventSchema, ReasoningStartEventSchema, RemoveOperationSchema, ReplaceOperationSchema, ResumeEntrySchema, RoleSchema, RunAgentInputSchema, RunErrorEventSchema, RunFinishedCancelledOutcomeSchema, RunFinishedEventSchema, RunFinishedInterruptOutcomeSchema, RunFinishedOutcomeSchema, RunFinishedSuccessOutcomeSchema, RunHandler, RunStartedEventSchema, SandboxFunctionsContext, StateCapabilitiesSchema, StateDeltaEventSchema, StateManager, StateSchema, StateSnapshotEventSchema, StepFinishedEventSchema, StepStartedEventSchema, StreamingMarkdownDefaultRenderer, SubagentErrorEventSchema, SubagentFinishedEventSchema, SubagentFinishedOutcomeSchema, SubagentFinishedSuccessOutcomeSchema, SubagentFinishedSuspendedOutcomeSchema, SubagentInfoSchema, SubagentRunIdSchema, SubagentStartedEventSchema, SuggestionEngine, SystemMessageSchema, TestOperationSchema, TextInputContentSchema, TextMessageChunkEventSchema, TextMessageContentEventSchema, TextMessageEndEventSchema, TextMessageRoleSchema, TextMessageStartEventSchema, TextPartSchema, TokenUsageSchema, ToolCallArgsEventSchema, ToolCallChunkEventSchema, ToolCallEndEventSchema, ToolCallResultEventSchema, ToolCallSchema, ToolCallStartEventSchema, ToolCallStatus, ToolMessageSchema, ToolSchema, ToolsCapabilitiesSchema, TranscriptionError, TranscriptionErrorCode, TransportCapabilitiesSchema, UrlSourceSchema, UseAgentUpdate, UserMessageSchema, VideoInputContentSchema, VideoInputPartSchema, VideoPartSchema, WebMCPRegistry, WildcardToolCallRender, a2uiDefaultTheme, aggregateTokenUsage, authoritativeActivityTypes, buildResumeArray, classifySurfaceCards, compactEvents, completePartialMarkdown, contentHasMedia, contentToText, convertToLegacyEvents, createA2UIMessageRenderer, createActionGroup, createDebugLogger, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, defaultApplyEvents, defineToolCallRenderer, emitInspectorActiveThread, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, empty, enforceEvents, enforceOutgoingInput, ensureObjectArgs, extractCompleteArrayItems, extractFenceOperations, extractStringField, flattenInformationalCards, getIntelligenceTurnAnchors, getMarkdownOperationSurfaceId, getRunOutcome, getWebMCPModelContext, isAbortError, isInspectorThreadBridgeEnabled, isInterruptExpired, isRecognizedEvent, isRunCompletionAware, mergeMetadata, messageGroup, messageRow, ofType, omitOptionalNulls, on, onInspectorActiveThread, onInspectorStopViewing, onInspectorViewThread, onInspectorViewThreadResult, parseProtoStream, parseSSEStream, parseToolArguments, prepareSurfaceOperations, props, randomUUID, resolveAgentDebugConfig, resolveDebugLogger, runHttpRequest, segmentSurfaceProse, select, splitA2UIMarkdown, structuredClone_, tokenUsageFromAiSdkUsage, tokenUsageFromLangChainMetadata, transformChunks, transformHttpEventStream, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useFrontendTools, useHumanInTheLoop, useInterrupt, useLearnFromUserAction, useLearnFromUserActionInCurrentThread, useLicenseContext, useMarkdownRenderer, useMemories, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSandboxFunctions, useSuggestions, useThreads, verifyEvents, withAuthoritativeActivityTypes, ɵCOPILOTKIT_FEATURES, ɵInterruptState, ɵMAX_SOCKET_RETRIES, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵTHREAD_REQUEST_TIMEOUT_MS, ɵclearAgentInterruptState, ɵcomposerButtonState, ɵcopilotIconSvgAttributes, ɵcopilotIcons, ɵcountFailedToolCalls, ɵcreateMemoryStore, ɵcreateThreadSelectors, ɵcreateThreadStore, ɵdeduplicateMessages, ɵformatCountLabel, ɵformatLabel, ɵformatReasoningDuration, ɵformatToolNames, ɵformatWorkDuration, ɵgetAgentInterruptState, ɵgetArgumentPreview, ɵgetLatestTurnKey, ɵgetToolCallLayouts, ɵgetToolCallPreview, ɵgetToolCallRendererNames, ɵgetToolCallRowStatus, ɵgetToolResults, ɵgetTurnWork, ɵgetWorkOpenState, ɵisCopilotKitFeature, ɵisHttpAgent, ɵisRetryableMemoryStatus, ɵisTurnWorkOpen, ɵisTurnWorking, ɵjoinPhoenixChannel$, ɵmapMemoryMetadataEvent, ɵmemoryAdapterEvents, ɵmemoryDomainEvents, ɵmemoryReducer, ɵmemoryRestEvents, ɵmessagesFingerprint, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵpluralize, ɵrecordWorkTime, ɵresolveActivityRenderer, ɵresolveComposerKey, ɵresolveCustomMessageRenderers, ɵresolveLicenseState, ɵresolveThreadsLicense, ɵresolveToolCallRenderer, ɵrunMcpFollowUp, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesIsMutating, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading, ɵstringifyToolCallPayload, ɵthreadAdapterEvents, ɵtranscribeAudio, ɵtranscriptionErrorMessageKey, ɵwithHeaderDefaults };
|
|
13921
13415
|
//# sourceMappingURL=index.mjs.map
|