@copilotkit/react-core 1.9.2-next.10 → 1.9.2-next.3
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/CHANGELOG.md +0 -56
- package/dist/{chunk-3YHYWAHK.mjs → chunk-2FW7HH6W.mjs} +3 -3
- package/dist/{chunk-OF4SZTLL.mjs → chunk-2XSUXRGG.mjs} +4 -4
- package/dist/{chunk-WOGURSAL.mjs → chunk-3XXVDQ7Z.mjs} +8 -10
- package/dist/chunk-3XXVDQ7Z.mjs.map +1 -0
- package/dist/{chunk-XFOTNHYA.mjs → chunk-6KGEF242.mjs} +2 -3
- package/dist/chunk-6KGEF242.mjs.map +1 -0
- package/dist/{chunk-EXU7GWLC.mjs → chunk-C3SYYVMR.mjs} +5 -5
- package/dist/{chunk-JPMIAGI6.mjs → chunk-C6F6EQNA.mjs} +2 -2
- package/dist/{chunk-3OQM3NEK.mjs → chunk-CCESTGAM.mjs} +2 -2
- package/dist/chunk-HD2GE3DK.mjs +359 -0
- package/dist/chunk-HD2GE3DK.mjs.map +1 -0
- package/dist/{chunk-G7LYGERN.mjs → chunk-HJP2RX5R.mjs} +14 -81
- package/dist/chunk-HJP2RX5R.mjs.map +1 -0
- package/dist/{chunk-ADIITPD2.mjs → chunk-IVXB3GYK.mjs} +6 -9
- package/dist/{chunk-ADIITPD2.mjs.map → chunk-IVXB3GYK.mjs.map} +1 -1
- package/dist/{chunk-EF5BNM34.mjs → chunk-LDACFA2B.mjs} +3 -3
- package/dist/{chunk-UBNRUXEK.mjs → chunk-LZDDYZEY.mjs} +2 -2
- package/dist/{chunk-FXK6RQIN.mjs → chunk-PUNALT2S.mjs} +2 -2
- package/dist/{chunk-CMQV4XNY.mjs → chunk-Q5D5XQFA.mjs} +2 -2
- package/dist/{chunk-SJJNFYGQ.mjs → chunk-QQZLIEXK.mjs} +3 -3
- package/dist/{chunk-JDEWNLNP.mjs → chunk-QRGDQSGZ.mjs} +5 -38
- package/dist/chunk-QRGDQSGZ.mjs.map +1 -0
- package/dist/{chunk-55QZ2SVJ.mjs → chunk-RUY6MLHA.mjs} +6 -36
- package/dist/chunk-RUY6MLHA.mjs.map +1 -0
- package/dist/{chunk-NQVCZQ5T.mjs → chunk-T42PN5VN.mjs} +4 -4
- package/dist/{chunk-ERXWDCY6.mjs → chunk-UHQMV2CE.mjs} +2 -2
- package/dist/chunk-VRXANACV.mjs +277 -0
- package/dist/chunk-VRXANACV.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +3 -37
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
- package/dist/components/copilot-provider/copilotkit-props.d.ts +2 -21
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
- package/dist/components/copilot-provider/copilotkit.js +238 -326
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +8 -8
- package/dist/components/copilot-provider/index.d.ts +1 -1
- package/dist/components/copilot-provider/index.js +238 -326
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +8 -8
- package/dist/components/error-boundary/error-boundary.js +146 -135
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +4 -4
- package/dist/components/error-boundary/error-utils.js.map +1 -1
- package/dist/components/error-boundary/error-utils.mjs +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +238 -326
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +8 -8
- package/dist/components/toast/toast-provider.js +85 -118
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -1
- package/dist/components/usage-banner.js +146 -135
- package/dist/components/usage-banner.js.map +1 -1
- package/dist/components/usage-banner.mjs +1 -1
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +1 -2
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +1 -2
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{copilot-context-3da805ab.d.ts → copilot-context-f9b2b4c3.d.ts} +1 -5
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +12 -108
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +19 -19
- package/dist/hooks/use-chat.d.ts +1 -1
- package/dist/hooks/use-chat.js +12 -105
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +5 -5
- package/dist/hooks/use-coagent-state-render.js +1 -2
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +3 -3
- package/dist/hooks/use-coagent.d.ts +1 -1
- package/dist/hooks/use-coagent.js +12 -108
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +11 -11
- package/dist/hooks/use-copilot-action.js +1 -2
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +4 -4
- package/dist/hooks/use-copilot-additional-instructions.js +1 -2
- package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
- package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
- package/dist/hooks/use-copilot-authenticated-action.js +1 -2
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
- package/dist/hooks/use-copilot-chat.d.ts +1 -1
- package/dist/hooks/use-copilot-chat.js +12 -105
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +10 -10
- package/dist/hooks/use-copilot-readable.js +1 -2
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-copilot-runtime-client.d.ts +0 -2
- package/dist/hooks/use-copilot-runtime-client.js +2 -52
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt-render.js +1 -2
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
- package/dist/hooks/use-langgraph-interrupt.js +12 -105
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +11 -11
- package/dist/hooks/use-make-copilot-document-readable.js +1 -2
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +247 -400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -20
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +9 -9
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -9
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/utils/extract.d.ts +1 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +8 -8
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +8 -8
- package/dist/utils/utils.test.d.ts +2 -0
- package/dist/utils/utils.test.js +9 -0
- package/dist/utils/utils.test.js.map +1 -0
- package/dist/utils/utils.test.mjs +7 -0
- package/dist/utils/utils.test.mjs.map +1 -0
- package/jest.config.js +3 -7
- package/package.json +3 -4
- package/src/components/copilot-provider/copilot-messages.tsx +3 -42
- package/src/components/copilot-provider/copilotkit-props.tsx +0 -21
- package/src/components/copilot-provider/copilotkit.tsx +0 -2
- package/src/components/toast/toast-provider.tsx +24 -49
- package/src/components/usage-banner.tsx +147 -144
- package/src/context/copilot-context.tsx +1 -7
- package/src/hooks/use-chat.ts +6 -106
- package/src/hooks/use-coagent.ts +0 -5
- package/src/hooks/use-copilot-runtime-client.ts +39 -41
- package/tsconfig.json +8 -1
- package/tsup.config.ts +6 -6
- package/dist/chunk-55QZ2SVJ.mjs.map +0 -1
- package/dist/chunk-57K2ZJ5F.mjs +0 -348
- package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
- package/dist/chunk-G7LYGERN.mjs.map +0 -1
- package/dist/chunk-JDEWNLNP.mjs.map +0 -1
- package/dist/chunk-WOGURSAL.mjs.map +0 -1
- package/dist/chunk-XFOTNHYA.mjs.map +0 -1
- package/dist/chunk-YAF2LATQ.mjs +0 -310
- package/dist/chunk-YAF2LATQ.mjs.map +0 -1
- package/src/components/copilot-provider/__tests__/copilotkit-trace.test.tsx +0 -75
- /package/dist/{chunk-3YHYWAHK.mjs.map → chunk-2FW7HH6W.mjs.map} +0 -0
- /package/dist/{chunk-OF4SZTLL.mjs.map → chunk-2XSUXRGG.mjs.map} +0 -0
- /package/dist/{chunk-EXU7GWLC.mjs.map → chunk-C3SYYVMR.mjs.map} +0 -0
- /package/dist/{chunk-JPMIAGI6.mjs.map → chunk-C6F6EQNA.mjs.map} +0 -0
- /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-CCESTGAM.mjs.map} +0 -0
- /package/dist/{chunk-EF5BNM34.mjs.map → chunk-LDACFA2B.mjs.map} +0 -0
- /package/dist/{chunk-UBNRUXEK.mjs.map → chunk-LZDDYZEY.mjs.map} +0 -0
- /package/dist/{chunk-FXK6RQIN.mjs.map → chunk-PUNALT2S.mjs.map} +0 -0
- /package/dist/{chunk-CMQV4XNY.mjs.map → chunk-Q5D5XQFA.mjs.map} +0 -0
- /package/dist/{chunk-SJJNFYGQ.mjs.map → chunk-QQZLIEXK.mjs.map} +0 -0
- /package/dist/{chunk-NQVCZQ5T.mjs.map → chunk-T42PN5VN.mjs.map} +0 -0
- /package/dist/{chunk-ERXWDCY6.mjs.map → chunk-UHQMV2CE.mjs.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context/copilot-context.tsx"],"sourcesContent":["import { CopilotCloudConfig, FunctionCallHandler, CopilotTraceHandler } from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId, Tree } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport {\n CopilotRuntimeClient,\n ExtensionsInput,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\nimport {\n LangGraphInterruptAction,\n LangGraphInterruptActionSetter,\n} from \"../types/interrupt-action\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Optional configuration for connecting to Model Context Protocol (MCP) servers.\n * This is typically derived from the CopilotKitProps and used internally.\n * @experimental\n */\n mcpServers?: Array<{ endpoint: string; apiKey?: string }>;\n}\n\nexport type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> =\n (props: TProps) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\nexport type ContextTree = Tree;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getAllContext: () => Tree;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n additionalInstructions?: string[];\n setAdditionalInstructions: React.Dispatch<React.SetStateAction<string[]>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean;\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string;\n setThreadId: React.Dispatch<React.SetStateAction<string>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates_c?: Record<ActionName, AuthState>;\n setAuthStates_c?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n extensions: ExtensionsInput;\n setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;\n langGraphInterruptAction: LangGraphInterruptAction | null;\n setLangGraphInterruptAction: LangGraphInterruptActionSetter;\n removeLangGraphInterruptAction: () => void;\n\n /**\n * Optional trace handler for comprehensive debugging and observability.\n */\n onTrace?: CopilotTraceHandler;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n getAllContext: () => [],\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n additionalInstructions: [],\n setAdditionalInstructions: () => returnAndThrowInDebug([]),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: false,\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: \"\",\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n extensions: {},\n setExtensions: () => {},\n langGraphInterruptAction: null,\n setLangGraphInterruptAction: () => null,\n removeLangGraphInterruptAction: () => null,\n onTrace: undefined,\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n}\n"],"mappings":";;;;;AAMA,OAAO,WAAW;AA6NlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,0BAA0B,MAAM;AAAA,EAAC;AAAA,EAEjC,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,EACzE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,eAAe,MAAM,CAAC;AAAA,EAEtB,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,WAAW;AAAA,EACX,cAAc,MAAM,sBAAsB,KAAK;AAAA,EAE/C,kBAAkB;AAAA,EAClB,qBAAqB,MAAM,sBAAsB,EAAE;AAAA,EAEnD,wBAAwB,CAAC;AAAA,EACzB,2BAA2B,MAAM,sBAAsB,CAAC,CAAC;AAAA,EAEzD,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,eAAe,CAAC;AAAA,EAEhB,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kB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
|
|
3
|
-
__spreadValues
|
|
4
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
5
|
-
|
|
6
|
-
// src/components/toast/toast-provider.tsx
|
|
7
|
-
import { createContext, useContext, useState, useCallback } from "react";
|
|
8
|
-
import { Severity } from "@copilotkit/shared";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
var ToastContext = createContext(void 0);
|
|
11
|
-
function getErrorSeverity(error) {
|
|
12
|
-
if (error.severity) {
|
|
13
|
-
switch (error.severity) {
|
|
14
|
-
case Severity.CRITICAL:
|
|
15
|
-
return "critical";
|
|
16
|
-
case Severity.WARNING:
|
|
17
|
-
return "warning";
|
|
18
|
-
case Severity.INFO:
|
|
19
|
-
return "info";
|
|
20
|
-
default:
|
|
21
|
-
return "info";
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const message = error.message.toLowerCase();
|
|
25
|
-
if (message.includes("api key") || message.includes("401") || message.includes("unauthorized") || message.includes("authentication") || message.includes("incorrect api key")) {
|
|
26
|
-
return "critical";
|
|
27
|
-
}
|
|
28
|
-
return "info";
|
|
29
|
-
}
|
|
30
|
-
function getErrorColors(severity) {
|
|
31
|
-
switch (severity) {
|
|
32
|
-
case "critical":
|
|
33
|
-
return {
|
|
34
|
-
background: "#fee2e2",
|
|
35
|
-
border: "#dc2626",
|
|
36
|
-
text: "#7f1d1d",
|
|
37
|
-
icon: "#dc2626"
|
|
38
|
-
};
|
|
39
|
-
case "warning":
|
|
40
|
-
return {
|
|
41
|
-
background: "#fef3c7",
|
|
42
|
-
border: "#d97706",
|
|
43
|
-
text: "#78350f",
|
|
44
|
-
icon: "#d97706"
|
|
45
|
-
};
|
|
46
|
-
case "info":
|
|
47
|
-
return {
|
|
48
|
-
background: "#dbeafe",
|
|
49
|
-
border: "#2563eb",
|
|
50
|
-
text: "#1e3a8a",
|
|
51
|
-
icon: "#2563eb"
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function useToast() {
|
|
56
|
-
const context = useContext(ToastContext);
|
|
57
|
-
if (!context) {
|
|
58
|
-
throw new Error("useToast must be used within a ToastProvider");
|
|
59
|
-
}
|
|
60
|
-
return context;
|
|
61
|
-
}
|
|
62
|
-
function ToastProvider({
|
|
63
|
-
enabled,
|
|
64
|
-
children
|
|
65
|
-
}) {
|
|
66
|
-
const [toasts, setToasts] = useState([]);
|
|
67
|
-
const [bannerError, setBannerErrorState] = useState(null);
|
|
68
|
-
const removeToast = useCallback((id) => {
|
|
69
|
-
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
70
|
-
}, []);
|
|
71
|
-
const addToast = useCallback(
|
|
72
|
-
(toast) => {
|
|
73
|
-
var _a;
|
|
74
|
-
if (!enabled) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const id = (_a = toast.id) != null ? _a : Math.random().toString(36).substring(2, 9);
|
|
78
|
-
setToasts((currentToasts) => {
|
|
79
|
-
if (currentToasts.find((toast2) => toast2.id === id))
|
|
80
|
-
return currentToasts;
|
|
81
|
-
return [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })];
|
|
82
|
-
});
|
|
83
|
-
if (toast.duration) {
|
|
84
|
-
setTimeout(() => {
|
|
85
|
-
removeToast(id);
|
|
86
|
-
}, toast.duration);
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
[enabled, removeToast]
|
|
90
|
-
);
|
|
91
|
-
const setBannerError = useCallback(
|
|
92
|
-
(error) => {
|
|
93
|
-
if (!enabled && error !== null) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
setBannerErrorState(error);
|
|
97
|
-
},
|
|
98
|
-
[enabled]
|
|
99
|
-
);
|
|
100
|
-
const addGraphQLErrorsToast = useCallback((errors) => {
|
|
101
|
-
console.warn("addGraphQLErrorsToast is deprecated. All errors now show as banners.");
|
|
102
|
-
}, []);
|
|
103
|
-
const value = {
|
|
104
|
-
toasts,
|
|
105
|
-
addToast,
|
|
106
|
-
addGraphQLErrorsToast,
|
|
107
|
-
removeToast,
|
|
108
|
-
enabled,
|
|
109
|
-
bannerError,
|
|
110
|
-
setBannerError
|
|
111
|
-
};
|
|
112
|
-
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
|
|
113
|
-
bannerError && (() => {
|
|
114
|
-
const severity = getErrorSeverity(bannerError);
|
|
115
|
-
const colors = getErrorColors(severity);
|
|
116
|
-
return /* @__PURE__ */ jsx(
|
|
117
|
-
"div",
|
|
118
|
-
{
|
|
119
|
-
style: {
|
|
120
|
-
position: "fixed",
|
|
121
|
-
bottom: "20px",
|
|
122
|
-
left: "50%",
|
|
123
|
-
transform: "translateX(-50%)",
|
|
124
|
-
zIndex: 9999,
|
|
125
|
-
backgroundColor: colors.background,
|
|
126
|
-
border: `1px solid ${colors.border}`,
|
|
127
|
-
borderLeft: `4px solid ${colors.border}`,
|
|
128
|
-
borderRadius: "8px",
|
|
129
|
-
padding: "12px 16px",
|
|
130
|
-
fontSize: "13px",
|
|
131
|
-
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
132
|
-
backdropFilter: "blur(8px)",
|
|
133
|
-
maxWidth: "min(90vw, 700px)",
|
|
134
|
-
width: "100%",
|
|
135
|
-
boxSizing: "border-box",
|
|
136
|
-
overflow: "hidden"
|
|
137
|
-
},
|
|
138
|
-
children: /* @__PURE__ */ jsxs(
|
|
139
|
-
"div",
|
|
140
|
-
{
|
|
141
|
-
style: {
|
|
142
|
-
display: "flex",
|
|
143
|
-
justifyContent: "space-between",
|
|
144
|
-
alignItems: "center",
|
|
145
|
-
gap: "10px"
|
|
146
|
-
},
|
|
147
|
-
children: [
|
|
148
|
-
/* @__PURE__ */ jsxs(
|
|
149
|
-
"div",
|
|
150
|
-
{
|
|
151
|
-
style: {
|
|
152
|
-
display: "flex",
|
|
153
|
-
alignItems: "center",
|
|
154
|
-
gap: "8px",
|
|
155
|
-
flex: 1,
|
|
156
|
-
minWidth: 0
|
|
157
|
-
},
|
|
158
|
-
children: [
|
|
159
|
-
/* @__PURE__ */ jsx(
|
|
160
|
-
"div",
|
|
161
|
-
{
|
|
162
|
-
style: {
|
|
163
|
-
width: "12px",
|
|
164
|
-
height: "12px",
|
|
165
|
-
borderRadius: "50%",
|
|
166
|
-
backgroundColor: colors.border,
|
|
167
|
-
flexShrink: 0
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
),
|
|
171
|
-
/* @__PURE__ */ jsxs(
|
|
172
|
-
"div",
|
|
173
|
-
{
|
|
174
|
-
style: {
|
|
175
|
-
display: "flex",
|
|
176
|
-
alignItems: "center",
|
|
177
|
-
gap: "10px",
|
|
178
|
-
flex: 1,
|
|
179
|
-
minWidth: 0
|
|
180
|
-
},
|
|
181
|
-
children: [
|
|
182
|
-
/* @__PURE__ */ jsx(
|
|
183
|
-
"div",
|
|
184
|
-
{
|
|
185
|
-
style: {
|
|
186
|
-
color: colors.text,
|
|
187
|
-
lineHeight: "1.4",
|
|
188
|
-
fontWeight: "400",
|
|
189
|
-
fontSize: "13px",
|
|
190
|
-
flex: 1,
|
|
191
|
-
wordBreak: "break-all",
|
|
192
|
-
overflowWrap: "break-word",
|
|
193
|
-
maxWidth: "550px",
|
|
194
|
-
overflow: "hidden",
|
|
195
|
-
display: "-webkit-box",
|
|
196
|
-
WebkitLineClamp: 10,
|
|
197
|
-
WebkitBoxOrient: "vertical"
|
|
198
|
-
},
|
|
199
|
-
children: (() => {
|
|
200
|
-
let message = bannerError.message;
|
|
201
|
-
const jsonMatch = message.match(/'message':\s*'([^']+)'/);
|
|
202
|
-
if (jsonMatch) {
|
|
203
|
-
return jsonMatch[1];
|
|
204
|
-
}
|
|
205
|
-
message = message.split(" - ")[0];
|
|
206
|
-
message = message.split(": Error code")[0];
|
|
207
|
-
message = message.replace(/:\s*\d{3}$/, "");
|
|
208
|
-
message = message.replace(/See more:.*$/g, "");
|
|
209
|
-
message = message.trim();
|
|
210
|
-
return message || "Configuration error occurred.";
|
|
211
|
-
})()
|
|
212
|
-
}
|
|
213
|
-
),
|
|
214
|
-
(() => {
|
|
215
|
-
const message = bannerError.message;
|
|
216
|
-
const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
217
|
-
const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
|
|
218
|
-
let url = null;
|
|
219
|
-
let buttonText = "See More";
|
|
220
|
-
const markdownMatch = markdownLinkRegex.exec(message);
|
|
221
|
-
if (markdownMatch) {
|
|
222
|
-
url = markdownMatch[2];
|
|
223
|
-
buttonText = "See More";
|
|
224
|
-
} else {
|
|
225
|
-
const urlMatch = plainUrlRegex.exec(message);
|
|
226
|
-
if (urlMatch) {
|
|
227
|
-
url = urlMatch[0].replace(/[.,;:'"]*$/, "");
|
|
228
|
-
buttonText = "See More";
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (!url)
|
|
232
|
-
return null;
|
|
233
|
-
return /* @__PURE__ */ jsx(
|
|
234
|
-
"button",
|
|
235
|
-
{
|
|
236
|
-
onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
|
|
237
|
-
style: {
|
|
238
|
-
background: colors.border,
|
|
239
|
-
color: "white",
|
|
240
|
-
border: "none",
|
|
241
|
-
borderRadius: "5px",
|
|
242
|
-
padding: "4px 10px",
|
|
243
|
-
fontSize: "11px",
|
|
244
|
-
fontWeight: "500",
|
|
245
|
-
cursor: "pointer",
|
|
246
|
-
transition: "all 0.2s ease",
|
|
247
|
-
flexShrink: 0
|
|
248
|
-
},
|
|
249
|
-
onMouseEnter: (e) => {
|
|
250
|
-
e.currentTarget.style.opacity = "0.9";
|
|
251
|
-
e.currentTarget.style.transform = "translateY(-1px)";
|
|
252
|
-
},
|
|
253
|
-
onMouseLeave: (e) => {
|
|
254
|
-
e.currentTarget.style.opacity = "1";
|
|
255
|
-
e.currentTarget.style.transform = "translateY(0)";
|
|
256
|
-
},
|
|
257
|
-
children: buttonText
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
})()
|
|
261
|
-
]
|
|
262
|
-
}
|
|
263
|
-
)
|
|
264
|
-
]
|
|
265
|
-
}
|
|
266
|
-
),
|
|
267
|
-
/* @__PURE__ */ jsx(
|
|
268
|
-
"button",
|
|
269
|
-
{
|
|
270
|
-
onClick: () => setBannerError(null),
|
|
271
|
-
style: {
|
|
272
|
-
background: "transparent",
|
|
273
|
-
border: "none",
|
|
274
|
-
color: colors.text,
|
|
275
|
-
cursor: "pointer",
|
|
276
|
-
padding: "2px",
|
|
277
|
-
borderRadius: "3px",
|
|
278
|
-
fontSize: "14px",
|
|
279
|
-
lineHeight: "1",
|
|
280
|
-
opacity: 0.6,
|
|
281
|
-
transition: "all 0.2s ease",
|
|
282
|
-
flexShrink: 0
|
|
283
|
-
},
|
|
284
|
-
title: "Dismiss",
|
|
285
|
-
onMouseEnter: (e) => {
|
|
286
|
-
e.currentTarget.style.opacity = "1";
|
|
287
|
-
e.currentTarget.style.background = "rgba(0, 0, 0, 0.05)";
|
|
288
|
-
},
|
|
289
|
-
onMouseLeave: (e) => {
|
|
290
|
-
e.currentTarget.style.opacity = "0.6";
|
|
291
|
-
e.currentTarget.style.background = "transparent";
|
|
292
|
-
},
|
|
293
|
-
children: "\xD7"
|
|
294
|
-
}
|
|
295
|
-
)
|
|
296
|
-
]
|
|
297
|
-
}
|
|
298
|
-
)
|
|
299
|
-
}
|
|
300
|
-
);
|
|
301
|
-
})(),
|
|
302
|
-
children
|
|
303
|
-
] });
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export {
|
|
307
|
-
useToast,
|
|
308
|
-
ToastProvider
|
|
309
|
-
};
|
|
310
|
-
//# sourceMappingURL=chunk-YAF2LATQ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/toast/toast-provider.tsx"],"sourcesContent":["import { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport React, { createContext, useContext, useState, useCallback } from \"react\";\nimport { ErrorToast } from \"../error-boundary/error-utils\";\nimport { PartialBy, CopilotKitError, CopilotKitErrorCode, Severity } from \"@copilotkit/shared\";\nimport { renderCopilotKitUsage } from \"../usage-banner\";\n\ninterface Toast {\n id: string;\n message: string | React.ReactNode;\n type: \"info\" | \"success\" | \"warning\" | \"error\";\n duration?: number;\n}\n\ninterface ToastContextValue {\n toasts: Toast[];\n addToast: (toast: PartialBy<Toast, \"id\">) => void;\n addGraphQLErrorsToast: (errors: GraphQLError[]) => void;\n removeToast: (id: string) => void;\n enabled: boolean;\n // Banner management\n bannerError: CopilotKitError | null;\n setBannerError: (error: CopilotKitError | null) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\n// Helper functions for error banner styling\ntype ErrorSeverity = \"critical\" | \"warning\" | \"info\";\n\ninterface ErrorColors {\n background: string;\n border: string;\n text: string;\n icon: string;\n}\n\nfunction getErrorSeverity(error: CopilotKitError): ErrorSeverity {\n // Use structured error severity if available\n if (error.severity) {\n switch (error.severity) {\n case Severity.CRITICAL:\n return \"critical\";\n case Severity.WARNING:\n return \"warning\";\n case Severity.INFO:\n return \"info\";\n default:\n return \"info\";\n }\n }\n\n // Fallback: Check for API key errors which should always be critical\n const message = error.message.toLowerCase();\n if (\n message.includes(\"api key\") ||\n message.includes(\"401\") ||\n message.includes(\"unauthorized\") ||\n message.includes(\"authentication\") ||\n message.includes(\"incorrect api key\")\n ) {\n return \"critical\";\n }\n\n // Default to info level\n return \"info\";\n}\n\nfunction getErrorColors(severity: ErrorSeverity): ErrorColors {\n switch (severity) {\n case \"critical\":\n return {\n background: \"#fee2e2\",\n border: \"#dc2626\",\n text: \"#7f1d1d\",\n icon: \"#dc2626\",\n };\n case \"warning\":\n return {\n background: \"#fef3c7\",\n border: \"#d97706\",\n text: \"#78350f\",\n icon: \"#d97706\",\n };\n case \"info\":\n return {\n background: \"#dbeafe\",\n border: \"#2563eb\",\n text: \"#1e3a8a\",\n icon: \"#2563eb\",\n };\n }\n}\n\nexport function useToast() {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error(\"useToast must be used within a ToastProvider\");\n }\n return context;\n}\n\nexport function ToastProvider({\n enabled,\n children,\n}: {\n enabled: boolean;\n children: React.ReactNode;\n}) {\n const [toasts, setToasts] = useState<Toast[]>([]);\n const [bannerError, setBannerErrorState] = useState<CopilotKitError | null>(null);\n\n const removeToast = useCallback((id: string) => {\n setToasts((prev) => prev.filter((toast) => toast.id !== id));\n }, []);\n\n const addToast = useCallback(\n (toast: PartialBy<Toast, \"id\">) => {\n // Respect the enabled flag for ALL toasts\n if (!enabled) {\n return;\n }\n\n const id = toast.id ?? Math.random().toString(36).substring(2, 9);\n\n setToasts((currentToasts) => {\n if (currentToasts.find((toast) => toast.id === id)) return currentToasts;\n return [...currentToasts, { ...toast, id }];\n });\n\n if (toast.duration) {\n setTimeout(() => {\n removeToast(id);\n }, toast.duration);\n }\n },\n [enabled, removeToast],\n );\n\n const setBannerError = useCallback(\n (error: CopilotKitError | null) => {\n // Respect the enabled flag for ALL errors\n if (!enabled && error !== null) {\n return;\n }\n setBannerErrorState(error);\n },\n [enabled],\n );\n\n const addGraphQLErrorsToast = useCallback((errors: GraphQLError[]) => {\n // DEPRECATED: All errors now route to banners for consistency\n console.warn(\"addGraphQLErrorsToast is deprecated. All errors now show as banners.\");\n // Function kept for backward compatibility - does nothing\n }, []);\n\n const value = {\n toasts,\n addToast,\n addGraphQLErrorsToast,\n removeToast,\n enabled,\n bannerError,\n setBannerError,\n };\n\n return (\n <ToastContext.Provider value={value}>\n {/* Banner Error Display */}\n {bannerError &&\n (() => {\n const severity = getErrorSeverity(bannerError);\n const colors = getErrorColors(severity);\n\n return (\n <div\n style={{\n position: \"fixed\",\n bottom: \"20px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 9999,\n backgroundColor: colors.background,\n border: `1px solid ${colors.border}`,\n borderLeft: `4px solid ${colors.border}`,\n borderRadius: \"8px\",\n padding: \"12px 16px\",\n fontSize: \"13px\",\n boxShadow: \"0 4px 12px rgba(0, 0, 0, 0.15)\",\n backdropFilter: \"blur(8px)\",\n maxWidth: \"min(90vw, 700px)\",\n width: \"100%\",\n boxSizing: \"border-box\",\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n gap: \"10px\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"8px\",\n flex: 1,\n minWidth: 0,\n }}\n >\n <div\n style={{\n width: \"12px\",\n height: \"12px\",\n borderRadius: \"50%\",\n backgroundColor: colors.border,\n flexShrink: 0,\n }}\n />\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"10px\",\n flex: 1,\n minWidth: 0,\n }}\n >\n <div\n style={{\n color: colors.text,\n lineHeight: \"1.4\",\n fontWeight: \"400\",\n fontSize: \"13px\",\n flex: 1,\n wordBreak: \"break-all\",\n overflowWrap: \"break-word\",\n maxWidth: \"550px\",\n overflow: \"hidden\",\n display: \"-webkit-box\",\n WebkitLineClamp: 10,\n WebkitBoxOrient: \"vertical\",\n }}\n >\n {(() => {\n let message = bannerError.message;\n\n // Try to extract the useful message from JSON first\n const jsonMatch = message.match(/'message':\\s*'([^']+)'/);\n if (jsonMatch) {\n return jsonMatch[1]; // Return the actual error message\n }\n\n // Strip technical garbage but keep the meaningful message\n message = message.split(\" - \")[0]; // Remove everything after \" - {\"\n message = message.split(\": Error code\")[0]; // Remove \": Error code: 401\"\n message = message.replace(/:\\s*\\d{3}$/, \"\"); // Remove trailing \": 401\"\n message = message.replace(/See more:.*$/g, \"\"); // Remove \"See more\" links\n message = message.trim();\n\n // If it's still garbage (contains { or '), use fallback\n // if (message.includes(\"{\") || message.includes(\"'\")) {\n // return \"Configuration error.... Please check your setup.\";\n // }\n\n return message || \"Configuration error occurred.\";\n })()}\n </div>\n\n {(() => {\n const message = bannerError.message;\n const markdownLinkRegex = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n const plainUrlRegex = /(https?:\\/\\/[^\\s)]+)/g;\n\n // Extract the first URL found\n let url = null;\n let buttonText = \"See More\";\n\n // Check for markdown links first\n const markdownMatch = markdownLinkRegex.exec(message);\n if (markdownMatch) {\n url = markdownMatch[2];\n buttonText = \"See More\";\n } else {\n // Check for plain URLs\n const urlMatch = plainUrlRegex.exec(message);\n if (urlMatch) {\n url = urlMatch[0].replace(/[.,;:'\"]*$/, \"\"); // Remove trailing punctuation\n buttonText = \"See More\";\n }\n }\n\n if (!url) return null;\n\n return (\n <button\n onClick={() => window.open(url, \"_blank\", \"noopener,noreferrer\")}\n style={{\n background: colors.border,\n color: \"white\",\n border: \"none\",\n borderRadius: \"5px\",\n padding: \"4px 10px\",\n fontSize: \"11px\",\n fontWeight: \"500\",\n cursor: \"pointer\",\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n }}\n onMouseEnter={(e) => {\n e.currentTarget.style.opacity = \"0.9\";\n e.currentTarget.style.transform = \"translateY(-1px)\";\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.opacity = \"1\";\n e.currentTarget.style.transform = \"translateY(0)\";\n }}\n >\n {buttonText}\n </button>\n );\n })()}\n </div>\n </div>\n <button\n onClick={() => setBannerError(null)}\n style={{\n background: \"transparent\",\n border: \"none\",\n color: colors.text,\n cursor: \"pointer\",\n padding: \"2px\",\n borderRadius: \"3px\",\n fontSize: \"14px\",\n lineHeight: \"1\",\n opacity: 0.6,\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n }}\n title=\"Dismiss\"\n onMouseEnter={(e) => {\n e.currentTarget.style.opacity = \"1\";\n e.currentTarget.style.background = \"rgba(0, 0, 0, 0.05)\";\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.opacity = \"0.6\";\n e.currentTarget.style.background = \"transparent\";\n }}\n >\n ×\n </button>\n </div>\n </div>\n );\n })()}\n\n {/* Toast Display - Deprecated: All errors now show as banners */}\n {children}\n </ToastContext.Provider>\n );\n}\n\n// Toast component removed - all errors now show as banners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sCAAE,cAAc,MAAM,UAAU;AAChC,sCAAE,cAAc,MAAM,YAAY;AAAA,kCACpC;AAAA,kCACA,cAAc,CAAC,MAAM;AACnB,sCAAE,cAAc,MAAM,UAAU;AAChC,sCAAE,cAAc,MAAM,YAAY;AAAA,kCACpC;AAAA,kCAEC;AAAA;AAAA,8BACH;AAAA,4BAEJ,GAAG;AAAA;AAAA;AAAA,sBACL;AAAA;AAAA;AAAA,gBACF;AAAA,gBACA;AAAA,kBAAC;AAAA;AAAA,oBACC,SAAS,MAAM,eAAe,IAAI;AAAA,oBAClC,OAAO;AAAA,sBACL,YAAY;AAAA,sBACZ,QAAQ;AAAA,sBACR,OAAO,OAAO;AAAA,sBACd,QAAQ;AAAA,sBACR,SAAS;AAAA,sBACT,cAAc;AAAA,sBACd,UAAU;AAAA,sBACV,YAAY;AAAA,sBACZ,SAAS;AAAA,sBACT,YAAY;AAAA,sBACZ,YAAY;AAAA,oBACd;AAAA,oBACA,OAAM;AAAA,oBACN,cAAc,CAAC,MAAM;AACnB,wBAAE,cAAc,MAAM,UAAU;AAChC,wBAAE,cAAc,MAAM,aAAa;AAAA,oBACrC;AAAA,oBACA,cAAc,CAAC,MAAM;AACnB,wBAAE,cAAc,MAAM,UAAU;AAChC,wBAAE,cAAc,MAAM,aAAa;AAAA,oBACrC;AAAA,oBACD;AAAA;AAAA,gBAED;AAAA;AAAA;AAAA,UACF;AAAA;AAAA,MACF;AAAA,IAEJ,GAAG;AAAA,IAGJ;AAAA,KACH;AAEJ;","names":["toast"]}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import { CopilotTraceEvent, CopilotTraceHandler } from "@copilotkit/shared";
|
|
3
|
-
|
|
4
|
-
describe("CopilotKit onTrace types", () => {
|
|
5
|
-
let mockTrace: jest.Mock;
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
mockTrace = jest.fn();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
describe("onTrace type checking", () => {
|
|
12
|
-
it("should accept CopilotTraceHandler type", () => {
|
|
13
|
-
// RED: Will fail - testing type compatibility
|
|
14
|
-
const handler: CopilotTraceHandler = mockTrace;
|
|
15
|
-
expect(handler).toBeDefined();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should validate trace event structure", () => {
|
|
19
|
-
// RED: Will fail - validating event structure
|
|
20
|
-
const mockEvent: CopilotTraceEvent = {
|
|
21
|
-
type: "error",
|
|
22
|
-
timestamp: Date.now(),
|
|
23
|
-
context: {
|
|
24
|
-
source: "ui",
|
|
25
|
-
request: {
|
|
26
|
-
operation: "test",
|
|
27
|
-
startTime: Date.now(),
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
expect(mockEvent.type).toBe("error");
|
|
33
|
-
expect(mockEvent.timestamp).toBeDefined();
|
|
34
|
-
expect(mockEvent.context.source).toBe("ui");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should validate trace event types", () => {
|
|
38
|
-
// RED: Will fail - ensuring all event types are valid
|
|
39
|
-
const validTypes: CopilotTraceEvent["type"][] = [
|
|
40
|
-
"error",
|
|
41
|
-
"request",
|
|
42
|
-
"response",
|
|
43
|
-
"agent_state",
|
|
44
|
-
"action",
|
|
45
|
-
"message",
|
|
46
|
-
"performance",
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
expect(validTypes).toContain("error");
|
|
50
|
-
expect(validTypes).toContain("request");
|
|
51
|
-
expect(validTypes).toContain("agent_state");
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe("trace handler functionality", () => {
|
|
56
|
-
it("should accept trace handler with proper signature", () => {
|
|
57
|
-
// RED: Will fail - testing handler function signature
|
|
58
|
-
const handler: CopilotTraceHandler = (traceEvent: CopilotTraceEvent) => {
|
|
59
|
-
console.log("Trace:", traceEvent.type);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
expect(typeof handler).toBe("function");
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should handle async trace handlers", async () => {
|
|
66
|
-
// RED: Will fail - testing async handler support
|
|
67
|
-
const asyncHandler: CopilotTraceHandler = async (traceEvent: CopilotTraceEvent) => {
|
|
68
|
-
await Promise.resolve();
|
|
69
|
-
return;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
expect(typeof asyncHandler).toBe("function");
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|