@copilotkit/vue 1.70.0 → 1.70.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.
@@ -5,6 +5,7 @@
5
5
  * v2 composable (useFrontendTool, useHumanInTheLoop, or useRenderTool).
6
6
  */
7
7
  import type { WatchSource } from "vue";
8
+ import type { WebMCPToolConfig } from "@copilotkit/core";
8
9
  import type { Parameter, MappedParameterTypes } from "@copilotkit/shared";
9
10
  import type { VueFrontendTool } from "../v2/types";
10
11
  export interface FrontendAction<T extends Parameter[] | [] = []> {
@@ -18,6 +19,12 @@ export interface FrontendAction<T extends Parameter[] | [] = []> {
18
19
  renderAndWaitForResponse?: VueFrontendTool<MappedParameterTypes<T>>["render"];
19
20
  renderAndWait?: VueFrontendTool<MappedParameterTypes<T>>["render"];
20
21
  agentId?: string;
22
+ /**
23
+ * Also expose this action to browser agents through the WebMCP API
24
+ * (`document.modelContext`). `true` uses default annotations;
25
+ * `{ annotations }` provides WebMCP annotations.
26
+ */
27
+ webmcp?: boolean | WebMCPToolConfig;
21
28
  }
22
29
  export interface CatchAllFrontendAction {
23
30
  name: "*";
@@ -1 +1 @@
1
- {"version":3,"file":"use-copilot-action.d.ts","sourceRoot":"","sources":["../../src/hooks/use-copilot-action.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAK1E,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AAiBtE,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,IAAI,EA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import { type Parameter, type MappedParameterTypes } from "@copilotkit/shared";
9
10
  import type { VueFrontendTool } from "../v2/types";
10
11
  export interface UseFrontendToolArgs<T extends Parameter[] | [] = []> {
@@ -16,6 +17,12 @@ export interface UseFrontendToolArgs<T extends Parameter[] | [] = []> {
16
17
  available?: "disabled" | "enabled";
17
18
  render?: VueFrontendTool<MappedParameterTypes<T>>["render"];
18
19
  agentId?: string;
20
+ /**
21
+ * Also expose this tool to browser agents through the WebMCP API
22
+ * (`document.modelContext`). `true` uses default annotations;
23
+ * `{ annotations }` provides WebMCP annotations.
24
+ */
25
+ webmcp?: boolean | WebMCPToolConfig;
19
26
  }
20
27
  export declare function useFrontendTool<const T extends Parameter[] = []>(tool: UseFrontendToolArgs<T>, deps?: WatchSource<unknown>[]): void;
21
28
  //# sourceMappingURL=use-frontend-tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-frontend-tool.d.ts","sourceRoot":"","sources":["../../src/hooks/use-frontend-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EACL,KAAK,SAAS,EACd,KAAK,oBAAoB,EAG1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,EAAE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;AAED,wBAAgB,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,EAC9D,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC5B,IAAI,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,QAoD9B"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@copilotkit/core"),A=require("@ag-ui/client"),e=require("./use-render-activity-message-h2NHCkBt.cjs"),i=require("vue"),C=require("@copilotkit/shared");function m(o){return typeof o!="function"?o:(n=>{const a=typeof n.result=="string"?{...n,result:C.parseJson(n.result,n.result)}:n;return o(a)})}function _(o,n){const a="parameters"in o?C.getZodParameters(o.parameters):void 0;if(o.name==="*"){e.useRenderTool({name:"*",render:m(o.render),..."agentId"in o?{agentId:o.agentId}:{}},n);return}const t=o;if("renderAndWaitForResponse"in t||"renderAndWait"in t){const l=t.render??t.renderAndWaitForResponse??t.renderAndWait;if(!l){console.warn(`[CopilotKit] useCopilotAction: HITL action '${t.name}' has no render function. Skipping.`);return}e.useHumanInTheLoop({name:t.name,description:t.description,parameters:a,render:m(l),agentId:t.agentId},n);return}if(t.available==="frontend"||t.available==="disabled"){t.render&&a?e.useRenderTool({name:t.name,parameters:a,render:m(t.render),agentId:t.agentId},n):console.warn(`[CopilotKit] useCopilotAction: action '${t.name}' with available="${t.available}" requires both 'render' and 'parameters'. Skipping registration.`);return}const c=t.handler?l=>Promise.resolve(t.handler(l)):void 0;let s;t.available==="remote"?s=!1:t.available!==void 0&&(s=!0),e.useFrontendTool({name:t.name,description:t.description,parameters:a,handler:c,followUp:t.followUp,render:m(t.render),available:s,agentId:t.agentId},n)}function b(o,n){const{name:a,description:t,parameters:c,handler:s,followUp:l,available:f,render:u,agentId:d}=o,p=C.getZodParameters(c),g=s?r=>Promise.resolve(s(r)):void 0,v=typeof u=="function"?r=>{const h=typeof r.result=="string"?{...r,result:C.parseJson(r.result,r.result)}:r;return u(h)}:u;e.useFrontendTool({name:a,description:t,parameters:p,handler:g,followUp:l,render:v,available:f===void 0?void 0:f!=="disabled",agentId:d},n)}function I(o,n){const{copilotkit:a}=e.useCopilotKit(),t=i.ref(void 0),c=n??[];return i.watch([()=>o.description,()=>o.value,()=>o.convert,()=>o.available,...c],(s,l,f)=>{const u=a.value;if(!u)return;const{description:d,value:p,convert:g,available:v}=o;let r;try{r=g?g(d,p):JSON.stringify(p)}catch(h){console.warn(`[CopilotKit] useCopilotReadable: failed to serialize value for "${d}":`,h),r=String(p)}v!=="disabled"&&(t.value=u.addContext({description:d,value:r}),f(()=>{t.value&&u.removeContext(t.value)}))},{immediate:!0}),t}const T=i.defineComponent({__name:"CopilotKit",props:{publicApiKey:{},publicLicenseKey:{},runtimeUrl:{},headers:{type:[Object,Function]},credentials:{},defaultThrottleMs:{},licenseToken:{},properties:{},useSingleEndpoint:{type:Boolean},agents__unsafe_dev_only:{},selfManagedAgents:{},renderToolCalls:{},renderActivityMessages:{},renderCustomMessages:{},frontendTools:{},humanInTheLoop:{},openGenerativeUI:{},showDevConsole:{type:[Boolean,String]},enableInspector:{type:Boolean},onError:{type:Function},a2ui:{},debug:{type:[Boolean,Object]}},setup(o){const n=o;return(a,t)=>(i.openBlock(),i.createBlock(e._sfc_main$15,i.normalizeProps(i.guardReactiveProps(n)),{default:i.withCtx(()=>[i.renderSlot(a.$slots,"default")]),_:3},16))}});exports.A2UIActivityContentSchema=e.A2UIActivityContentSchema;exports.A2UISurfaceActivityRenderer=e._sfc_main;exports.A2UISurfaceActivityType=e.A2UISurfaceActivityType;exports.CopilotChat=e.CopilotChat;exports.CopilotChatAssistantMessage=e._sfc_main$1;exports.CopilotChatAttachmentQueue=e._sfc_main$2;exports.CopilotChatAttachmentRenderer=e._sfc_main$3;exports.CopilotChatAudioRecorder=e._sfc_main$4;exports.CopilotChatConfigurationProvider=e._sfc_main$5;exports.CopilotChatDefaultLabels=e.CopilotChatDefaultLabels;exports.CopilotChatInput=e._sfc_main$6;exports.CopilotChatMessageView=e._sfc_main$7;exports.CopilotChatReasoningMessage=e._sfc_main$8;exports.CopilotChatSuggestionPill=e._sfc_main$9;exports.CopilotChatSuggestionView=e._sfc_main$10;exports.CopilotChatToggleButton=e.CopilotChatToggleButton;exports.CopilotChatToggleButtonCloseIcon=e.CopilotChatToggleButtonCloseIcon;exports.CopilotChatToggleButtonOpenIcon=e.CopilotChatToggleButtonOpenIcon;exports.CopilotChatToolCallsView=e._sfc_main$11;exports.CopilotChatUserMessage=e._sfc_main$12;exports.CopilotChatView=e._sfc_main$13;exports.CopilotKitCoreVue=e.CopilotKitCoreVue;exports.CopilotKitInspector=e._sfc_main$14;exports.CopilotKitProvider=e._sfc_main$15;exports.CopilotModalHeader=e.CopilotModalHeader;exports.CopilotPopup=e._sfc_main$16;exports.CopilotPopupView=e.CopilotPopupView;exports.CopilotSidebar=e._sfc_main$17;exports.CopilotSidebarView=e.CopilotSidebarView;exports.CopilotThreadsDrawer=e._sfc_main$18;exports.GenerateSandboxedUiArgsSchema=e.GenerateSandboxedUiArgsSchema;exports.LicenseContextKey=e.LicenseContextKey;exports.MCPAppsActivityContentSchema=e.MCPAppsActivityContentSchema;exports.MCPAppsActivityRenderer=e.MCPAppsActivityRenderer;exports.MCPAppsActivityType=e.MCPAppsActivityType;exports.OpenGenerativeUIActivityRenderer=e.OpenGenerativeUIActivityRenderer;exports.OpenGenerativeUIActivityType=e.OpenGenerativeUIActivityType;exports.OpenGenerativeUIContentSchema=e.OpenGenerativeUIContentSchema;exports.OpenGenerativeUIRenderer=e.OpenGenerativeUIRenderer;exports.OpenGenerativeUIToolRenderer=e.OpenGenerativeUIToolRenderer;exports.UseAgentUpdate=e.UseAgentUpdate;exports.createA2UIMessageRenderer=e.createA2UIMessageRenderer;exports.createDefaultLicenseRef=e.createDefaultLicenseRef;exports.defineToolCallRenderer=e.defineToolCallRenderer;exports.extractCompleteStyles=e.extractCompleteStyles;exports.getOperationSurfaceId=e.getOperationSurfaceId;exports.processPartialHtml=e.processPartialHtml;exports.useAgent=e.useAgent;exports.useAgentContext=e.useAgentContext;exports.useAttachments=e.useAttachments;exports.useCapabilities=e.useCapabilities;exports.useComponent=e.useComponent;exports.useConfigureSuggestions=e.useConfigureSuggestions;exports.useCopilotChatConfiguration=e.useCopilotChatConfiguration;exports.useCopilotKit=e.useCopilotKit;exports.useDefaultRenderTool=e.useDefaultRenderTool;exports.useHumanInTheLoop=e.useHumanInTheLoop;exports.useInterrupt=e.useInterrupt;exports.useKatexStyles=e.useKatexStyles;exports.useKeyboardHeight=e.useKeyboardHeight;exports.useLicenseContext=e.useLicenseContext;exports.useRenderActivityMessage=e.useRenderActivityMessage;exports.useRenderCustomMessages=e.useRenderCustomMessages;exports.useRenderTool=e.useRenderTool;exports.useSandboxFunctions=e.useSandboxFunctions;exports.useSuggestions=e.useSuggestions;exports.useThreads=e.useThreads;exports.vueBasicCatalog=e.vueBasicCatalog;Object.defineProperty(exports,"createLicenseContextValue",{enumerable:!0,get:()=>C.createLicenseContextValue});exports.CopilotKit=T;exports.useCopilotAction=_;exports.useCopilotReadable=I;exports.useFrontendTool=b;Object.keys(y).forEach(o=>{o!=="default"&&!Object.prototype.hasOwnProperty.call(exports,o)&&Object.defineProperty(exports,o,{enumerable:!0,get:()=>y[o]})});Object.keys(A).forEach(o=>{o!=="default"&&!Object.prototype.hasOwnProperty.call(exports,o)&&Object.defineProperty(exports,o,{enumerable:!0,get:()=>A[o]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@copilotkit/core"),A=require("@ag-ui/client"),e=require("./use-render-activity-message-CyThomMH.cjs"),i=require("vue"),C=require("@copilotkit/shared");function g(n){return typeof n!="function"?n:(o=>{const a=typeof o.result=="string"?{...o,result:C.parseJson(o.result,o.result)}:o;return n(a)})}function b(n,o){const a="parameters"in n?C.getZodParameters(n.parameters):void 0;if(n.name==="*"){e.useRenderTool({name:"*",render:g(n.render),..."agentId"in n?{agentId:n.agentId}:{}},o);return}const t=n;if("renderAndWaitForResponse"in t||"renderAndWait"in t){const l=t.render??t.renderAndWaitForResponse??t.renderAndWait;if(!l){console.warn(`[CopilotKit] useCopilotAction: HITL action '${t.name}' has no render function. Skipping.`);return}e.useHumanInTheLoop({name:t.name,description:t.description,parameters:a,render:g(l),agentId:t.agentId},o);return}if(t.available==="frontend"||t.available==="disabled"){t.render&&a?e.useRenderTool({name:t.name,parameters:a,render:g(t.render),agentId:t.agentId},o):console.warn(`[CopilotKit] useCopilotAction: action '${t.name}' with available="${t.available}" requires both 'render' and 'parameters'. Skipping registration.`);return}const c=t.handler?l=>Promise.resolve(t.handler(l)):void 0;let s;t.available==="remote"?s=!1:t.available!==void 0&&(s=!0),e.useFrontendTool({name:t.name,description:t.description,parameters:a,handler:c,followUp:t.followUp,render:g(t.render),available:s,agentId:t.agentId,get webmcp(){return t.webmcp}},o)}function _(n,o){const{name:a,description:t,parameters:c,handler:s,followUp:l,available:m,render:u,agentId:d}=n,p=C.getZodParameters(c),f=s?r=>Promise.resolve(s(r)):void 0,v=typeof u=="function"?r=>{const h=typeof r.result=="string"?{...r,result:C.parseJson(r.result,r.result)}:r;return u(h)}:u;e.useFrontendTool({name:a,description:t,parameters:p,handler:f,followUp:l,render:v,available:m===void 0?void 0:m!=="disabled",agentId:d,get webmcp(){return n.webmcp}},o)}function I(n,o){const{copilotkit:a}=e.useCopilotKit(),t=i.ref(void 0),c=o??[];return i.watch([()=>n.description,()=>n.value,()=>n.convert,()=>n.available,...c],(s,l,m)=>{const u=a.value;if(!u)return;const{description:d,value:p,convert:f,available:v}=n;let r;try{r=f?f(d,p):JSON.stringify(p)}catch(h){console.warn(`[CopilotKit] useCopilotReadable: failed to serialize value for "${d}":`,h),r=String(p)}v!=="disabled"&&(t.value=u.addContext({description:d,value:r}),m(()=>{t.value&&u.removeContext(t.value)}))},{immediate:!0}),t}const T=i.defineComponent({__name:"CopilotKit",props:{publicApiKey:{},publicLicenseKey:{},runtimeUrl:{},headers:{type:[Object,Function]},credentials:{},defaultThrottleMs:{},licenseToken:{},properties:{},useSingleEndpoint:{type:Boolean},agents__unsafe_dev_only:{},selfManagedAgents:{},renderToolCalls:{},renderActivityMessages:{},renderCustomMessages:{},frontendTools:{},humanInTheLoop:{},openGenerativeUI:{},showDevConsole:{type:[Boolean,String]},enableInspector:{type:Boolean},onError:{type:Function},a2ui:{},debug:{type:[Boolean,Object]}},setup(n){const o=n;return(a,t)=>(i.openBlock(),i.createBlock(e._sfc_main$15,i.normalizeProps(i.guardReactiveProps(o)),{default:i.withCtx(()=>[i.renderSlot(a.$slots,"default")]),_:3},16))}});exports.A2UIActivityContentSchema=e.A2UIActivityContentSchema;exports.A2UISurfaceActivityRenderer=e._sfc_main;exports.A2UISurfaceActivityType=e.A2UISurfaceActivityType;exports.CopilotChat=e.CopilotChat;exports.CopilotChatAssistantMessage=e._sfc_main$1;exports.CopilotChatAttachmentQueue=e._sfc_main$2;exports.CopilotChatAttachmentRenderer=e._sfc_main$3;exports.CopilotChatAudioRecorder=e._sfc_main$4;exports.CopilotChatConfigurationProvider=e._sfc_main$5;exports.CopilotChatDefaultLabels=e.CopilotChatDefaultLabels;exports.CopilotChatInput=e._sfc_main$6;exports.CopilotChatMessageView=e._sfc_main$7;exports.CopilotChatReasoningMessage=e._sfc_main$8;exports.CopilotChatSuggestionPill=e._sfc_main$9;exports.CopilotChatSuggestionView=e._sfc_main$10;exports.CopilotChatToggleButton=e.CopilotChatToggleButton;exports.CopilotChatToggleButtonCloseIcon=e.CopilotChatToggleButtonCloseIcon;exports.CopilotChatToggleButtonOpenIcon=e.CopilotChatToggleButtonOpenIcon;exports.CopilotChatToolCallsView=e._sfc_main$11;exports.CopilotChatUserMessage=e._sfc_main$12;exports.CopilotChatView=e._sfc_main$13;exports.CopilotKitCoreVue=e.CopilotKitCoreVue;exports.CopilotKitInspector=e._sfc_main$14;exports.CopilotKitProvider=e._sfc_main$15;exports.CopilotModalHeader=e.CopilotModalHeader;exports.CopilotPopup=e._sfc_main$16;exports.CopilotPopupView=e.CopilotPopupView;exports.CopilotSidebar=e._sfc_main$17;exports.CopilotSidebarView=e.CopilotSidebarView;exports.CopilotThreadsDrawer=e._sfc_main$18;exports.GenerateSandboxedUiArgsSchema=e.GenerateSandboxedUiArgsSchema;exports.LicenseContextKey=e.LicenseContextKey;exports.MCPAppsActivityContentSchema=e.MCPAppsActivityContentSchema;exports.MCPAppsActivityRenderer=e.MCPAppsActivityRenderer;exports.MCPAppsActivityType=e.MCPAppsActivityType;exports.OpenGenerativeUIActivityRenderer=e.OpenGenerativeUIActivityRenderer;exports.OpenGenerativeUIActivityType=e.OpenGenerativeUIActivityType;exports.OpenGenerativeUIContentSchema=e.OpenGenerativeUIContentSchema;exports.OpenGenerativeUIRenderer=e.OpenGenerativeUIRenderer;exports.OpenGenerativeUIToolRenderer=e.OpenGenerativeUIToolRenderer;exports.UseAgentUpdate=e.UseAgentUpdate;exports.createA2UIMessageRenderer=e.createA2UIMessageRenderer;exports.createDefaultLicenseRef=e.createDefaultLicenseRef;exports.defineToolCallRenderer=e.defineToolCallRenderer;exports.extractCompleteStyles=e.extractCompleteStyles;exports.getOperationSurfaceId=e.getOperationSurfaceId;exports.processPartialHtml=e.processPartialHtml;exports.useAgent=e.useAgent;exports.useAgentContext=e.useAgentContext;exports.useAttachments=e.useAttachments;exports.useCapabilities=e.useCapabilities;exports.useComponent=e.useComponent;exports.useConfigureSuggestions=e.useConfigureSuggestions;exports.useCopilotChatConfiguration=e.useCopilotChatConfiguration;exports.useCopilotKit=e.useCopilotKit;exports.useDefaultRenderTool=e.useDefaultRenderTool;exports.useHumanInTheLoop=e.useHumanInTheLoop;exports.useInterrupt=e.useInterrupt;exports.useKatexStyles=e.useKatexStyles;exports.useKeyboardHeight=e.useKeyboardHeight;exports.useLicenseContext=e.useLicenseContext;exports.useRenderActivityMessage=e.useRenderActivityMessage;exports.useRenderCustomMessages=e.useRenderCustomMessages;exports.useRenderTool=e.useRenderTool;exports.useSandboxFunctions=e.useSandboxFunctions;exports.useSuggestions=e.useSuggestions;exports.useThreads=e.useThreads;exports.vueBasicCatalog=e.vueBasicCatalog;Object.defineProperty(exports,"createLicenseContextValue",{enumerable:!0,get:()=>C.createLicenseContextValue});exports.CopilotKit=T;exports.useCopilotAction=b;exports.useCopilotReadable=I;exports.useFrontendTool=_;Object.keys(y).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>y[n]})});Object.keys(A).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>A[n]})});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/hooks/use-copilot-action.ts","../src/hooks/use-frontend-tool.ts","../src/hooks/use-copilot-readable.ts","../src/components/copilot-provider/CopilotKit.vue"],"sourcesContent":["/**\n * V1 compatibility wrapper for useCopilotAction.\n *\n * Accepts the legacy Parameter[] action format and routes to the appropriate\n * v2 composable (useFrontendTool, useHumanInTheLoop, or useRenderTool).\n */\nimport type { WatchSource } from \"vue\";\nimport type { Parameter, MappedParameterTypes } from \"@copilotkit/shared\";\nimport { getZodParameters, parseJson } from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport { useHumanInTheLoop as useHumanInTheLoopV2 } from \"../v2/hooks/use-human-in-the-loop\";\nimport { useRenderTool as useRenderToolV2 } from \"../v2/hooks/use-render-tool\";\nimport type { VueFrontendTool, VueHumanInTheLoop } from \"../v2/types\";\n\n// Wraps a v1 render function so a JSON-string `result` is parsed before being\n// passed through. Mirrors the v1 React behavior. If render is a Component\n// (object) rather than a function, returns it unchanged — Components receive\n// props through Vue's prop system and the user is responsible for parsing.\nfunction wrapRenderWithJsonResult<R>(render: R): R {\n if (typeof render !== \"function\") return render;\n return ((props: { result?: unknown }) => {\n const next =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(next);\n }) as R;\n}\n\nexport interface FrontendAction<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\" | \"remote\" | \"frontend\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWaitForResponse?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWait?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n}\n\nexport interface CatchAllFrontendAction {\n name: \"*\";\n render: (props: unknown) => unknown;\n}\n\nexport function useCopilotAction<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T> | CatchAllFrontendAction,\n deps?: WatchSource<unknown>[],\n): void {\n const zodParameters =\n \"parameters\" in action\n ? getZodParameters(action.parameters as T)\n : undefined;\n\n // Catch-all render action\n if (action.name === \"*\") {\n useRenderToolV2(\n {\n name: \"*\",\n render: wrapRenderWithJsonResult(\n (action as CatchAllFrontendAction).render,\n ),\n ...(\"agentId\" in action\n ? { agentId: (action as FrontendAction<T>).agentId }\n : {}),\n },\n deps,\n );\n return;\n }\n\n const typedAction = action as FrontendAction<T>;\n\n // Human-in-the-loop: has renderAndWaitForResponse or renderAndWait\n if (\n \"renderAndWaitForResponse\" in typedAction ||\n \"renderAndWait\" in typedAction\n ) {\n const render =\n typedAction.render ??\n typedAction.renderAndWaitForResponse ??\n typedAction.renderAndWait;\n\n if (!render) {\n console.warn(\n `[CopilotKit] useCopilotAction: HITL action '${typedAction.name}' ` +\n `has no render function. Skipping.`,\n );\n return;\n }\n\n useHumanInTheLoopV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(render) as VueHumanInTheLoop<\n MappedParameterTypes<T>\n >[\"render\"],\n agentId: typedAction.agentId,\n },\n deps,\n );\n return;\n }\n\n // Render-only: available is \"frontend\" or \"disabled\" (no handler invoked remotely)\n if (\n typedAction.available === \"frontend\" ||\n typedAction.available === \"disabled\"\n ) {\n if (typedAction.render && zodParameters) {\n useRenderToolV2(\n {\n name: typedAction.name,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(\n typedAction.render as (props: unknown) => unknown,\n ),\n agentId: typedAction.agentId,\n },\n deps,\n );\n } else {\n console.warn(\n `[CopilotKit] useCopilotAction: action '${typedAction.name}' ` +\n `with available=\"${typedAction.available}\" requires both ` +\n `'render' and 'parameters'. Skipping registration.`,\n );\n }\n return;\n }\n\n // Default: frontend tool with handler\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = typedAction.handler\n ? (args: MappedParameterTypes<T>) =>\n Promise.resolve(typedAction.handler!(args))\n : undefined;\n\n // Convert v1 available (string enum) to v2 available (boolean)\n // At this point, \"frontend\" and \"disabled\" have been handled above,\n // so remaining values are \"enabled\", \"remote\", or undefined.\n // \"remote\" means server-only: register the tool but mark it as not\n // available on the frontend (matches React's ActionInputAvailability.Remote).\n let normalizedAvailable: boolean | undefined;\n if (typedAction.available === \"remote\") {\n normalizedAvailable = false;\n } else if (typedAction.available !== undefined) {\n normalizedAvailable = true;\n }\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp: typedAction.followUp,\n render: wrapRenderWithJsonResult(typedAction.render),\n available: normalizedAvailable,\n agentId: typedAction.agentId,\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useFrontendTool.\n *\n * Accepts the legacy Parameter[] format and converts to Zod via getZodParameters,\n * then delegates to the v2 composable.\n */\nimport type { WatchSource } from \"vue\";\nimport {\n type Parameter,\n type MappedParameterTypes,\n getZodParameters,\n parseJson,\n} from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport type { VueFrontendTool } from \"../v2/types\";\n\nexport interface UseFrontendToolArgs<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n}\n\nexport function useFrontendTool<const T extends Parameter[] = []>(\n tool: UseFrontendToolArgs<T>,\n deps?: WatchSource<unknown>[],\n) {\n const {\n name,\n description,\n parameters,\n handler,\n followUp,\n available,\n render,\n agentId,\n } = tool;\n const zodParameters = getZodParameters(parameters);\n\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = handler\n ? (args: MappedParameterTypes<T>) => Promise.resolve(handler(args))\n : undefined;\n\n // Wrap render to parse JSON-string results before passing them to the\n // user's render function — matches the v1 React behavior. If render is a\n // Component rather than a function, leave it unchanged.\n const normalizedRender =\n typeof render === \"function\"\n ? (props: { result?: unknown }) => {\n const renderProps =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(renderProps);\n }\n : render;\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name,\n description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp,\n render: normalizedRender,\n available: available === undefined ? undefined : available !== \"disabled\",\n agentId,\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useCopilotReadable.\n *\n * Provides app-state and other information to the Copilot context.\n * Delegates directly to the v2 CopilotKitCoreVue instance.\n */\nimport { watch, ref, type Ref } from \"vue\";\nimport type { WatchSource } from \"vue\";\nimport { useCopilotKit } from \"../v2/providers/useCopilotKit\";\n\nexport interface UseCopilotReadableOptions {\n /** The description of the information to be added to the Copilot context. */\n description: string;\n /** The value to be added to the Copilot context. Object values are automatically stringified. */\n value: unknown;\n /** Whether the context is available to the Copilot. */\n available?: \"enabled\" | \"disabled\";\n /** Custom conversion function to serialize the value to a string. */\n convert?: (description: string, value: unknown) => string;\n}\n\nexport function useCopilotReadable(\n options: UseCopilotReadableOptions,\n deps?: WatchSource<unknown>[],\n): Ref<string | undefined> {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = ref<string | undefined>(undefined);\n\n const extraDeps = deps ?? [];\n\n watch(\n [\n () => options.description,\n () => options.value,\n () => options.convert,\n () => options.available,\n ...extraDeps,\n ],\n (_newValues, _old, onCleanup) => {\n const core = copilotkit.value;\n if (!core) return;\n\n const { description, value, convert, available } = options;\n\n let serializedValue: string;\n try {\n serializedValue = convert\n ? convert(description, value)\n : JSON.stringify(value);\n } catch (err) {\n console.warn(\n `[CopilotKit] useCopilotReadable: failed to serialize ` +\n `value for \"${description}\":`,\n err,\n );\n serializedValue = String(value);\n }\n\n if (available === \"disabled\") return;\n\n ctxIdRef.value = core.addContext({\n description,\n value: serializedValue,\n });\n\n onCleanup(() => {\n if (!ctxIdRef.value) return;\n core.removeContext(ctxIdRef.value);\n });\n },\n { immediate: true },\n );\n\n return ctxIdRef;\n}\n","<script setup lang=\"ts\">\n/**\n * V1 compatibility wrapper for CopilotKitProvider.\n *\n * Accepts the same props as CopilotKitProvider plus legacy v1 props\n * (publicApiKey, publicLicenseKey) and delegates to the v2 provider.\n */\nimport type { CopilotKitProps } from \"./types\";\nimport CopilotKitProvider from \"../../v2/providers/CopilotKitProvider.vue\";\n\nconst props = defineProps<CopilotKitProps>();\n</script>\n\n<template>\n <CopilotKitProvider v-bind=\"props\">\n <slot />\n </CopilotKitProvider>\n</template>\n"],"names":["wrapRenderWithJsonResult","render","props","next","parseJson","useCopilotAction","action","deps","zodParameters","getZodParameters","useRenderToolV2","typedAction","useHumanInTheLoopV2","normalizedHandler","args","normalizedAvailable","useFrontendToolV2","useFrontendTool","tool","name","description","parameters","handler","followUp","available","agentId","normalizedRender","renderProps","useCopilotReadable","options","copilotkit","useCopilotKit","ctxIdRef","ref","extraDeps","watch","_newValues","_old","onCleanup","core","value","convert","serializedValue","err","__props","_openBlock","_createBlock","CopilotKitProvider","_renderSlot","_ctx"],"mappings":"wPAkBA,SAASA,EAA4BC,EAAc,CACjD,OAAI,OAAOA,GAAW,WAAmBA,GAChCC,GAAgC,CACvC,MAAMC,EACJ,OAAOD,EAAM,QAAW,SACpB,CAAE,GAAGA,EAAO,OAAQE,EAAAA,UAAUF,EAAM,OAAQA,EAAM,MAAM,GACxDA,EACN,OAAQD,EAAmCE,CAAI,CACjD,EACF,CAoBO,SAASE,EACdC,EACAC,EACM,CACN,MAAMC,EACJ,eAAgBF,EACZG,EAAAA,iBAAiBH,EAAO,UAAe,EACvC,OAGN,GAAIA,EAAO,OAAS,IAAK,CACvBI,EAAAA,cACE,CACE,KAAM,IACN,OAAQV,EACLM,EAAkC,MAAA,EAErC,GAAI,YAAaA,EACb,CAAE,QAAUA,EAA6B,OAAA,EACzC,CAAA,CAAC,EAEPC,CAAA,EAEF,MACF,CAEA,MAAMI,EAAcL,EAGpB,GACE,6BAA8BK,GAC9B,kBAAmBA,EACnB,CACA,MAAMV,EACJU,EAAY,QACZA,EAAY,0BACZA,EAAY,cAEd,GAAI,CAACV,EAAQ,CACX,QAAQ,KACN,+CAA+CU,EAAY,IAAI,qCAAA,EAGjE,MACF,CAEAC,EAAAA,kBACE,CACE,KAAMD,EAAY,KAClB,YAAaA,EAAY,YACzB,WAAYH,EACZ,OAAQR,EAAyBC,CAAM,EAGvC,QAASU,EAAY,OAAA,EAEvBJ,CAAA,EAEF,MACF,CAGA,GACEI,EAAY,YAAc,YAC1BA,EAAY,YAAc,WAC1B,CACIA,EAAY,QAAUH,EACxBE,EAAAA,cACE,CACE,KAAMC,EAAY,KAClB,WAAYH,EACZ,OAAQR,EACNW,EAAY,MAAA,EAEd,QAASA,EAAY,OAAA,EAEvBJ,CAAA,EAGF,QAAQ,KACN,0CAA0CI,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AAMN,EAAQ,YACd,IAAMA,EAAQ,MACd,IAAMA,EAAQ,QACd,IAAMA,EAAQ,UACd,GAAGK,CAAA,EAEL,CAACE,EAAYC,EAAMC,IAAc,CAC/B,MAAMC,EAAOT,EAAW,MACxB,GAAI,CAACS,EAAM,OAEX,KAAM,CAAE,YAAAnB,EAAa,MAAAoB,EAAO,QAAAC,EAAS,UAAAjB,GAAcK,EAEnD,IAAIa,EACJ,GAAI,CACFA,EAAkBD,EACdA,EAAQrB,EAAaoB,CAAK,EAC1B,KAAK,UAAUA,CAAK,CAC1B,OAASG,EAAK,CACZ,QAAQ,KACN,mEACgBvB,CAAW,KAC3BuB,CAAA,EAEFD,EAAkB,OAAOF,CAAK,CAChC,CAEIhB,IAAc,aAElBQ,EAAS,MAAQO,EAAK,WAAW,CAC/B,YAAAnB,EACA,MAAOsB,CAAA,CACR,EAEDJ,EAAU,IAAM,CACTN,EAAS,OACdO,EAAK,cAAcP,EAAS,KAAK,CACnC,CAAC,EACH,EACA,CAAE,UAAW,EAAA,CAAK,EAGbA,CACT,uiBChEA,MAAM9B,EAAQ0C,gBAIZC,EAAAA,UAAA,EAAAC,cAEqBC,EAAAA,mDAFO7C,CAAK,CAAA,EAAA,mBAC/B,IAAQ,CAAR8C,aAAQC,EAAA,OAAA,SAAA,CAAA"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/hooks/use-copilot-action.ts","../src/hooks/use-frontend-tool.ts","../src/hooks/use-copilot-readable.ts","../src/components/copilot-provider/CopilotKit.vue"],"sourcesContent":["/**\n * V1 compatibility wrapper for useCopilotAction.\n *\n * Accepts the legacy Parameter[] action format and routes to the appropriate\n * v2 composable (useFrontendTool, useHumanInTheLoop, or useRenderTool).\n */\nimport type { WatchSource } from \"vue\";\nimport type { WebMCPToolConfig } from \"@copilotkit/core\";\nimport type { Parameter, MappedParameterTypes } from \"@copilotkit/shared\";\nimport { getZodParameters, parseJson } from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport { useHumanInTheLoop as useHumanInTheLoopV2 } from \"../v2/hooks/use-human-in-the-loop\";\nimport { useRenderTool as useRenderToolV2 } from \"../v2/hooks/use-render-tool\";\nimport type { VueFrontendTool, VueHumanInTheLoop } from \"../v2/types\";\n\n// Wraps a v1 render function so a JSON-string `result` is parsed before being\n// passed through. Mirrors the v1 React behavior. If render is a Component\n// (object) rather than a function, returns it unchanged — Components receive\n// props through Vue's prop system and the user is responsible for parsing.\nfunction wrapRenderWithJsonResult<R>(render: R): R {\n if (typeof render !== \"function\") return render;\n return ((props: { result?: unknown }) => {\n const next =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(next);\n }) as R;\n}\n\nexport interface FrontendAction<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\" | \"remote\" | \"frontend\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWaitForResponse?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWait?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n /**\n * Also expose this action to browser agents through the WebMCP API\n * (`document.modelContext`). `true` uses default annotations;\n * `{ annotations }` provides WebMCP annotations.\n */\n webmcp?: boolean | WebMCPToolConfig;\n}\n\nexport interface CatchAllFrontendAction {\n name: \"*\";\n render: (props: unknown) => unknown;\n}\n\nexport function useCopilotAction<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T> | CatchAllFrontendAction,\n deps?: WatchSource<unknown>[],\n): void {\n const zodParameters =\n \"parameters\" in action\n ? getZodParameters(action.parameters as T)\n : undefined;\n\n // Catch-all render action\n if (action.name === \"*\") {\n useRenderToolV2(\n {\n name: \"*\",\n render: wrapRenderWithJsonResult(\n (action as CatchAllFrontendAction).render,\n ),\n ...(\"agentId\" in action\n ? { agentId: (action as FrontendAction<T>).agentId }\n : {}),\n },\n deps,\n );\n return;\n }\n\n const typedAction = action as FrontendAction<T>;\n\n // Human-in-the-loop: has renderAndWaitForResponse or renderAndWait\n if (\n \"renderAndWaitForResponse\" in typedAction ||\n \"renderAndWait\" in typedAction\n ) {\n const render =\n typedAction.render ??\n typedAction.renderAndWaitForResponse ??\n typedAction.renderAndWait;\n\n if (!render) {\n console.warn(\n `[CopilotKit] useCopilotAction: HITL action '${typedAction.name}' ` +\n `has no render function. Skipping.`,\n );\n return;\n }\n\n useHumanInTheLoopV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(render) as VueHumanInTheLoop<\n MappedParameterTypes<T>\n >[\"render\"],\n agentId: typedAction.agentId,\n },\n deps,\n );\n return;\n }\n\n // Render-only: available is \"frontend\" or \"disabled\" (no handler invoked remotely)\n if (\n typedAction.available === \"frontend\" ||\n typedAction.available === \"disabled\"\n ) {\n if (typedAction.render && zodParameters) {\n useRenderToolV2(\n {\n name: typedAction.name,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(\n typedAction.render as (props: unknown) => unknown,\n ),\n agentId: typedAction.agentId,\n },\n deps,\n );\n } else {\n console.warn(\n `[CopilotKit] useCopilotAction: action '${typedAction.name}' ` +\n `with available=\"${typedAction.available}\" requires both ` +\n `'render' and 'parameters'. Skipping registration.`,\n );\n }\n return;\n }\n\n // Default: frontend tool with handler\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = typedAction.handler\n ? (args: MappedParameterTypes<T>) =>\n Promise.resolve(typedAction.handler!(args))\n : undefined;\n\n // Convert v1 available (string enum) to v2 available (boolean)\n // At this point, \"frontend\" and \"disabled\" have been handled above,\n // so remaining values are \"enabled\", \"remote\", or undefined.\n // \"remote\" means server-only: register the tool but mark it as not\n // available on the frontend (matches React's ActionInputAvailability.Remote).\n let normalizedAvailable: boolean | undefined;\n if (typedAction.available === \"remote\") {\n normalizedAvailable = false;\n } else if (typedAction.available !== undefined) {\n normalizedAvailable = true;\n }\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp: typedAction.followUp,\n render: wrapRenderWithJsonResult(typedAction.render),\n available: normalizedAvailable,\n agentId: typedAction.agentId,\n // Read webmcp at watch time: the action object may expose it as a getter\n // over reactive state, and capturing the initial value here would\n // re-register a stale configuration.\n get webmcp() {\n return typedAction.webmcp;\n },\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useFrontendTool.\n *\n * Accepts the legacy Parameter[] format and converts to Zod via getZodParameters,\n * then delegates to the v2 composable.\n */\nimport type { WatchSource } from \"vue\";\nimport type { WebMCPToolConfig } from \"@copilotkit/core\";\nimport {\n type Parameter,\n type MappedParameterTypes,\n getZodParameters,\n parseJson,\n} from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport type { VueFrontendTool } from \"../v2/types\";\n\nexport interface UseFrontendToolArgs<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n /**\n * Also expose this tool to browser agents through the WebMCP API\n * (`document.modelContext`). `true` uses default annotations;\n * `{ annotations }` provides WebMCP annotations.\n */\n webmcp?: boolean | WebMCPToolConfig;\n}\n\nexport function useFrontendTool<const T extends Parameter[] = []>(\n tool: UseFrontendToolArgs<T>,\n deps?: WatchSource<unknown>[],\n) {\n const {\n name,\n description,\n parameters,\n handler,\n followUp,\n available,\n render,\n agentId,\n } = tool;\n const zodParameters = getZodParameters(parameters);\n\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = handler\n ? (args: MappedParameterTypes<T>) => Promise.resolve(handler(args))\n : undefined;\n\n // Wrap render to parse JSON-string results before passing them to the\n // user's render function — matches the v1 React behavior. If render is a\n // Component rather than a function, leave it unchanged.\n const normalizedRender =\n typeof render === \"function\"\n ? (props: { result?: unknown }) => {\n const renderProps =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(renderProps);\n }\n : render;\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name,\n description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp,\n render: normalizedRender,\n available: available === undefined ? undefined : available !== \"disabled\",\n agentId,\n // Read webmcp at watch time: the v1 args may expose it as a getter over\n // reactive state, and capturing the initial value here would re-register\n // a stale configuration.\n get webmcp() {\n return tool.webmcp;\n },\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useCopilotReadable.\n *\n * Provides app-state and other information to the Copilot context.\n * Delegates directly to the v2 CopilotKitCoreVue instance.\n */\nimport { watch, ref, type Ref } from \"vue\";\nimport type { WatchSource } from \"vue\";\nimport { useCopilotKit } from \"../v2/providers/useCopilotKit\";\n\nexport interface UseCopilotReadableOptions {\n /** The description of the information to be added to the Copilot context. */\n description: string;\n /** The value to be added to the Copilot context. Object values are automatically stringified. */\n value: unknown;\n /** Whether the context is available to the Copilot. */\n available?: \"enabled\" | \"disabled\";\n /** Custom conversion function to serialize the value to a string. */\n convert?: (description: string, value: unknown) => string;\n}\n\nexport function useCopilotReadable(\n options: UseCopilotReadableOptions,\n deps?: WatchSource<unknown>[],\n): Ref<string | undefined> {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = ref<string | undefined>(undefined);\n\n const extraDeps = deps ?? [];\n\n watch(\n [\n () => options.description,\n () => options.value,\n () => options.convert,\n () => options.available,\n ...extraDeps,\n ],\n (_newValues, _old, onCleanup) => {\n const core = copilotkit.value;\n if (!core) return;\n\n const { description, value, convert, available } = options;\n\n let serializedValue: string;\n try {\n serializedValue = convert\n ? convert(description, value)\n : JSON.stringify(value);\n } catch (err) {\n console.warn(\n `[CopilotKit] useCopilotReadable: failed to serialize ` +\n `value for \"${description}\":`,\n err,\n );\n serializedValue = String(value);\n }\n\n if (available === \"disabled\") return;\n\n ctxIdRef.value = core.addContext({\n description,\n value: serializedValue,\n });\n\n onCleanup(() => {\n if (!ctxIdRef.value) return;\n core.removeContext(ctxIdRef.value);\n });\n },\n { immediate: true },\n );\n\n return ctxIdRef;\n}\n","<script setup lang=\"ts\">\n/**\n * V1 compatibility wrapper for CopilotKitProvider.\n *\n * Accepts the same props as CopilotKitProvider plus legacy v1 props\n * (publicApiKey, publicLicenseKey) and delegates to the v2 provider.\n */\nimport type { CopilotKitProps } from \"./types\";\nimport CopilotKitProvider from \"../../v2/providers/CopilotKitProvider.vue\";\n\nconst props = defineProps<CopilotKitProps>();\n</script>\n\n<template>\n <CopilotKitProvider v-bind=\"props\">\n <slot />\n </CopilotKitProvider>\n</template>\n"],"names":["wrapRenderWithJsonResult","render","props","next","parseJson","useCopilotAction","action","deps","zodParameters","getZodParameters","useRenderToolV2","typedAction","useHumanInTheLoopV2","normalizedHandler","args","normalizedAvailable","useFrontendToolV2","useFrontendTool","tool","name","description","parameters","handler","followUp","available","agentId","normalizedRender","renderProps","useCopilotReadable","options","copilotkit","useCopilotKit","ctxIdRef","ref","extraDeps","watch","_newValues","_old","onCleanup","core","value","convert","serializedValue","err","__props","_openBlock","_createBlock","CopilotKitProvider","_renderSlot","_ctx"],"mappings":"wPAmBA,SAASA,EAA4BC,EAAc,CACjD,OAAI,OAAOA,GAAW,WAAmBA,GAChCC,GAAgC,CACvC,MAAMC,EACJ,OAAOD,EAAM,QAAW,SACpB,CAAE,GAAGA,EAAO,OAAQE,EAAAA,UAAUF,EAAM,OAAQA,EAAM,MAAM,GACxDA,EACN,OAAQD,EAAmCE,CAAI,CACjD,EACF,CA0BO,SAASE,EACdC,E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C1B,KAAK,UAAUA,CAAK,CAC1B,OAASG,EAAK,CACZ,QAAQ,KACN,mEACgBvB,CAAW,KAC3BuB,CAAA,EAEFD,EAAkB,OAAOF,CAAK,CAChC,CAEIhB,IAAc,aAElBQ,EAAS,MAAQO,EAAK,WAAW,CAC/B,YAAAnB,EACA,MAAOsB,CAAA,CACR,EAEDJ,EAAU,IAAM,CACTN,EAAS,OACdO,EAAK,cAAcP,EAAS,KAAK,CACnC,CAAC,EACH,EACA,CAAE,UAAW,EAAA,CAAK,EAGbA,CACT,uiBChEA,MAAM9B,EAAQ0C,gBAIZC,EAAAA,UAAA,EAAAC,cAEqBC,EAAAA,mDAFO7C,CAAK,CAAA,EAAA,mBAC/B,IAAQ,CAAR8C,aAAQC,EAAA,OAAA,SAAA,CAAA"}
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from "@copilotkit/core";
2
2
  export * from "@ag-ui/client";
3
- import { aa as g, a3 as y, a2 as v, a0 as b, u as I } from "./use-render-activity-message-ytoSQi6V.js";
4
- import { A as k, _ as W, a as J, C as j, b as E, c as q, d as N, e as Q, f as Z, g as X, h as Y, i as ee, j as ae, k as te, l as oe, m as ne, n as re, o as se, p as ie, q as le, r as de, s as ue, t as pe, v as ce, w as Ce, x as me, y as fe, z as ge, B as ve, G as he, L as Ae, M as ye, D as be, E as Ie, O as Re, F as Se, H as Te, I as xe, J as we, U as Ue, K as Pe, N as Me, P as Ke, Q as _e, R as ze, S as Be, T as Oe, V as Ve, W as Le, X as He, Y as De, Z as Fe, $ as Ge, a1 as $e, a4 as ke, a5 as We, a6 as Je, a7 as je, a8 as Ee, a9 as qe, ab as Ne, ac as Qe, ad as Ze, ae as Xe } from "./use-render-activity-message-ytoSQi6V.js";
5
- import { ref as R, watch as S, defineComponent as T, openBlock as x, createBlock as w, normalizeProps as U, guardReactiveProps as P, withCtx as M, renderSlot as K } from "vue";
3
+ import { aa as f, a3 as b, a2 as v, a0 as y, u as I } from "./use-render-activity-message-WeN5iF5H.js";
4
+ import { A as k, _ as W, a as J, C as j, b as E, c as q, d as N, e as Q, f as Z, g as X, h as Y, i as ee, j as ae, k as te, l as oe, m as ne, n as re, o as se, p as ie, q as le, r as de, s as ue, t as pe, v as ce, w as Ce, x as me, y as ge, z as fe, B as ve, G as he, L as Ae, M as be, D as ye, E as Ie, O as Re, F as Se, H as we, I as Te, J as xe, U as Ue, K as Pe, N as Me, P as Ke, Q as _e, R as ze, S as Be, T as Oe, V as Ve, W as Le, X as He, Y as De, Z as Fe, $ as Ge, a1 as $e, a4 as ke, a5 as We, a6 as Je, a7 as je, a8 as Ee, a9 as qe, ab as Ne, ac as Qe, ad as Ze, ae as Xe } from "./use-render-activity-message-WeN5iF5H.js";
5
+ import { ref as R, watch as S, defineComponent as w, openBlock as T, createBlock as x, normalizeProps as U, guardReactiveProps as P, withCtx as M, renderSlot as K } from "vue";
6
6
  import { getZodParameters as h, parseJson as A } from "@copilotkit/shared";
7
7
  import { createLicenseContextValue as ea } from "@copilotkit/shared";
8
8
  function c(a) {
@@ -14,7 +14,7 @@ function c(a) {
14
14
  function O(a, t) {
15
15
  const o = "parameters" in a ? h(a.parameters) : void 0;
16
16
  if (a.name === "*") {
17
- g(
17
+ f(
18
18
  {
19
19
  name: "*",
20
20
  render: c(
@@ -35,7 +35,7 @@ function O(a, t) {
35
35
  );
36
36
  return;
37
37
  }
38
- y(
38
+ b(
39
39
  {
40
40
  name: e.name,
41
41
  description: e.description,
@@ -48,7 +48,7 @@ function O(a, t) {
48
48
  return;
49
49
  }
50
50
  if (e.available === "frontend" || e.available === "disabled") {
51
- e.render && o ? g(
51
+ e.render && o ? f(
52
52
  {
53
53
  name: e.name,
54
54
  parameters: o,
@@ -74,7 +74,13 @@ function O(a, t) {
74
74
  followUp: e.followUp,
75
75
  render: c(e.render),
76
76
  available: r,
77
- agentId: e.agentId
77
+ agentId: e.agentId,
78
+ // Read webmcp at watch time: the action object may expose it as a getter
79
+ // over reactive state, and capturing the initial value here would
80
+ // re-register a stale configuration.
81
+ get webmcp() {
82
+ return e.webmcp;
83
+ }
78
84
  },
79
85
  t
80
86
  );
@@ -102,13 +108,19 @@ function V(a, t) {
102
108
  return i(m);
103
109
  } : i,
104
110
  available: p === void 0 ? void 0 : p !== "disabled",
105
- agentId: l
111
+ agentId: l,
112
+ // Read webmcp at watch time: the v1 args may expose it as a getter over
113
+ // reactive state, and capturing the initial value here would re-register
114
+ // a stale configuration.
115
+ get webmcp() {
116
+ return a.webmcp;
117
+ }
106
118
  },
107
119
  t
108
120
  );
109
121
  }
110
122
  function L(a, t) {
111
- const { copilotkit: o } = b(), e = R(void 0);
123
+ const { copilotkit: o } = y(), e = R(void 0);
112
124
  return S(
113
125
  [
114
126
  () => a.description,
@@ -120,7 +132,7 @@ function L(a, t) {
120
132
  (r, s, p) => {
121
133
  const i = o.value;
122
134
  if (!i) return;
123
- const { description: l, value: d, convert: C, available: f } = a;
135
+ const { description: l, value: d, convert: C, available: g } = a;
124
136
  let n;
125
137
  try {
126
138
  n = C ? C(l, d) : JSON.stringify(d);
@@ -130,7 +142,7 @@ function L(a, t) {
130
142
  m
131
143
  ), n = String(d);
132
144
  }
133
- f !== "disabled" && (e.value = i.addContext({
145
+ g !== "disabled" && (e.value = i.addContext({
134
146
  description: l,
135
147
  value: n
136
148
  }), p(() => {
@@ -140,7 +152,7 @@ function L(a, t) {
140
152
  { immediate: !0 }
141
153
  ), e;
142
154
  }
143
- const H = /* @__PURE__ */ T({
155
+ const H = /* @__PURE__ */ w({
144
156
  __name: "CopilotKit",
145
157
  props: {
146
158
  publicApiKey: {},
@@ -168,7 +180,7 @@ const H = /* @__PURE__ */ T({
168
180
  },
169
181
  setup(a) {
170
182
  const t = a;
171
- return (o, e) => (x(), w(I, U(P(t)), {
183
+ return (o, e) => (T(), x(I, U(P(t)), {
172
184
  default: M(() => [
173
185
  K(o.$slots, "default")
174
186
  ]),
@@ -205,19 +217,19 @@ export {
205
217
  ce as CopilotModalHeader,
206
218
  Ce as CopilotPopup,
207
219
  me as CopilotPopupView,
208
- fe as CopilotSidebar,
209
- ge as CopilotSidebarView,
220
+ ge as CopilotSidebar,
221
+ fe as CopilotSidebarView,
210
222
  ve as CopilotThreadsDrawer,
211
223
  he as GenerateSandboxedUiArgsSchema,
212
224
  Ae as LicenseContextKey,
213
- ye as MCPAppsActivityContentSchema,
214
- be as MCPAppsActivityRenderer,
225
+ be as MCPAppsActivityContentSchema,
226
+ ye as MCPAppsActivityRenderer,
215
227
  Ie as MCPAppsActivityType,
216
228
  Re as OpenGenerativeUIActivityRenderer,
217
229
  Se as OpenGenerativeUIActivityType,
218
- Te as OpenGenerativeUIContentSchema,
219
- xe as OpenGenerativeUIRenderer,
220
- we as OpenGenerativeUIToolRenderer,
230
+ we as OpenGenerativeUIContentSchema,
231
+ Te as OpenGenerativeUIRenderer,
232
+ xe as OpenGenerativeUIToolRenderer,
221
233
  Ue as UseAgentUpdate,
222
234
  Pe as createA2UIMessageRenderer,
223
235
  Me as createDefaultLicenseRef,
@@ -234,18 +246,18 @@ export {
234
246
  Fe as useConfigureSuggestions,
235
247
  O as useCopilotAction,
236
248
  Ge as useCopilotChatConfiguration,
237
- b as useCopilotKit,
249
+ y as useCopilotKit,
238
250
  L as useCopilotReadable,
239
251
  $e as useDefaultRenderTool,
240
252
  V as useFrontendTool,
241
- y as useHumanInTheLoop,
253
+ b as useHumanInTheLoop,
242
254
  ke as useInterrupt,
243
255
  We as useKatexStyles,
244
256
  Je as useKeyboardHeight,
245
257
  je as useLicenseContext,
246
258
  Ee as useRenderActivityMessage,
247
259
  qe as useRenderCustomMessages,
248
- g as useRenderTool,
260
+ f as useRenderTool,
249
261
  Ne as useSandboxFunctions,
250
262
  Qe as useSuggestions,
251
263
  Ze as useThreads,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/hooks/use-copilot-action.ts","../src/hooks/use-frontend-tool.ts","../src/hooks/use-copilot-readable.ts","../src/components/copilot-provider/CopilotKit.vue"],"sourcesContent":["/**\n * V1 compatibility wrapper for useCopilotAction.\n *\n * Accepts the legacy Parameter[] action format and routes to the appropriate\n * v2 composable (useFrontendTool, useHumanInTheLoop, or useRenderTool).\n */\nimport type { WatchSource } from \"vue\";\nimport type { Parameter, MappedParameterTypes } from \"@copilotkit/shared\";\nimport { getZodParameters, parseJson } from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport { useHumanInTheLoop as useHumanInTheLoopV2 } from \"../v2/hooks/use-human-in-the-loop\";\nimport { useRenderTool as useRenderToolV2 } from \"../v2/hooks/use-render-tool\";\nimport type { VueFrontendTool, VueHumanInTheLoop } from \"../v2/types\";\n\n// Wraps a v1 render function so a JSON-string `result` is parsed before being\n// passed through. Mirrors the v1 React behavior. If render is a Component\n// (object) rather than a function, returns it unchanged — Components receive\n// props through Vue's prop system and the user is responsible for parsing.\nfunction wrapRenderWithJsonResult<R>(render: R): R {\n if (typeof render !== \"function\") return render;\n return ((props: { result?: unknown }) => {\n const next =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(next);\n }) as R;\n}\n\nexport interface FrontendAction<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\" | \"remote\" | \"frontend\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWaitForResponse?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWait?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n}\n\nexport interface CatchAllFrontendAction {\n name: \"*\";\n render: (props: unknown) => unknown;\n}\n\nexport function useCopilotAction<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T> | CatchAllFrontendAction,\n deps?: WatchSource<unknown>[],\n): void {\n const zodParameters =\n \"parameters\" in action\n ? getZodParameters(action.parameters as T)\n : undefined;\n\n // Catch-all render action\n if (action.name === \"*\") {\n useRenderToolV2(\n {\n name: \"*\",\n render: wrapRenderWithJsonResult(\n (action as CatchAllFrontendAction).render,\n ),\n ...(\"agentId\" in action\n ? { agentId: (action as FrontendAction<T>).agentId }\n : {}),\n },\n deps,\n );\n return;\n }\n\n const typedAction = action as FrontendAction<T>;\n\n // Human-in-the-loop: has renderAndWaitForResponse or renderAndWait\n if (\n \"renderAndWaitForResponse\" in typedAction ||\n \"renderAndWait\" in typedAction\n ) {\n const render =\n typedAction.render ??\n typedAction.renderAndWaitForResponse ??\n typedAction.renderAndWait;\n\n if (!render) {\n console.warn(\n `[CopilotKit] useCopilotAction: HITL action '${typedAction.name}' ` +\n `has no render function. Skipping.`,\n );\n return;\n }\n\n useHumanInTheLoopV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(render) as VueHumanInTheLoop<\n MappedParameterTypes<T>\n >[\"render\"],\n agentId: typedAction.agentId,\n },\n deps,\n );\n return;\n }\n\n // Render-only: available is \"frontend\" or \"disabled\" (no handler invoked remotely)\n if (\n typedAction.available === \"frontend\" ||\n typedAction.available === \"disabled\"\n ) {\n if (typedAction.render && zodParameters) {\n useRenderToolV2(\n {\n name: typedAction.name,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(\n typedAction.render as (props: unknown) => unknown,\n ),\n agentId: typedAction.agentId,\n },\n deps,\n );\n } else {\n console.warn(\n `[CopilotKit] useCopilotAction: action '${typedAction.name}' ` +\n `with available=\"${typedAction.available}\" requires both ` +\n `'render' and 'parameters'. Skipping registration.`,\n );\n }\n return;\n }\n\n // Default: frontend tool with handler\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = typedAction.handler\n ? (args: MappedParameterTypes<T>) =>\n Promise.resolve(typedAction.handler!(args))\n : undefined;\n\n // Convert v1 available (string enum) to v2 available (boolean)\n // At this point, \"frontend\" and \"disabled\" have been handled above,\n // so remaining values are \"enabled\", \"remote\", or undefined.\n // \"remote\" means server-only: register the tool but mark it as not\n // available on the frontend (matches React's ActionInputAvailability.Remote).\n let normalizedAvailable: boolean | undefined;\n if (typedAction.available === \"remote\") {\n normalizedAvailable = false;\n } else if (typedAction.available !== undefined) {\n normalizedAvailable = true;\n }\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp: typedAction.followUp,\n render: wrapRenderWithJsonResult(typedAction.render),\n available: normalizedAvailable,\n agentId: typedAction.agentId,\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useFrontendTool.\n *\n * Accepts the legacy Parameter[] format and converts to Zod via getZodParameters,\n * then delegates to the v2 composable.\n */\nimport type { WatchSource } from \"vue\";\nimport {\n type Parameter,\n type MappedParameterTypes,\n getZodParameters,\n parseJson,\n} from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport type { VueFrontendTool } from \"../v2/types\";\n\nexport interface UseFrontendToolArgs<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n}\n\nexport function useFrontendTool<const T extends Parameter[] = []>(\n tool: UseFrontendToolArgs<T>,\n deps?: WatchSource<unknown>[],\n) {\n const {\n name,\n description,\n parameters,\n handler,\n followUp,\n available,\n render,\n agentId,\n } = tool;\n const zodParameters = getZodParameters(parameters);\n\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = handler\n ? (args: MappedParameterTypes<T>) => Promise.resolve(handler(args))\n : undefined;\n\n // Wrap render to parse JSON-string results before passing them to the\n // user's render function — matches the v1 React behavior. If render is a\n // Component rather than a function, leave it unchanged.\n const normalizedRender =\n typeof render === \"function\"\n ? (props: { result?: unknown }) => {\n const renderProps =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(renderProps);\n }\n : render;\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name,\n description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp,\n render: normalizedRender,\n available: available === undefined ? undefined : available !== \"disabled\",\n agentId,\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useCopilotReadable.\n *\n * Provides app-state and other information to the Copilot context.\n * Delegates directly to the v2 CopilotKitCoreVue instance.\n */\nimport { watch, ref, type Ref } from \"vue\";\nimport type { WatchSource } from \"vue\";\nimport { useCopilotKit } from \"../v2/providers/useCopilotKit\";\n\nexport interface UseCopilotReadableOptions {\n /** The description of the information to be added to the Copilot context. */\n description: string;\n /** The value to be added to the Copilot context. Object values are automatically stringified. */\n value: unknown;\n /** Whether the context is available to the Copilot. */\n available?: \"enabled\" | \"disabled\";\n /** Custom conversion function to serialize the value to a string. */\n convert?: (description: string, value: unknown) => string;\n}\n\nexport function useCopilotReadable(\n options: UseCopilotReadableOptions,\n deps?: WatchSource<unknown>[],\n): Ref<string | undefined> {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = ref<string | undefined>(undefined);\n\n const extraDeps = deps ?? [];\n\n watch(\n [\n () => options.description,\n () => options.value,\n () => options.convert,\n () => options.available,\n ...extraDeps,\n ],\n (_newValues, _old, onCleanup) => {\n const core = copilotkit.value;\n if (!core) return;\n\n const { description, value, convert, available } = options;\n\n let serializedValue: string;\n try {\n serializedValue = convert\n ? convert(description, value)\n : JSON.stringify(value);\n } catch (err) {\n console.warn(\n `[CopilotKit] useCopilotReadable: failed to serialize ` +\n `value for \"${description}\":`,\n err,\n );\n serializedValue = String(value);\n }\n\n if (available === \"disabled\") return;\n\n ctxIdRef.value = core.addContext({\n description,\n value: serializedValue,\n });\n\n onCleanup(() => {\n if (!ctxIdRef.value) return;\n core.removeContext(ctxIdRef.value);\n });\n },\n { immediate: true },\n );\n\n return ctxIdRef;\n}\n","<script setup lang=\"ts\">\n/**\n * V1 compatibility wrapper for CopilotKitProvider.\n *\n * Accepts the same props as CopilotKitProvider plus legacy v1 props\n * (publicApiKey, publicLicenseKey) and delegates to the v2 provider.\n */\nimport type { CopilotKitProps } from \"./types\";\nimport CopilotKitProvider from \"../../v2/providers/CopilotKitProvider.vue\";\n\nconst props = defineProps<CopilotKitProps>();\n</script>\n\n<template>\n <CopilotKitProvider v-bind=\"props\">\n <slot />\n </CopilotKitProvider>\n</template>\n"],"names":["wrapRenderWithJsonResult","render","props","next","parseJson","useCopilotAction","action","deps","zodParameters","getZodParameters","useRenderToolV2","typedAction","useHumanInTheLoopV2","normalizedHandler","args","normalizedAvailable","useFrontendToolV2","useFrontendTool","tool","name","description","parameters","handler","followUp","available","agentId","renderProps","useCopilotReadable","options","copilotkit","useCopilotKit","ctxIdRef","ref","watch","_newValues","_old","onCleanup","core","value","convert","serializedValue","err","__props","_openBlock","_createBlock","CopilotKitProvider","_renderSlot","_ctx"],"mappings":";;;;;;;AAkBA,SAASA,EAA4BC,GAAc;AACjD,SAAI,OAAOA,KAAW,aAAmBA,KACjC,CAACC,MAAgC;AACvC,UAAMC,IACJ,OAAOD,EAAM,UAAW,WACpB,EAAE,GAAGA,GAAO,QAAQE,EAAUF,EAAM,QAAQA,EAAM,MAAM,MACxDA;AACN,WAAQD,EAAmCE,CAAI;AAAA,EACjD;AACF;AAoBO,SAASE,EACdC,GACAC,GACM;AACN,QAAMC,IACJ,gBAAgBF,IACZG,EAAiBH,EAAO,UAAe,IACvC;AAGN,MAAIA,EAAO,SAAS,KAAK;AACvBI,IAAAA;AAAAA,MACE;AAAA,QACE,MAAM;AAAA,QACN,QAAQV;AAAA,UACLM,EAAkC;AAAA,QAAA;AAAA,QAErC,GAAI,aAAaA,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B,GAAO,SAAAC,GAAS,WAAAf,MAAcI;AAEnD,UAAIY;AACJ,UAAI;AACF,QAAAA,IAAkBD,IACdA,EAAQnB,GAAakB,CAAK,IAC1B,KAAK,UAAUA,CAAK;AAAA,MAC1B,SAASG,GAAK;AACZ,gBAAQ;AAAA,UACN,mEACgBrB,CAAW;AAAA,UAC3BqB;AAAA,QAAA,GAEFD,IAAkB,OAAOF,CAAK;AAAA,MAChC;AAEA,MAAId,MAAc,eAElBO,EAAS,QAAQM,EAAK,WAAW;AAAA,QAC/B,aAAAjB;AAAA,QACA,OAAOoB;AAAA,MAAA,CACR,GAEDJ,EAAU,MAAM;AACd,QAAKL,EAAS,SACdM,EAAK,cAAcN,EAAS,KAAK;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,IACA,EAAE,WAAW,GAAA;AAAA,EAAK,GAGbA;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChEA,UAAM7B,IAAQwC;sBAIZC,EAAA,GAAAC,EAEqBC,OAFO3C,CAAK,CAAA,GAAA;AAAA,iBAC/B,MAAQ;AAAA,QAAR4C,EAAQC,EAAA,QAAA,SAAA;AAAA,MAAA;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/hooks/use-copilot-action.ts","../src/hooks/use-frontend-tool.ts","../src/hooks/use-copilot-readable.ts","../src/components/copilot-provider/CopilotKit.vue"],"sourcesContent":["/**\n * V1 compatibility wrapper for useCopilotAction.\n *\n * Accepts the legacy Parameter[] action format and routes to the appropriate\n * v2 composable (useFrontendTool, useHumanInTheLoop, or useRenderTool).\n */\nimport type { WatchSource } from \"vue\";\nimport type { WebMCPToolConfig } from \"@copilotkit/core\";\nimport type { Parameter, MappedParameterTypes } from \"@copilotkit/shared\";\nimport { getZodParameters, parseJson } from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport { useHumanInTheLoop as useHumanInTheLoopV2 } from \"../v2/hooks/use-human-in-the-loop\";\nimport { useRenderTool as useRenderToolV2 } from \"../v2/hooks/use-render-tool\";\nimport type { VueFrontendTool, VueHumanInTheLoop } from \"../v2/types\";\n\n// Wraps a v1 render function so a JSON-string `result` is parsed before being\n// passed through. Mirrors the v1 React behavior. If render is a Component\n// (object) rather than a function, returns it unchanged — Components receive\n// props through Vue's prop system and the user is responsible for parsing.\nfunction wrapRenderWithJsonResult<R>(render: R): R {\n if (typeof render !== \"function\") return render;\n return ((props: { result?: unknown }) => {\n const next =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(next);\n }) as R;\n}\n\nexport interface FrontendAction<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\" | \"remote\" | \"frontend\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWaitForResponse?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n renderAndWait?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n /**\n * Also expose this action to browser agents through the WebMCP API\n * (`document.modelContext`). `true` uses default annotations;\n * `{ annotations }` provides WebMCP annotations.\n */\n webmcp?: boolean | WebMCPToolConfig;\n}\n\nexport interface CatchAllFrontendAction {\n name: \"*\";\n render: (props: unknown) => unknown;\n}\n\nexport function useCopilotAction<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T> | CatchAllFrontendAction,\n deps?: WatchSource<unknown>[],\n): void {\n const zodParameters =\n \"parameters\" in action\n ? getZodParameters(action.parameters as T)\n : undefined;\n\n // Catch-all render action\n if (action.name === \"*\") {\n useRenderToolV2(\n {\n name: \"*\",\n render: wrapRenderWithJsonResult(\n (action as CatchAllFrontendAction).render,\n ),\n ...(\"agentId\" in action\n ? { agentId: (action as FrontendAction<T>).agentId }\n : {}),\n },\n deps,\n );\n return;\n }\n\n const typedAction = action as FrontendAction<T>;\n\n // Human-in-the-loop: has renderAndWaitForResponse or renderAndWait\n if (\n \"renderAndWaitForResponse\" in typedAction ||\n \"renderAndWait\" in typedAction\n ) {\n const render =\n typedAction.render ??\n typedAction.renderAndWaitForResponse ??\n typedAction.renderAndWait;\n\n if (!render) {\n console.warn(\n `[CopilotKit] useCopilotAction: HITL action '${typedAction.name}' ` +\n `has no render function. Skipping.`,\n );\n return;\n }\n\n useHumanInTheLoopV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(render) as VueHumanInTheLoop<\n MappedParameterTypes<T>\n >[\"render\"],\n agentId: typedAction.agentId,\n },\n deps,\n );\n return;\n }\n\n // Render-only: available is \"frontend\" or \"disabled\" (no handler invoked remotely)\n if (\n typedAction.available === \"frontend\" ||\n typedAction.available === \"disabled\"\n ) {\n if (typedAction.render && zodParameters) {\n useRenderToolV2(\n {\n name: typedAction.name,\n parameters: zodParameters,\n render: wrapRenderWithJsonResult(\n typedAction.render as (props: unknown) => unknown,\n ),\n agentId: typedAction.agentId,\n },\n deps,\n );\n } else {\n console.warn(\n `[CopilotKit] useCopilotAction: action '${typedAction.name}' ` +\n `with available=\"${typedAction.available}\" requires both ` +\n `'render' and 'parameters'. Skipping registration.`,\n );\n }\n return;\n }\n\n // Default: frontend tool with handler\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = typedAction.handler\n ? (args: MappedParameterTypes<T>) =>\n Promise.resolve(typedAction.handler!(args))\n : undefined;\n\n // Convert v1 available (string enum) to v2 available (boolean)\n // At this point, \"frontend\" and \"disabled\" have been handled above,\n // so remaining values are \"enabled\", \"remote\", or undefined.\n // \"remote\" means server-only: register the tool but mark it as not\n // available on the frontend (matches React's ActionInputAvailability.Remote).\n let normalizedAvailable: boolean | undefined;\n if (typedAction.available === \"remote\") {\n normalizedAvailable = false;\n } else if (typedAction.available !== undefined) {\n normalizedAvailable = true;\n }\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name: typedAction.name,\n description: typedAction.description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp: typedAction.followUp,\n render: wrapRenderWithJsonResult(typedAction.render),\n available: normalizedAvailable,\n agentId: typedAction.agentId,\n // Read webmcp at watch time: the action object may expose it as a getter\n // over reactive state, and capturing the initial value here would\n // re-register a stale configuration.\n get webmcp() {\n return typedAction.webmcp;\n },\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useFrontendTool.\n *\n * Accepts the legacy Parameter[] format and converts to Zod via getZodParameters,\n * then delegates to the v2 composable.\n */\nimport type { WatchSource } from \"vue\";\nimport type { WebMCPToolConfig } from \"@copilotkit/core\";\nimport {\n type Parameter,\n type MappedParameterTypes,\n getZodParameters,\n parseJson,\n} from \"@copilotkit/shared\";\nimport { useFrontendTool as useFrontendToolV2 } from \"../v2/hooks/use-frontend-tool\";\nimport type { VueFrontendTool } from \"../v2/types\";\n\nexport interface UseFrontendToolArgs<T extends Parameter[] | [] = []> {\n name: string;\n description?: string;\n parameters?: T;\n handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;\n followUp?: boolean;\n available?: \"disabled\" | \"enabled\";\n render?: VueFrontendTool<MappedParameterTypes<T>>[\"render\"];\n agentId?: string;\n /**\n * Also expose this tool to browser agents through the WebMCP API\n * (`document.modelContext`). `true` uses default annotations;\n * `{ annotations }` provides WebMCP annotations.\n */\n webmcp?: boolean | WebMCPToolConfig;\n}\n\nexport function useFrontendTool<const T extends Parameter[] = []>(\n tool: UseFrontendToolArgs<T>,\n deps?: WatchSource<unknown>[],\n) {\n const {\n name,\n description,\n parameters,\n handler,\n followUp,\n available,\n render,\n agentId,\n } = tool;\n const zodParameters = getZodParameters(parameters);\n\n // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature\n const normalizedHandler = handler\n ? (args: MappedParameterTypes<T>) => Promise.resolve(handler(args))\n : undefined;\n\n // Wrap render to parse JSON-string results before passing them to the\n // user's render function — matches the v1 React behavior. If render is a\n // Component rather than a function, leave it unchanged.\n const normalizedRender =\n typeof render === \"function\"\n ? (props: { result?: unknown }) => {\n const renderProps =\n typeof props.result === \"string\"\n ? { ...props, result: parseJson(props.result, props.result) }\n : props;\n return (render as (p: unknown) => unknown)(renderProps);\n }\n : render;\n\n useFrontendToolV2<MappedParameterTypes<T>>(\n {\n name,\n description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp,\n render: normalizedRender,\n available: available === undefined ? undefined : available !== \"disabled\",\n agentId,\n // Read webmcp at watch time: the v1 args may expose it as a getter over\n // reactive state, and capturing the initial value here would re-register\n // a stale configuration.\n get webmcp() {\n return tool.webmcp;\n },\n },\n deps,\n );\n}\n","/**\n * V1 compatibility wrapper for useCopilotReadable.\n *\n * Provides app-state and other information to the Copilot context.\n * Delegates directly to the v2 CopilotKitCoreVue instance.\n */\nimport { watch, ref, type Ref } from \"vue\";\nimport type { WatchSource } from \"vue\";\nimport { useCopilotKit } from \"../v2/providers/useCopilotKit\";\n\nexport interface UseCopilotReadableOptions {\n /** The description of the information to be added to the Copilot context. */\n description: string;\n /** The value to be added to the Copilot context. Object values are automatically stringified. */\n value: unknown;\n /** Whether the context is available to the Copilot. */\n available?: \"enabled\" | \"disabled\";\n /** Custom conversion function to serialize the value to a string. */\n convert?: (description: string, value: unknown) => string;\n}\n\nexport function useCopilotReadable(\n options: UseCopilotReadableOptions,\n deps?: WatchSource<unknown>[],\n): Ref<string | undefined> {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = ref<string | undefined>(undefined);\n\n const extraDeps = deps ?? [];\n\n watch(\n [\n () => options.description,\n () => options.value,\n () => options.convert,\n () => options.available,\n ...extraDeps,\n ],\n (_newValues, _old, onCleanup) => {\n const core = copilotkit.value;\n if (!core) return;\n\n const { description, value, convert, available } = options;\n\n let serializedValue: string;\n try {\n serializedValue = convert\n ? convert(description, value)\n : JSON.stringify(value);\n } catch (err) {\n console.warn(\n `[CopilotKit] useCopilotReadable: failed to serialize ` +\n `value for \"${description}\":`,\n err,\n );\n serializedValue = String(value);\n }\n\n if (available === \"disabled\") return;\n\n ctxIdRef.value = core.addContext({\n description,\n value: serializedValue,\n });\n\n onCleanup(() => {\n if (!ctxIdRef.value) return;\n core.removeContext(ctxIdRef.value);\n });\n },\n { immediate: true },\n );\n\n return ctxIdRef;\n}\n","<script setup lang=\"ts\">\n/**\n * V1 compatibility wrapper for CopilotKitProvider.\n *\n * Accepts the same props as CopilotKitProvider plus legacy v1 props\n * (publicApiKey, publicLicenseKey) and delegates to the v2 provider.\n */\nimport type { CopilotKitProps } from \"./types\";\nimport CopilotKitProvider from \"../../v2/providers/CopilotKitProvider.vue\";\n\nconst props = defineProps<CopilotKitProps>();\n</script>\n\n<template>\n <CopilotKitProvider v-bind=\"props\">\n <slot />\n </CopilotKitProvider>\n</template>\n"],"names":["wrapRenderWithJsonResult","render","props","next","parseJson","useCopilotAction","action","deps","zodParameters","getZodParameters","useRenderToolV2","typedAction","useHumanInTheLoopV2","normalizedHandler","args","normalizedAvailable","useFrontendToolV2","useFrontendTool","tool","name","description","parameters","handler","followUp","available","agentId","renderProps","useCopilotReadable","options","copilotkit","useCopilotKit","ctxIdRef","ref","watch","_newValues","_old","onCleanup","core","value","convert","serializedValue","err","__props","_openBlock","_createBlock","CopilotKitProvider","_renderSlot","_ctx"],"mappings":";;;;;;;AAmBA,SAASA,EAA4BC,GAAc;AACjD,SAAI,OAAOA,KAAW,aAAmBA,KACjC,CAACC,MAAgC;AACvC,UAAMC,IACJ,OAAOD,EAAM,UAAW,WACpB,EAAE,GAAGA,GAAO,QAAQE,EAAUF,EAAM,QAAQA,EAAM,MAAM,MACxDA;AACN,WAAQD,EAAmCE,CAAI;AAAA,EACjD;AACF;AA0BO,SAASE,EACdC,GACAC,GACM;AACN,QAAMC,IACJ,gBAAgBF,IACZG,EAAiBH,EAAO,UAAe,IACvC;AAGN,MAAIA,EAAO,SAAS,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AAML,EAAQ;AAAA,MACd,MAAMA,EAAQ;AAAA,MACd,MAAMA,EAAQ;AAAA,MACd,MAAMA,EAAQ;AAAA,MACd,GARcrB,KAAQ,CAAA;AAAA,IAQnB;AAAA,IAEL,CAAC2B,GAAYC,GAAMC,MAAc;AAC/B,YAAMC,IAAOR,EAAW;AACxB,UAAI,CAACQ,EAAM;AAEX,YAAM,EAAE,aAAAjB,GAAa,OAAAkB,GAAO,SAAAC,GAAS,WAAAf,MAAcI;AAEnD,UAAIY;AACJ,UAAI;AACF,QAAAA,IAAkBD,IACdA,EAAQnB,GAAakB,CAAK,IAC1B,KAAK,UAAUA,CAAK;AAAA,MAC1B,SAASG,GAAK;AACZ,gBAAQ;AAAA,UACN,mEACgBrB,CAAW;AAAA,UAC3BqB;AAAA,QAAA,GAEFD,IAAkB,OAAOF,CAAK;AAAA,MAChC;AAEA,MAAId,MAAc,eAElBO,EAAS,QAAQM,EAAK,WAAW;AAAA,QAC/B,aAAAjB;AAAA,QACA,OAAOoB;AAAA,MAAA,CACR,GAEDJ,EAAU,MAAM;AACd,QAAKL,EAAS,SACdM,EAAK,cAAcN,EAAS,KAAK;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,IACA,EAAE,WAAW,GAAA;AAAA,EAAK,GAGbA;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChEA,UAAM7B,IAAQwC;sBAIZC,EAAA,GAAAC,EAEqBC,OAFO3C,CAAK,CAAA,GAAA;AAAA,iBAC/B,MAAQ;AAAA,QAAR4C,EAAQC,EAAA,QAAA,SAAA;AAAA,MAAA;;;;;"}
@@ -79,7 +79,7 @@ PARAMETER ORDER IS CRITICAL — generate parameters in exactly this order:
79
79
  transition: margin-inline-end ${Pr}ms ease;
80
80
  }
81
81
  }
82
- `);function g($){const O=l.value[$];return Array.isArray(O)?O.length>0:!!O}function f($){return typeof $=="number"?`${$}px`:$}function y($){return typeof $=="number"?`${$}px`:$}function S(){if(n.width!==void 0||!c.value)return;const $=c.value.getBoundingClientRect().width;$>0&&(d.value=$)}function B(){s.value?.setModalOpen?.(!1)}function M(){s.value?.setModalOpen?.(!0)}function T(){s.value?.setModalOpen?.(!p.value)}function R($){a("submit-message",$)}function V(){a("stop")}function z($){a("input-change",$)}function H($,O){a("select-suggestion",$,O)}function N(){a("add-file")}function P(){a("start-transcribe")}function J(){a("cancel-transcribe")}function F(){a("finish-transcribe")}const I=e.computed(()=>{const $={onSubmitMessage:R,onInputChange:z,onSelectSuggestion:H};return v.value&&($.onStop=V),g("onAddFile")&&($.onAddFile=N),g("onStartTranscribe")&&($.onStartTranscribe=P),g("onCancelTranscribe")&&($.onCancelTranscribe=J),g("onFinishTranscribe")&&($.onFinishTranscribe=F),$});return e.watch(()=>n.width,$=>{if($!==void 0){d.value=$;return}S()}),e.onMounted(async()=>{await e.nextTick(),S(),!(n.width!==void 0||!c.value||typeof ResizeObserver>"u")&&(C=new ResizeObserver(()=>{S()}),C.observe(c.value))}),e.onBeforeUnmount(()=>{C?.disconnect(),C=null}),($,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[p.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent("style"),{key:0},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.value),1)]),_:1})):e.createCommentVNode("",!0),e.renderSlot($.$slots,"toggle-button",{isOpen:p.value,toggle:T,open:M,close:B},()=>[e.createVNode(Ft)]),e.createElementVNode("aside",e.mergeProps({ref_key:"sidebarRef",ref:c,"data-copilotkit":"","data-copilot-sidebar":"",class:k.value,style:w.value,"aria-label":"Copilot chat sidebar","aria-hidden":!p.value,role:"complementary"},b.value),[e.createElementVNode("div",Dr,[e.renderSlot($.$slots,"header",{title:u.value,onClose:B,isOpen:p.value},()=>[e.createVNode(Vt,{title:u.value},null,8,["title"])]),e.createElementVNode("div",Or,[e.createVNode(at,e.mergeProps({messages:t.messages,"auto-scroll":t.autoScroll,"is-running":t.isRunning,suggestions:t.suggestions,"suggestion-loading-indexes":t.suggestionLoadingIndexes,"welcome-screen":t.welcomeScreen,"input-value":t.inputValue,"input-mode":t.inputMode,"input-tools-menu":t.inputToolsMenu,"on-finish-transcribe-with-audio":t.onFinishTranscribeWithAudio},I.value),e.createSlots({_:2},[$.$slots["message-view"]?{name:"message-view",fn:e.withCtx(q=>[e.renderSlot($.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(q)))]),key:"0"}:void 0,$.$slots["scroll-view"]?{name:"scroll-view",fn:e.withCtx(q=>[e.renderSlot($.$slots,"scroll-view",e.normalizeProps(e.guardReactiveProps(q)))]),key:"1"}:void 0,$.$slots.feather?{name:"feather",fn:e.withCtx(()=>[e.renderSlot($.$slots,"feather")]),key:"2"}:void 0,$.$slots["scroll-to-bottom-button"]?{name:"scroll-to-bottom-button",fn:e.withCtx(q=>[e.renderSlot($.$slots,"scroll-to-bottom-button",e.normalizeProps(e.guardReactiveProps(q)))]),key:"3"}:void 0,$.$slots.input?{name:"input",fn:e.withCtx(q=>[e.renderSlot($.$slots,"input",e.normalizeProps(e.guardReactiveProps(q)))]),key:"4"}:void 0,$.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(q=>[e.renderSlot($.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(q)))]),key:"5"}:void 0,$.$slots["welcome-screen"]?{name:"welcome-screen",fn:e.withCtx(q=>[e.renderSlot($.$slots,"welcome-screen",e.normalizeProps(e.guardReactiveProps(q)))]),key:"6"}:void 0,$.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot($.$slots,"welcome-message")]),key:"7"}:void 0]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","on-finish-transcribe-with-audio"])])])],16,Vr)],64))}}),Gn=e.defineComponent({inheritAttrs:!1,__name:"CopilotSidebarView",props:{width:{default:void 0},defaultOpen:{type:Boolean,default:!0},messages:{default:()=>[]},autoScroll:{type:[String,Boolean],default:!0},isRunning:{type:Boolean,default:!1},suggestions:{default:()=>[]},suggestionLoadingIndexes:{default:()=>[]},welcomeScreen:{type:Boolean,default:!0},attachments:{},dragOver:{type:Boolean},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onRemoveAttachment:{},onAddFile:{},onDragOver:{},onDragLeave:{},onDrop:{},onFinishTranscribeWithAudio:{type:Function,default:void 0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(t,{emit:o}){const n=t,a=o,r=e.useAttrs(),s=e.getCurrentInstance(),i=e.computed(()=>s?.vnode.props??{}),l=e.computed(()=>{const{defaultOpen:p,...h}=n;return h}),c=e.computed(()=>({...r,...l.value,...C.value}));function d(p){const h=i.value[p];return Array.isArray(h)?h.length>0:!!h}const C=e.computed(()=>{const p={onSubmitMessage:h=>a("submit-message",h),onStop:()=>a("stop"),onInputChange:h=>a("input-change",h),onSelectSuggestion:(h,u)=>a("select-suggestion",h,u)};return d("onAddFile")&&(p.onAddFile=()=>a("add-file")),d("onStartTranscribe")&&(p.onStartTranscribe=()=>a("start-transcribe")),d("onCancelTranscribe")&&(p.onCancelTranscribe=()=>a("cancel-transcribe")),d("onFinishTranscribe")&&(p.onFinishTranscribe=()=>a("finish-transcribe")),p});return(p,h)=>(e.openBlock(),e.createBlock(ft,{"is-modal-default-open":t.defaultOpen},{default:e.withCtx(()=>[e.createVNode(Ur,e.normalizeProps(e.guardReactiveProps(c.value)),e.createSlots({_:2},[p.$slots.header?{name:"header",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"header",e.normalizeProps(e.guardReactiveProps(u)))]),key:"0"}:void 0,p.$slots["toggle-button"]?{name:"toggle-button",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"toggle-button",e.normalizeProps(e.guardReactiveProps(u)))]),key:"1"}:void 0,p.$slots["message-view"]?{name:"message-view",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(u)))]),key:"2"}:void 0,p.$slots["scroll-view"]?{name:"scroll-view",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"scroll-view",e.normalizeProps(e.guardReactiveProps(u)))]),key:"3"}:void 0,p.$slots.feather?{name:"feather",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"feather",e.normalizeProps(e.guardReactiveProps(u)))]),key:"4"}:void 0,p.$slots["scroll-to-bottom-button"]?{name:"scroll-to-bottom-button",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"scroll-to-bottom-button",e.normalizeProps(e.guardReactiveProps(u)))]),key:"5"}:void 0,p.$slots.input?{name:"input",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"input",e.normalizeProps(e.guardReactiveProps(u)))]),key:"6"}:void 0,p.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(u)))]),key:"7"}:void 0,p.$slots["welcome-screen"]?{name:"welcome-screen",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"welcome-screen",e.normalizeProps(e.guardReactiveProps(u)))]),key:"8"}:void 0,p.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot(p.$slots,"welcome-message")]),key:"9"}:void 0]),1040)]),_:3},8,["is-modal-default-open"]))}}),zr={"data-copilotkit":"",class:"cpk:h-full cpk:flex cpk:flex-col","data-testid":"copilot-sidebar-welcome-screen"},_r={class:"cpk:flex-1 cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:px-4"},jr={class:"cpk:text-xl cpk:sm:text-2xl cpk:font-medium cpk:text-foreground cpk:text-center"},Hr={class:"cpk:px-8 cpk:pb-4"},Wr={class:"cpk:max-w-3xl cpk:mx-auto"},qr={class:"cpk:mb-4 cpk:flex cpk:justify-center"},Jn=e.defineComponent({__name:"CopilotSidebarWelcomeScreen",props:{modelValue:{default:""},isRunning:{type:Boolean,default:!1},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onUpdateModelValue:{},onSubmitMessage:{},onStop:{},onAddFile:{type:Function,default:void 0},onStartTranscribe:{type:Function,default:void 0},onCancelTranscribe:{type:Function,default:void 0},onFinishTranscribe:{type:Function,default:void 0},onFinishTranscribeWithAudio:{type:Function,default:void 0},suggestions:{default:()=>[]},loadingIndexes:{default:()=>[]},onSelectSuggestion:{}},setup(t){const o=t,n=ve(),a=e.computed(()=>n.value?.labels??De),r=e.computed(()=>({modelValue:o.modelValue,isRunning:o.isRunning,inputMode:o.inputMode,inputToolsMenu:o.inputToolsMenu,onUpdateModelValue:o.onUpdateModelValue,onSubmitMessage:o.onSubmitMessage,onStop:o.onStop,onAddFile:o.onAddFile,onStartTranscribe:o.onStartTranscribe,onCancelTranscribe:o.onCancelTranscribe,onFinishTranscribe:o.onFinishTranscribe,onFinishTranscribeWithAudio:o.onFinishTranscribeWithAudio})),s=e.computed(()=>({suggestions:o.suggestions,loadingIndexes:o.loadingIndexes,onSelectSuggestion:o.onSelectSuggestion})),i=e.computed(()=>({...r.value,...s.value})),l=e.computed(()=>{const c={"onUpdate:modelValue":o.onUpdateModelValue,onSubmitMessage:o.onSubmitMessage,onStop:o.onStop};return o.onAddFile&&(c.onAddFile=o.onAddFile),o.onStartTranscribe&&(c.onStartTranscribe=o.onStartTranscribe),o.onCancelTranscribe&&(c.onCancelTranscribe=o.onCancelTranscribe),o.onFinishTranscribe&&(c.onFinishTranscribe=o.onFinishTranscribe),o.onFinishTranscribeWithAudio&&(c.onFinishTranscribeWithAudio=o.onFinishTranscribeWithAudio),c});return(c,d)=>e.renderSlot(c.$slots,"layout",e.normalizeProps(e.guardReactiveProps(i.value)),()=>[e.createElementVNode("div",zr,[e.createElementVNode("div",_r,[e.renderSlot(c.$slots,"welcome-message",{},()=>[e.createElementVNode("h1",jr,e.toDisplayString(a.value.welcomeMessageText),1)])]),e.createElementVNode("div",Hr,[e.createElementVNode("div",Wr,[e.createElementVNode("div",qr,[e.renderSlot(c.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(s.value)),()=>[e.createVNode(tt,{suggestions:t.suggestions,"loading-indexes":t.loadingIndexes,onSelectSuggestion:t.onSelectSuggestion},null,8,["suggestions","loading-indexes","onSelectSuggestion"])])]),e.renderSlot(c.$slots,"input",e.normalizeProps(e.guardReactiveProps(r.value)),()=>[e.createVNode(et,e.mergeProps({"model-value":t.modelValue,"is-running":t.isRunning,mode:t.inputMode,"tools-menu":t.inputToolsMenu,positioning:"static","show-disclaimer":!0},l.value),null,16,["model-value","is-running","mode","tools-menu"])])])])])])}}),Kr=e.defineComponent({__name:"CopilotPopup",props:{width:{default:void 0},height:{default:void 0},clickOutsideToClose:{type:Boolean,default:!1},defaultOpen:{type:Boolean,default:!0},agentId:{},threadId:{},throttleMs:{},labels:{},attachments:{},onError:{},autoScroll:{type:[String,Boolean],default:!0},welcomeScreen:{type:Boolean,default:!0},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onFinishTranscribeWithAudio:{type:Function,default:void 0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(t){function o(s){return{onSubmitMessage:s.onSubmitMessage,onInputChange:s.onInputChange,onSelectSuggestion:s.onSelectSuggestion,...s.onStop?{onStop:s.onStop}:{},...s.onAddFile?{onAddFile:s.onAddFile}:{},...s.onStartTranscribe?{onStartTranscribe:s.onStartTranscribe}:{},...s.onCancelTranscribe?{onCancelTranscribe:s.onCancelTranscribe}:{},...s.onFinishTranscribe?{onFinishTranscribe:s.onFinishTranscribe}:{}}}const n=t,a=ot(),r=e.computed(()=>a.value.checkFeature("popup"));return e.watch(r,s=>{s||console.warn('[CopilotKit] Warning: "popup" feature is not licensed. Visit copilotkit.ai/pricing')},{immediate:!0}),(s,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Mt,{key:0,"feature-name":"Popup"})),e.createVNode($t,e.mergeProps(n,{onSubmitMessage:i[0]||(i[0]=l=>s.$emit("submit-message",l)),onStop:i[1]||(i[1]=l=>s.$emit("stop")),onInputChange:i[2]||(i[2]=l=>s.$emit("input-change",l)),onSelectSuggestion:i[3]||(i[3]=(l,c)=>s.$emit("select-suggestion",l,c)),onAddFile:i[4]||(i[4]=l=>s.$emit("add-file")),onStartTranscribe:i[5]||(i[5]=l=>s.$emit("start-transcribe")),onCancelTranscribe:i[6]||(i[6]=l=>s.$emit("cancel-transcribe")),onFinishTranscribe:i[7]||(i[7]=l=>s.$emit("finish-transcribe"))}),{"chat-view":e.withCtx(l=>[s.$slots["chat-view"]?e.renderSlot(s.$slots,"chat-view",e.normalizeProps(e.mergeProps({key:0},l))):(e.openBlock(),e.createBlock(qn,e.mergeProps({key:1,messages:l.messages,"auto-scroll":l.autoScroll,"is-running":l.isRunning,suggestions:l.suggestions,"suggestion-loading-indexes":l.suggestionLoadingIndexes,"welcome-screen":l.welcomeScreen,"input-value":l.inputValue,"input-mode":l.inputMode,"input-tools-menu":l.inputToolsMenu,width:t.width,height:t.height,"click-outside-to-close":t.clickOutsideToClose,"default-open":t.defaultOpen,"on-finish-transcribe-with-audio":l.onFinishTranscribeWithAudio},o(l)),e.createSlots({"welcome-screen":e.withCtx(c=>[s.$slots["welcome-screen"]?e.renderSlot(s.$slots,"welcome-screen",e.normalizeProps(e.mergeProps({key:0},c))):(e.openBlock(),e.createBlock(Kn,e.normalizeProps(e.mergeProps({key:1},c)),e.createSlots({_:2},[s.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot(s.$slots,"welcome-message")]),key:"0"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(d)))]),key:"1"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(d)))]),key:"2"}:void 0]),1040))]),_:2},[s.$slots.header?{name:"header",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"header",e.normalizeProps(e.guardReactiveProps(c)))]),key:"0"}:void 0,s.$slots["toggle-button"]?{name:"toggle-button",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"toggle-button",e.normalizeProps(e.guardReactiveProps(c)))]),key:"1"}:void 0,s.$slots["message-view"]?{name:"message-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"2"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(c)))]),key:"3"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"4"}:void 0]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","width","height","click-outside-to-close","default-open","on-finish-transcribe-with-audio"]))]),_:3},16)],64))}}),Gr=e.defineComponent({__name:"CopilotSidebar",props:{width:{default:void 0},defaultOpen:{type:Boolean,default:!0},agentId:{},threadId:{},throttleMs:{},labels:{},attachments:{},onError:{},autoScroll:{type:[String,Boolean],default:!0},welcomeScreen:{type:Boolean,default:!0},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onFinishTranscribeWithAudio:{type:Function,default:void 0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(t){function o(s){return{onSubmitMessage:s.onSubmitMessage,onInputChange:s.onInputChange,onSelectSuggestion:s.onSelectSuggestion,...s.onStop?{onStop:s.onStop}:{},...s.onAddFile?{onAddFile:s.onAddFile}:{},...s.onStartTranscribe?{onStartTranscribe:s.onStartTranscribe}:{},...s.onCancelTranscribe?{onCancelTranscribe:s.onCancelTranscribe}:{},...s.onFinishTranscribe?{onFinishTranscribe:s.onFinishTranscribe}:{}}}const n=t,a=ot(),r=e.computed(()=>a.value.checkFeature("sidebar"));return e.watch(r,s=>{s||console.warn('[CopilotKit] Warning: "sidebar" feature is not licensed. Visit copilotkit.ai/pricing')},{immediate:!0}),(s,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Mt,{key:0,"feature-name":"Sidebar"})),e.createVNode($t,e.mergeProps(n,{onSubmitMessage:i[0]||(i[0]=l=>s.$emit("submit-message",l)),onStop:i[1]||(i[1]=l=>s.$emit("stop")),onInputChange:i[2]||(i[2]=l=>s.$emit("input-change",l)),onSelectSuggestion:i[3]||(i[3]=(l,c)=>s.$emit("select-suggestion",l,c)),onAddFile:i[4]||(i[4]=l=>s.$emit("add-file")),onStartTranscribe:i[5]||(i[5]=l=>s.$emit("start-transcribe")),onCancelTranscribe:i[6]||(i[6]=l=>s.$emit("cancel-transcribe")),onFinishTranscribe:i[7]||(i[7]=l=>s.$emit("finish-transcribe"))}),{"chat-view":e.withCtx(l=>[s.$slots["chat-view"]?e.renderSlot(s.$slots,"chat-view",e.normalizeProps(e.mergeProps({key:0},l))):(e.openBlock(),e.createBlock(Gn,e.mergeProps({key:1,messages:l.messages,"auto-scroll":l.autoScroll,"is-running":l.isRunning,suggestions:l.suggestions,"suggestion-loading-indexes":l.suggestionLoadingIndexes,"welcome-screen":l.welcomeScreen,"input-value":l.inputValue,"input-mode":l.inputMode,"input-tools-menu":l.inputToolsMenu,width:t.width,"default-open":t.defaultOpen,"on-finish-transcribe-with-audio":l.onFinishTranscribeWithAudio},o(l)),e.createSlots({"welcome-screen":e.withCtx(c=>[s.$slots["welcome-screen"]?e.renderSlot(s.$slots,"welcome-screen",e.normalizeProps(e.mergeProps({key:0},c))):(e.openBlock(),e.createBlock(Jn,e.normalizeProps(e.mergeProps({key:1},c)),e.createSlots({_:2},[s.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot(s.$slots,"welcome-message")]),key:"0"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(d)))]),key:"1"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(d)))]),key:"2"}:void 0]),1040))]),_:2},[s.$slots.header?{name:"header",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"header",e.normalizeProps(e.guardReactiveProps(c)))]),key:"0"}:void 0,s.$slots["toggle-button"]?{name:"toggle-button",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"toggle-button",e.normalizeProps(e.guardReactiveProps(c)))]),key:"1"}:void 0,s.$slots["message-view"]?{name:"message-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"2"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(c)))]),key:"3"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"4"}:void 0]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","width","default-open","on-finish-transcribe-with-audio"]))]),_:3},16)],64))}}),Jr=Object.assign($t,{View:at}),Qr=Object.assign(Ft,{OpenIcon:Nt,CloseIcon:Bt}),Xr=Object.assign(Vt,{Title:Wn,CloseButton:Hn}),Yr=Object.assign(qn,{WelcomeScreen:Kn}),Zr=Object.assign(Gn,{WelcomeScreen:Jn});function ei(t){const{copilotkit:o}=xe(),n=e.computed(()=>e.toValue(t.description)),a=e.computed(()=>e.toValue(t.value)),r=e.computed(()=>typeof a.value=="string"?a.value:JSON.stringify(a.value));e.watch([()=>o.value,n,r],(s,i,l)=>{const c=o.value,d=c.addContext({description:n.value,value:r.value});l(()=>c.removeContext(d))},{immediate:!0})}const ti=[];function Dt(t,o){const{copilotkit:n}=xe(),a=o??ti;e.watch([()=>t.name,()=>t.available,()=>a.length,...a],(r,s,i)=>{const l=n.value,c=t.name;l.getTool({toolName:c,agentId:t.agentId})&&(console.warn(`Tool '${c}' already exists for agent '${t.agentId||"global"}'. Overriding with latest registration.`),l.removeTool(c,t.agentId)),l.addTool(t),t.render&&l.addHookRenderToolCall({name:c,args:t.parameters,agentId:t.agentId,render:t.render}),i(()=>{l.removeTool(c,t.agentId)})},{immediate:!0})}function ni(t,o){const n=`Use this tool to display the "${t.name}" component in the chat. This tool renders a visual UI component for the user.`,a=t.description?`${n}
82
+ `);function g($){const O=l.value[$];return Array.isArray(O)?O.length>0:!!O}function f($){return typeof $=="number"?`${$}px`:$}function y($){return typeof $=="number"?`${$}px`:$}function S(){if(n.width!==void 0||!c.value)return;const $=c.value.getBoundingClientRect().width;$>0&&(d.value=$)}function B(){s.value?.setModalOpen?.(!1)}function M(){s.value?.setModalOpen?.(!0)}function T(){s.value?.setModalOpen?.(!p.value)}function R($){a("submit-message",$)}function V(){a("stop")}function z($){a("input-change",$)}function H($,O){a("select-suggestion",$,O)}function N(){a("add-file")}function P(){a("start-transcribe")}function J(){a("cancel-transcribe")}function F(){a("finish-transcribe")}const I=e.computed(()=>{const $={onSubmitMessage:R,onInputChange:z,onSelectSuggestion:H};return v.value&&($.onStop=V),g("onAddFile")&&($.onAddFile=N),g("onStartTranscribe")&&($.onStartTranscribe=P),g("onCancelTranscribe")&&($.onCancelTranscribe=J),g("onFinishTranscribe")&&($.onFinishTranscribe=F),$});return e.watch(()=>n.width,$=>{if($!==void 0){d.value=$;return}S()}),e.onMounted(async()=>{await e.nextTick(),S(),!(n.width!==void 0||!c.value||typeof ResizeObserver>"u")&&(C=new ResizeObserver(()=>{S()}),C.observe(c.value))}),e.onBeforeUnmount(()=>{C?.disconnect(),C=null}),($,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[p.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent("style"),{key:0},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.value),1)]),_:1})):e.createCommentVNode("",!0),e.renderSlot($.$slots,"toggle-button",{isOpen:p.value,toggle:T,open:M,close:B},()=>[e.createVNode(Ft)]),e.createElementVNode("aside",e.mergeProps({ref_key:"sidebarRef",ref:c,"data-copilotkit":"","data-copilot-sidebar":"",class:k.value,style:w.value,"aria-label":"Copilot chat sidebar","aria-hidden":!p.value,role:"complementary"},b.value),[e.createElementVNode("div",Dr,[e.renderSlot($.$slots,"header",{title:u.value,onClose:B,isOpen:p.value},()=>[e.createVNode(Vt,{title:u.value},null,8,["title"])]),e.createElementVNode("div",Or,[e.createVNode(at,e.mergeProps({messages:t.messages,"auto-scroll":t.autoScroll,"is-running":t.isRunning,suggestions:t.suggestions,"suggestion-loading-indexes":t.suggestionLoadingIndexes,"welcome-screen":t.welcomeScreen,"input-value":t.inputValue,"input-mode":t.inputMode,"input-tools-menu":t.inputToolsMenu,"on-finish-transcribe-with-audio":t.onFinishTranscribeWithAudio},I.value),e.createSlots({_:2},[$.$slots["message-view"]?{name:"message-view",fn:e.withCtx(q=>[e.renderSlot($.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(q)))]),key:"0"}:void 0,$.$slots["scroll-view"]?{name:"scroll-view",fn:e.withCtx(q=>[e.renderSlot($.$slots,"scroll-view",e.normalizeProps(e.guardReactiveProps(q)))]),key:"1"}:void 0,$.$slots.feather?{name:"feather",fn:e.withCtx(()=>[e.renderSlot($.$slots,"feather")]),key:"2"}:void 0,$.$slots["scroll-to-bottom-button"]?{name:"scroll-to-bottom-button",fn:e.withCtx(q=>[e.renderSlot($.$slots,"scroll-to-bottom-button",e.normalizeProps(e.guardReactiveProps(q)))]),key:"3"}:void 0,$.$slots.input?{name:"input",fn:e.withCtx(q=>[e.renderSlot($.$slots,"input",e.normalizeProps(e.guardReactiveProps(q)))]),key:"4"}:void 0,$.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(q=>[e.renderSlot($.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(q)))]),key:"5"}:void 0,$.$slots["welcome-screen"]?{name:"welcome-screen",fn:e.withCtx(q=>[e.renderSlot($.$slots,"welcome-screen",e.normalizeProps(e.guardReactiveProps(q)))]),key:"6"}:void 0,$.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot($.$slots,"welcome-message")]),key:"7"}:void 0]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","on-finish-transcribe-with-audio"])])])],16,Vr)],64))}}),Gn=e.defineComponent({inheritAttrs:!1,__name:"CopilotSidebarView",props:{width:{default:void 0},defaultOpen:{type:Boolean,default:!0},messages:{default:()=>[]},autoScroll:{type:[String,Boolean],default:!0},isRunning:{type:Boolean,default:!1},suggestions:{default:()=>[]},suggestionLoadingIndexes:{default:()=>[]},welcomeScreen:{type:Boolean,default:!0},attachments:{},dragOver:{type:Boolean},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onRemoveAttachment:{},onAddFile:{},onDragOver:{},onDragLeave:{},onDrop:{},onFinishTranscribeWithAudio:{type:Function,default:void 0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(t,{emit:o}){const n=t,a=o,r=e.useAttrs(),s=e.getCurrentInstance(),i=e.computed(()=>s?.vnode.props??{}),l=e.computed(()=>{const{defaultOpen:p,...h}=n;return h}),c=e.computed(()=>({...r,...l.value,...C.value}));function d(p){const h=i.value[p];return Array.isArray(h)?h.length>0:!!h}const C=e.computed(()=>{const p={onSubmitMessage:h=>a("submit-message",h),onStop:()=>a("stop"),onInputChange:h=>a("input-change",h),onSelectSuggestion:(h,u)=>a("select-suggestion",h,u)};return d("onAddFile")&&(p.onAddFile=()=>a("add-file")),d("onStartTranscribe")&&(p.onStartTranscribe=()=>a("start-transcribe")),d("onCancelTranscribe")&&(p.onCancelTranscribe=()=>a("cancel-transcribe")),d("onFinishTranscribe")&&(p.onFinishTranscribe=()=>a("finish-transcribe")),p});return(p,h)=>(e.openBlock(),e.createBlock(ft,{"is-modal-default-open":t.defaultOpen},{default:e.withCtx(()=>[e.createVNode(Ur,e.normalizeProps(e.guardReactiveProps(c.value)),e.createSlots({_:2},[p.$slots.header?{name:"header",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"header",e.normalizeProps(e.guardReactiveProps(u)))]),key:"0"}:void 0,p.$slots["toggle-button"]?{name:"toggle-button",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"toggle-button",e.normalizeProps(e.guardReactiveProps(u)))]),key:"1"}:void 0,p.$slots["message-view"]?{name:"message-view",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(u)))]),key:"2"}:void 0,p.$slots["scroll-view"]?{name:"scroll-view",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"scroll-view",e.normalizeProps(e.guardReactiveProps(u)))]),key:"3"}:void 0,p.$slots.feather?{name:"feather",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"feather",e.normalizeProps(e.guardReactiveProps(u)))]),key:"4"}:void 0,p.$slots["scroll-to-bottom-button"]?{name:"scroll-to-bottom-button",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"scroll-to-bottom-button",e.normalizeProps(e.guardReactiveProps(u)))]),key:"5"}:void 0,p.$slots.input?{name:"input",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"input",e.normalizeProps(e.guardReactiveProps(u)))]),key:"6"}:void 0,p.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(u)))]),key:"7"}:void 0,p.$slots["welcome-screen"]?{name:"welcome-screen",fn:e.withCtx(u=>[e.renderSlot(p.$slots,"welcome-screen",e.normalizeProps(e.guardReactiveProps(u)))]),key:"8"}:void 0,p.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot(p.$slots,"welcome-message")]),key:"9"}:void 0]),1040)]),_:3},8,["is-modal-default-open"]))}}),zr={"data-copilotkit":"",class:"cpk:h-full cpk:flex cpk:flex-col","data-testid":"copilot-sidebar-welcome-screen"},_r={class:"cpk:flex-1 cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:px-4"},jr={class:"cpk:text-xl cpk:sm:text-2xl cpk:font-medium cpk:text-foreground cpk:text-center"},Hr={class:"cpk:px-8 cpk:pb-4"},Wr={class:"cpk:max-w-3xl cpk:mx-auto"},qr={class:"cpk:mb-4 cpk:flex cpk:justify-center"},Jn=e.defineComponent({__name:"CopilotSidebarWelcomeScreen",props:{modelValue:{default:""},isRunning:{type:Boolean,default:!1},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onUpdateModelValue:{},onSubmitMessage:{},onStop:{},onAddFile:{type:Function,default:void 0},onStartTranscribe:{type:Function,default:void 0},onCancelTranscribe:{type:Function,default:void 0},onFinishTranscribe:{type:Function,default:void 0},onFinishTranscribeWithAudio:{type:Function,default:void 0},suggestions:{default:()=>[]},loadingIndexes:{default:()=>[]},onSelectSuggestion:{}},setup(t){const o=t,n=ve(),a=e.computed(()=>n.value?.labels??De),r=e.computed(()=>({modelValue:o.modelValue,isRunning:o.isRunning,inputMode:o.inputMode,inputToolsMenu:o.inputToolsMenu,onUpdateModelValue:o.onUpdateModelValue,onSubmitMessage:o.onSubmitMessage,onStop:o.onStop,onAddFile:o.onAddFile,onStartTranscribe:o.onStartTranscribe,onCancelTranscribe:o.onCancelTranscribe,onFinishTranscribe:o.onFinishTranscribe,onFinishTranscribeWithAudio:o.onFinishTranscribeWithAudio})),s=e.computed(()=>({suggestions:o.suggestions,loadingIndexes:o.loadingIndexes,onSelectSuggestion:o.onSelectSuggestion})),i=e.computed(()=>({...r.value,...s.value})),l=e.computed(()=>{const c={"onUpdate:modelValue":o.onUpdateModelValue,onSubmitMessage:o.onSubmitMessage,onStop:o.onStop};return o.onAddFile&&(c.onAddFile=o.onAddFile),o.onStartTranscribe&&(c.onStartTranscribe=o.onStartTranscribe),o.onCancelTranscribe&&(c.onCancelTranscribe=o.onCancelTranscribe),o.onFinishTranscribe&&(c.onFinishTranscribe=o.onFinishTranscribe),o.onFinishTranscribeWithAudio&&(c.onFinishTranscribeWithAudio=o.onFinishTranscribeWithAudio),c});return(c,d)=>e.renderSlot(c.$slots,"layout",e.normalizeProps(e.guardReactiveProps(i.value)),()=>[e.createElementVNode("div",zr,[e.createElementVNode("div",_r,[e.renderSlot(c.$slots,"welcome-message",{},()=>[e.createElementVNode("h1",jr,e.toDisplayString(a.value.welcomeMessageText),1)])]),e.createElementVNode("div",Hr,[e.createElementVNode("div",Wr,[e.createElementVNode("div",qr,[e.renderSlot(c.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(s.value)),()=>[e.createVNode(tt,{suggestions:t.suggestions,"loading-indexes":t.loadingIndexes,onSelectSuggestion:t.onSelectSuggestion},null,8,["suggestions","loading-indexes","onSelectSuggestion"])])]),e.renderSlot(c.$slots,"input",e.normalizeProps(e.guardReactiveProps(r.value)),()=>[e.createVNode(et,e.mergeProps({"model-value":t.modelValue,"is-running":t.isRunning,mode:t.inputMode,"tools-menu":t.inputToolsMenu,positioning:"static","show-disclaimer":!0},l.value),null,16,["model-value","is-running","mode","tools-menu"])])])])])])}}),Kr=e.defineComponent({__name:"CopilotPopup",props:{width:{default:void 0},height:{default:void 0},clickOutsideToClose:{type:Boolean,default:!1},defaultOpen:{type:Boolean,default:!0},agentId:{},threadId:{},throttleMs:{},labels:{},attachments:{},onError:{},autoScroll:{type:[String,Boolean],default:!0},welcomeScreen:{type:Boolean,default:!0},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onFinishTranscribeWithAudio:{type:Function,default:void 0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(t){function o(s){return{onSubmitMessage:s.onSubmitMessage,onInputChange:s.onInputChange,onSelectSuggestion:s.onSelectSuggestion,...s.onStop?{onStop:s.onStop}:{},...s.onAddFile?{onAddFile:s.onAddFile}:{},...s.onStartTranscribe?{onStartTranscribe:s.onStartTranscribe}:{},...s.onCancelTranscribe?{onCancelTranscribe:s.onCancelTranscribe}:{},...s.onFinishTranscribe?{onFinishTranscribe:s.onFinishTranscribe}:{}}}const n=t,a=ot(),r=e.computed(()=>a.value.checkFeature("popup"));return e.watch(r,s=>{s||console.warn('[CopilotKit] Warning: "popup" feature is not licensed. Visit copilotkit.ai/pricing')},{immediate:!0}),(s,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Mt,{key:0,"feature-name":"Popup"})),e.createVNode($t,e.mergeProps(n,{onSubmitMessage:i[0]||(i[0]=l=>s.$emit("submit-message",l)),onStop:i[1]||(i[1]=l=>s.$emit("stop")),onInputChange:i[2]||(i[2]=l=>s.$emit("input-change",l)),onSelectSuggestion:i[3]||(i[3]=(l,c)=>s.$emit("select-suggestion",l,c)),onAddFile:i[4]||(i[4]=l=>s.$emit("add-file")),onStartTranscribe:i[5]||(i[5]=l=>s.$emit("start-transcribe")),onCancelTranscribe:i[6]||(i[6]=l=>s.$emit("cancel-transcribe")),onFinishTranscribe:i[7]||(i[7]=l=>s.$emit("finish-transcribe"))}),{"chat-view":e.withCtx(l=>[s.$slots["chat-view"]?e.renderSlot(s.$slots,"chat-view",e.normalizeProps(e.mergeProps({key:0},l))):(e.openBlock(),e.createBlock(qn,e.mergeProps({key:1,messages:l.messages,"auto-scroll":l.autoScroll,"is-running":l.isRunning,suggestions:l.suggestions,"suggestion-loading-indexes":l.suggestionLoadingIndexes,"welcome-screen":l.welcomeScreen,"input-value":l.inputValue,"input-mode":l.inputMode,"input-tools-menu":l.inputToolsMenu,width:t.width,height:t.height,"click-outside-to-close":t.clickOutsideToClose,"default-open":t.defaultOpen,"on-finish-transcribe-with-audio":l.onFinishTranscribeWithAudio},o(l)),e.createSlots({"welcome-screen":e.withCtx(c=>[s.$slots["welcome-screen"]?e.renderSlot(s.$slots,"welcome-screen",e.normalizeProps(e.mergeProps({key:0},c))):(e.openBlock(),e.createBlock(Kn,e.normalizeProps(e.mergeProps({key:1},c)),e.createSlots({_:2},[s.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot(s.$slots,"welcome-message")]),key:"0"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(d)))]),key:"1"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(d)))]),key:"2"}:void 0]),1040))]),_:2},[s.$slots.header?{name:"header",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"header",e.normalizeProps(e.guardReactiveProps(c)))]),key:"0"}:void 0,s.$slots["toggle-button"]?{name:"toggle-button",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"toggle-button",e.normalizeProps(e.guardReactiveProps(c)))]),key:"1"}:void 0,s.$slots["message-view"]?{name:"message-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"2"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(c)))]),key:"3"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"4"}:void 0]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","width","height","click-outside-to-close","default-open","on-finish-transcribe-with-audio"]))]),_:3},16)],64))}}),Gr=e.defineComponent({__name:"CopilotSidebar",props:{width:{default:void 0},defaultOpen:{type:Boolean,default:!0},agentId:{},threadId:{},throttleMs:{},labels:{},attachments:{},onError:{},autoScroll:{type:[String,Boolean],default:!0},welcomeScreen:{type:Boolean,default:!0},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onFinishTranscribeWithAudio:{type:Function,default:void 0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(t){function o(s){return{onSubmitMessage:s.onSubmitMessage,onInputChange:s.onInputChange,onSelectSuggestion:s.onSelectSuggestion,...s.onStop?{onStop:s.onStop}:{},...s.onAddFile?{onAddFile:s.onAddFile}:{},...s.onStartTranscribe?{onStartTranscribe:s.onStartTranscribe}:{},...s.onCancelTranscribe?{onCancelTranscribe:s.onCancelTranscribe}:{},...s.onFinishTranscribe?{onFinishTranscribe:s.onFinishTranscribe}:{}}}const n=t,a=ot(),r=e.computed(()=>a.value.checkFeature("sidebar"));return e.watch(r,s=>{s||console.warn('[CopilotKit] Warning: "sidebar" feature is not licensed. Visit copilotkit.ai/pricing')},{immediate:!0}),(s,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Mt,{key:0,"feature-name":"Sidebar"})),e.createVNode($t,e.mergeProps(n,{onSubmitMessage:i[0]||(i[0]=l=>s.$emit("submit-message",l)),onStop:i[1]||(i[1]=l=>s.$emit("stop")),onInputChange:i[2]||(i[2]=l=>s.$emit("input-change",l)),onSelectSuggestion:i[3]||(i[3]=(l,c)=>s.$emit("select-suggestion",l,c)),onAddFile:i[4]||(i[4]=l=>s.$emit("add-file")),onStartTranscribe:i[5]||(i[5]=l=>s.$emit("start-transcribe")),onCancelTranscribe:i[6]||(i[6]=l=>s.$emit("cancel-transcribe")),onFinishTranscribe:i[7]||(i[7]=l=>s.$emit("finish-transcribe"))}),{"chat-view":e.withCtx(l=>[s.$slots["chat-view"]?e.renderSlot(s.$slots,"chat-view",e.normalizeProps(e.mergeProps({key:0},l))):(e.openBlock(),e.createBlock(Gn,e.mergeProps({key:1,messages:l.messages,"auto-scroll":l.autoScroll,"is-running":l.isRunning,suggestions:l.suggestions,"suggestion-loading-indexes":l.suggestionLoadingIndexes,"welcome-screen":l.welcomeScreen,"input-value":l.inputValue,"input-mode":l.inputMode,"input-tools-menu":l.inputToolsMenu,width:t.width,"default-open":t.defaultOpen,"on-finish-transcribe-with-audio":l.onFinishTranscribeWithAudio},o(l)),e.createSlots({"welcome-screen":e.withCtx(c=>[s.$slots["welcome-screen"]?e.renderSlot(s.$slots,"welcome-screen",e.normalizeProps(e.mergeProps({key:0},c))):(e.openBlock(),e.createBlock(Jn,e.normalizeProps(e.mergeProps({key:1},c)),e.createSlots({_:2},[s.$slots["welcome-message"]?{name:"welcome-message",fn:e.withCtx(()=>[e.renderSlot(s.$slots,"welcome-message")]),key:"0"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(d)))]),key:"1"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(d=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(d)))]),key:"2"}:void 0]),1040))]),_:2},[s.$slots.header?{name:"header",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"header",e.normalizeProps(e.guardReactiveProps(c)))]),key:"0"}:void 0,s.$slots["toggle-button"]?{name:"toggle-button",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"toggle-button",e.normalizeProps(e.guardReactiveProps(c)))]),key:"1"}:void 0,s.$slots["message-view"]?{name:"message-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"message-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"2"}:void 0,s.$slots.input?{name:"input",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"input",e.normalizeProps(e.guardReactiveProps(c)))]),key:"3"}:void 0,s.$slots["suggestion-view"]?{name:"suggestion-view",fn:e.withCtx(c=>[e.renderSlot(s.$slots,"suggestion-view",e.normalizeProps(e.guardReactiveProps(c)))]),key:"4"}:void 0]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","width","default-open","on-finish-transcribe-with-audio"]))]),_:3},16)],64))}}),Jr=Object.assign($t,{View:at}),Qr=Object.assign(Ft,{OpenIcon:Nt,CloseIcon:Bt}),Xr=Object.assign(Vt,{Title:Wn,CloseButton:Hn}),Yr=Object.assign(qn,{WelcomeScreen:Kn}),Zr=Object.assign(Gn,{WelcomeScreen:Jn});function ei(t){const{copilotkit:o}=xe(),n=e.computed(()=>e.toValue(t.description)),a=e.computed(()=>e.toValue(t.value)),r=e.computed(()=>typeof a.value=="string"?a.value:JSON.stringify(a.value));e.watch([()=>o.value,n,r],(s,i,l)=>{const c=o.value,d=c.addContext({description:n.value,value:r.value});l(()=>c.removeContext(d))},{immediate:!0})}const ti=[];function Dt(t,o){const{copilotkit:n}=xe(),a=o??ti;e.watch([()=>t.name,()=>t.available,()=>JSON.stringify(t.webmcp??null),()=>a.length,...a],(r,s,i)=>{const l=n.value,c=t.name;l.getTool({toolName:c,agentId:t.agentId})&&(console.warn(`Tool '${c}' already exists for agent '${t.agentId||"global"}'. Overriding with latest registration.`),l.removeTool(c,t.agentId)),l.addTool(t),t.render&&l.addHookRenderToolCall({name:c,args:t.parameters,agentId:t.agentId,render:t.render}),i(()=>{l.removeTool(c,t.agentId)})},{immediate:!0})}function ni(t,o){const n=`Use this tool to display the "${t.name}" component in the chat. This tool renders a visual UI component for the user.`,a=t.description?`${n}
83
83
 
84
84
  ${t.description}`:n;Dt({name:t.name,description:a,parameters:t.parameters,render:({args:r})=>{const s=t.render;return e.h(s,r)},agentId:t.agentId},o)}const oi=[];function Qn(t,o){const{copilotkit:n}=xe(),a=o??oi;e.watch([()=>n.value,()=>t.name,()=>t.agentId,()=>a.length,...a],()=>{const r=i=>typeof t.render=="function"?t.render(i):e.h(t.render,i),s=t.name==="*"&&!t.parameters?ut({name:"*",render:i=>r({...i,parameters:i.args}),...t.agentId?{agentId:t.agentId}:{}}):ut({name:t.name,args:t.parameters,render:i=>r({...i,parameters:i.args}),...t.agentId?{agentId:t.agentId}:{}});n.value.addHookRenderToolCall(s)},{immediate:!0})}const tn=new Set;function ai(t){switch(t){case te.ToolCallStatus.Complete:return"complete";case te.ToolCallStatus.Executing:return"executing";case te.ToolCallStatus.InProgress:return"inProgress";default:{const o=String(t);return tn.has(o)||(tn.add(o),console.warn(`[CopilotKit] Unknown ToolCallStatus "${o}" in default tool-call renderer; falling back to "inProgress".`)),"inProgress"}}}function bt(t){const o=t.parameters!==void 0?t.parameters:t.args,n=t.status,a=n==="inProgress"||n==="executing"||n==="complete"?n:ai(n);return{name:t.name,toolCallId:t.toolCallId,parameters:o,status:a,result:t.result}}function nn(t){try{return JSON.stringify(t,null,2)}catch(o){console.warn("[CopilotKit] Failed to JSON.stringify tool-call payload for default renderer; falling back to String():",o);try{return String(t)}catch(n){return console.warn("[CopilotKit] safeStringifyForPre: value could not be stringified:",n),"[unserializable]"}}}const si=e.defineComponent({props:{name:{type:String,required:!0},toolCallId:{type:String,required:!0},parameters:{type:null,required:!1,default:void 0},status:{type:String,required:!0},result:{type:null,required:!1,default:void 0}},setup(t){const o=e.ref(!1);return()=>{const n=t.status==="inProgress"||t.status==="executing",a=t.status==="complete",r=n?"Running":a?"Done":t.status;return e.h("div",{"data-testid":"copilot-tool-render","data-tool-name":t.name,"data-tool-call-id":t.toolCallId,"data-status":t.status,"data-args":on(t.parameters),"data-result":on(t.result),style:{marginTop:"8px",paddingBottom:"8px"}},[e.h("div",{style:{borderRadius:"12px",border:"1px solid #e4e4e7",backgroundColor:"#fafafa",padding:"14px 16px"}},[e.h("button",{type:"button","aria-expanded":String(o.value),onClick:()=>{o.value=!o.value},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"10px",cursor:"pointer",border:"none",padding:0,margin:0,background:"transparent",textAlign:"left"}},[e.h("span",{"data-testid":"copilot-tool-render-name",style:{fontWeight:"600"}},t.name),e.h("span",{"data-testid":"copilot-tool-render-status"},r)]),o.value?e.h("div",{style:{marginTop:"12px"}},[e.h("div","Arguments"),e.h("pre",nn(t.parameters??{})),t.result!==void 0?e.h("div",[e.h("div","Result"),e.h("pre",typeof t.result=="string"?t.result:nn(t.result))]):null]):null])])}}});function on(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t)}catch(o){console.warn("[CopilotKit] Failed to JSON.stringify tool-call payload for data-* attribute; falling back to String():",o);try{return String(t)}catch(n){return console.warn("[CopilotKit] safeStringifyForAttr: value could not be stringified:",n),""}}}function ri(t,o){const n=t?.render;let a;if(typeof n=="function"){const r=n;a=(s=>{const i=bt(s);return r(i)})}else if(n){const r=n;a=(s=>{const i=bt(s);return e.h(r,{name:i.name,toolCallId:i.toolCallId,parameters:i.parameters,status:i.status,result:i.result})})}else a=(r=>{const s=bt(r);return e.h(si,{name:s.name,toolCallId:s.toolCallId,parameters:s.parameters,status:s.status,result:s.result})});Qn({name:"*",render:a},o)}function ii(t,o){const{copilotkit:n}=xe(),a=e.ref(null),r=async c=>{a.value&&(a.value(c),a.value=null)},l={...t,handler:async()=>new Promise(c=>{a.value=c}),render:c=>{const d=t.render;return c.status==="inProgress"?e.h(d,{...c,name:t.name,description:t.description||"",respond:void 0}):c.status==="executing"?e.h(d,{...c,name:t.name,description:t.description||"",respond:r}):c.status==="complete"?e.h(d,{...c,name:t.name,description:t.description||"",respond:void 0}):e.h(d,c)}};Dt(l,o),e.onScopeDispose(()=>{n.value.removeHookRenderToolCall(t.name,t.agentId)})}function li(t){return"instructions"in t}function ci(t){return t.map(o=>({...o,isLoading:o.isLoading??!1}))}function ui(t,o){const{copilotkit:n}=xe(),a=ve(),r=o??[],s=e.computed(()=>a.value?.agentId??j.DEFAULT_AGENT_ID),i=e.computed(()=>t?t.consumerAgentId:void 0),l=e.computed(()=>{if(!t||t.available==="disabled")return null;if(li(t))return{...t};const v=ci(t.suggestions);return{...t,suggestions:v}}),c=e.computed(()=>l.value?JSON.stringify(l.value):null),d=e.computed(()=>{if(!l.value)return s.value;const v=l.value.consumerAgentId;return!v||v==="*"?s.value:v}),C=e.computed(()=>i.value===void 0||i.value==="*"),p=e.ref(!1),h=e.ref(null),u=e.ref(null),k=()=>{if(!p.value||!C.value)return;if(Object.values(n.value.agents??{}).some(w=>!!w.agentId&&w.isRunning)){h.value=setTimeout(()=>{h.value=null,k()},0);return}p.value=!1,b()},b=()=>{if(l.value){if(C.value){let v=!1;const w=Object.values(n.value.agents??{});for(const m of w){const g=m.agentId;g&&(m.isRunning?v=!0:n.value.reloadSuggestions(g))}p.value=v,v&&h.value===null&&(h.value=setTimeout(()=>{h.value=null,k()},0));return}d.value&&n.value.reloadSuggestions(d.value)}};e.watch([()=>n.value,c],([v,w],m,g)=>{if(!w||!l.value)return;const f=n.value,y=l.value,S=f.addSuggestionsConfig(y);b(),g(()=>f.removeSuggestionsConfig(S))},{immediate:!0}),e.watch([l,c],([v,w])=>{if(!v){u.value=null;return}w&&u.value===w||(w&&(u.value=w),b())},{immediate:!1}),e.watch([l,()=>r.length,...r],([v])=>{!v||r.length===0||b()},{immediate:!0}),e.watch([()=>n.value,p],(v,w,m)=>{m(()=>{h.value!==null&&(clearTimeout(h.value),h.value=null)})},{immediate:!0}),e.watch([()=>n.value,C],([v,w],m,g)=>{if(!w)return;const f=Object.values(v.agents??{}).filter(y=>!!y).map(y=>y.subscribe({onRunStartedEvent:k,onRunFinishedEvent:k,onRunFinalized:k,onRunFailed:k,onRunErrorEvent:k}));g(()=>{for(const y of f)y.unsubscribe()})},{immediate:!0})}const Xn="on_interrupt";function di(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&typeof Reflect.get(t,"then")=="function"}function pi(t){return t instanceof Promise?t:new Promise((o,n)=>{try{t.then(o,n)}catch(a){n(a)}})}function yt(t){return t.kind==="legacy"?t.event:{name:Xn,value:t.interrupts[0]}}function mi(t={}){const{copilotkit:o}=xe(),{agent:n}=gt({agentId:t.agentId}),a=e.shallowRef(null),r=e.shallowRef(null),s={};e.watch(n,(u,k,b)=>{if(!u){a.value=null,r.value=null;return}let v=null,w=null;const m=u.subscribe({onCustomEvent:({event:g})=>{g.name===Xn&&(v={name:g.name,value:g.value})},onRunFinishedEvent:g=>{g.outcome==="interrupt"&&(w=g.interrupts)},onRunStartedEvent:()=>{v=null,w=null;for(const g of Object.keys(s))delete s[g];a.value=null},onRunFinalized:()=>{w&&w.length>0?a.value={kind:"standard",interrupts:w}:v&&(a.value={kind:"legacy",event:v}),v=null,w=null},onRunFailed:()=>{v=null,w=null;for(const g of Object.keys(s))delete s[g];a.value=null}});b(()=>m.unsubscribe())},{immediate:!0});const i=async u=>{if(!u.every(m=>s[m.id]))return;const b=u.find(m=>Xe.isInterruptExpired(m));if(b){console.error(`[CopilotKit] useInterrupt: interrupt ${b.id} expired at ${b.expiresAt}; not resuming.`);for(const m of Object.keys(s))delete s[m];a.value=null;return}const v=Xe.buildResumeArray(u,s);for(const m of Object.keys(s))delete s[m];const w=n.value;if(w)try{return await o.value.runAgent({agent:w,resume:v})}catch(m){throw console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing",m),a.value=null,m}},l=async(u,k)=>{const b=a.value;if(!b)return;const v=n.value;if(!v)return;if(b.kind==="legacy"){const m=b.event.value;try{return await o.value.runAgent({agent:v,forwardedProps:{command:{resume:u,interruptEvent:m}}})}catch(g){throw console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing",g),a.value=null,g}}b.interrupts.length>1&&k===void 0&&console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${b.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);const w=k??b.interrupts[0]?.id;if(w)return s[w]={status:"resolved",payload:u},i(b.interrupts)},c=async u=>{const k=a.value;if(!k)return;if(k.kind==="legacy"){console.warn("[CopilotKit] useInterrupt: cancel() is not supported for legacy on_interrupt interrupts; dismissing."),a.value=null;return}k.interrupts.length>1&&u===void 0&&console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${k.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);const b=u??k.interrupts[0]?.id;if(b)return s[b]={status:"cancelled"},i(k.interrupts)},d=l,C=c;e.watch(a,(u,k,b)=>{if(!u){r.value=null;return}const v=yt(u);if(t.enabled&&!t.enabled(v)){r.value=null;return}const w=t.handler;if(!w){r.value=null;return}let m=!1;const g=w({event:v,interrupt:u.kind==="standard"?u.interrupts[0]??null:null,interrupts:u.kind==="standard"?u.interrupts:[],resolve:l,cancel:c});di(g)?pi(g).then(f=>{m||(r.value=f)}).catch(f=>{m||(console.error("[CopilotKit] useInterrupt handler failed:",f),r.value=null)}):r.value=g,b(()=>{m=!0})},{immediate:!0});const p=e.computed(()=>a.value?yt(a.value):null),h=e.computed(()=>{const u=a.value;if(!u)return null;const k=yt(u);return t.enabled&&!t.enabled(k)?null:{event:k,interrupt:u.kind==="standard"?u.interrupts[0]??null:null,interrupts:u.kind==="standard"?u.interrupts:[],result:r.value,resolve:l,cancel:c}});return e.watch([()=>o.value,h,()=>t.renderInChat!==!1],([u,k,b],v,w)=>{if(!b)return;u.setInterruptState(k);const m=k;w(()=>{u.interruptState===m&&u.setInterruptState(null)})},{immediate:!0}),e.onScopeDispose(()=>{const u=o.value;t.renderInChat!==!1&&u.interruptState===h.value&&u.setInterruptState(null)}),{interrupt:p,result:r,hasInterrupt:e.computed(()=>h.value!==null),resolve:l,resolveInterrupt:d,cancel:c,cancelInterrupt:C,slotProps:h}}function fi(t){const{agent:o}=gt({agentId:t});return e.computed(()=>{const n=o.value;if(n&&"capabilities"in n)return n.capabilities})}function gi(){const{copilotkit:t}=xe(),o=ve();return function(a){const r=o.value;if(!r)return null;const s=r.agentId||j.DEFAULT_AGENT_ID,{threadId:i}=r,l=t.value,c=[...l.renderCustomMessages].filter(y=>y.agentId===void 0||y.agentId===s).sort((y,S)=>{const B=y.agentId!==void 0,M=S.agentId!==void 0;return B===M?0:B?-1:1});if(!c.length)return null;const{message:d,position:C}=a,p=l.getRunIdForMessage(s,i,d.id)??l.getRunIdsForThread(s,i).slice(-1)[0],h=p??`missing-run-id:${d.id}`,u=l.getAgent(s);if(!u)return null;const k=p?u.messages.filter(y=>l.getRunIdForMessage(s,i,y.id)===p).map(y=>y.id):[d.id],b=u.messages.findIndex(y=>y.id===d.id);b<0&&console.warn(`[CopilotKit] useRenderCustomMessages: message "${d.id}" not found in agent "${s}" messages`);const v=Math.max(0,b),w=p?Math.max(k.indexOf(d.id),0):0,m=p?k.length:1,g=p?l.getStateByRun(s,i,p):void 0,f={message:d,position:C,runId:h,messageIndex:v,messageIndexInRun:w,numberOfMessagesInRun:m,agentId:s,stateSnapshot:g};for(const y of c)if(y.render)return{renderer:y.render,props:f};return null}}function vi(){const{copilotkit:t}=xe(),o=ve(),n=e.computed(()=>o.value?.agentId??j.DEFAULT_AGENT_ID),a=e.computed(()=>[...t.value.renderActivityMessages]);function r(i){const l=a.value;if(!l.length)return null;const c=l.filter(d=>d.activityType===i);return c.find(d=>d.agentId===n.value)??c.find(d=>d.agentId===void 0)??l.find(d=>d.activityType==="*")??null}function s(i){const l=r(i.activityType);if(!l)return null;const c=l.content.safeParse(i.content);if(!c.success)return console.warn(`Failed to parse content for activity message '${i.activityType}':`,c.error),null;const d=t.value.getAgent(n.value);return{renderer:l.render,props:{activityType:i.activityType,content:c.data,message:i,agent:d}}}return{renderActivityMessage:s,findRenderer:r}}exports.A2UIActivityContentSchema=mo;exports.A2UISurfaceActivityType=po;exports.CopilotChat=Jr;exports.CopilotChatDefaultLabels=De;exports.CopilotChatToggleButton=Qr;exports.CopilotChatToggleButtonCloseIcon=Bt;exports.CopilotChatToggleButtonOpenIcon=Nt;exports.CopilotKitCoreVue=pn;exports.CopilotModalHeader=Xr;exports.CopilotPopupView=Yr;exports.CopilotSidebarView=Zr;exports.GenerateSandboxedUiArgsSchema=yn;exports.LicenseContextKey=Rt;exports.MCPAppsActivityContentSchema=un;exports.MCPAppsActivityRenderer=dn;exports.MCPAppsActivityType=cn;exports.OpenGenerativeUIActivityRenderer=Cn;exports.OpenGenerativeUIActivityType=kn;exports.OpenGenerativeUIContentSchema=bn;exports.OpenGenerativeUIRenderer=wn;exports.OpenGenerativeUIToolRenderer=xn;exports.UseAgentUpdate=Fn;exports._sfc_main=Rn;exports._sfc_main$1=Bn;exports._sfc_main$10=tt;exports._sfc_main$11=Mn;exports._sfc_main$12=Un;exports._sfc_main$13=at;exports._sfc_main$14=sn;exports._sfc_main$15=oa;exports._sfc_main$16=Kr;exports._sfc_main$17=Gr;exports._sfc_main$18=hr;exports._sfc_main$2=St;exports._sfc_main$3=gr;exports._sfc_main$4=Nn;exports._sfc_main$5=ft;exports._sfc_main$6=et;exports._sfc_main$7=zn;exports._sfc_main$8=Pn;exports._sfc_main$9=_n;exports.createA2UIMessageRenderer=mn;exports.createDefaultLicenseRef=Sn;exports.defineToolCallRenderer=ut;exports.extractCompleteStyles=gn;exports.getOperationSurfaceId=Ct;exports.processPartialHtml=vn;exports.useAgent=gt;exports.useAgentContext=ei;exports.useAttachments=Dn;exports.useCapabilities=fi;exports.useComponent=ni;exports.useConfigureSuggestions=ui;exports.useCopilotChatConfiguration=ve;exports.useCopilotKit=xe;exports.useDefaultRenderTool=ri;exports.useFrontendTool=Dt;exports.useHumanInTheLoop=ii;exports.useInterrupt=mi;exports.useKatexStyles=$n;exports.useKeyboardHeight=On;exports.useLicenseContext=ot;exports.useRenderActivityMessage=vi;exports.useRenderCustomMessages=gi;exports.useRenderTool=Qn;exports.useSandboxFunctions=hn;exports.useSuggestions=Vn;exports.useThreads=jn;exports.vueBasicCatalog=Ye;
85
- //# sourceMappingURL=use-render-activity-message-h2NHCkBt.cjs.map
85
+ //# sourceMappingURL=use-render-activity-message-CyThomMH.cjs.map