@copilotkit/react-core 1.50.1 → 1.51.0-next.1

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # ui
2
2
 
3
+ ## 1.51.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @copilotkit/runtime-client-gql@1.51.0-next.1
8
+ - @copilotkit/shared@1.51.0-next.1
9
+ - @copilotkitnext/core@1.51.0-next.1
10
+ - @copilotkitnext/react@1.51.0-next.1
11
+
12
+ ## 1.50.2-next.0
13
+
14
+ ### Patch Changes
15
+
16
+ - @copilotkit/runtime-client-gql@1.50.2-next.0
17
+ - @copilotkit/shared@1.50.2-next.0
18
+
3
19
  ## 1.50.1
4
20
 
5
21
  ### Patch Changes
@@ -605,14 +621,12 @@
605
621
  agentic runtimes we acquired tech-debt that, with this PR, is being alleviated.
606
622
 
607
623
  As such, the following features have been updated to be completely functional with Headless UI.
608
-
609
624
  - Generative UI
610
625
  - Suggestions
611
626
  - Agentic Generative UI
612
627
  - Interrupts
613
628
 
614
629
  In addition, a variety of QOL changes have been made.
615
-
616
630
  - New AG-UI based message types
617
631
  - Inline code rendering is fixed
618
632
 
@@ -624,19 +638,15 @@
624
638
  - 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
625
639
 
626
640
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
627
-
628
641
  - fix: more fixes addressing breaking changes in new Headless UI
629
642
 
630
643
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
631
-
632
644
  - chore: address linting issues
633
645
 
634
646
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
635
-
636
647
  - chore: fixing branding and docs
637
648
 
638
649
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
639
-
640
650
  - chore: more docs fixing
641
651
 
642
652
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
@@ -678,19 +688,15 @@
678
688
  - 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
679
689
 
680
690
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
681
-
682
691
  - fix: more fixes addressing breaking changes in new Headless UI
683
692
 
684
693
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
685
-
686
694
  - chore: address linting issues
687
695
 
688
696
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
689
-
690
697
  - chore: fixing branding and docs
691
698
 
692
699
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
693
-
694
700
  - chore: more docs fixing
695
701
 
696
702
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
@@ -775,14 +781,12 @@
775
781
  agentic runtimes we acquired tech-debt that, with this PR, is being alleviated.
776
782
 
777
783
  As such, the following features have been updated to be completely functional with Headless UI.
778
-
779
784
  - Generative UI
780
785
  - Suggestions
781
786
  - Agentic Generative UI
782
787
  - Interrupts
783
788
 
784
789
  In addition, a variety of QOL changes have been made.
785
-
786
790
  - New AG-UI based message types
787
791
  - Inline code rendering is fixed
788
792
 
@@ -848,7 +852,6 @@
848
852
  - 3f8c575: - fix: use time travel for regeneration of messages
849
853
  - fix: use a better cutoff for regeneration request
850
854
  - fac89c2: - refactor: rename onTrace to onError throughout codebase
851
-
852
855
  - Rename CopilotTraceEvent to CopilotErrorEvent and CopilotTraceHandler to CopilotErrorHandler
853
856
 
854
857
  - e1de032: - fix: synchronously execute renderAndWaitForResponse
@@ -941,7 +944,6 @@
941
944
  works with any combination of action given much more freedom when asking for user input.
942
945
 
943
946
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
944
-
945
947
  - @copilotkit/runtime-client-gql@1.9.2-next.20
946
948
  - @copilotkit/shared@1.9.2-next.20
947
949
 
@@ -957,7 +959,6 @@
957
959
  ### Patch Changes
958
960
 
959
961
  - fac89c2: - refactor: rename onTrace to onError throughout codebase
960
-
961
962
  - Rename CopilotTraceEvent to CopilotErrorEvent and CopilotTraceHandler to CopilotErrorHandler
962
963
 
963
964
  - Updated dependencies [fac89c2]
@@ -1454,11 +1455,9 @@
1454
1455
  - c0d3261: - full AWP support
1455
1456
 
1456
1457
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1457
-
1458
1458
  - refactor: address linter issues with the new pages
1459
1459
 
1460
1460
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1461
-
1462
1461
  - Merge branch 'mme/acp' into mme/mastra
1463
1462
  - add sse example
1464
1463
  - Create small-turkeys-agree.md
@@ -1484,11 +1483,9 @@
1484
1483
  - c0d3261: - full AWP support
1485
1484
 
1486
1485
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1487
-
1488
1486
  - refactor: address linter issues with the new pages
1489
1487
 
1490
1488
  Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1491
-
1492
1489
  - Merge branch 'mme/acp' into mme/mastra
1493
1490
  - add sse example
1494
1491
  - Create small-turkeys-agree.md
@@ -2603,7 +2600,6 @@
2603
2600
  - e16d95e: New prerelease
2604
2601
  - 1721cbd: Add convertActionsToDynamicStructuredTools to sdk-js
2605
2602
  - CopilotKit Core:
2606
-
2607
2603
  - Improved error messages and overall logs
2608
2604
  - `useCopilotAction.renderAndAwait` renamed to `.renderAndAwaitForResponse` (backwards compatible, will be deprecated in the future)
2609
2605
  - Improved scrolling behavior. It is now possible to scroll up during LLM response generation
@@ -2611,7 +2607,6 @@
2611
2607
  - Updated interfaces for better developer ergonomics
2612
2608
 
2613
2609
  CoAgents:
2614
-
2615
2610
  - Renamed `remoteActions` to `remoteEndpoints` (backwards compatible, will be deprecated in the future)
2616
2611
  - Support for LangGraph Platform in Remote Endpoints
2617
2612
  - LangGraph JS Support for CoAgents (locally via `langgraph dev`, `langgraph up` or deployed to LangGraph Platform)
@@ -2619,7 +2614,6 @@
2619
2614
  - Enhanced state management and message handling
2620
2615
 
2621
2616
  CopilotKid Back-end SDK:
2622
-
2623
2617
  - Released a whole-new `@copilotkit/sdk-js` for building agents with LangGraph JS Support
2624
2618
 
2625
2619
  - 8d0144f: bump
@@ -2994,7 +2988,6 @@ CopilotKid Back-end SDK:
2994
2988
  ### Patch Changes
2995
2989
 
2996
2990
  - inject minified css in bundle
2997
-
2998
2991
  - removes the need to import `styles.css` manually
2999
2992
  - empty `styles.css` included in the build for backwards compatibility
3000
2993
  - uses tsup's `injectStyles` with `postcss` to bundle and minify the CSS, then inject it as a style tag
@@ -3145,7 +3138,6 @@ CopilotKid Back-end SDK:
3145
3138
  ### Major Changes
3146
3139
 
3147
3140
  - b6a4b6eb: V1.0 Release Candidate
3148
-
3149
3141
  - A robust new protocol between the frontend and the Copilot Runtime
3150
3142
  - Support for Copilot Cloud
3151
3143
  - Generative UI
@@ -3153,7 +3145,6 @@ CopilotKid Back-end SDK:
3153
3145
  - OpenAI assistant API streaming
3154
3146
 
3155
3147
  - V1.0 Release
3156
-
3157
3148
  - A robust new protocol between the frontend and the Copilot Runtime
3158
3149
  - Support for Copilot Cloud
3159
3150
  - Generative UI
@@ -3194,7 +3185,6 @@ CopilotKid Back-end SDK:
3194
3185
  ### Major Changes
3195
3186
 
3196
3187
  - V1.0 Release Candidate
3197
-
3198
3188
  - A robust new protocol between the frontend and the Copilot Runtime
3199
3189
  - Support for Copilot Cloud
3200
3190
  - Generative UI
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Atai Barkai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -117,4 +117,4 @@ ${instructions}
117
117
  export {
118
118
  CopilotTask
119
119
  };
120
- //# sourceMappingURL=chunk-LCZZ7YGZ.mjs.map
120
+ //# sourceMappingURL=chunk-3V5TOYKW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/copilot-task.ts"],"sourcesContent":["/**\n * This class is used to execute one-off tasks, for example on button press. It can use the context available via [useCopilotReadable](/reference/hooks/useCopilotReadable) and the actions provided by [useCopilotAction](/reference/hooks/useCopilotAction), or you can provide your own context and actions.\n *\n * ## Example\n * In the simplest case, use CopilotTask in the context of your app by giving it instructions on what to do.\n *\n * ```tsx\n * import { CopilotTask, useCopilotContext } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const context = useCopilotContext();\n *\n * const task = new CopilotTask({\n * instructions: \"Set a random message\",\n * actions: [\n * {\n * name: \"setMessage\",\n * description: \"Set the message.\",\n * argumentAnnotations: [\n * {\n * name: \"message\",\n * type: \"string\",\n * description:\n * \"A message to display.\",\n * required: true,\n * },\n * ],\n * }\n * ]\n * });\n *\n * const executeTask = async () => {\n * await task.run(context, action);\n * }\n *\n * return (\n * <>\n * <button onClick={executeTask}>\n * Execute task\n * </button>\n * </>\n * )\n * }\n * ```\n *\n * Have a look at the [Presentation Example App](https://github.com/CopilotKit/CopilotKit/blob/main/src/v1.x/examples/next-openai/src/app/presentation/page.tsx) for a more complete example.\n */\n\nimport {\n ActionExecutionMessage,\n CopilotRuntimeClient,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n CopilotRequestType,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { FrontendAction, processActionsForRuntimeRequest } from \"../types/frontend-action\";\nimport { CopilotContextParams } from \"../context\";\nimport { defaultCopilotContextCategories } from \"../components\";\n\nexport interface CopilotTaskConfig {\n /**\n * The instructions to be given to the assistant.\n */\n instructions: string;\n /**\n * An array of action definitions that can be called.\n */\n actions?: FrontendAction<any>[];\n /**\n * Whether to include the copilot readable context in the task.\n */\n includeCopilotReadable?: boolean;\n\n /**\n * Whether to include actions defined via useCopilotAction in the task.\n */\n includeCopilotActions?: boolean;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: ForwardedParametersInput;\n}\n\nexport class CopilotTask<T = any> {\n private instructions: string;\n private actions: FrontendAction<any>[];\n private includeCopilotReadable: boolean;\n private includeCopilotActions: boolean;\n private forwardedParameters?: ForwardedParametersInput;\n constructor(config: CopilotTaskConfig) {\n this.instructions = config.instructions;\n this.actions = config.actions || [];\n this.includeCopilotReadable = config.includeCopilotReadable !== false;\n this.includeCopilotActions = config.includeCopilotActions !== false;\n this.forwardedParameters = config.forwardedParameters;\n }\n\n /**\n * Run the task.\n * @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.\n * @param data The data to use for the task.\n */\n async run(context: CopilotContextParams, data?: T): Promise<void> {\n const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};\n\n // merge functions into entry points\n for (const fn of this.actions) {\n actions[fn.name] = fn;\n }\n\n let contextString = \"\";\n\n if (data) {\n contextString = (typeof data === \"string\" ? data : JSON.stringify(data)) + \"\\n\\n\";\n }\n\n if (this.includeCopilotReadable) {\n contextString += context.getContextString([], defaultCopilotContextCategories);\n }\n\n const systemMessage = new TextMessage({\n content: taskSystemMessage(contextString, this.instructions),\n role: Role.System,\n });\n\n const messages: Message[] = [systemMessage];\n\n const runtimeClient = new CopilotRuntimeClient({\n url: context.copilotApiConfig.chatApiEndpoint,\n publicApiKey: context.copilotApiConfig.publicApiKey,\n headers: context.copilotApiConfig.headers,\n credentials: context.copilotApiConfig.credentials,\n });\n\n const response = await runtimeClient\n .generateCopilotResponse({\n data: {\n frontend: {\n actions: processActionsForRuntimeRequest(Object.values(actions)),\n url: window.location.href,\n },\n messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),\n metadata: {\n requestType: CopilotRequestType.Task,\n },\n forwardedParameters: {\n // if forwardedParameters is provided, use it\n toolChoice: \"required\",\n ...(this.forwardedParameters ?? {}),\n },\n },\n properties: context.copilotApiConfig.properties,\n })\n .toPromise();\n\n const functionCallHandler = context.getFunctionCallHandler(actions);\n const functionCalls = convertGqlOutputToMessages(\n response.data?.generateCopilotResponse?.messages || [],\n ).filter((m): m is ActionExecutionMessage => m.isActionExecutionMessage());\n\n for (const functionCall of functionCalls) {\n await functionCallHandler({\n messages,\n name: functionCall.name,\n args: functionCall.arguments,\n });\n }\n }\n}\n\nfunction taskSystemMessage(contextString: string, instructions: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf.\n\nPlease assist them as best you can.\n\nThis is not a conversation, so please do not ask questions. Just call a function without saying anything else.\n\nThe user has given you the following task to complete:\n\n\\`\\`\\`\n${instructions}\n\\`\\`\\`\n`;\n}\n"],"mappings":";;;;;;;;;;;;AAgDA;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA8BA,IAAM,cAAN,MAA2B;AAAA,EAMhC,YAAY,QAA2B;AACrC,SAAK,eAAe,OAAO;AAC3B,SAAK,UAAU,OAAO,WAAW,CAAC;AAClC,SAAK,yBAAyB,OAAO,2BAA2B;AAChE,SAAK,wBAAwB,OAAO,0BAA0B;AAC9D,SAAK,sBAAsB,OAAO;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOM,IAAI,SAA+B,MAAyB;AAAA;AA5GpE;AA6GI,YAAM,UAAU,KAAK,wBAAwB,OAAO,OAAO,CAAC,GAAG,QAAQ,OAAO,IAAI,CAAC;AAGnF,iBAAW,MAAM,KAAK,SAAS;AAC7B,gBAAQ,GAAG,IAAI,IAAI;AAAA,MACrB;AAEA,UAAI,gBAAgB;AAEpB,UAAI,MAAM;AACR,yBAAiB,OAAO,SAAS,WAAW,OAAO,KAAK,UAAU,IAAI,KAAK;AAAA,MAC7E;AAEA,UAAI,KAAK,wBAAwB;AAC/B,yBAAiB,QAAQ,iBAAiB,CAAC,GAAG,+BAA+B;AAAA,MAC/E;AAEA,YAAM,gBAAgB,IAAI,YAAY;AAAA,QACpC,SAAS,kBAAkB,eAAe,KAAK,YAAY;AAAA,QAC3D,MAAM,KAAK;AAAA,MACb,CAAC;AAED,YAAM,WAAsB,CAAC,aAAa;AAE1C,YAAM,gBAAgB,IAAI,qBAAqB;AAAA,QAC7C,KAAK,QAAQ,iBAAiB;AAAA,QAC9B,cAAc,QAAQ,iBAAiB;AAAA,QACvC,SAAS,QAAQ,iBAAiB;AAAA,QAClC,aAAa,QAAQ,iBAAiB;AAAA,MACxC,CAAC;AAED,YAAM,WAAW,MAAM,cACpB,wBAAwB;AAAA,QACvB,MAAM;AAAA,UACJ,UAAU;AAAA,YACR,SAAS,gCAAgC,OAAO,OAAO,OAAO,CAAC;AAAA,YAC/D,KAAK,OAAO,SAAS;AAAA,UACvB;AAAA,UACA,UAAU,0BAA0B,yBAAyB,QAAQ,CAAC;AAAA,UACtE,UAAU;AAAA,YACR,aAAa,mBAAmB;AAAA,UAClC;AAAA,UACA,qBAAqB;AAAA;AAAA,YAEnB,YAAY;AAAA,cACR,UAAK,wBAAL,YAA4B,CAAC;AAAA,QAErC;AAAA,QACA,YAAY,QAAQ,iBAAiB;AAAA,MACvC,CAAC,EACA,UAAU;AAEb,YAAM,sBAAsB,QAAQ,uBAAuB,OAAO;AAClE,YAAM,gBAAgB;AAAA,UACpB,oBAAS,SAAT,mBAAe,4BAAf,mBAAwC,aAAY,CAAC;AAAA,MACvD,EAAE,OAAO,CAAC,MAAmC,EAAE,yBAAyB,CAAC;AAEzE,iBAAW,gBAAgB,eAAe;AACxC,cAAM,oBAAoB;AAAA,UACxB;AAAA,UACA,MAAM,aAAa;AAAA,UACnB,MAAM,aAAa;AAAA,QACrB,CAAC;AAAA,MACH;AAAA,IACF;AAAA;AACF;AAEA,SAAS,kBAAkB,eAAuB,cAA8B;AAC9E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AAAA;AAAA;AAGF;","names":[]}
@@ -4,9 +4,9 @@ import {
4
4
  defaultCopilotContextCategories
5
5
  } from "../../chunk-4YZA2BZC.mjs";
6
6
  import "../../chunk-LHERIF3L.mjs";
7
- import "../../chunk-HE22TZMF.mjs";
8
7
  import "../../chunk-CYDWEPFL.mjs";
9
8
  import "../../chunk-2IDV5OHF.mjs";
9
+ import "../../chunk-HE22TZMF.mjs";
10
10
  import "../../chunk-ICIK2BSB.mjs";
11
11
  import "../../chunk-RKTVJRK7.mjs";
12
12
  import "../../chunk-PMAFHQ7P.mjs";
@@ -4,9 +4,9 @@ import {
4
4
  defaultCopilotContextCategories
5
5
  } from "../../chunk-4YZA2BZC.mjs";
6
6
  import "../../chunk-LHERIF3L.mjs";
7
- import "../../chunk-HE22TZMF.mjs";
8
7
  import "../../chunk-CYDWEPFL.mjs";
9
8
  import "../../chunk-2IDV5OHF.mjs";
9
+ import "../../chunk-HE22TZMF.mjs";
10
10
  import "../../chunk-ICIK2BSB.mjs";
11
11
  import "../../chunk-RKTVJRK7.mjs";
12
12
  import "../../chunk-PMAFHQ7P.mjs";
@@ -5,9 +5,9 @@ import {
5
5
  defaultCopilotContextCategories
6
6
  } from "../chunk-4YZA2BZC.mjs";
7
7
  import "../chunk-LHERIF3L.mjs";
8
- import "../chunk-HE22TZMF.mjs";
9
8
  import "../chunk-CYDWEPFL.mjs";
10
9
  import "../chunk-2IDV5OHF.mjs";
10
+ import "../chunk-HE22TZMF.mjs";
11
11
  import "../chunk-ICIK2BSB.mjs";
12
12
  import "../chunk-RKTVJRK7.mjs";
13
13
  import "../chunk-PMAFHQ7P.mjs";
@@ -1,19 +1,34 @@
1
1
  import "../chunk-A6NKSGH3.mjs";
2
+ import {
3
+ useMakeCopilotDocumentReadable
4
+ } from "../chunk-7IBF6RBW.mjs";
5
+ import {
6
+ useCopilotRuntimeClient
7
+ } from "../chunk-6ESSSQ7Q.mjs";
2
8
  import {
3
9
  useDefaultTool
4
10
  } from "../chunk-BUSWSDYO.mjs";
5
11
  import {
6
12
  useLangGraphInterrupt
7
13
  } from "../chunk-4RRMC7L2.mjs";
8
- import {
9
- useMakeCopilotDocumentReadable
10
- } from "../chunk-7IBF6RBW.mjs";
11
14
  import {
12
15
  useCopilotAdditionalInstructions
13
16
  } from "../chunk-ABWT4DRT.mjs";
14
17
  import {
15
18
  useCopilotAuthenticatedAction_c
16
19
  } from "../chunk-E7SE25ZU.mjs";
20
+ import {
21
+ useCopilotAction
22
+ } from "../chunk-GPEJNVE5.mjs";
23
+ import {
24
+ useRenderToolCall
25
+ } from "../chunk-NBK4KBLX.mjs";
26
+ import {
27
+ useFrontendTool
28
+ } from "../chunk-CDUIA2WM.mjs";
29
+ import {
30
+ useHumanInTheLoop
31
+ } from "../chunk-7DTB7S5V.mjs";
17
32
  import {
18
33
  useCopilotChatHeadless_c
19
34
  } from "../chunk-FQFXYAV7.mjs";
@@ -35,9 +50,6 @@ import {
35
50
  import {
36
51
  useCopilotReadable
37
52
  } from "../chunk-Z6JV2LRY.mjs";
38
- import {
39
- useCopilotRuntimeClient
40
- } from "../chunk-6ESSSQ7Q.mjs";
41
53
  import {
42
54
  useCoAgentStateRender
43
55
  } from "../chunk-YTQHRJUA.mjs";
@@ -45,18 +57,6 @@ import {
45
57
  useCoAgent
46
58
  } from "../chunk-ZYTXB6HH.mjs";
47
59
  import "../chunk-I76HKHPJ.mjs";
48
- import {
49
- useCopilotAction
50
- } from "../chunk-GPEJNVE5.mjs";
51
- import {
52
- useRenderToolCall
53
- } from "../chunk-NBK4KBLX.mjs";
54
- import {
55
- useFrontendTool
56
- } from "../chunk-CDUIA2WM.mjs";
57
- import {
58
- useHumanInTheLoop
59
- } from "../chunk-7DTB7S5V.mjs";
60
60
  import "../chunk-6PUNP7CD.mjs";
61
61
  import "../chunk-O7ARI5CV.mjs";
62
62
  import "../chunk-QNUAXSDP.mjs";
@@ -0,0 +1,36 @@
1
+ import { useSuggestions } from '@copilotkitnext/react';
2
+ import { StaticSuggestionsConfig, Suggestion } from '@copilotkitnext/core';
3
+
4
+ type StaticSuggestionInput = Omit<Suggestion, "isLoading"> & Partial<Pick<Suggestion, "isLoading">>;
5
+ type StaticSuggestionsConfigInput = Omit<StaticSuggestionsConfig, "suggestions"> & {
6
+ suggestions: StaticSuggestionInput[];
7
+ };
8
+ type DynamicSuggestionsConfigInput = {
9
+ /**
10
+ * A prompt or instructions for the GPT to generate suggestions.
11
+ */
12
+ instructions: string;
13
+ /**
14
+ * The minimum number of suggestions to generate. Defaults to `1`.
15
+ * @default 1
16
+ */
17
+ minSuggestions?: number;
18
+ /**
19
+ * The maximum number of suggestions to generate. Defaults to `3`.
20
+ * @default 1
21
+ */
22
+ maxSuggestions?: number;
23
+ /**
24
+ * Whether the suggestions are available. Defaults to `enabled`.
25
+ * @default enabled
26
+ */
27
+ available?: "enabled" | "disabled" | "always" | "before-first-message" | "after-first-message";
28
+ /**
29
+ * An optional class name to apply to the suggestions.
30
+ */
31
+ className?: string;
32
+ };
33
+ type UseCopilotChatSuggestionsConfiguration = DynamicSuggestionsConfigInput | StaticSuggestionsConfigInput;
34
+ declare function useConfigureChatSuggestions(config: UseCopilotChatSuggestionsConfiguration, dependencies?: any[]): ReturnType<typeof useSuggestions>;
35
+
36
+ export { UseCopilotChatSuggestionsConfiguration, useConfigureChatSuggestions };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // src/hooks/use-configure-chat-suggestions.tsx
38
+ var use_configure_chat_suggestions_exports = {};
39
+ __export(use_configure_chat_suggestions_exports, {
40
+ useConfigureChatSuggestions: () => useConfigureChatSuggestions
41
+ });
42
+ module.exports = __toCommonJS(use_configure_chat_suggestions_exports);
43
+ var import_react = require("@copilotkitnext/react");
44
+ var import_react2 = require("react");
45
+ function useConfigureChatSuggestions(config, dependencies = []) {
46
+ var _a;
47
+ const existingConfig = (0, import_react.useCopilotChatConfiguration)();
48
+ const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
49
+ const { copilotkit } = (0, import_react.useCopilotKit)();
50
+ const available = config.available === "enabled" ? "always" : config.available;
51
+ const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
52
+ available,
53
+ consumerAgentId: resolvedAgentId
54
+ // Use chatConfig.agentId here
55
+ });
56
+ (0, import_react.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
57
+ const result = (0, import_react.useSuggestions)({ agentId: resolvedAgentId });
58
+ (0, import_react2.useEffect)(() => {
59
+ if (finalSuggestionConfig.available === "disabled")
60
+ return;
61
+ const subscription = copilotkit.subscribe({
62
+ onAgentsChanged: () => {
63
+ const agent = copilotkit.getAgent(resolvedAgentId);
64
+ if (agent && !agent.isRunning && !result.suggestions.length) {
65
+ copilotkit.reloadSuggestions(resolvedAgentId);
66
+ }
67
+ }
68
+ });
69
+ return () => {
70
+ subscription.unsubscribe();
71
+ };
72
+ }, [resolvedAgentId]);
73
+ return result;
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ useConfigureChatSuggestions
78
+ });
79
+ //# sourceMappingURL=use-configure-chat-suggestions.js.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;AAAA;AAAA;AAAA;AAAA,mBAKO;AAGP,IAAAA,gBAAmC;AAwC5B,SAAS,4BACd,QACA,eAAsB,CAAC,GACY;AAnDrC;AAoDE,QAAM,qBAAiB,0CAA4B;AACnD,QAAM,mBAAkB,sDAAgB,YAAhB,YAA2B;AACnD,QAAM,EAAE,WAAW,QAAI,4BAAc;AAErC,QAAM,YAAY,OAAO,cAAc,YAAY,WAAW,OAAO;AAErE,QAAM,wBAAwB,iCACzB,SADyB;AAAA,IAE5B;AAAA,IACA,iBAAiB;AAAA;AAAA,EACnB;AACA,4CAAwB,uBAAuB,YAAY;AAE3D,QAAM,aAAS,6BAAe,EAAE,SAAS,gBAAgB,CAAC;AAE1D,+BAAU,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":["import_react"]}
@@ -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":[]}