11"use client" ;
2- import { useCopilotReadable , useHumanInTheLoop } from "@copilotkit/react-core" ;
2+ import { useAgentContext , useHumanInTheLoop } from "@copilotkit/react-core/v2" ;
3+ import { z } from "zod" ;
34import { useAuthContext } from "@/components/auth-context" ;
45import { Button } from "./ui/button" ;
56
@@ -30,12 +31,12 @@ const CopilotContext = ({ children }: { children: React.ReactNode }) => {
3031 // A readable of app wide authentication and authorization context.
3132 // The LLM will now know which user is it working against, when performing operations.
3233 // Given the respective authorization role, the LLM will allow/deny actions/information throughout the entire app.
33- useCopilotReadable ( {
34+ useAgentContext ( {
3435 description : "The current user logged into the system" ,
35- value : currentUser ,
36+ value : JSON . stringify ( currentUser ) ,
3637 } ) ;
3738
38- useCopilotReadable ( {
39+ useAgentContext ( {
3940 description :
4041 "The available pages and operations, as well as the current page" ,
4142 value : {
@@ -59,28 +60,20 @@ const CopilotContext = ({ children }: { children: React.ReactNode }) => {
5960 For example, if the user is on the cards page and asks to add a card, do NOT use this action - use the addNewCard tool instead.
6061 Only use this when the user is on the wrong page entirely (e.g., on team page but asking about cards).
6162 ` ,
62- parameters : [
63- {
64- name : "page" ,
65- type : "string" ,
66- description : "The page in which to perform the operation" ,
67- required : true ,
68- enum : [ "/cards" , "/team" , "/" ] ,
69- } ,
70- {
71- name : "operation" ,
72- type : "string" ,
73- description :
63+ parameters : z . object ( {
64+ page : z
65+ . enum ( [ "/cards" , "/team" , "/" ] )
66+ . describe ( "The page in which to perform the operation" ) ,
67+ operation : z
68+ . string ( )
69+ . describe (
7470 "The operation to perform. Use operation code from available operations per page. If the operation is unavailable, do not pass it" ,
75- required : false ,
76- } ,
77- {
78- name : "operationAvailable" ,
79- type : "boolean" ,
80- description : "Flag if the operation is available" ,
81- required : true ,
82- } ,
83- ] ,
71+ )
72+ . optional ( ) ,
73+ operationAvailable : z
74+ . boolean ( )
75+ . describe ( "Flag if the operation is available" ) ,
76+ } ) ,
8477 followUp : false ,
8578 render : ( { args, respond } ) => {
8679 const { page, operation, operationAvailable } = args ;
0 commit comments