@copilotkitnext/react 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AssistantMessage, Message, UserMessage, ToolCall, ToolMessage, ActivityMessage } from '@ag-ui/core';
2
2
  export * from '@ag-ui/core';
3
- import { AbstractAgent, Context } from '@ag-ui/client';
3
+ import { AbstractAgent } from '@ag-ui/client';
4
4
  export * from '@ag-ui/client';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import * as React$1 from 'react';
@@ -508,7 +508,23 @@ declare function useAgent({ agentId, updates }?: UseAgentProps): {
508
508
  agent: AbstractAgent;
509
509
  };
510
510
 
511
- declare function useAgentContext(context: Context): void;
511
+ /**
512
+ * Represents any value that can be serialized to JSON.
513
+ */
514
+ type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
515
+ [key: string]: JsonSerializable;
516
+ };
517
+ /**
518
+ * Context configuration for useAgentContext.
519
+ * Accepts any JSON-serializable value which will be converted to a string.
520
+ */
521
+ interface AgentContextInput {
522
+ /** A human-readable description of what this context represents */
523
+ description: string;
524
+ /** The context value - will be converted to a JSON string if not already a string */
525
+ value: JsonSerializable;
526
+ }
527
+ declare function useAgentContext(context: AgentContextInput): void;
512
528
 
513
529
  interface UseSuggestionsOptions {
514
530
  agentId?: string;
@@ -630,4 +646,4 @@ interface CopilotKitProviderProps {
630
646
  declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
631
647
  declare const useCopilotKit: () => CopilotKitContextValue;
632
648
 
633
- export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorBaseProps, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
649
+ export { type AgentContextInput, AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorBaseProps, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type JsonSerializable, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AssistantMessage, Message, UserMessage, ToolCall, ToolMessage, ActivityMessage } from '@ag-ui/core';
2
2
  export * from '@ag-ui/core';
3
- import { AbstractAgent, Context } from '@ag-ui/client';
3
+ import { AbstractAgent } from '@ag-ui/client';
4
4
  export * from '@ag-ui/client';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import * as React$1 from 'react';
@@ -508,7 +508,23 @@ declare function useAgent({ agentId, updates }?: UseAgentProps): {
508
508
  agent: AbstractAgent;
509
509
  };
510
510
 
511
- declare function useAgentContext(context: Context): void;
511
+ /**
512
+ * Represents any value that can be serialized to JSON.
513
+ */
514
+ type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
515
+ [key: string]: JsonSerializable;
516
+ };
517
+ /**
518
+ * Context configuration for useAgentContext.
519
+ * Accepts any JSON-serializable value which will be converted to a string.
520
+ */
521
+ interface AgentContextInput {
522
+ /** A human-readable description of what this context represents */
523
+ description: string;
524
+ /** The context value - will be converted to a JSON string if not already a string */
525
+ value: JsonSerializable;
526
+ }
527
+ declare function useAgentContext(context: AgentContextInput): void;
512
528
 
513
529
  interface UseSuggestionsOptions {
514
530
  agentId?: string;
@@ -630,4 +646,4 @@ interface CopilotKitProviderProps {
630
646
  declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
631
647
  declare const useCopilotKit: () => CopilotKitContextValue;
632
648
 
633
- export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorBaseProps, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
649
+ export { type AgentContextInput, AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorBaseProps, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type JsonSerializable, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
package/dist/index.js CHANGED
@@ -2124,13 +2124,19 @@ var import_react13 = require("react");
2124
2124
  function useAgentContext(context) {
2125
2125
  const { description, value } = context;
2126
2126
  const { copilotkit } = useCopilotKit();
2127
+ const stringValue = (0, import_react13.useMemo)(() => {
2128
+ if (typeof value === "string") {
2129
+ return value;
2130
+ }
2131
+ return JSON.stringify(value);
2132
+ }, [value]);
2127
2133
  (0, import_react13.useEffect)(() => {
2128
2134
  if (!copilotkit) return;
2129
- const id = copilotkit.addContext(context);
2135
+ const id = copilotkit.addContext({ description, value: stringValue });
2130
2136
  return () => {
2131
2137
  copilotkit.removeContext(id);
2132
2138
  };
2133
- }, [description, value, copilotkit]);
2139
+ }, [description, stringValue, copilotkit]);
2134
2140
  }
2135
2141
 
2136
2142
  // src/hooks/use-suggestions.tsx