@copilotkit/react-core 1.50.1-next.3 → 1.50.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/{chunk-3FHX5RLS.mjs → chunk-3V5TOYKW.mjs} +2 -2
- package/dist/chunk-3V5TOYKW.mjs.map +1 -0
- package/dist/{chunk-RB2TXKFP.mjs → chunk-4YZA2BZC.mjs} +13 -13
- package/dist/{chunk-IZGUA5WC.mjs → chunk-53K6WNJG.mjs} +2 -2
- package/dist/{chunk-F62YUR4R.mjs → chunk-FQFXYAV7.mjs} +2 -2
- package/dist/{chunk-INPM7YKW.mjs → chunk-HE22TZMF.mjs} +4 -4
- package/dist/{chunk-SNON4QA6.mjs → chunk-LHERIF3L.mjs} +4 -4
- package/dist/{chunk-CGKXLHL3.mjs → chunk-LSHFN2Y5.mjs} +4 -4
- package/dist/{chunk-3MHWEKFN.mjs → chunk-YCG6SNAU.mjs} +4 -4
- package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
- package/dist/components/copilot-provider/copilotkit.mjs +8 -8
- package/dist/components/copilot-provider/index.mjs +8 -8
- package/dist/components/dev-console/console-trigger.mjs +2 -2
- package/dist/components/dev-console/developer-console-modal.mjs +2 -2
- package/dist/components/error-boundary/error-boundary.mjs +2 -2
- package/dist/components/index.mjs +8 -8
- package/dist/context/index.mjs +4 -4
- package/dist/hooks/index.mjs +19 -19
- package/dist/hooks/use-coagent-state-render-bridge.mjs +1 -1
- package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
- package/dist/hooks/use-configure-chat-suggestions.js +79 -0
- package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs +47 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat-headless_c.mjs +6 -6
- package/dist/hooks/use-copilot-chat.mjs +6 -6
- package/dist/hooks/use-copilot-chat_internal.mjs +5 -5
- package/dist/hooks/use-langgraph-interrupt-render.mjs +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -43
- 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.js.map +1 -1
- package/dist/lib/index.mjs +9 -9
- package/package.json +3 -3
- package/src/hooks/use-configure-chat-suggestions.tsx +86 -0
- package/src/lib/copilot-task.ts +1 -1
- package/tsup.config.ts +1 -1
- package/dist/chunk-3FHX5RLS.mjs.map +0 -1
- /package/dist/{chunk-RB2TXKFP.mjs.map → chunk-4YZA2BZC.mjs.map} +0 -0
- /package/dist/{chunk-IZGUA5WC.mjs.map → chunk-53K6WNJG.mjs.map} +0 -0
- /package/dist/{chunk-F62YUR4R.mjs.map → chunk-FQFXYAV7.mjs.map} +0 -0
- /package/dist/{chunk-INPM7YKW.mjs.map → chunk-HE22TZMF.mjs.map} +0 -0
- /package/dist/{chunk-SNON4QA6.mjs.map → chunk-LHERIF3L.mjs.map} +0 -0
- /package/dist/{chunk-CGKXLHL3.mjs.map → chunk-LSHFN2Y5.mjs.map} +0 -0
- /package/dist/{chunk-3MHWEKFN.mjs.map → chunk-YCG6SNAU.mjs.map} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../chunk-SKC7AJIV.mjs";
|
|
5
|
+
|
|
6
|
+
// src/hooks/use-configure-chat-suggestions.tsx
|
|
7
|
+
import {
|
|
8
|
+
useConfigureSuggestions,
|
|
9
|
+
useCopilotChatConfiguration,
|
|
10
|
+
useCopilotKit,
|
|
11
|
+
useSuggestions
|
|
12
|
+
} from "@copilotkitnext/react";
|
|
13
|
+
import { useEffect } from "react";
|
|
14
|
+
function useConfigureChatSuggestions(config, dependencies = []) {
|
|
15
|
+
var _a;
|
|
16
|
+
const existingConfig = useCopilotChatConfiguration();
|
|
17
|
+
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
18
|
+
const { copilotkit } = useCopilotKit();
|
|
19
|
+
const available = config.available === "enabled" ? "always" : config.available;
|
|
20
|
+
const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
|
|
21
|
+
available,
|
|
22
|
+
consumerAgentId: resolvedAgentId
|
|
23
|
+
// Use chatConfig.agentId here
|
|
24
|
+
});
|
|
25
|
+
useConfigureSuggestions(finalSuggestionConfig, dependencies);
|
|
26
|
+
const result = useSuggestions({ agentId: resolvedAgentId });
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (finalSuggestionConfig.available === "disabled")
|
|
29
|
+
return;
|
|
30
|
+
const subscription = copilotkit.subscribe({
|
|
31
|
+
onAgentsChanged: () => {
|
|
32
|
+
const agent = copilotkit.getAgent(resolvedAgentId);
|
|
33
|
+
if (agent && !agent.isRunning && !result.suggestions.length) {
|
|
34
|
+
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return () => {
|
|
39
|
+
subscription.unsubscribe();
|
|
40
|
+
};
|
|
41
|
+
}, [resolvedAgentId]);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
useConfigureChatSuggestions
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=use-configure-chat-suggestions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-configure-chat-suggestions.tsx"],"sourcesContent":["import {\n useConfigureSuggestions,\n useCopilotChatConfiguration,\n useCopilotKit,\n useSuggestions,\n} from \"@copilotkitnext/react\";\nimport { StaticSuggestionsConfig, Suggestion } from \"@copilotkitnext/core\";\nimport { useCopilotContext } from \"../context\";\nimport { useEffect, useMemo } from \"react\";\n\ntype StaticSuggestionInput = Omit<Suggestion, \"isLoading\"> & Partial<Pick<Suggestion, \"isLoading\">>;\n\ntype StaticSuggestionsConfigInput = Omit<StaticSuggestionsConfig, \"suggestions\"> & {\n suggestions: StaticSuggestionInput[];\n};\n\ntype DynamicSuggestionsConfigInput = {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n\n /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\" | \"always\" | \"before-first-message\" | \"after-first-message\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n};\n\nexport type UseCopilotChatSuggestionsConfiguration =\n | DynamicSuggestionsConfigInput\n | StaticSuggestionsConfigInput;\n\nexport function useConfigureChatSuggestions(\n config: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n): ReturnType<typeof useSuggestions> {\n const existingConfig = useCopilotChatConfiguration();\n const resolvedAgentId = existingConfig?.agentId ?? \"default\";\n const { copilotkit } = useCopilotKit();\n\n const available = config.available === \"enabled\" ? \"always\" : config.available;\n\n const finalSuggestionConfig = {\n ...config,\n available,\n consumerAgentId: resolvedAgentId, // Use chatConfig.agentId here\n };\n useConfigureSuggestions(finalSuggestionConfig, dependencies);\n\n const result = useSuggestions({ agentId: resolvedAgentId });\n\n useEffect(() => {\n if (finalSuggestionConfig.available === \"disabled\") return;\n const subscription = copilotkit.subscribe({\n onAgentsChanged: () => {\n // When agents change, check if our target agent now exists and reload\n const agent = copilotkit.getAgent(resolvedAgentId);\n if (agent && !agent.isRunning && !result.suggestions.length) {\n copilotkit.reloadSuggestions(resolvedAgentId);\n }\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [resolvedAgentId]);\n\n return result;\n}\n"],"mappings":";;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAA0B;AAwC5B,SAAS,4BACd,QACA,eAAsB,CAAC,GACY;AAnDrC;AAoDE,QAAM,iBAAiB,4BAA4B;AACnD,QAAM,mBAAkB,sDAAgB,YAAhB,YAA2B;AACnD,QAAM,EAAE,WAAW,IAAI,cAAc;AAErC,QAAM,YAAY,OAAO,cAAc,YAAY,WAAW,OAAO;AAErE,QAAM,wBAAwB,iCACzB,SADyB;AAAA,IAE5B;AAAA,IACA,iBAAiB;AAAA;AAAA,EACnB;AACA,0BAAwB,uBAAuB,YAAY;AAE3D,QAAM,SAAS,eAAe,EAAE,SAAS,gBAAgB,CAAC;AAE1D,YAAU,MAAM;AACd,QAAI,sBAAsB,cAAc;AAAY;AACpD,UAAM,eAAe,WAAW,UAAU;AAAA,MACxC,iBAAiB,MAAM;AAErB,cAAM,QAAQ,WAAW,SAAS,eAAe;AACjD,YAAI,SAAS,CAAC,MAAM,aAAa,CAAC,OAAO,YAAY,QAAQ;AAC3D,qBAAW,kBAAkB,eAAe;AAAA,QAC9C;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,mBAAa,YAAY;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAEpB,SAAO;AACT;","names":[]}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChatHeadless_c
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-FQFXYAV7.mjs";
|
|
4
4
|
import {
|
|
5
5
|
defaultSystemMessage
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-ZVF5Q6IH.mjs";
|
|
6
|
+
} from "../chunk-LSHFN2Y5.mjs";
|
|
8
7
|
import "../chunk-VV56AVPB.mjs";
|
|
8
|
+
import "../chunk-ZVF5Q6IH.mjs";
|
|
9
|
+
import "../chunk-I76HKHPJ.mjs";
|
|
9
10
|
import "../chunk-6PUNP7CD.mjs";
|
|
10
11
|
import "../chunk-O7ARI5CV.mjs";
|
|
11
|
-
import "../chunk-EFL5OBKN.mjs";
|
|
12
|
-
import "../chunk-I76HKHPJ.mjs";
|
|
13
12
|
import "../chunk-QNUAXSDP.mjs";
|
|
14
13
|
import "../chunk-NB2FKV2V.mjs";
|
|
15
14
|
import "../chunk-F555TVE4.mjs";
|
|
16
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-EFL5OBKN.mjs";
|
|
17
16
|
import "../chunk-FDOMAPJY.mjs";
|
|
18
17
|
import "../chunk-AFNWX62Q.mjs";
|
|
18
|
+
import "../chunk-DMLQZG75.mjs";
|
|
19
19
|
import "../chunk-SKC7AJIV.mjs";
|
|
20
20
|
export {
|
|
21
21
|
defaultSystemMessage,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-ZVF5Q6IH.mjs";
|
|
3
|
+
} from "../chunk-53K6WNJG.mjs";
|
|
4
|
+
import "../chunk-LSHFN2Y5.mjs";
|
|
6
5
|
import "../chunk-VV56AVPB.mjs";
|
|
6
|
+
import "../chunk-ZVF5Q6IH.mjs";
|
|
7
|
+
import "../chunk-I76HKHPJ.mjs";
|
|
7
8
|
import "../chunk-6PUNP7CD.mjs";
|
|
8
9
|
import "../chunk-O7ARI5CV.mjs";
|
|
9
|
-
import "../chunk-EFL5OBKN.mjs";
|
|
10
|
-
import "../chunk-I76HKHPJ.mjs";
|
|
11
10
|
import "../chunk-QNUAXSDP.mjs";
|
|
12
11
|
import "../chunk-NB2FKV2V.mjs";
|
|
13
12
|
import "../chunk-F555TVE4.mjs";
|
|
14
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-EFL5OBKN.mjs";
|
|
15
14
|
import "../chunk-FDOMAPJY.mjs";
|
|
16
15
|
import "../chunk-AFNWX62Q.mjs";
|
|
16
|
+
import "../chunk-DMLQZG75.mjs";
|
|
17
17
|
import "../chunk-SKC7AJIV.mjs";
|
|
18
18
|
export {
|
|
19
19
|
useCopilotChat
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultSystemMessage,
|
|
3
3
|
useCopilotChatInternal
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-ZVF5Q6IH.mjs";
|
|
4
|
+
} from "../chunk-LSHFN2Y5.mjs";
|
|
6
5
|
import "../chunk-VV56AVPB.mjs";
|
|
6
|
+
import "../chunk-ZVF5Q6IH.mjs";
|
|
7
|
+
import "../chunk-I76HKHPJ.mjs";
|
|
7
8
|
import "../chunk-6PUNP7CD.mjs";
|
|
8
9
|
import "../chunk-O7ARI5CV.mjs";
|
|
9
|
-
import "../chunk-EFL5OBKN.mjs";
|
|
10
|
-
import "../chunk-I76HKHPJ.mjs";
|
|
11
10
|
import "../chunk-QNUAXSDP.mjs";
|
|
12
11
|
import "../chunk-NB2FKV2V.mjs";
|
|
13
12
|
import "../chunk-F555TVE4.mjs";
|
|
14
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-EFL5OBKN.mjs";
|
|
15
14
|
import "../chunk-FDOMAPJY.mjs";
|
|
16
15
|
import "../chunk-AFNWX62Q.mjs";
|
|
16
|
+
import "../chunk-DMLQZG75.mjs";
|
|
17
17
|
import "../chunk-SKC7AJIV.mjs";
|
|
18
18
|
export {
|
|
19
19
|
defaultSystemMessage,
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
import "../chunk-I76HKHPJ.mjs";
|
|
5
5
|
import "../chunk-NB2FKV2V.mjs";
|
|
6
6
|
import "../chunk-F555TVE4.mjs";
|
|
7
|
-
import "../chunk-DMLQZG75.mjs";
|
|
8
7
|
import "../chunk-FDOMAPJY.mjs";
|
|
9
8
|
import "../chunk-AFNWX62Q.mjs";
|
|
9
|
+
import "../chunk-DMLQZG75.mjs";
|
|
10
10
|
import "../chunk-SKC7AJIV.mjs";
|
|
11
11
|
export {
|
|
12
12
|
useLangGraphInterruptRender
|