@copilotkit/react-ui 1.10.0-next.3 → 1.10.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/{chunk-O7KTFUAN.mjs → chunk-226ZMOE3.mjs} +2 -2
- package/dist/{chunk-QNG5G23E.mjs → chunk-2TABXABK.mjs} +2 -2
- package/dist/{chunk-SGFUVPDB.mjs → chunk-FFJHOZX6.mjs} +2 -2
- package/dist/{chunk-GVKA7RQQ.mjs → chunk-GDSZGYCE.mjs} +2 -2
- package/dist/{chunk-QN7T3GWI.mjs → chunk-JY2CSDKN.mjs} +4 -6
- package/dist/chunk-JY2CSDKN.mjs.map +1 -0
- package/dist/{chunk-7L34XQRL.mjs → chunk-P6O2MZGT.mjs} +4 -4
- package/dist/chunk-P6O2MZGT.mjs.map +1 -0
- package/dist/{chunk-DNSSBMAS.mjs → chunk-QKDRZ7WA.mjs} +4 -4
- package/dist/{chunk-WHDNKXMP.mjs → chunk-U5ATIGWH.mjs} +2 -2
- package/dist/chunk-U5ATIGWH.mjs.map +1 -0
- package/dist/{chunk-Q2467VHZ.mjs → chunk-W26XFBEG.mjs} +2 -2
- package/dist/chunk-W26XFBEG.mjs.map +1 -0
- package/dist/{chunk-PF3QW6U5.mjs → chunk-WYEGK6BP.mjs} +2 -2
- package/dist/components/chat/Chat.d.ts +11 -9
- package/dist/components/chat/Chat.js +3 -3
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +4 -4
- package/dist/components/chat/Header.js +6 -8
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +3 -3
- package/dist/components/chat/Messages.js +1 -1
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +23 -25
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +8 -8
- package/dist/components/chat/Popup.d.ts +1 -1
- package/dist/components/chat/Popup.js +23 -25
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +9 -9
- package/dist/components/chat/Sidebar.d.ts +1 -1
- package/dist/components/chat/Sidebar.js +23 -25
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +9 -9
- package/dist/components/chat/Suggestion.js +1 -1
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/Suggestions.js +1 -1
- package/dist/components/chat/Suggestions.js.map +1 -1
- package/dist/components/chat/Suggestions.mjs +2 -2
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +23 -25
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +10 -10
- package/dist/components/dev-console/console.d.ts +1 -0
- package/dist/components/dev-console/console.js +6 -8
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +2 -2
- package/dist/components/dev-console/index.d.ts +1 -3
- package/dist/components/dev-console/index.js +7 -9
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +2 -2
- package/dist/components/dev-console/utils.d.ts +2 -2
- package/dist/components/dev-console/utils.js +2 -4
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/index.d.ts +2 -4
- package/dist/components/index.js +24 -26
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -10
- package/dist/index.d.ts +2 -4
- package/dist/index.js +26 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/package.json +5 -5
- package/src/components/chat/Chat.tsx +1 -1
- package/src/components/chat/Messages.tsx +2 -2
- package/src/components/chat/Suggestion.tsx +1 -1
- package/src/components/dev-console/utils.ts +1 -6
- package/dist/chunk-7L34XQRL.mjs.map +0 -1
- package/dist/chunk-Q2467VHZ.mjs.map +0 -1
- package/dist/chunk-QN7T3GWI.mjs.map +0 -1
- package/dist/chunk-WHDNKXMP.mjs.map +0 -1
- /package/dist/{chunk-O7KTFUAN.mjs.map → chunk-226ZMOE3.mjs.map} +0 -0
- /package/dist/{chunk-QNG5G23E.mjs.map → chunk-2TABXABK.mjs.map} +0 -0
- /package/dist/{chunk-SGFUVPDB.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
- /package/dist/{chunk-GVKA7RQQ.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
- /package/dist/{chunk-DNSSBMAS.mjs.map → chunk-QKDRZ7WA.mjs.map} +0 -0
- /package/dist/{chunk-PF3QW6U5.mjs.map → chunk-WYEGK6BP.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.10.0-next.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 967d0ab: - refactor(chat): separate useCopilotChat into internal implementation and public API
|
|
8
|
+
- Updated dependencies [967d0ab]
|
|
9
|
+
- @copilotkit/react-core@1.10.0-next.4
|
|
10
|
+
- @copilotkit/runtime-client-gql@1.10.0-next.4
|
|
11
|
+
- @copilotkit/shared@1.10.0-next.4
|
|
12
|
+
|
|
3
13
|
## 1.10.0-next.3
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Suggestion
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W26XFBEG.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/chat/Suggestions.tsx
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -21,4 +21,4 @@ function Suggestions({ suggestions, onSuggestionClick }) {
|
|
|
21
21
|
export {
|
|
22
22
|
Suggestions
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-226ZMOE3.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QKDRZ7WA.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
|
|
|
27
27
|
export {
|
|
28
28
|
CopilotSidebar
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-2TABXABK.mjs.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
logMessages,
|
|
11
11
|
logReadables,
|
|
12
12
|
shouldShowDevConsole
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JY2CSDKN.mjs";
|
|
14
14
|
import {
|
|
15
15
|
CopilotKitHelpModal
|
|
16
16
|
} from "./chunk-NRA3CFEE.mjs";
|
|
@@ -199,4 +199,4 @@ export {
|
|
|
199
199
|
CopilotDevConsole,
|
|
200
200
|
DebugMenuButton
|
|
201
201
|
};
|
|
202
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-FFJHOZX6.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotDevConsole
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FFJHOZX6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useChatContext
|
|
6
6
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
@@ -29,4 +29,4 @@ var Header = ({}) => {
|
|
|
29
29
|
export {
|
|
30
30
|
Header
|
|
31
31
|
};
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-GDSZGYCE.mjs.map
|
|
@@ -6,9 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
defaultCopilotContextCategories
|
|
8
8
|
} from "@copilotkit/react-core";
|
|
9
|
-
|
|
10
|
-
return showDevConsole;
|
|
11
|
-
}
|
|
9
|
+
import { shouldShowDevConsole } from "@copilotkit/react-core";
|
|
12
10
|
function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
13
11
|
return __async(this, null, function* () {
|
|
14
12
|
const LOCAL_STORAGE_KEY = "__copilotkit_version_check__";
|
|
@@ -128,10 +126,10 @@ function logMessages(context) {
|
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
export {
|
|
131
|
-
shouldShowDevConsole,
|
|
132
129
|
getPublishedCopilotKitVersion,
|
|
133
130
|
logReadables,
|
|
134
131
|
logActions,
|
|
135
|
-
logMessages
|
|
132
|
+
logMessages,
|
|
133
|
+
shouldShowDevConsole
|
|
136
134
|
};
|
|
137
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-JY2CSDKN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/dev-console/utils.ts"],"sourcesContent":["import {\n CopilotContextParams,\n CopilotMessagesContextParams,\n defaultCopilotContextCategories,\n} from \"@copilotkit/react-core\";\nimport { CopilotKitVersion } from \"./types\";\nexport { shouldShowDevConsole } from \"@copilotkit/react-core\";\n\nexport async function getPublishedCopilotKitVersion(\n current: string,\n forceCheck: boolean = false,\n): Promise<CopilotKitVersion> {\n const LOCAL_STORAGE_KEY = \"__copilotkit_version_check__\";\n const serializedVersion = localStorage.getItem(LOCAL_STORAGE_KEY);\n if (serializedVersion && !forceCheck) {\n try {\n const parsedVersion: CopilotKitVersion = JSON.parse(serializedVersion);\n const oneHour = 60 * 60 * 1000;\n const now = new Date().getTime();\n\n if (\n parsedVersion.current === current &&\n now - new Date(parsedVersion.lastChecked).getTime() < oneHour\n ) {\n return parsedVersion;\n }\n } catch (error) {\n console.error(\"Failed to parse CopilotKitVersion from localStorage\", error);\n }\n }\n\n try {\n const response = await fetch(\"https://api.cloud.copilotkit.ai/check-for-updates\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n packages: [\n {\n packageName: \"@copilotkit/shared\",\n packageVersion: current,\n },\n ],\n }),\n });\n\n const data = await response.json();\n\n const version: CopilotKitVersion = {\n current,\n lastChecked: new Date().getTime(),\n latest: data.packages[0].latestVersion,\n severity: data.packages[0].severity,\n advisory: data.packages[0].advisory || null,\n };\n\n localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(version));\n return version;\n } catch (error) {\n console.error(\"Failed to check for updates\", error);\n throw error;\n }\n}\n\nexport function logReadables(context: CopilotContextParams) {\n console.log(\"%cCurrent Readables:\", \"font-size: 16px; font-weight: bold;\");\n\n const readables = context.getContextString([], defaultCopilotContextCategories).trim();\n if (readables.length === 0) {\n console.log(\"No readables found\");\n return;\n }\n console.log(readables);\n}\n\nexport function logActions(context: CopilotContextParams) {\n console.log(\"%cCurrent Actions:\", \"font-size: 16px; font-weight: bold;\");\n\n if (Object.values(context.actions).length === 0) {\n console.log(\"No actions found\");\n return;\n }\n for (const action of Object.values(context.actions)) {\n console.group(action.name);\n console.log(\"name\", action.name);\n console.log(\"description\", action.description);\n console.log(\"parameters\", action.parameters);\n\n console.groupEnd();\n }\n}\n\nexport function logMessages(context: CopilotMessagesContextParams) {\n console.log(\"%cCurrent Messages:\", \"font-size: 16px; font-weight: bold;\");\n\n if (context.messages.length === 0) {\n console.log(\"No messages found\");\n return;\n }\n\n const tableData = context.messages.map((message) => {\n if (message.isTextMessage()) {\n return {\n id: message.id,\n type: \"TextMessage\",\n role: message.role,\n name: undefined,\n scope: undefined,\n content: message.content,\n };\n } else if (message.isActionExecutionMessage()) {\n return {\n id: message.id,\n type: \"ActionExecutionMessage\",\n role: undefined,\n name: message.name,\n scope: message.parentMessageId,\n content: message.arguments,\n };\n } else if (message.isResultMessage()) {\n return {\n id: message.id,\n type: \"ResultMessage\",\n role: undefined,\n name: message.actionName,\n scope: message.actionExecutionId,\n content: message.result,\n };\n } else if (message.isAgentStateMessage()) {\n return {\n id: message.id,\n type: `AgentStateMessage (running: ${message.running})`,\n role: message.role,\n name: undefined,\n scope: message.threadId,\n content: message.state,\n };\n }\n });\n console.table(tableData);\n}\n"],"mappings":";;;;;AAAA;AAAA,EAGE;AAAA,OACK;AAEP,SAAS,4BAA4B;AAErC,SAAsB,8BACpB,SACA,aAAsB,OACM;AAAA;AAC5B,UAAM,oBAAoB;AAC1B,UAAM,oBAAoB,aAAa,QAAQ,iBAAiB;AAChE,QAAI,qBAAqB,CAAC,YAAY;AACpC,UAAI;AACF,cAAM,gBAAmC,KAAK,MAAM,iBAAiB;AACrE,cAAM,UAAU,KAAK,KAAK;AAC1B,cAAM,OAAM,oBAAI,KAAK,GAAE,QAAQ;AAE/B,YACE,cAAc,YAAY,WAC1B,MAAM,IAAI,KAAK,cAAc,WAAW,EAAE,QAAQ,IAAI,SACtD;AACA,iBAAO;AAAA,QACT;AAAA,MACF,SAAS,OAAP;AACA,gBAAQ,MAAM,uDAAuD,KAAK;AAAA,MAC5E;AAAA,IACF;AAEA,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,qDAAqD;AAAA,QAChF,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,QAClB;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,UAAU;AAAA,YACR;AAAA,cACE,aAAa;AAAA,cACb,gBAAgB;AAAA,YAClB;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAED,YAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,YAAM,UAA6B;AAAA,QACjC;AAAA,QACA,cAAa,oBAAI,KAAK,GAAE,QAAQ;AAAA,QAChC,QAAQ,KAAK,SAAS,CAAC,EAAE;AAAA,QACzB,UAAU,KAAK,SAAS,CAAC,EAAE;AAAA,QAC3B,UAAU,KAAK,SAAS,CAAC,EAAE,YAAY;AAAA,MACzC;AAEA,mBAAa,Q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AA,QACZ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf,SAAS,QAAQ;AAAA,MACnB;AAAA,IACF,WAAW,QAAQ,gBAAgB,GAAG;AACpC,aAAO;AAAA,QACL,IAAI,QAAQ;AAAA,QACZ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf,SAAS,QAAQ;AAAA,MACnB;AAAA,IACF,WAAW,QAAQ,oBAAoB,GAAG;AACxC,aAAO;AAAA,QACL,IAAI,QAAQ;AAAA,QACZ,MAAM,+BAA+B,QAAQ;AAAA,QAC7C,MAAM,QAAQ;AAAA,QACd,MAAM;AAAA,QACN,OAAO,QAAQ;AAAA,QACf,SAAS,QAAQ;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACD,UAAQ,MAAM,SAAS;AACzB;","names":[]}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-VVL6JFCJ.mjs";
|
|
13
13
|
import {
|
|
14
14
|
Suggestions
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-226ZMOE3.mjs";
|
|
16
16
|
import {
|
|
17
17
|
ImageUploadQueue
|
|
18
18
|
} from "./chunk-PLHTVHUW.mjs";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-DTRPPNSA.mjs";
|
|
22
22
|
import {
|
|
23
23
|
Messages
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-U5ATIGWH.mjs";
|
|
25
25
|
import {
|
|
26
26
|
ChatContext,
|
|
27
27
|
ChatContextProvider
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
// src/components/chat/Chat.tsx
|
|
36
36
|
import React, { useEffect, useRef, useState, useCallback, useMemo } from "react";
|
|
37
37
|
import {
|
|
38
|
-
useCopilotChat,
|
|
38
|
+
useCopilotChatInternal as useCopilotChat,
|
|
39
39
|
useCopilotContext,
|
|
40
40
|
useCopilotMessagesContext
|
|
41
41
|
} from "@copilotkit/react-core";
|
|
@@ -506,4 +506,4 @@ export {
|
|
|
506
506
|
WrappedCopilotChat,
|
|
507
507
|
useCopilotChatLogic
|
|
508
508
|
};
|
|
509
|
-
//# sourceMappingURL=chunk-
|
|
509
|
+
//# sourceMappingURL=chunk-P6O2MZGT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Chat.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/CopilotChat.gif\" width=\"500\" />\n *\n * A chatbot panel component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * ## Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ## Usage\n *\n * ```tsx\n * import { CopilotChat } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * <CopilotChat\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-ui/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n */\n\nimport {\n ChatContext,\n ChatContextProvider,\n CopilotChatIcons,\n CopilotChatLabels,\n} from \"./ChatContext\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { RenderMessage as DefaultRenderMessage } from \"./messages/RenderMessage\";\nimport { AssistantMessage as DefaultAssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage as DefaultUserMessage } from \"./messages/UserMessage\";\nimport { ImageRenderer as DefaultImageRenderer } from \"./messages/ImageRenderer\";\nimport React, { useEffect, useRef, useState, useCallback, useMemo } from \"react\";\nimport {\n SystemMessageFunction,\n useCopilotChatInternal as useCopilotChat,\n useCopilotContext,\n useCopilotMessagesContext,\n} from \"@copilotkit/react-core\";\nimport type { SuggestionItem } from \"@copilotkit/react-core\";\nimport { Message } from \"@copilotkit/shared\";\nimport { randomId } from \"@copilotkit/shared\";\nimport {\n AssistantMessageProps,\n ComponentsMap,\n ImageRendererProps,\n InputProps,\n MessagesProps,\n RenderMessageProps,\n RenderSuggestionsListProps,\n UserMessageProps,\n} from \"./props\";\n\nimport { HintFunction, runAgent, stopAgent } from \"@copilotkit/react-core\";\nimport { ImageUploadQueue } from \"./ImageUploadQueue\";\nimport { Suggestions as DefaultRenderSuggestionsList } from \"./Suggestions\";\n\n/**\n * The type of suggestions to use in the chat.\n *\n * `auto` - Suggestions are generated automatically.\n * `manual` - Suggestions are controlled programmatically.\n * `SuggestionItem[]` - Static suggestions array.\n */\nexport type ChatSuggestions = \"auto\" | \"manual\" | SuggestionItem[];\n\n/**\n * Props for CopilotChat component.\n */\nexport interface CopilotChatProps {\n /**\n * Custom instructions to be added to the system message. Use this property to\n * provide additional context or guidance to the language model, influencing\n * its responses. These instructions can include specific directions,\n * preferences, or criteria that the model should consider when generating\n * its output, thereby tailoring the conversation more precisely to the\n * user's needs or the application's requirements.\n */\n instructions?: string;\n\n /**\n * Controls the behavior of suggestions in the chat interface.\n *\n * `auto` (default) - Suggestions are generated automatically:\n * - When the chat is first opened (empty state)\n * - After each message exchange completes\n * - Uses configuration from `useCopilotChatSuggestions` hooks\n *\n * `manual` - Suggestions are controlled programmatically:\n * - Use `setSuggestions()` to set custom suggestions\n * - Use `generateSuggestions()` to trigger AI generation\n * - Access via `useCopilotChat` hook\n *\n * `SuggestionItem[]` - Static suggestions array:\n * - Always shows the same suggestions\n * - No AI generation involved\n */\n suggestions?: ChatSuggestions;\n\n /**\n * A callback that gets called when the in progress state changes.\n */\n onInProgress?: (inProgress: boolean) => void;\n\n /**\n * A callback that gets called when a new message it submitted.\n */\n onSubmitMessage?: (message: string) => void | Promise<void>;\n\n /**\n * A custom stop generation function.\n */\n onStopGeneration?: OnStopGeneration;\n\n /**\n * A custom reload messages function.\n */\n onReloadMessages?: OnReloadMessages;\n\n /**\n * A callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * A callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * A callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * A callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n\n /**\n * Icons can be used to set custom icons for the chat window.\n */\n icons?: CopilotChatIcons;\n\n /**\n * Labels can be used to set custom labels for the chat window.\n */\n labels?: CopilotChatLabels;\n\n /**\n * Enable image upload button (image inputs only supported on some models)\n */\n imageUploadsEnabled?: boolean;\n\n /**\n * The 'accept' attribute for the file input used for image uploads.\n * Defaults to \"image/*\".\n */\n inputFileAccept?: string;\n\n /**\n * A function that takes in context string and instructions and returns\n * the system message to include in the chat request.\n * Use this to completely override the system message, when providing\n * instructions is not enough.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * A custom assistant message component to use instead of the default.\n */\n AssistantMessage?: React.ComponentType<AssistantMessageProps>;\n\n /**\n * A custom user message component to use instead of the default.\n */\n UserMessage?: React.ComponentType<UserMessageProps>;\n\n /**\n * A custom Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\n\n /**\n * A custom RenderMessage component to use instead of the default.\n *\n * **Warning**: This is a break-glass solution to allow for custom\n * rendering of messages. You are most likely looking to swap out\n * the AssistantMessage and UserMessage components instead which\n * are also props.\n */\n RenderMessage?: React.ComponentType<RenderMessageProps>;\n\n /**\n * A custom suggestions list component to use instead of the default.\n */\n RenderSuggestionsList?: React.ComponentType<RenderSuggestionsListProps>;\n\n /**\n * A custom Input component to use instead of the default.\n */\n Input?: React.ComponentType<InputProps>;\n\n /**\n * A custom image rendering component to use instead of the default.\n */\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n\n /**\n * A class name to apply to the root element.\n */\n className?: string;\n\n /**\n * Children to render.\n */\n children?: React.ReactNode;\n\n hideStopButton?: boolean;\n}\n\ninterface OnStopGenerationArguments {\n /**\n * The name of the currently executing agent.\n */\n currentAgentName: string | undefined;\n\n /**\n * The messages in the chat.\n */\n messages: Message[];\n\n /**\n * Set the messages in the chat.\n */\n setMessages: (messages: Message[]) => void;\n\n /**\n * Stop chat generation.\n */\n stopGeneration: () => void;\n\n /**\n * Restart the currently executing agent.\n */\n restartCurrentAgent: () => void;\n\n /**\n * Stop the currently executing agent.\n */\n stopCurrentAgent: () => void;\n\n /**\n * Run the currently executing agent.\n */\n runCurrentAgent: (hint?: HintFunction) => Promise<void>;\n\n /**\n * Set the state of the currently executing agent.\n */\n setCurrentAgentState: (state: any) => void;\n}\n\nexport type OnReloadMessagesArguments = OnStopGenerationArguments & {\n /**\n * The message on which \"regenerate\" was pressed\n */\n messageId: string;\n};\n\nexport type OnStopGeneration = (args: OnStopGenerationArguments) => void;\n\nexport type OnReloadMessages = (args: OnReloadMessagesArguments) => void;\n\nexport type ImageUpload = {\n contentType: string;\n bytes: string;\n};\n\nexport function CopilotChat({\n instructions,\n suggestions = \"auto\",\n onSubmitMessage,\n makeSystemMessage,\n onInProgress,\n onStopGeneration,\n onReloadMessages,\n onRegenerate,\n onCopy,\n onThumbsUp,\n onThumbsDown,\n markdownTagRenderers,\n Messages = DefaultMessages,\n RenderMessage = DefaultRenderMessage,\n RenderSuggestionsList = DefaultRenderSuggestionsList,\n Input = DefaultInput,\n className,\n icons,\n labels,\n AssistantMessage = DefaultAssistantMessage,\n UserMessage = DefaultUserMessage,\n ImageRenderer = DefaultImageRenderer,\n imageUploadsEnabled,\n inputFileAccept = \"image/*\",\n hideStopButton,\n}: CopilotChatProps) {\n const { additionalInstructions, setChatInstructions } = useCopilotContext();\n const [selectedImages, setSelectedImages] = useState<Array<ImageUpload>>([]);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Clipboard paste handler\n useEffect(() => {\n if (!imageUploadsEnabled) return;\n\n const handlePaste = async (e: ClipboardEvent) => {\n const target = e.target as HTMLElement;\n if (!target.parentElement?.classList.contains(\"copilotKitInput\")) return;\n\n const items = Array.from(e.clipboardData?.items || []);\n const imageItems = items.filter((item) => item.type.startsWith(\"image/\"));\n\n if (imageItems.length === 0) return;\n\n e.preventDefault(); // Prevent default paste behavior for images\n\n const imagePromises: Promise<ImageUpload | null>[] = imageItems.map((item) => {\n const file = item.getAsFile();\n if (!file) return Promise.resolve(null);\n\n return new Promise<ImageUpload | null>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const base64String = (e.target?.result as string)?.split(\",\")[1];\n if (base64String) {\n resolve({\n contentType: file.type,\n bytes: base64String,\n });\n } else {\n resolve(null);\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n });\n\n try {\n const loadedImages = (await Promise.all(imagePromises)).filter((img) => img !== null);\n setSelectedImages((prev) => [...prev, ...loadedImages]);\n } catch (error) {\n // TODO: Show an error message to the user\n console.error(\"Error processing pasted images:\", error);\n }\n };\n\n document.addEventListener(\"paste\", handlePaste);\n return () => document.removeEventListener(\"paste\", handlePaste);\n }, [imageUploadsEnabled]);\n\n useEffect(() => {\n if (!additionalInstructions?.length) {\n setChatInstructions(instructions || \"\");\n return;\n }\n\n /*\n Will result in a prompt like:\n\n You are a helpful assistant. \n Additionally, follow these instructions:\n - Do not answer questions about the weather.\n - Do not answer questions about the stock market.\"\n */\n const combinedAdditionalInstructions = [\n instructions,\n \"Additionally, follow these instructions:\",\n ...additionalInstructions.map((instruction) => `- ${instruction}`),\n ];\n\n setChatInstructions(combinedAdditionalInstructions.join(\"\\n\") || \"\");\n }, [instructions, additionalInstructions]);\n\n const {\n visibleMessages,\n isLoading,\n sendMessage,\n stopGeneration,\n reloadMessages,\n suggestions: currentSuggestions,\n } = useCopilotChatLogic(\n suggestions,\n makeSystemMessage,\n onInProgress,\n onSubmitMessage,\n onStopGeneration,\n onReloadMessages,\n );\n\n // Wrapper for sendMessage to clear selected images\n const handleSendMessage = (text: string) => {\n const images = selectedImages;\n setSelectedImages([]);\n if (fileInputRef.current) {\n fileInputRef.current.value = \"\";\n }\n\n return sendMessage(text, images);\n };\n\n const chatContext = React.useContext(ChatContext);\n const isVisible = chatContext ? chatContext.open : true;\n\n const handleRegenerate = (messageId: string) => {\n if (onRegenerate) {\n onRegenerate(messageId);\n }\n\n reloadMessages(messageId);\n };\n\n const handleCopy = (message: string) => {\n if (onCopy) {\n onCopy(message);\n }\n };\n\n const handleImageUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!event.target.files || event.target.files.length === 0) {\n return;\n }\n\n const files = Array.from(event.target.files).filter((file) => file.type.startsWith(\"image/\"));\n if (files.length === 0) return;\n\n const fileReadPromises = files.map((file) => {\n return new Promise<{ contentType: string; bytes: string }>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const base64String = (e.target?.result as string)?.split(\",\")[1] || \"\";\n if (base64String) {\n resolve({\n contentType: file.type,\n bytes: base64String,\n });\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n });\n\n try {\n const loadedImages = await Promise.all(fileReadPromises);\n setSelectedImages((prev) => [...prev, ...loadedImages]);\n } catch (error) {\n // TODO: Show an error message to the user\n console.error(\"Error reading files:\", error);\n }\n };\n\n const removeSelectedImage = (index: number) => {\n setSelectedImages((prev) => prev.filter((_, i) => i !== index));\n };\n\n return (\n <WrappedCopilotChat icons={icons} labels={labels} className={className}>\n <Messages\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n RenderMessage={RenderMessage}\n messages={visibleMessages}\n inProgress={isLoading}\n onRegenerate={handleRegenerate}\n onCopy={handleCopy}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n markdownTagRenderers={markdownTagRenderers}\n ImageRenderer={ImageRenderer}\n >\n {currentSuggestions.length > 0 && (\n <RenderSuggestionsList\n onSuggestionClick={handleSendMessage}\n suggestions={currentSuggestions}\n />\n )}\n </Messages>\n\n {imageUploadsEnabled && (\n <>\n <ImageUploadQueue images={selectedImages} onRemoveImage={removeSelectedImage} />\n <input\n type=\"file\"\n multiple\n ref={fileInputRef}\n onChange={handleImageUpload}\n accept={inputFileAccept}\n style={{ display: \"none\" }}\n />\n </>\n )}\n <Input\n inProgress={isLoading}\n onSend={handleSendMessage}\n isVisible={isVisible}\n onStop={stopGeneration}\n onUpload={imageUploadsEnabled ? () => fileInputRef.current?.click() : undefined}\n hideStopButton={hideStopButton}\n />\n </WrappedCopilotChat>\n );\n}\n\nexport function WrappedCopilotChat({\n children,\n icons,\n labels,\n className,\n}: {\n children: React.ReactNode;\n icons?: CopilotChatIcons;\n labels?: CopilotChatLabels;\n className?: string;\n}) {\n const chatContext = React.useContext(ChatContext);\n if (!chatContext) {\n return (\n <ChatContextProvider icons={icons} labels={labels} open={true} setOpen={() => {}}>\n <div className={`copilotKitChat ${className ?? \"\"}`}>{children}</div>\n </ChatContextProvider>\n );\n }\n return <>{children}</>;\n}\n\nexport const useCopilotChatLogic = (\n chatSuggestions: ChatSuggestions,\n makeSystemMessage?: SystemMessageFunction,\n onInProgress?: (isLoading: boolean) => void,\n onSubmitMessage?: (messageContent: string) => Promise<void> | void,\n onStopGeneration?: OnStopGeneration,\n onReloadMessages?: OnReloadMessages,\n) => {\n const {\n visibleMessages,\n appendMessage,\n setMessages,\n reloadMessages: defaultReloadMessages,\n stopGeneration: defaultStopGeneration,\n runChatCompletion,\n isLoading,\n suggestions,\n setSuggestions,\n generateSuggestions,\n resetSuggestions: resetSuggestionsFromHook,\n isLoadingSuggestions,\n } = useCopilotChat({\n makeSystemMessage,\n });\n\n const generalContext = useCopilotContext();\n const messagesContext = useCopilotMessagesContext();\n\n // Get actions from context for message conversion\n const { actions } = generalContext;\n\n // Suggestion state management\n const [suggestionsFailed, setSuggestionsFailed] = useState(false);\n const hasGeneratedInitialSuggestions = useRef<boolean>(false);\n\n // Handle static suggestions (when suggestions prop is an array)\n useEffect(() => {\n if (Array.isArray(chatSuggestions)) {\n setSuggestions(chatSuggestions);\n hasGeneratedInitialSuggestions.current = true;\n }\n }, [JSON.stringify(chatSuggestions), setSuggestions]);\n\n // Error handling wrapper\n const generateSuggestionsWithErrorHandling = useCallback(\n async (context: string) => {\n try {\n await generateSuggestions();\n } catch (error) {\n console.error(\"Failed to generate suggestions:\", error);\n setSuggestionsFailed(true);\n }\n },\n [generateSuggestions],\n );\n\n // Automatic suggestion generation logic\n useEffect(() => {\n // Only proceed if in auto mode, not currently loading, and not failed\n if (chatSuggestions !== \"auto\" || isLoadingSuggestions || suggestionsFailed) {\n return;\n }\n\n // Don't run during chat loading (when the assistant is responding)\n if (isLoading) {\n return;\n }\n\n // Check if we have any configurations\n if (Object.keys(generalContext.chatSuggestionConfiguration).length === 0) {\n return;\n }\n\n // Generate initial suggestions when chat is empty\n if (visibleMessages.length === 0 && !hasGeneratedInitialSuggestions.current) {\n hasGeneratedInitialSuggestions.current = true;\n generateSuggestionsWithErrorHandling(\"initial\");\n return;\n }\n\n // Generate post-message suggestions after assistant responds\n if (visibleMessages.length > 0 && suggestions.length === 0) {\n generateSuggestionsWithErrorHandling(\"post-message\");\n return;\n }\n }, [\n chatSuggestions,\n isLoadingSuggestions,\n suggestionsFailed,\n visibleMessages.length,\n isLoading,\n suggestions.length,\n Object.keys(generalContext.chatSuggestionConfiguration).join(\",\"), // Use stable string instead of object reference\n generateSuggestionsWithErrorHandling,\n ]);\n\n // Reset suggestion state when switching away from auto mode\n useEffect(() => {\n if (chatSuggestions !== \"auto\") {\n hasGeneratedInitialSuggestions.current = false;\n setSuggestionsFailed(false);\n }\n }, [chatSuggestions]);\n\n // Memoize context to prevent infinite re-renders\n const stableContext = useMemo(\n () => ({\n ...generalContext,\n ...messagesContext,\n }),\n [\n // Only include stable dependencies\n generalContext.actions,\n messagesContext.messages.length,\n generalContext.isLoading,\n ],\n );\n\n // Wrapper for resetSuggestions that also resets local state\n const resetSuggestions = useCallback(() => {\n resetSuggestionsFromHook();\n setSuggestionsFailed(false);\n hasGeneratedInitialSuggestions.current = false;\n }, [resetSuggestionsFromHook]);\n\n useEffect(() => {\n onInProgress?.(isLoading);\n }, [onInProgress, isLoading]);\n\n const sendMessage = async (\n messageContent: string,\n imagesToUse?: Array<{ contentType: string; bytes: string }>,\n ) => {\n const images = imagesToUse || [];\n\n // Clear existing suggestions when user sends a message\n // This prevents stale suggestions from remaining visible during new conversation flow\n if (chatSuggestions === \"auto\" || chatSuggestions === \"manual\") {\n setSuggestions([]);\n }\n\n let firstMessage: Message | null = null;\n\n // Send text message if content provided\n if (messageContent.trim().length > 0) {\n const textMessage: Message = {\n id: randomId(),\n role: \"user\",\n content: messageContent,\n };\n\n // Call user-provided submit handler if available\n if (onSubmitMessage) {\n try {\n await onSubmitMessage(messageContent);\n } catch (error) {\n console.error(\"Error in onSubmitMessage:\", error);\n }\n }\n\n // Send the message and clear suggestions for auto/manual modes\n await appendMessage(textMessage, {\n followUp: images.length === 0,\n clearSuggestions: chatSuggestions === \"auto\" || chatSuggestions === \"manual\",\n });\n\n if (!firstMessage) {\n firstMessage = textMessage;\n }\n }\n\n // Send image messages\n if (images.length > 0) {\n for (let i = 0; i < images.length; i++) {\n const imageMessage = {\n id: randomId(),\n role: \"user\" as const,\n image: {\n format: images[i].contentType.replace(\"image/\", \"\"),\n bytes: images[i].bytes,\n },\n } as unknown as Message;\n await appendMessage(imageMessage, { followUp: i === images.length - 1 });\n if (!firstMessage) {\n firstMessage = imageMessage;\n }\n }\n }\n\n if (!firstMessage) {\n // Should not happen if send button is properly disabled, but handle just in case\n return { role: \"user\", content: \"\", id: randomId() } as Message; // Return a dummy message\n }\n\n // The hook implicitly triggers API call on appendMessage.\n // We return the first message sent (either text or first image)\n return firstMessage;\n };\n\n const messages = visibleMessages;\n const currentAgentName = generalContext.agentSession?.agentName;\n const restartCurrentAgent = async (hint?: HintFunction) => {\n if (generalContext.agentSession) {\n generalContext.setAgentSession({\n ...generalContext.agentSession,\n nodeName: undefined,\n threadId: undefined,\n });\n generalContext.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [generalContext.agentSession!.agentName]: {\n ...prevAgentStates[generalContext.agentSession!.agentName],\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n },\n };\n });\n }\n };\n const runCurrentAgent = async (hint?: HintFunction) => {\n if (generalContext.agentSession) {\n await runAgent(\n generalContext.agentSession.agentName,\n stableContext,\n appendMessage,\n runChatCompletion,\n hint,\n );\n }\n };\n const stopCurrentAgent = () => {\n if (generalContext.agentSession) {\n stopAgent(generalContext.agentSession.agentName, stableContext);\n }\n };\n const setCurrentAgentState = (state: any) => {\n if (generalContext.agentSession) {\n generalContext.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [generalContext.agentSession!.agentName]: {\n state,\n },\n } as any;\n });\n }\n };\n\n function stopGeneration() {\n // Clear suggestions when stopping generation\n setSuggestions([]);\n\n if (onStopGeneration) {\n onStopGeneration({\n messages: messages,\n setMessages,\n stopGeneration: defaultStopGeneration,\n currentAgentName,\n restartCurrentAgent,\n stopCurrentAgent,\n runCurrentAgent,\n setCurrentAgentState,\n });\n } else {\n defaultStopGeneration();\n }\n }\n function reloadMessages(messageId: string) {\n if (onReloadMessages) {\n onReloadMessages({\n messages: messages,\n setMessages,\n stopGeneration: defaultStopGeneration,\n currentAgentName,\n restartCurrentAgent,\n stopCurrentAgent,\n runCurrentAgent,\n setCurrentAgentState,\n messageId,\n });\n } else {\n defaultReloadMessages(messageId);\n }\n }\n\n return {\n messages,\n visibleMessages,\n isLoading,\n suggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n resetSuggestions,\n context: stableContext,\n actions,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,OAAO,SAAS,WAAW,QAAQ,UAAU,aAAa,eAAe;AACzE;AAAA,EAEE,0BAA0B;AAAA,EAC1B;AAAA,EACA;AAAA,OACK;AAGP,SAAS,gBAAgB;AAYzB,SAAuB,UAAU,iBAAiB;AAkbxC,SAQF,UARE,KAQF,YARE;AA1MH,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAA,YAAW;AAAA,EACX,eAAAC,iBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,OAAAC,SAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAAC,oBAAmB;AAAA,EACnB,aAAAC,eAAc;AAAA,EACd,eAAAC,iBAAgB;AAAA,EAChB;AAAA,EACA,kBAAkB;AAAA,EAClB;AACF,GAAqB;AACnB,QAAM,EAAE,wBAAwB,oBAAoB,IAAI,kBAAkB;AAC1E,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA6B,CAAC,CAAC;AAC3E,QAAM,eAAe,OAAyB,IAAI;AAGlD,YAAU,MAAM;AACd,QAAI,CAAC;AAAqB;AAE1B,UAAM,cAAc,CAAO,MAAsB;AA3VrD;AA4VM,YAAM,SAAS,EAAE;AACjB,UAAI,GAAC,YAAO,kBAAP,mBAAsB,UAAU,SAAS;AAAoB;AAElE,YAAM,QAAQ,MAAM,OAAK,OAAE,kBAAF,mBAAiB,UAAS,CAAC,CA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;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,4BAAsB,SAAS;AAAA,IACjC;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF;AACF;","names":["Messages","RenderMessage","Input","AssistantMessage","UserMessage","ImageRenderer","e","_a","_b"]}
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-C3GSYRC3.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Header
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GDSZGYCE.mjs";
|
|
7
7
|
import {
|
|
8
8
|
Button
|
|
9
9
|
} from "./chunk-UFN2VWSR.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotChat
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-P6O2MZGT.mjs";
|
|
13
13
|
import {
|
|
14
14
|
AssistantMessage
|
|
15
15
|
} from "./chunk-GCKKSSBU.mjs";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-DTRPPNSA.mjs";
|
|
22
22
|
import {
|
|
23
23
|
Messages
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-U5ATIGWH.mjs";
|
|
25
25
|
import {
|
|
26
26
|
ChatContextProvider
|
|
27
27
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
@@ -141,4 +141,4 @@ var CopilotModal = (_a) => {
|
|
|
141
141
|
export {
|
|
142
142
|
CopilotModal
|
|
143
143
|
};
|
|
144
|
-
//# sourceMappingURL=chunk-
|
|
144
|
+
//# sourceMappingURL=chunk-QKDRZ7WA.mjs.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/components/chat/Messages.tsx
|
|
6
6
|
import { useEffect, useMemo, useRef } from "react";
|
|
7
|
-
import { useCopilotChat } from "@copilotkit/react-core";
|
|
7
|
+
import { useCopilotChatInternal as useCopilotChat } from "@copilotkit/react-core";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
var Messages = ({
|
|
10
10
|
inProgress,
|
|
@@ -132,4 +132,4 @@ export {
|
|
|
132
132
|
Messages,
|
|
133
133
|
useScrollToBottom
|
|
134
134
|
};
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-U5ATIGWH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Messages.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\nimport { MessagesProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { Message } from \"@copilotkit/shared\";\nimport { useCopilotChatInternal as useCopilotChat } from \"@copilotkit/react-core\";\n\nexport const Messages = ({\n inProgress,\n children,\n RenderMessage,\n AssistantMessage,\n UserMessage,\n onRegenerate,\n onCopy,\n onThumbsUp,\n onThumbsDown,\n markdownTagRenderers,\n}: MessagesProps) => {\n const { labels } = useChatContext();\n const { visibleMessages, interrupt } = useCopilotChat();\n const initialMessages = useMemo(() => makeInitialMessages(labels.initial), [labels.initial]);\n const messages = [...initialMessages, ...visibleMessages];\n const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);\n\n return (\n <div className=\"copilotKitMessages\" ref={messagesContainerRef}>\n <div className=\"copilotKitMessagesContainer\">\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1;\n return (\n <RenderMessage\n key={index}\n message={message}\n inProgress={inProgress}\n index={index}\n isCurrentMessage={isCurrentMessage}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n onRegenerate={onRegenerate}\n onCopy={onCopy}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n markdownTagRenderers={markdownTagRenderers}\n />\n );\n })}\n {interrupt}\n </div>\n <footer className=\"copilotKitMessagesFooter\" ref={messagesEndRef}>\n {children}\n </footer>\n </div>\n );\n};\n\nfunction makeInitialMessages(initial: string | string[] | undefined): Message[] {\n if (!initial) return [];\n\n if (Array.isArray(initial)) {\n return initial.map((message) => {\n return {\n id: message,\n role: \"assistant\",\n content: message,\n };\n });\n }\n\n return [\n {\n id: initial,\n role: \"system\",\n content: initial,\n },\n ];\n}\n\nexport function useScrollToBottom(messages: Message[]) {\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const messagesContainerRef = useRef<HTMLDivElement | null>(null);\n const isProgrammaticScrollRef = useRef(false);\n const isUserScrollUpRef = useRef(false);\n\n const scrollToBottom = () => {\n if (messagesContainerRef.current && messagesEndRef.current) {\n isProgrammaticScrollRef.current = true;\n messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;\n }\n };\n\n const handleScroll = () => {\n if (isProgrammaticScrollRef.current) {\n isProgrammaticScrollRef.current = false;\n return;\n }\n\n if (messagesContainerRef.current) {\n const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;\n isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;\n }\n };\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (container) {\n container.addEventListener(\"scroll\", handleScroll);\n }\n return () => {\n if (container) {\n container.removeEventListener(\"scroll\", handleScroll);\n }\n };\n }, []);\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (!container) {\n return;\n }\n\n const mutationObserver = new MutationObserver(() => {\n if (!isUserScrollUpRef.current) {\n scrollToBottom();\n }\n });\n\n mutationObserver.observe(container, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n mutationObserver.disconnect();\n };\n }, []);\n\n useEffect(() => {\n isUserScrollUpRef.current = false;\n scrollToBottom();\n }, [messages.filter((m) => m.role === \"user\").length]);\n\n return { messagesEndRef, messagesContainerRef };\n}\n"],"mappings":";;;;;AAAA,SAAS,WAAW,SAA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;AAAA,EACjB,GAAG,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,MAAM,CAAC;AAErD,SAAO,EAAE,gBAAgB,qBAAqB;AAChD;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-XWG3L6QC.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/chat/Suggestion.tsx
|
|
6
|
-
import { useCopilotChat } from "@copilotkit/react-core";
|
|
6
|
+
import { useCopilotChatInternal as useCopilotChat } from "@copilotkit/react-core";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
function Suggestion({ title, onClick, partial, className }) {
|
|
9
9
|
if (!title)
|
|
@@ -27,4 +27,4 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
27
27
|
export {
|
|
28
28
|
Suggestion
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-W26XFBEG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Suggestion.tsx"],"sourcesContent":["import { useCopilotChatInternal as useCopilotChat } from \"@copilotkit/react-core\";\nimport { SmallSpinnerIcon } from \"./Icons\";\n\ninterface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: () => void;\n}\n\nexport function Suggestion({ title, onClick, partial, className }: SuggestionsProps) {\n if (!title) return null;\n const { isLoading } = useCopilotChat();\n\n return (\n <button\n disabled={partial || isLoading}\n onClick={(e) => {\n e.preventDefault();\n onClick();\n }}\n className={className || (partial ? \"suggestion loading\" : \"suggestion\")}\n data-test-id=\"suggestion\"\n >\n {partial ? SmallSpinnerIcon : <span>{title}</span>}\n </button>\n );\n}\n"],"mappings":";;;;;AAAA,SAAS,0BAA0B,sBAAsB;AAyBrB;AAd7B,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,UAAU,GAAqB;AACnF,MAAI,CAAC;AAAO,WAAO;AACnB,QAAM,EAAE,UAAU,IAAI,eAAe;AAErC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,WAAW;AAAA,MACrB,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ;AAAA,MACV;AAAA,MACA,WAAW,cAAc,UAAU,uBAAuB;AAAA,MAC1D,gBAAa;AAAA,MAEZ,oBAAU,mBAAmB,oBAAC,UAAM,iBAAM;AAAA;AAAA,EAC7C;AAEJ;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QKDRZ7WA.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
|
|
|
18
18
|
export {
|
|
19
19
|
CopilotPopup
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-WYEGK6BP.mjs.map
|
|
@@ -2,7 +2,7 @@ import * as _copilotkit_react_core_dist_types_coagent_state from '@copilotkit/re
|
|
|
2
2
|
import * as _copilotkit_react_core_dist_hooks_use_tree from '@copilotkit/react-core/dist/hooks/use-tree';
|
|
3
3
|
import * as _copilotkit_shared from '@copilotkit/shared';
|
|
4
4
|
import { Message } from '@copilotkit/shared';
|
|
5
|
-
import * as
|
|
5
|
+
import * as _copilotkit_react_core_dist_copilot_context_78fc727c from '@copilotkit/react-core/dist/copilot-context-78fc727c';
|
|
6
6
|
import * as _copilotkit_react_core_dist_types_coagent_action from '@copilotkit/react-core/dist/types/coagent-action';
|
|
7
7
|
import * as _copilotkit_react_core from '@copilotkit/react-core';
|
|
8
8
|
import { SuggestionItem, SystemMessageFunction, HintFunction } from '@copilotkit/react-core';
|
|
@@ -230,7 +230,7 @@ declare const useCopilotChatLogic: (chatSuggestions: ChatSuggestions, makeSystem
|
|
|
230
230
|
coAgentStateRenders: Record<string, _copilotkit_react_core_dist_types_coagent_action.CoAgentStateRender<any>>;
|
|
231
231
|
setCoAgentStateRender: (id: string, stateRender: _copilotkit_react_core_dist_types_coagent_action.CoAgentStateRender<any>) => void;
|
|
232
232
|
removeCoAgentStateRender: (id: string) => void;
|
|
233
|
-
chatComponentsCache: React__default.RefObject<
|
|
233
|
+
chatComponentsCache: React__default.RefObject<_copilotkit_react_core_dist_copilot_context_78fc727c.j>;
|
|
234
234
|
getFunctionCallHandler: (customEntryPoints?: Record<string, _copilotkit_react_core.FrontendAction<any>>) => _copilotkit_shared.FunctionCallHandler;
|
|
235
235
|
addContext: (context: string, parentId?: string, categories?: string[]) => _copilotkit_react_core_dist_hooks_use_tree.TreeNodeId;
|
|
236
236
|
removeContext: (id: _copilotkit_react_core_dist_hooks_use_tree.TreeNodeId) => void;
|
|
@@ -256,8 +256,8 @@ declare const useCopilotChatLogic: (chatSuggestions: ChatSuggestions, makeSystem
|
|
|
256
256
|
setCoagentStates: React__default.Dispatch<React__default.SetStateAction<Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>>>;
|
|
257
257
|
coagentStatesRef: React__default.RefObject<Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>>;
|
|
258
258
|
setCoagentStatesWithRef: (value: Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState> | ((prev: Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>) => Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>)) => void;
|
|
259
|
-
agentSession:
|
|
260
|
-
setAgentSession: React__default.Dispatch<React__default.SetStateAction<
|
|
259
|
+
agentSession: _copilotkit_react_core_dist_copilot_context_78fc727c.A | null;
|
|
260
|
+
setAgentSession: React__default.Dispatch<React__default.SetStateAction<_copilotkit_react_core_dist_copilot_context_78fc727c.A | null>>;
|
|
261
261
|
agentLock: string | null;
|
|
262
262
|
threadId: string;
|
|
263
263
|
setThreadId: React__default.Dispatch<React__default.SetStateAction<string>>;
|
|
@@ -267,20 +267,22 @@ declare const useCopilotChatLogic: (chatSuggestions: ChatSuggestions, makeSystem
|
|
|
267
267
|
runtimeClient: _copilotkit_runtime_client_gql.CopilotRuntimeClient;
|
|
268
268
|
forwardedParameters?: Partial<Pick<_copilotkit_runtime_client_gql.ForwardedParametersInput, "temperature">>;
|
|
269
269
|
availableAgents: _copilotkit_runtime_client_gql.Agent[];
|
|
270
|
-
authStates_c?: Record<
|
|
271
|
-
setAuthStates_c?: React__default.Dispatch<React__default.SetStateAction<Record<
|
|
270
|
+
authStates_c?: Record<_copilotkit_react_core_dist_copilot_context_78fc727c.k, _copilotkit_react_core_dist_copilot_context_78fc727c.f>;
|
|
271
|
+
setAuthStates_c?: React__default.Dispatch<React__default.SetStateAction<Record<_copilotkit_react_core_dist_copilot_context_78fc727c.k, _copilotkit_react_core_dist_copilot_context_78fc727c.f>>>;
|
|
272
272
|
authConfig_c?: {
|
|
273
273
|
SignInComponent: React__default.ComponentType<{
|
|
274
|
-
onSignInComplete: (authState:
|
|
274
|
+
onSignInComplete: (authState: _copilotkit_react_core_dist_copilot_context_78fc727c.f) => void;
|
|
275
275
|
}>;
|
|
276
276
|
};
|
|
277
277
|
extensions: _copilotkit_runtime_client_gql.ExtensionsInput;
|
|
278
278
|
setExtensions: React__default.Dispatch<React__default.SetStateAction<_copilotkit_runtime_client_gql.ExtensionsInput>>;
|
|
279
|
-
langGraphInterruptAction:
|
|
280
|
-
setLangGraphInterruptAction:
|
|
279
|
+
langGraphInterruptAction: _copilotkit_react_core_dist_copilot_context_78fc727c.L | null;
|
|
280
|
+
setLangGraphInterruptAction: _copilotkit_react_core_dist_copilot_context_78fc727c.d;
|
|
281
281
|
removeLangGraphInterruptAction: () => void;
|
|
282
282
|
onError?: _copilotkit_shared.CopilotErrorHandler;
|
|
283
283
|
suggestions: SuggestionItem[];
|
|
284
|
+
bannerError: _copilotkit_shared.CopilotKitError | null;
|
|
285
|
+
setBannerError: React__default.Dispatch<React__default.SetStateAction<_copilotkit_shared.CopilotKitError | null>>;
|
|
284
286
|
setSuggestions: React__default.Dispatch<React__default.SetStateAction<SuggestionItem[]>>;
|
|
285
287
|
};
|
|
286
288
|
actions: Record<string, _copilotkit_react_core.FrontendAction<any>>;
|
|
@@ -411,7 +411,7 @@ var Messages = ({
|
|
|
411
411
|
markdownTagRenderers
|
|
412
412
|
}) => {
|
|
413
413
|
const { labels } = useChatContext();
|
|
414
|
-
const { visibleMessages, interrupt } = (0, import_react_core.
|
|
414
|
+
const { visibleMessages, interrupt } = (0, import_react_core.useCopilotChatInternal)();
|
|
415
415
|
const initialMessages = (0, import_react2.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
|
|
416
416
|
const messages = [...initialMessages, ...visibleMessages];
|
|
417
417
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
@@ -1624,7 +1624,7 @@ var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
|
1624
1624
|
function Suggestion({ title, onClick, partial, className }) {
|
|
1625
1625
|
if (!title)
|
|
1626
1626
|
return null;
|
|
1627
|
-
const { isLoading } = (0, import_react_core4.
|
|
1627
|
+
const { isLoading } = (0, import_react_core4.useCopilotChatInternal)();
|
|
1628
1628
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1629
1629
|
"button",
|
|
1630
1630
|
{
|
|
@@ -1897,7 +1897,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
1897
1897
|
generateSuggestions,
|
|
1898
1898
|
resetSuggestions: resetSuggestionsFromHook,
|
|
1899
1899
|
isLoadingSuggestions
|
|
1900
|
-
} = (0, import_react_core5.
|
|
1900
|
+
} = (0, import_react_core5.useCopilotChatInternal)({
|
|
1901
1901
|
makeSystemMessage
|
|
1902
1902
|
});
|
|
1903
1903
|
const generalContext = (0, import_react_core5.useCopilotContext)();
|