@copilotkit/react-native 1.66.0 → 1.66.1-canary.rn-tool-render
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/RenderToolContext-CBNKcJqz.cjs.map +1 -1
- package/dist/RenderToolContext-D8M-JhD1.mjs.map +1 -1
- package/dist/components/index.cjs +8 -6
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.mjs +8 -6
- package/dist/components/index.mjs.map +1 -1
- package/dist/headless.cjs +5 -9
- package/dist/headless.d.cts +3 -3
- package/dist/headless.d.mts +3 -3
- package/dist/headless.mjs +3 -3
- package/dist/index.cjs +5 -9
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{useRenderTool-9YDIfZ0D.d.mts → useRenderToolCall-BToS3UWC.d.cts} +92 -6
- package/dist/{useRenderTool-BugVTDoM.d.cts → useRenderToolCall-DAvPBgpB.d.mts} +92 -6
- package/dist/{useRenderTool-DLavcsVB.cjs → useRenderToolCall-DawGeFfu.cjs} +98 -1
- package/dist/useRenderToolCall-DawGeFfu.cjs.map +1 -0
- package/dist/{useRenderTool-DUqpS97B.mjs → useRenderToolCall-DjhQb8Ki.mjs} +91 -6
- package/dist/useRenderToolCall-DjhQb8Ki.mjs.map +1 -0
- package/package.json +5 -5
- package/src/components/CopilotChat.tsx +19 -12
- package/src/headless.ts +11 -1
- package/src/hooks/RenderToolContext.tsx +15 -2
- package/src/hooks/__tests__/useRenderToolCall.test.tsx +160 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useComponent.tsx +69 -0
- package/src/hooks/useRenderToolCall.ts +75 -0
- package/src/index.ts +4 -1
- package/dist/useRenderTool-DLavcsVB.cjs.map +0 -1
- package/dist/useRenderTool-DUqpS97B.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderToolContext-CBNKcJqz.cjs","names":[],"sources":["../src/hooks/RenderToolContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\n\n/**\n * Props passed to a render tool function.\n */\nexport interface RenderToolProps<T = Record<string, unknown>> {\n args: T
|
|
1
|
+
{"version":3,"file":"RenderToolContext-CBNKcJqz.cjs","names":[],"sources":["../src/hooks/RenderToolContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\n\n/**\n * Props passed to a render tool function.\n */\nexport interface RenderToolProps<T = Record<string, unknown>> {\n /**\n * The tool call arguments.\n *\n * While the call is still streaming (`status: \"inProgress\"`) these are PARTIAL: the model has not\n * finished writing the JSON, so fields arrive progressively and arrays fill in. Renderers must\n * tolerate missing fields — that is what allows UI to build as the agent writes it rather than\n * appearing all at once when the call completes.\n */\n args: Partial<T> & Record<string, unknown>;\n /**\n * \"inProgress\" — arguments are still streaming; `args` is incomplete.\n * \"executing\" — arguments are complete and the handler (if any) is running.\n * \"complete\" — the handler finished; `result` is populated.\n */\n status: \"inProgress\" | \"executing\" | \"complete\";\n result?: string;\n}\n\n/**\n * A render function that returns a React Native element for a tool call.\n * Returns `ReactElement | null` (not ReactNode) because React Native's\n * FlatList cannot render strings or portals.\n */\nexport type RenderToolFunction<T = Record<string, unknown>> = (\n props: RenderToolProps<T>,\n) => React.ReactElement | null;\n\n/**\n * The registry maps tool names to their render functions.\n */\nexport type RenderToolRegistry = Map<string, RenderToolFunction>;\n\n/**\n * Internal store that notifies subscribers when the registry changes.\n * This avoids unnecessary re-renders of the entire tree when a single\n * tool's render function is registered or removed.\n */\ninterface RegistryStore {\n registry: RenderToolRegistry;\n version: number;\n listeners: Set<() => void>;\n}\n\nfunction createRegistryStore(): RegistryStore {\n return {\n registry: new Map(),\n version: 0,\n listeners: new Set(),\n };\n}\n\nfunction emitChange(store: RegistryStore) {\n store.version++;\n // Create a new Map so useSyncExternalStore detects the reference change\n store.registry = new Map(store.registry);\n for (const listener of store.listeners) {\n listener();\n }\n}\n\ninterface RenderToolContextValue {\n store: RegistryStore;\n register: (name: string, render: RenderToolFunction) => () => void;\n}\n\nconst RenderToolCtx = createContext<RenderToolContextValue | null>(null);\n\n/**\n * Provider that maintains the render tool registry.\n * Should be nested inside CopilotKitProvider.\n */\nexport function RenderToolProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const storeRef = useRef<RegistryStore>(createRegistryStore());\n\n const register = useCallback(\n (name: string, render: RenderToolFunction): (() => void) => {\n const store = storeRef.current;\n store.registry.set(name, render);\n emitChange(store);\n\n // Return unregister function\n return () => {\n // Only delete if the current render function is the one we registered\n if (store.registry.get(name) === render) {\n store.registry.delete(name);\n emitChange(store);\n }\n };\n },\n [],\n );\n\n const value = useMemo<RenderToolContextValue>(\n () => ({ store: storeRef.current, register }),\n [register],\n );\n\n return (\n <RenderToolCtx.Provider value={value}>{children}</RenderToolCtx.Provider>\n );\n}\n\n/**\n * Returns the current render tool registry (a Map of tool name to render function).\n * Re-renders when the registry changes.\n *\n * @throws if called outside of RenderToolProvider\n */\nexport function useRenderToolRegistry(): RenderToolRegistry {\n const ctx = useContext(RenderToolCtx);\n if (!ctx) {\n throw new Error(\n \"useRenderToolRegistry must be used within a RenderToolProvider\",\n );\n }\n\n const { store } = ctx;\n\n // Subscribe to registry changes via useSyncExternalStore for tear-safe reads\n return useSyncExternalStore(\n (onStoreChange) => {\n store.listeners.add(onStoreChange);\n return () => {\n store.listeners.delete(onStoreChange);\n };\n },\n () => store.registry,\n () => store.registry,\n );\n}\n\n/**\n * Internal hook used by useRenderTool to register a render function.\n * Not exported from the package — consumers use useRenderTool instead.\n *\n * @throws if called outside of RenderToolProvider\n */\nexport function useRenderToolContext() {\n const ctx = useContext(RenderToolCtx);\n if (!ctx) {\n throw new Error(\n \"useRenderTool must be used within a RenderToolProvider (inside CopilotKitProvider)\",\n );\n }\n return ctx;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAS,sBAAqC;AAC5C,QAAO;EACL,0BAAU,IAAI,KAAK;EACnB,SAAS;EACT,2BAAW,IAAI,KAAK;EACrB;;AAGH,SAAS,WAAW,OAAsB;AACxC,OAAM;AAEN,OAAM,WAAW,IAAI,IAAI,MAAM,SAAS;AACxC,MAAK,MAAM,YAAY,MAAM,UAC3B,WAAU;;AASd,MAAM,yCAA6D,KAAK;;;;;AAMxE,SAAgB,mBAAmB,EACjC,YAGC;CACD,MAAM,6BAAiC,qBAAqB,CAAC;CAE7D,MAAM,mCACH,MAAc,WAA6C;EAC1D,MAAM,QAAQ,SAAS;AACvB,QAAM,SAAS,IAAI,MAAM,OAAO;AAChC,aAAW,MAAM;AAGjB,eAAa;AAEX,OAAI,MAAM,SAAS,IAAI,KAAK,KAAK,QAAQ;AACvC,UAAM,SAAS,OAAO,KAAK;AAC3B,eAAW,MAAM;;;IAIvB,EAAE,CACH;CAED,MAAM,kCACG;EAAE,OAAO,SAAS;EAAS;EAAU,GAC5C,CAAC,SAAS,CACX;AAED,QACE,2CAAC,cAAc;EAAgB;EAAQ;GAAkC;;;;;;;;AAU7E,SAAgB,wBAA4C;CAC1D,MAAM,4BAAiB,cAAc;AACrC,KAAI,CAAC,IACH,OAAM,IAAI,MACR,iEACD;CAGH,MAAM,EAAE,UAAU;AAGlB,yCACG,kBAAkB;AACjB,QAAM,UAAU,IAAI,cAAc;AAClC,eAAa;AACX,SAAM,UAAU,OAAO,cAAc;;UAGnC,MAAM,gBACN,MAAM,SACb;;;;;;;;AASH,SAAgB,uBAAuB;CACrC,MAAM,4BAAiB,cAAc;AACrC,KAAI,CAAC,IACH,OAAM,IAAI,MACR,qFACD;AAEH,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderToolContext-D8M-JhD1.mjs","names":[],"sources":["../src/hooks/RenderToolContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\n\n/**\n * Props passed to a render tool function.\n */\nexport interface RenderToolProps<T = Record<string, unknown>> {\n args: T
|
|
1
|
+
{"version":3,"file":"RenderToolContext-D8M-JhD1.mjs","names":[],"sources":["../src/hooks/RenderToolContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\n\n/**\n * Props passed to a render tool function.\n */\nexport interface RenderToolProps<T = Record<string, unknown>> {\n /**\n * The tool call arguments.\n *\n * While the call is still streaming (`status: \"inProgress\"`) these are PARTIAL: the model has not\n * finished writing the JSON, so fields arrive progressively and arrays fill in. Renderers must\n * tolerate missing fields — that is what allows UI to build as the agent writes it rather than\n * appearing all at once when the call completes.\n */\n args: Partial<T> & Record<string, unknown>;\n /**\n * \"inProgress\" — arguments are still streaming; `args` is incomplete.\n * \"executing\" — arguments are complete and the handler (if any) is running.\n * \"complete\" — the handler finished; `result` is populated.\n */\n status: \"inProgress\" | \"executing\" | \"complete\";\n result?: string;\n}\n\n/**\n * A render function that returns a React Native element for a tool call.\n * Returns `ReactElement | null` (not ReactNode) because React Native's\n * FlatList cannot render strings or portals.\n */\nexport type RenderToolFunction<T = Record<string, unknown>> = (\n props: RenderToolProps<T>,\n) => React.ReactElement | null;\n\n/**\n * The registry maps tool names to their render functions.\n */\nexport type RenderToolRegistry = Map<string, RenderToolFunction>;\n\n/**\n * Internal store that notifies subscribers when the registry changes.\n * This avoids unnecessary re-renders of the entire tree when a single\n * tool's render function is registered or removed.\n */\ninterface RegistryStore {\n registry: RenderToolRegistry;\n version: number;\n listeners: Set<() => void>;\n}\n\nfunction createRegistryStore(): RegistryStore {\n return {\n registry: new Map(),\n version: 0,\n listeners: new Set(),\n };\n}\n\nfunction emitChange(store: RegistryStore) {\n store.version++;\n // Create a new Map so useSyncExternalStore detects the reference change\n store.registry = new Map(store.registry);\n for (const listener of store.listeners) {\n listener();\n }\n}\n\ninterface RenderToolContextValue {\n store: RegistryStore;\n register: (name: string, render: RenderToolFunction) => () => void;\n}\n\nconst RenderToolCtx = createContext<RenderToolContextValue | null>(null);\n\n/**\n * Provider that maintains the render tool registry.\n * Should be nested inside CopilotKitProvider.\n */\nexport function RenderToolProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const storeRef = useRef<RegistryStore>(createRegistryStore());\n\n const register = useCallback(\n (name: string, render: RenderToolFunction): (() => void) => {\n const store = storeRef.current;\n store.registry.set(name, render);\n emitChange(store);\n\n // Return unregister function\n return () => {\n // Only delete if the current render function is the one we registered\n if (store.registry.get(name) === render) {\n store.registry.delete(name);\n emitChange(store);\n }\n };\n },\n [],\n );\n\n const value = useMemo<RenderToolContextValue>(\n () => ({ store: storeRef.current, register }),\n [register],\n );\n\n return (\n <RenderToolCtx.Provider value={value}>{children}</RenderToolCtx.Provider>\n );\n}\n\n/**\n * Returns the current render tool registry (a Map of tool name to render function).\n * Re-renders when the registry changes.\n *\n * @throws if called outside of RenderToolProvider\n */\nexport function useRenderToolRegistry(): RenderToolRegistry {\n const ctx = useContext(RenderToolCtx);\n if (!ctx) {\n throw new Error(\n \"useRenderToolRegistry must be used within a RenderToolProvider\",\n );\n }\n\n const { store } = ctx;\n\n // Subscribe to registry changes via useSyncExternalStore for tear-safe reads\n return useSyncExternalStore(\n (onStoreChange) => {\n store.listeners.add(onStoreChange);\n return () => {\n store.listeners.delete(onStoreChange);\n };\n },\n () => store.registry,\n () => store.registry,\n );\n}\n\n/**\n * Internal hook used by useRenderTool to register a render function.\n * Not exported from the package — consumers use useRenderTool instead.\n *\n * @throws if called outside of RenderToolProvider\n */\nexport function useRenderToolContext() {\n const ctx = useContext(RenderToolCtx);\n if (!ctx) {\n throw new Error(\n \"useRenderTool must be used within a RenderToolProvider (inside CopilotKitProvider)\",\n );\n }\n return ctx;\n}\n"],"mappings":";;;;AAwDA,SAAS,sBAAqC;AAC5C,QAAO;EACL,0BAAU,IAAI,KAAK;EACnB,SAAS;EACT,2BAAW,IAAI,KAAK;EACrB;;AAGH,SAAS,WAAW,OAAsB;AACxC,OAAM;AAEN,OAAM,WAAW,IAAI,IAAI,MAAM,SAAS;AACxC,MAAK,MAAM,YAAY,MAAM,UAC3B,WAAU;;AASd,MAAM,gBAAgB,cAA6C,KAAK;;;;;AAMxE,SAAgB,mBAAmB,EACjC,YAGC;CACD,MAAM,WAAW,OAAsB,qBAAqB,CAAC;CAE7D,MAAM,WAAW,aACd,MAAc,WAA6C;EAC1D,MAAM,QAAQ,SAAS;AACvB,QAAM,SAAS,IAAI,MAAM,OAAO;AAChC,aAAW,MAAM;AAGjB,eAAa;AAEX,OAAI,MAAM,SAAS,IAAI,KAAK,KAAK,QAAQ;AACvC,UAAM,SAAS,OAAO,KAAK;AAC3B,eAAW,MAAM;;;IAIvB,EAAE,CACH;CAED,MAAM,QAAQ,eACL;EAAE,OAAO,SAAS;EAAS;EAAU,GAC5C,CAAC,SAAS,CACX;AAED,QACE,oBAAC,cAAc;EAAgB;EAAQ;GAAkC;;;;;;;;AAU7E,SAAgB,wBAA4C;CAC1D,MAAM,MAAM,WAAW,cAAc;AACrC,KAAI,CAAC,IACH,OAAM,IAAI,MACR,iEACD;CAGH,MAAM,EAAE,UAAU;AAGlB,QAAO,sBACJ,kBAAkB;AACjB,QAAM,UAAU,IAAI,cAAc;AAClC,eAAa;AACX,SAAM,UAAU,OAAO,cAAc;;UAGnC,MAAM,gBACN,MAAM,SACb;;;;;;;;AASH,SAAgB,uBAAuB;CACrC,MAAM,MAAM,WAAW,cAAc;AACrC,KAAI,CAAC,IACH,OAAM,IAAI,MACR,qFACD;AAEH,QAAO"}
|
|
@@ -4,6 +4,7 @@ let react = require("react");
|
|
|
4
4
|
react = require_RenderToolContext.__toESM(react);
|
|
5
5
|
let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
|
|
6
6
|
let _copilotkit_react_core_v2_headless = require("@copilotkit/react-core/v2/headless");
|
|
7
|
+
let _copilotkit_shared = require("@copilotkit/shared");
|
|
7
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
9
|
let react_native = require("react-native");
|
|
9
10
|
let react_native_streamdown = require("react-native-streamdown");
|
|
@@ -400,16 +401,17 @@ function CopilotChat({ agentName = "default", placeholder = "Type a message...",
|
|
|
400
401
|
const tc = item.toolCalls[0];
|
|
401
402
|
const renderer = toolRenderers.get(tc.function.name);
|
|
402
403
|
if (renderer) {
|
|
403
|
-
|
|
404
|
+
const raw = tc.function.arguments || "{}";
|
|
405
|
+
const args = (0, _copilotkit_shared.partialJSONParse)(raw);
|
|
406
|
+
let argsComplete = true;
|
|
404
407
|
try {
|
|
405
|
-
|
|
406
|
-
} catch
|
|
407
|
-
|
|
408
|
+
JSON.parse(raw);
|
|
409
|
+
} catch {
|
|
410
|
+
argsComplete = false;
|
|
408
411
|
}
|
|
409
|
-
const status = executingToolCallIds.has(tc.id) ? "executing" : "complete";
|
|
410
412
|
return renderer({
|
|
411
413
|
args,
|
|
412
|
-
status
|
|
414
|
+
status: !argsComplete ? "inProgress" : executingToolCallIds.has(tc.id) ? "executing" : "complete"
|
|
413
415
|
});
|
|
414
416
|
}
|
|
415
417
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["StreamdownText","Animated","styles","View","StyleSheet","TIMESTAMP_COLOR","View","styles","Text","StyleSheet","View","styles","Text","StyleSheet","FlatList","useRenderToolRegistry","View","styles","Text","Pressable","TextInput","TouchableOpacity","KeyboardAvoidingView","Platform","StyleSheet","BottomSheetBackdrop","BottomSheet","BottomSheetView","BottomSheetFlatList","StyleSheet"],"sources":["../../src/components/Markdown.tsx","../../src/components/messages/TypingIndicator.tsx","../../src/components/messages/utils.ts","../../src/components/messages/AssistantMessage.tsx","../../src/components/messages/UserMessage.tsx","../../src/components/CopilotChat.tsx","../../src/components/CopilotModal.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { StreamdownText } from \"react-native-streamdown\";\n\n/**\n * Style object accepted by `react-native-enriched-markdown` (and therefore\n * `react-native-streamdown`). Each key targets a markdown element; the\n * available properties vary per element — see the enriched-markdown style\n * reference for the full list.\n */\nexport type MarkdownStyle = Record<string, Record<string, unknown>>;\n\n/**\n * Props for the CopilotMarkdown component.\n */\nexport interface CopilotMarkdownProps {\n /** Markdown string to render. */\n content: string;\n /** Optional style overrides merged on top of the defaults. */\n style?: MarkdownStyle;\n /** Whether to enable the streaming fade-in animation (default: true). */\n streamingAnimation?: boolean;\n}\n\n/**\n * Default markdown styles tuned for chat bubble display.\n *\n * Exported so consumers can spread and extend:\n * ```ts\n * import { defaultMarkdownStyles } from \"@copilotkit/react-native\";\n * const custom = { ...defaultMarkdownStyles, h1: { fontSize: 28 } };\n * ```\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n paragraph: {\n fontSize: 16,\n lineHeight: 24,\n color: \"#1a1a1a\",\n marginTop: 4,\n marginBottom: 4,\n },\n h1: {\n fontSize: 24,\n fontWeight: \"bold\",\n marginTop: 12,\n marginBottom: 8,\n color: \"#111111\",\n },\n h2: {\n fontSize: 20,\n fontWeight: \"bold\",\n marginTop: 10,\n marginBottom: 6,\n color: \"#111111\",\n },\n h3: {\n fontSize: 18,\n fontWeight: \"600\",\n marginTop: 8,\n marginBottom: 4,\n color: \"#222222\",\n },\n strong: {\n fontWeight: \"bold\",\n },\n em: {\n fontStyle: \"italic\",\n },\n link: {\n color: \"#0066cc\",\n underline: true,\n },\n blockquote: {\n backgroundColor: \"#f5f5f5\",\n borderWidth: 4,\n borderColor: \"#cccccc\",\n gapWidth: 12,\n },\n code: {\n backgroundColor: \"#f0f0f0\",\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n codeBlock: {\n backgroundColor: \"#f0f0f0\",\n borderRadius: 8,\n padding: 12,\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n list: {\n marginTop: 4,\n marginBottom: 4,\n },\n};\n\n/**\n * Renders markdown content using `react-native-streamdown` with\n * pre-configured styles suited for CopilotKit chat bubbles.\n *\n * `react-native-streamdown` processes incomplete streaming markdown in the\n * background, rendering incrementally without visual glitches — ideal for\n * displaying LLM output as it arrives.\n *\n * Custom styles are merged on top of the defaults so callers only need\n * to override what they want to change.\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = true,\n}: CopilotMarkdownProps) {\n const mergedStyles = useMemo(() => {\n if (!style) return defaultMarkdownStyles;\n return { ...defaultMarkdownStyles, ...style };\n }, [style]);\n\n return (\n <StreamdownText\n markdown={content}\n markdownStyle={mergedStyles}\n streamingAnimation={streamingAnimation}\n />\n );\n}\n","import React, { useEffect, useRef } from \"react\";\nimport { View, Animated, StyleSheet } from \"react-native\";\nimport type { ViewStyle } from \"react-native\";\n\n/**\n * Props for the TypingIndicator component.\n */\nexport interface TypingIndicatorProps {\n /** Optional style override for the container */\n style?: ViewStyle;\n}\n\nconst DOT_SIZE = 6;\nconst DOT_SPACING = 4;\nconst ANIMATION_DURATION = 400;\n\n/**\n * Three animated dots that pulse in sequence, suitable for embedding\n * inside an AssistantMessage to indicate the AI is still generating.\n *\n * Uses React Native's built-in `Animated` API (no Reanimated dependency).\n */\nexport function TypingIndicator({ style }: TypingIndicatorProps) {\n const dot1 = useRef(new Animated.Value(0)).current;\n const dot2 = useRef(new Animated.Value(0)).current;\n const dot3 = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n const createPulse = (dot: Animated.Value, delay: number) =>\n Animated.sequence([\n Animated.delay(delay),\n Animated.loop(\n Animated.sequence([\n Animated.timing(dot, {\n toValue: 1,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n Animated.timing(dot, {\n toValue: 0,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n ]),\n ),\n ]);\n\n const animation = Animated.parallel([\n createPulse(dot1, 0),\n createPulse(dot2, ANIMATION_DURATION * 0.33),\n createPulse(dot3, ANIMATION_DURATION * 0.66),\n ]);\n\n animation.start();\n\n return () => {\n animation.stop();\n };\n }, [dot1, dot2, dot3]);\n\n const dotStyle = (animatedValue: Animated.Value) => ({\n ...styles.dot,\n opacity: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.3, 1],\n }),\n transform: [\n {\n scale: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.8, 1.2],\n }),\n },\n ],\n });\n\n return (\n <View\n testID=\"copilot-loading-cursor\"\n style={[styles.container, style]}\n accessibilityLabel=\"Typing indicator\"\n accessibilityRole=\"text\"\n >\n <Animated.View style={dotStyle(dot1)} />\n <Animated.View style={dotStyle(dot2)} />\n <Animated.View style={dotStyle(dot3)} />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: \"row\",\n alignItems: \"center\",\n paddingVertical: 4,\n paddingHorizontal: 2,\n },\n dot: {\n width: DOT_SIZE,\n height: DOT_SIZE,\n borderRadius: DOT_SIZE / 2,\n backgroundColor: \"#999999\",\n marginHorizontal: DOT_SPACING / 2,\n },\n});\n","/**\n * Format a Date as a 12-hour time string (e.g. \"2:05 PM\").\n */\nexport function formatTimestamp(date: Date): string {\n const hours = date.getHours();\n const minutes = date.getMinutes();\n const ampm = hours >= 12 ? \"PM\" : \"AM\";\n const displayHours = hours % 12 || 12;\n const displayMinutes = minutes.toString().padStart(2, \"0\");\n return `${displayHours}:${displayMinutes} ${ampm}`;\n}\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { CopilotMarkdown } from \"../Markdown\";\nimport { TypingIndicator } from \"./TypingIndicator\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst ASSISTANT_BUBBLE_BG = \"#F0F0F0\";\nconst ASSISTANT_TEXT_COLOR = \"#1A1A1A\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the AssistantMessage component.\n */\nexport interface AssistantMessageProps {\n /** Markdown content to render inside the bubble */\n content: string;\n /** When true, shows a typing indicator instead of content */\n isLoading?: boolean;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Left-aligned chat bubble for AI assistant responses.\n *\n * Renders markdown content via `CopilotMarkdown` and shows an animated\n * typing indicator when `isLoading` is true.\n */\nexport function AssistantMessage({\n content,\n isLoading = false,\n timestamp,\n style,\n}: AssistantMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n {content ? <CopilotMarkdown content={content} /> : null}\n {isLoading ? <TypingIndicator /> : null}\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-start\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: ASSISTANT_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomRightRadius: 16,\n borderBottomLeftRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginLeft: 4,\n },\n});\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst USER_BUBBLE_BG = \"#0066CC\";\nconst USER_TEXT_COLOR = \"#FFFFFF\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the UserMessage component.\n */\nexport interface UserMessageProps {\n /** Plain text content to display */\n content: string;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Right-aligned chat bubble for user messages.\n *\n * Renders plain text (no markdown) with a primary-color background\n * and white text. Optionally displays a subtle timestamp below.\n */\nexport function UserMessage({ content, timestamp, style }: UserMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n <Text style={styles.text}>{content}</Text>\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-end\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: USER_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomLeftRadius: 16,\n borderBottomRightRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n text: {\n color: USER_TEXT_COLOR,\n fontSize: 16,\n lineHeight: 22,\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginRight: 4,\n },\n});\n","import React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n FlatList,\n KeyboardAvoidingView,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n type ListRenderItemInfo,\n type ViewStyle,\n} from \"react-native\";\nimport { useAgent } from \"@copilotkit/react-core/v2/headless\";\nimport { useCopilotKit } from \"@copilotkit/react-core/v2/context\";\nimport { AssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage } from \"./messages/UserMessage\";\nimport { useRenderToolRegistry } from \"../hooks/RenderToolContext\";\nimport type { Message } from \"@copilotkit/shared\";\n\n/** Shape of an assistant message with optional tool calls. */\ninterface AssistantMessageShape {\n id: string;\n role: \"assistant\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\nexport interface CopilotChatProps {\n /** Agent ID to connect to. Defaults to 'default'. */\n agentName?: string;\n /** Placeholder text for the input field. */\n placeholder?: string;\n /** Suggestion pills shown in the empty state. */\n initialMessages?: string[];\n /** Title shown when there are no messages. */\n emptyStateTitle?: string;\n /** Subtitle shown when there are no messages. */\n emptyStateSubtitle?: string;\n /** Title for the optional header bar. */\n headerTitle?: string;\n /** Whether to show the header bar. Defaults to true. */\n showHeader?: boolean;\n /** Style override for the outermost container. */\n style?: ViewStyle;\n /** Style override for the message list container. */\n messageContainerStyle?: ViewStyle;\n /** Style override for the input bar container. */\n inputContainerStyle?: ViewStyle;\n /** Callback fired when the user sends a message. */\n onSendMessage?: (text: string) => void;\n /** Custom FlatList component (e.g. BottomSheetFlatList for use inside a bottom sheet). */\n FlatListComponent?: React.ComponentType<any>;\n /** When true, skip the KeyboardAvoidingView wrapper (useful when a parent already handles keyboard). */\n disableKeyboardAvoiding?: boolean;\n}\n\ninterface ChatListItem {\n id: string;\n type: \"user\" | \"assistant\" | \"tool-call\" | \"loading\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\n/**\n * Full-screen chat UI component for React Native.\n *\n * Connects to a CopilotKit agent via `useAgent` and renders messages\n * using platform-appropriate AssistantMessage / UserMessage components.\n *\n * Usage:\n * ```tsx\n * <CopilotChat agentName=\"my-agent\" headerTitle=\"Assistant\" />\n * ```\n */\nexport function CopilotChat({\n agentName = \"default\",\n placeholder = \"Type a message...\",\n initialMessages = [],\n emptyStateTitle = \"How can I help?\",\n emptyStateSubtitle = \"Ask me anything or try a suggestion below.\",\n headerTitle = \"Chat\",\n showHeader = true,\n style,\n messageContainerStyle,\n inputContainerStyle,\n onSendMessage,\n FlatListComponent = FlatList,\n disableKeyboardAvoiding = false,\n}: CopilotChatProps) {\n const [inputText, setInputText] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n const flatListRef = useRef<FlatList>(null);\n const messageIdCounter = useRef(0);\n\n const { copilotkit, executingToolCallIds } = useCopilotKit();\n const { agent } = useAgent({ agentId: agentName });\n\n const messages = agent.messages ?? [];\n const isRunning = agent.isRunning;\n\n const toolRenderers = useRenderToolRegistry();\n\n // Stable extraData for FlatList to avoid re-creating the object every render\n const extraData = useMemo(\n () => ({ isRunning, executingToolCallIds, toolRenderers }),\n [isRunning, executingToolCallIds, toolRenderers],\n );\n\n // Build flat list items from messages\n const listItems: ChatListItem[] = useMemo(() => {\n const items: ChatListItem[] = [];\n\n for (const msg of messages) {\n if (msg.role === \"user\") {\n items.push({\n id: msg.id,\n type: \"user\",\n content: typeof msg.content === \"string\" ? msg.content : \"\",\n });\n } else if (msg.role === \"assistant\") {\n const assistantMsg = msg as AssistantMessageShape;\n // Add text content if present\n if (assistantMsg.content) {\n items.push({\n id: msg.id,\n type: \"assistant\",\n content: assistantMsg.content,\n });\n }\n // Add tool calls if present\n if (assistantMsg.toolCalls && assistantMsg.toolCalls.length > 0) {\n for (const tc of assistantMsg.toolCalls) {\n items.push({\n id: `${msg.id}-tc-${tc.id}`,\n type: \"tool-call\",\n toolCalls: [tc],\n });\n }\n }\n }\n }\n\n // Show loading indicator when agent is running and the last message\n // is not already the assistant streaming\n if (isRunning) {\n const lastItem = items[items.length - 1];\n if (!lastItem || lastItem.type !== \"assistant\") {\n items.push({ id: \"__loading__\", type: \"loading\" });\n }\n }\n\n return items;\n }, [messages, isRunning]);\n\n // Shared logic for sending a message to the agent\n const sendMessage = useCallback(\n async (text: string) => {\n if (!text || isRunning || !agent) return;\n\n setError(null);\n onSendMessage?.(text);\n\n const id = `user-${++messageIdCounter.current}`;\n agent.addMessage({\n id,\n role: \"user\",\n content: text,\n } as Message);\n\n try {\n await copilotkit.runAgent({ agent });\n } catch (err) {\n const message =\n err instanceof Error ? err.message : \"An unexpected error occurred\";\n console.error(\"[CopilotChat] runAgent failed:\", err);\n setError(message);\n }\n },\n [isRunning, agent, copilotkit, onSendMessage],\n );\n\n // Send from the input field\n const handleSend = useCallback(async () => {\n const text = inputText.trim();\n if (!text) return;\n setInputText(\"\");\n await sendMessage(text);\n }, [inputText, sendMessage]);\n\n // Handle suggestion pill press\n const handleSuggestion = useCallback(\n (text: string) => {\n void sendMessage(text);\n },\n [sendMessage],\n );\n\n // Auto-scroll when content changes\n const handleContentSizeChange = useCallback(() => {\n flatListRef.current?.scrollToEnd({ animated: true });\n }, []);\n\n // Render a single list item\n const renderItem = useCallback(\n ({ item }: ListRenderItemInfo<ChatListItem>) => {\n if (item.type === \"user\") {\n return <UserMessage content={item.content ?? \"\"} />;\n }\n\n if (item.type === \"assistant\") {\n return (\n <AssistantMessage\n content={item.content ?? \"\"}\n isLoading={\n isRunning && item.id === listItems[listItems.length - 1]?.id\n }\n />\n );\n }\n\n if (item.type === \"tool-call\" && item.toolCalls) {\n const tc = item.toolCalls[0];\n const renderer = toolRenderers.get(tc.function.name);\n if (renderer) {\n let args: Record<string, unknown> = {};\n try {\n args = JSON.parse(tc.function.arguments || \"{}\");\n } catch (e) {\n console.warn(\n `[CopilotChat] Failed to parse tool call arguments for ${tc.function.name}:`,\n e,\n );\n }\n const status = executingToolCallIds.has(tc.id)\n ? \"executing\"\n : \"complete\";\n return renderer({ args, status });\n }\n // Subtle indicator for unregistered tool calls\n return (\n <View style={styles.toolCallIndicator}>\n <Text style={styles.toolCallText}>Called: {tc.function.name}</Text>\n </View>\n );\n }\n\n if (item.type === \"loading\") {\n return <AssistantMessage content=\"\" isLoading />;\n }\n\n return null;\n },\n [isRunning, listItems, toolRenderers, executingToolCallIds],\n );\n\n const keyExtractor = useCallback((item: ChatListItem) => item.id, []);\n\n // Empty state component\n const emptyComponent = useMemo(\n () => (\n <View style={styles.emptyState}>\n <Text style={styles.emptyTitle}>{emptyStateTitle}</Text>\n <Text style={styles.emptySubtitle}>{emptyStateSubtitle}</Text>\n {initialMessages.map((suggestion, i) => (\n <Pressable\n key={`suggestion-${i}`}\n style={styles.suggestionPill}\n onPress={() => handleSuggestion(suggestion)}\n >\n <Text style={styles.suggestionText}>{suggestion}</Text>\n </Pressable>\n ))}\n </View>\n ),\n [emptyStateTitle, emptyStateSubtitle, initialMessages, handleSuggestion],\n );\n\n const sendDisabled = !inputText.trim() || isRunning;\n\n const content = (\n <>\n {showHeader && (\n <View style={styles.header}>\n <Text style={styles.headerTitle}>{headerTitle}</Text>\n </View>\n )}\n\n <FlatListComponent\n ref={flatListRef}\n data={listItems}\n renderItem={renderItem}\n keyExtractor={keyExtractor}\n extraData={extraData}\n contentContainerStyle={[styles.messageList, messageContainerStyle]}\n onContentSizeChange={handleContentSizeChange}\n ListEmptyComponent={emptyComponent}\n />\n\n {error && (\n <View style={styles.errorContainer} testID=\"error-message\">\n <Text style={styles.errorText}>{error}</Text>\n </View>\n )}\n\n <View style={[styles.inputContainer, inputContainerStyle]}>\n <TextInput\n style={styles.input}\n value={inputText}\n onChangeText={setInputText}\n placeholder={placeholder}\n placeholderTextColor=\"#999\"\n multiline\n numberOfLines={4}\n returnKeyType=\"send\"\n onSubmitEditing={handleSend}\n />\n <TouchableOpacity\n style={[styles.sendButton, sendDisabled && styles.sendButtonDisabled]}\n onPress={handleSend}\n disabled={sendDisabled}\n testID=\"send-button\"\n >\n <Text style={styles.sendButtonIcon}>{\"↑\"}</Text>\n </TouchableOpacity>\n </View>\n </>\n );\n\n if (disableKeyboardAvoiding) {\n return <View style={[styles.container, style]}>{content}</View>;\n }\n\n return (\n <KeyboardAvoidingView\n style={[styles.container, style]}\n behavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n keyboardVerticalOffset={0}\n >\n {content}\n </KeyboardAvoidingView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"#FFFFFF\",\n },\n header: {\n height: 56,\n justifyContent: \"center\",\n alignItems: \"center\",\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderBottomColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n headerTitle: {\n fontSize: 17,\n fontWeight: \"600\",\n color: \"#1A1A1A\",\n },\n messageList: {\n paddingHorizontal: 16,\n flexGrow: 1,\n },\n inputContainer: {\n flexDirection: \"row\",\n alignItems: \"flex-end\",\n paddingHorizontal: 8,\n paddingVertical: 8,\n borderTopWidth: StyleSheet.hairlineWidth,\n borderTopColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n input: {\n flex: 1,\n backgroundColor: \"#F5F5F5\",\n borderRadius: 20,\n paddingHorizontal: 12,\n paddingVertical: 8,\n fontSize: 15,\n maxHeight: 100,\n color: \"#1A1A1A\",\n },\n sendButton: {\n width: 36,\n height: 36,\n borderRadius: 18,\n backgroundColor: \"#0066CC\",\n justifyContent: \"center\",\n alignItems: \"center\",\n marginLeft: 8,\n },\n sendButtonDisabled: {\n opacity: 0.4,\n },\n sendButtonIcon: {\n color: \"#FFFFFF\",\n fontSize: 18,\n fontWeight: \"700\",\n },\n emptyState: {\n flex: 1,\n justifyContent: \"center\",\n alignItems: \"center\",\n paddingTop: 100,\n gap: 12,\n },\n emptyTitle: {\n fontSize: 22,\n fontWeight: \"700\",\n color: \"#1A1A1A\",\n marginBottom: 4,\n },\n emptySubtitle: {\n fontSize: 15,\n color: \"#666666\",\n marginBottom: 16,\n },\n suggestionPill: {\n backgroundColor: \"#E8F0FE\",\n borderRadius: 20,\n paddingHorizontal: 16,\n paddingVertical: 10,\n },\n suggestionText: {\n color: \"#0066CC\",\n fontWeight: \"600\",\n fontSize: 14,\n },\n toolCallIndicator: {\n alignSelf: \"flex-start\",\n backgroundColor: \"#F0F0F0\",\n borderRadius: 12,\n paddingHorizontal: 12,\n paddingVertical: 6,\n marginBottom: 8,\n },\n toolCallText: {\n fontSize: 12,\n color: \"#999999\",\n fontStyle: \"italic\",\n },\n errorContainer: {\n backgroundColor: \"#FEE2E2\",\n paddingHorizontal: 12,\n paddingVertical: 8,\n marginHorizontal: 8,\n borderRadius: 8,\n },\n errorText: {\n color: \"#DC2626\",\n fontSize: 13,\n },\n});\n","/**\n * CopilotModal — a bottom-sheet chat overlay for React Native.\n *\n * Mobile equivalent of CopilotPopup on web. Wraps CopilotChat inside\n * @gorhom/bottom-sheet so the chat can slide up over any screen.\n */\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport { StyleSheet, View } from \"react-native\";\nimport BottomSheet, {\n BottomSheetBackdrop,\n BottomSheetFlatList,\n BottomSheetView,\n} from \"@gorhom/bottom-sheet\";\nimport type { BottomSheetBackdropProps } from \"@gorhom/bottom-sheet\";\nimport { CopilotChat } from \"./CopilotChat\";\nimport type { CopilotChatProps } from \"./CopilotChat\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface CopilotModalProps {\n /** Controlled visibility — when true the sheet opens, when false it closes. */\n visible?: boolean;\n\n /** Called when the sheet is dismissed (via backdrop tap, swipe-down, or close()). */\n onDismiss?: () => void;\n\n /**\n * Bottom-sheet snap points.\n * @default ['50%', '90%']\n */\n snapPoints?: (string | number)[];\n\n /**\n * Which snap-point index to open at.\n * @default 0\n */\n initialSnapIndex?: number;\n\n /**\n * Whether closing the sheet fires onDismiss.\n * @default true\n */\n enableDismissOnClose?: boolean;\n\n /**\n * Backdrop opacity when the sheet is open.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n // -- Pass-through to CopilotChat ------------------------------------------\n\n /** Which agent to connect to. */\n agentName?: string;\n\n /** Input placeholder text. */\n placeholder?: string;\n\n /** Seed messages shown on first render. */\n initialMessages?: string[];\n\n /** Title shown in the CopilotChat header area. */\n headerTitle?: string;\n}\n\n/** Imperative handle exposed via ref. */\nexport interface CopilotModalRef {\n /** Programmatically open the bottom sheet. */\n open: () => void;\n /** Programmatically close the bottom sheet. */\n close: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\nexport const CopilotModal = forwardRef<CopilotModalRef, CopilotModalProps>(\n function CopilotModal(\n {\n visible,\n onDismiss,\n snapPoints: snapPointsProp,\n initialSnapIndex = 0,\n enableDismissOnClose = true,\n backdropOpacity = 0.5,\n agentName,\n placeholder,\n initialMessages,\n headerTitle,\n },\n ref,\n ) {\n const bottomSheetRef = useRef<BottomSheet>(null);\n\n // Stable snap-points array\n const snapPoints = useMemo(\n () => snapPointsProp ?? [\"50%\", \"90%\"],\n [snapPointsProp],\n );\n\n // ── Imperative API ────────────────────────────────────────────────────\n useImperativeHandle(\n ref,\n () => ({\n open() {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n },\n close() {\n bottomSheetRef.current?.close();\n },\n }),\n [initialSnapIndex],\n );\n\n // ── Controlled visibility ─────────────────────────────────────────────\n useEffect(() => {\n if (visible === undefined) return;\n if (visible) {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n } else {\n bottomSheetRef.current?.close();\n }\n }, [visible, initialSnapIndex]);\n\n // ── Backdrop renderer ─────────────────────────────────────────────────\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n disappearsOnIndex={-1}\n appearsOnIndex={0}\n opacity={backdropOpacity}\n pressBehavior=\"close\"\n />\n ),\n [backdropOpacity],\n );\n\n // ── Sheet close handler ───────────────────────────────────────────────\n const handleClose = useCallback(() => {\n if (enableDismissOnClose) {\n onDismiss?.();\n }\n }, [enableDismissOnClose, onDismiss]);\n\n // ── Build CopilotChat props ───────────────────────────────────────────\n const chatProps = useMemo(() => {\n const props: Partial<CopilotChatProps> = {};\n if (agentName !== undefined) props.agentName = agentName;\n if (placeholder !== undefined) props.placeholder = placeholder;\n if (initialMessages !== undefined)\n props.initialMessages = initialMessages;\n if (headerTitle !== undefined) props.headerTitle = headerTitle;\n return props;\n }, [agentName, placeholder, initialMessages, headerTitle]);\n\n return (\n <BottomSheet\n ref={bottomSheetRef}\n index={-1}\n snapPoints={snapPoints}\n enablePanDownToClose\n backdropComponent={renderBackdrop}\n onClose={handleClose}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n backgroundStyle={styles.sheetBackground}\n handleIndicatorStyle={styles.handleIndicator}\n >\n <BottomSheetView style={styles.contentContainer}>\n <CopilotChat\n {...chatProps}\n FlatListComponent={BottomSheetFlatList}\n disableKeyboardAvoiding\n />\n </BottomSheetView>\n </BottomSheet>\n );\n },\n);\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst styles = StyleSheet.create({\n sheetBackground: {\n backgroundColor: \"#FFFFFF\",\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n },\n handleIndicator: {\n width: 40,\n height: 4,\n backgroundColor: \"#DDDDDD\",\n },\n contentContainer: {\n flex: 1,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,wBAAuC;CAClD,WAAW;EACT,UAAU;EACV,YAAY;EACZ,OAAO;EACP,WAAW;EACX,cAAc;EACf;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WAAW;EACX,cAAc;EACd,OAAO;EACR;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WAAW;EACX,cAAc;EACd,OAAO;EACR;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WAAW;EACX,cAAc;EACd,OAAO;EACR;CACD,QAAQ,EACN,YAAY,QACb;CACD,IAAI,EACF,WAAW,UACZ;CACD,MAAM;EACJ,OAAO;EACP,WAAW;EACZ;CACD,YAAY;EACV,iBAAiB;EACjB,aAAa;EACb,aAAa;EACb,UAAU;EACX;CACD,MAAM;EACJ,iBAAiB;EACjB,YAAY;EACZ,UAAU;EACX;CACD,WAAW;EACT,iBAAiB;EACjB,cAAc;EACd,SAAS;EACT,YAAY;EACZ,UAAU;EACX;CACD,MAAM;EACJ,WAAW;EACX,cAAc;EACf;CACF;;;;;;;;;;;;AAaD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,QACE;AAMvB,QACE,2CAACA;EACC,UAAU;EACV,wCAR+B;AACjC,OAAI,CAAC,MAAO,QAAO;AACnB,UAAO;IAAE,GAAG;IAAuB,GAAG;IAAO;KAC5C,CAAC,MAAM,CAAC;EAMa;GACpB;;;;;AC7GN,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,qBAAqB;;;;;;;AAQ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AChB,MAAM,GACP;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["StreamdownText","Animated","styles","View","StyleSheet","TIMESTAMP_COLOR","View","styles","Text","StyleSheet","View","styles","Text","StyleSheet","FlatList","useRenderToolRegistry","View","styles","Text","Pressable","TextInput","TouchableOpacity","KeyboardAvoidingView","Platform","StyleSheet","BottomSheetBackdrop","BottomSheet","BottomSheetView","BottomSheetFlatList","StyleSheet"],"sources":["../../src/components/Markdown.tsx","../../src/components/messages/TypingIndicator.tsx","../../src/components/messages/utils.ts","../../src/components/messages/AssistantMessage.tsx","../../src/components/messages/UserMessage.tsx","../../src/components/CopilotChat.tsx","../../src/components/CopilotModal.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { StreamdownText } from \"react-native-streamdown\";\n\n/**\n * Style object accepted by `react-native-enriched-markdown` (and therefore\n * `react-native-streamdown`). Each key targets a markdown element; the\n * available properties vary per element — see the enriched-markdown style\n * reference for the full list.\n */\nexport type MarkdownStyle = Record<string, Record<string, unknown>>;\n\n/**\n * Props for the CopilotMarkdown component.\n */\nexport interface CopilotMarkdownProps {\n /** Markdown string to render. */\n content: string;\n /** Optional style overrides merged on top of the defaults. */\n style?: MarkdownStyle;\n /** Whether to enable the streaming fade-in animation (default: true). */\n streamingAnimation?: boolean;\n}\n\n/**\n * Default markdown styles tuned for chat bubble display.\n *\n * Exported so consumers can spread and extend:\n * ```ts\n * import { defaultMarkdownStyles } from \"@copilotkit/react-native\";\n * const custom = { ...defaultMarkdownStyles, h1: { fontSize: 28 } };\n * ```\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n paragraph: {\n fontSize: 16,\n lineHeight: 24,\n color: \"#1a1a1a\",\n marginTop: 4,\n marginBottom: 4,\n },\n h1: {\n fontSize: 24,\n fontWeight: \"bold\",\n marginTop: 12,\n marginBottom: 8,\n color: \"#111111\",\n },\n h2: {\n fontSize: 20,\n fontWeight: \"bold\",\n marginTop: 10,\n marginBottom: 6,\n color: \"#111111\",\n },\n h3: {\n fontSize: 18,\n fontWeight: \"600\",\n marginTop: 8,\n marginBottom: 4,\n color: \"#222222\",\n },\n strong: {\n fontWeight: \"bold\",\n },\n em: {\n fontStyle: \"italic\",\n },\n link: {\n color: \"#0066cc\",\n underline: true,\n },\n blockquote: {\n backgroundColor: \"#f5f5f5\",\n borderWidth: 4,\n borderColor: \"#cccccc\",\n gapWidth: 12,\n },\n code: {\n backgroundColor: \"#f0f0f0\",\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n codeBlock: {\n backgroundColor: \"#f0f0f0\",\n borderRadius: 8,\n padding: 12,\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n list: {\n marginTop: 4,\n marginBottom: 4,\n },\n};\n\n/**\n * Renders markdown content using `react-native-streamdown` with\n * pre-configured styles suited for CopilotKit chat bubbles.\n *\n * `react-native-streamdown` processes incomplete streaming markdown in the\n * background, rendering incrementally without visual glitches — ideal for\n * displaying LLM output as it arrives.\n *\n * Custom styles are merged on top of the defaults so callers only need\n * to override what they want to change.\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = true,\n}: CopilotMarkdownProps) {\n const mergedStyles = useMemo(() => {\n if (!style) return defaultMarkdownStyles;\n return { ...defaultMarkdownStyles, ...style };\n }, [style]);\n\n return (\n <StreamdownText\n markdown={content}\n markdownStyle={mergedStyles}\n streamingAnimation={streamingAnimation}\n />\n );\n}\n","import React, { useEffect, useRef } from \"react\";\nimport { View, Animated, StyleSheet } from \"react-native\";\nimport type { ViewStyle } from \"react-native\";\n\n/**\n * Props for the TypingIndicator component.\n */\nexport interface TypingIndicatorProps {\n /** Optional style override for the container */\n style?: ViewStyle;\n}\n\nconst DOT_SIZE = 6;\nconst DOT_SPACING = 4;\nconst ANIMATION_DURATION = 400;\n\n/**\n * Three animated dots that pulse in sequence, suitable for embedding\n * inside an AssistantMessage to indicate the AI is still generating.\n *\n * Uses React Native's built-in `Animated` API (no Reanimated dependency).\n */\nexport function TypingIndicator({ style }: TypingIndicatorProps) {\n const dot1 = useRef(new Animated.Value(0)).current;\n const dot2 = useRef(new Animated.Value(0)).current;\n const dot3 = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n const createPulse = (dot: Animated.Value, delay: number) =>\n Animated.sequence([\n Animated.delay(delay),\n Animated.loop(\n Animated.sequence([\n Animated.timing(dot, {\n toValue: 1,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n Animated.timing(dot, {\n toValue: 0,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n ]),\n ),\n ]);\n\n const animation = Animated.parallel([\n createPulse(dot1, 0),\n createPulse(dot2, ANIMATION_DURATION * 0.33),\n createPulse(dot3, ANIMATION_DURATION * 0.66),\n ]);\n\n animation.start();\n\n return () => {\n animation.stop();\n };\n }, [dot1, dot2, dot3]);\n\n const dotStyle = (animatedValue: Animated.Value) => ({\n ...styles.dot,\n opacity: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.3, 1],\n }),\n transform: [\n {\n scale: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.8, 1.2],\n }),\n },\n ],\n });\n\n return (\n <View\n testID=\"copilot-loading-cursor\"\n style={[styles.container, style]}\n accessibilityLabel=\"Typing indicator\"\n accessibilityRole=\"text\"\n >\n <Animated.View style={dotStyle(dot1)} />\n <Animated.View style={dotStyle(dot2)} />\n <Animated.View style={dotStyle(dot3)} />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: \"row\",\n alignItems: \"center\",\n paddingVertical: 4,\n paddingHorizontal: 2,\n },\n dot: {\n width: DOT_SIZE,\n height: DOT_SIZE,\n borderRadius: DOT_SIZE / 2,\n backgroundColor: \"#999999\",\n marginHorizontal: DOT_SPACING / 2,\n },\n});\n","/**\n * Format a Date as a 12-hour time string (e.g. \"2:05 PM\").\n */\nexport function formatTimestamp(date: Date): string {\n const hours = date.getHours();\n const minutes = date.getMinutes();\n const ampm = hours >= 12 ? \"PM\" : \"AM\";\n const displayHours = hours % 12 || 12;\n const displayMinutes = minutes.toString().padStart(2, \"0\");\n return `${displayHours}:${displayMinutes} ${ampm}`;\n}\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { CopilotMarkdown } from \"../Markdown\";\nimport { TypingIndicator } from \"./TypingIndicator\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst ASSISTANT_BUBBLE_BG = \"#F0F0F0\";\nconst ASSISTANT_TEXT_COLOR = \"#1A1A1A\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the AssistantMessage component.\n */\nexport interface AssistantMessageProps {\n /** Markdown content to render inside the bubble */\n content: string;\n /** When true, shows a typing indicator instead of content */\n isLoading?: boolean;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Left-aligned chat bubble for AI assistant responses.\n *\n * Renders markdown content via `CopilotMarkdown` and shows an animated\n * typing indicator when `isLoading` is true.\n */\nexport function AssistantMessage({\n content,\n isLoading = false,\n timestamp,\n style,\n}: AssistantMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n {content ? <CopilotMarkdown content={content} /> : null}\n {isLoading ? <TypingIndicator /> : null}\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-start\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: ASSISTANT_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomRightRadius: 16,\n borderBottomLeftRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginLeft: 4,\n },\n});\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst USER_BUBBLE_BG = \"#0066CC\";\nconst USER_TEXT_COLOR = \"#FFFFFF\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the UserMessage component.\n */\nexport interface UserMessageProps {\n /** Plain text content to display */\n content: string;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Right-aligned chat bubble for user messages.\n *\n * Renders plain text (no markdown) with a primary-color background\n * and white text. Optionally displays a subtle timestamp below.\n */\nexport function UserMessage({ content, timestamp, style }: UserMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n <Text style={styles.text}>{content}</Text>\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-end\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: USER_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomLeftRadius: 16,\n borderBottomRightRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n text: {\n color: USER_TEXT_COLOR,\n fontSize: 16,\n lineHeight: 22,\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginRight: 4,\n },\n});\n","import React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n FlatList,\n KeyboardAvoidingView,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n} from \"react-native\";\nimport type { ListRenderItemInfo, ViewStyle } from \"react-native\";\nimport { useAgent } from \"@copilotkit/react-core/v2/headless\";\nimport { useCopilotKit } from \"@copilotkit/react-core/v2/context\";\nimport { AssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage } from \"./messages/UserMessage\";\nimport { useRenderToolRegistry } from \"../hooks/RenderToolContext\";\nimport type { Message } from \"@copilotkit/shared\";\nimport { partialJSONParse } from \"@copilotkit/shared\";\n\n/** Shape of an assistant message with optional tool calls. */\ninterface AssistantMessageShape {\n id: string;\n role: \"assistant\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\nexport interface CopilotChatProps {\n /** Agent ID to connect to. Defaults to 'default'. */\n agentName?: string;\n /** Placeholder text for the input field. */\n placeholder?: string;\n /** Suggestion pills shown in the empty state. */\n initialMessages?: string[];\n /** Title shown when there are no messages. */\n emptyStateTitle?: string;\n /** Subtitle shown when there are no messages. */\n emptyStateSubtitle?: string;\n /** Title for the optional header bar. */\n headerTitle?: string;\n /** Whether to show the header bar. Defaults to true. */\n showHeader?: boolean;\n /** Style override for the outermost container. */\n style?: ViewStyle;\n /** Style override for the message list container. */\n messageContainerStyle?: ViewStyle;\n /** Style override for the input bar container. */\n inputContainerStyle?: ViewStyle;\n /** Callback fired when the user sends a message. */\n onSendMessage?: (text: string) => void;\n /** Custom FlatList component (e.g. BottomSheetFlatList for use inside a bottom sheet). */\n FlatListComponent?: React.ComponentType<any>;\n /** When true, skip the KeyboardAvoidingView wrapper (useful when a parent already handles keyboard). */\n disableKeyboardAvoiding?: boolean;\n}\n\ninterface ChatListItem {\n id: string;\n type: \"user\" | \"assistant\" | \"tool-call\" | \"loading\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\n/**\n * Full-screen chat UI component for React Native.\n *\n * Connects to a CopilotKit agent via `useAgent` and renders messages\n * using platform-appropriate AssistantMessage / UserMessage components.\n *\n * Usage:\n * ```tsx\n * <CopilotChat agentName=\"my-agent\" headerTitle=\"Assistant\" />\n * ```\n */\nexport function CopilotChat({\n agentName = \"default\",\n placeholder = \"Type a message...\",\n initialMessages = [],\n emptyStateTitle = \"How can I help?\",\n emptyStateSubtitle = \"Ask me anything or try a suggestion below.\",\n headerTitle = \"Chat\",\n showHeader = true,\n style,\n messageContainerStyle,\n inputContainerStyle,\n onSendMessage,\n FlatListComponent = FlatList,\n disableKeyboardAvoiding = false,\n}: CopilotChatProps) {\n const [inputText, setInputText] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n const flatListRef = useRef<FlatList>(null);\n const messageIdCounter = useRef(0);\n\n const { copilotkit, executingToolCallIds } = useCopilotKit();\n const { agent } = useAgent({ agentId: agentName });\n\n const messages = agent.messages ?? [];\n const isRunning = agent.isRunning;\n\n const toolRenderers = useRenderToolRegistry();\n\n // Stable extraData for FlatList to avoid re-creating the object every render\n const extraData = useMemo(\n () => ({ isRunning, executingToolCallIds, toolRenderers }),\n [isRunning, executingToolCallIds, toolRenderers],\n );\n\n // Build flat list items from messages\n const listItems: ChatListItem[] = useMemo(() => {\n const items: ChatListItem[] = [];\n\n for (const msg of messages) {\n if (msg.role === \"user\") {\n items.push({\n id: msg.id,\n type: \"user\",\n content: typeof msg.content === \"string\" ? msg.content : \"\",\n });\n } else if (msg.role === \"assistant\") {\n const assistantMsg = msg as AssistantMessageShape;\n // Add text content if present\n if (assistantMsg.content) {\n items.push({\n id: msg.id,\n type: \"assistant\",\n content: assistantMsg.content,\n });\n }\n // Add tool calls if present\n if (assistantMsg.toolCalls && assistantMsg.toolCalls.length > 0) {\n for (const tc of assistantMsg.toolCalls) {\n items.push({\n id: `${msg.id}-tc-${tc.id}`,\n type: \"tool-call\",\n toolCalls: [tc],\n });\n }\n }\n }\n }\n\n // Show loading indicator when agent is running and the last message\n // is not already the assistant streaming\n if (isRunning) {\n const lastItem = items[items.length - 1];\n if (!lastItem || lastItem.type !== \"assistant\") {\n items.push({ id: \"__loading__\", type: \"loading\" });\n }\n }\n\n return items;\n }, [messages, isRunning]);\n\n // Shared logic for sending a message to the agent\n const sendMessage = useCallback(\n async (text: string) => {\n if (!text || isRunning || !agent) return;\n\n setError(null);\n onSendMessage?.(text);\n\n const id = `user-${++messageIdCounter.current}`;\n agent.addMessage({\n id,\n role: \"user\",\n content: text,\n } as Message);\n\n try {\n await copilotkit.runAgent({ agent });\n } catch (err) {\n const message =\n err instanceof Error ? err.message : \"An unexpected error occurred\";\n console.error(\"[CopilotChat] runAgent failed:\", err);\n setError(message);\n }\n },\n [isRunning, agent, copilotkit, onSendMessage],\n );\n\n // Send from the input field\n const handleSend = useCallback(async () => {\n const text = inputText.trim();\n if (!text) return;\n setInputText(\"\");\n await sendMessage(text);\n }, [inputText, sendMessage]);\n\n // Handle suggestion pill press\n const handleSuggestion = useCallback(\n (text: string) => {\n void sendMessage(text);\n },\n [sendMessage],\n );\n\n // Auto-scroll when content changes\n const handleContentSizeChange = useCallback(() => {\n flatListRef.current?.scrollToEnd({ animated: true });\n }, []);\n\n // Render a single list item\n const renderItem = useCallback(\n ({ item }: ListRenderItemInfo<ChatListItem>) => {\n if (item.type === \"user\") {\n return <UserMessage content={item.content ?? \"\"} />;\n }\n\n if (item.type === \"assistant\") {\n return (\n <AssistantMessage\n content={item.content ?? \"\"}\n isLoading={\n isRunning && item.id === listItems[listItems.length - 1]?.id\n }\n />\n );\n }\n\n if (item.type === \"tool-call\" && item.toolCalls) {\n const tc = item.toolCalls[0];\n const renderer = toolRenderers.get(tc.function.name);\n if (renderer) {\n // Partial parse, NOT JSON.parse: while the model is still writing the call, the argument\n // string is incomplete JSON. JSON.parse threw on every streamed delta, warned, and fell\n // back to {} — so a registered component rendered nothing until the call finished. Partial\n // parsing lets it paint as the arguments arrive, which is what the web renderer does.\n const raw = tc.function.arguments || \"{}\";\n const args = partialJSONParse(raw);\n // Incomplete JSON IS the signal that the model is still writing this call — no extra\n // stream state needed. Once it parses strictly, fall back to the previous semantics.\n let argsComplete = true;\n try {\n JSON.parse(raw);\n } catch {\n argsComplete = false;\n }\n const status = !argsComplete\n ? \"inProgress\"\n : executingToolCallIds.has(tc.id)\n ? \"executing\"\n : \"complete\";\n return renderer({ args, status });\n }\n // Subtle indicator for unregistered tool calls\n return (\n <View style={styles.toolCallIndicator}>\n <Text style={styles.toolCallText}>Called: {tc.function.name}</Text>\n </View>\n );\n }\n\n if (item.type === \"loading\") {\n return <AssistantMessage content=\"\" isLoading />;\n }\n\n return null;\n },\n [isRunning, listItems, toolRenderers, executingToolCallIds],\n );\n\n const keyExtractor = useCallback((item: ChatListItem) => item.id, []);\n\n // Empty state component\n const emptyComponent = useMemo(\n () => (\n <View style={styles.emptyState}>\n <Text style={styles.emptyTitle}>{emptyStateTitle}</Text>\n <Text style={styles.emptySubtitle}>{emptyStateSubtitle}</Text>\n {initialMessages.map((suggestion, i) => (\n <Pressable\n key={`suggestion-${i}`}\n style={styles.suggestionPill}\n onPress={() => handleSuggestion(suggestion)}\n >\n <Text style={styles.suggestionText}>{suggestion}</Text>\n </Pressable>\n ))}\n </View>\n ),\n [emptyStateTitle, emptyStateSubtitle, initialMessages, handleSuggestion],\n );\n\n const sendDisabled = !inputText.trim() || isRunning;\n\n const content = (\n <>\n {showHeader && (\n <View style={styles.header}>\n <Text style={styles.headerTitle}>{headerTitle}</Text>\n </View>\n )}\n\n <FlatListComponent\n ref={flatListRef}\n data={listItems}\n renderItem={renderItem}\n keyExtractor={keyExtractor}\n extraData={extraData}\n contentContainerStyle={[styles.messageList, messageContainerStyle]}\n onContentSizeChange={handleContentSizeChange}\n ListEmptyComponent={emptyComponent}\n />\n\n {error && (\n <View style={styles.errorContainer} testID=\"error-message\">\n <Text style={styles.errorText}>{error}</Text>\n </View>\n )}\n\n <View style={[styles.inputContainer, inputContainerStyle]}>\n <TextInput\n style={styles.input}\n value={inputText}\n onChangeText={setInputText}\n placeholder={placeholder}\n placeholderTextColor=\"#999\"\n multiline\n numberOfLines={4}\n returnKeyType=\"send\"\n onSubmitEditing={handleSend}\n />\n <TouchableOpacity\n style={[styles.sendButton, sendDisabled && styles.sendButtonDisabled]}\n onPress={handleSend}\n disabled={sendDisabled}\n testID=\"send-button\"\n >\n <Text style={styles.sendButtonIcon}>{\"↑\"}</Text>\n </TouchableOpacity>\n </View>\n </>\n );\n\n if (disableKeyboardAvoiding) {\n return <View style={[styles.container, style]}>{content}</View>;\n }\n\n return (\n <KeyboardAvoidingView\n style={[styles.container, style]}\n behavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n keyboardVerticalOffset={0}\n >\n {content}\n </KeyboardAvoidingView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"#FFFFFF\",\n },\n header: {\n height: 56,\n justifyContent: \"center\",\n alignItems: \"center\",\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderBottomColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n headerTitle: {\n fontSize: 17,\n fontWeight: \"600\",\n color: \"#1A1A1A\",\n },\n messageList: {\n paddingHorizontal: 16,\n flexGrow: 1,\n },\n inputContainer: {\n flexDirection: \"row\",\n alignItems: \"flex-end\",\n paddingHorizontal: 8,\n paddingVertical: 8,\n borderTopWidth: StyleSheet.hairlineWidth,\n borderTopColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n input: {\n flex: 1,\n backgroundColor: \"#F5F5F5\",\n borderRadius: 20,\n paddingHorizontal: 12,\n paddingVertical: 8,\n fontSize: 15,\n maxHeight: 100,\n color: \"#1A1A1A\",\n },\n sendButton: {\n width: 36,\n height: 36,\n borderRadius: 18,\n backgroundColor: \"#0066CC\",\n justifyContent: \"center\",\n alignItems: \"center\",\n marginLeft: 8,\n },\n sendButtonDisabled: {\n opacity: 0.4,\n },\n sendButtonIcon: {\n color: \"#FFFFFF\",\n fontSize: 18,\n fontWeight: \"700\",\n },\n emptyState: {\n flex: 1,\n justifyContent: \"center\",\n alignItems: \"center\",\n paddingTop: 100,\n gap: 12,\n },\n emptyTitle: {\n fontSize: 22,\n fontWeight: \"700\",\n color: \"#1A1A1A\",\n marginBottom: 4,\n },\n emptySubtitle: {\n fontSize: 15,\n color: \"#666666\",\n marginBottom: 16,\n },\n suggestionPill: {\n backgroundColor: \"#E8F0FE\",\n borderRadius: 20,\n paddingHorizontal: 16,\n paddingVertical: 10,\n },\n suggestionText: {\n color: \"#0066CC\",\n fontWeight: \"600\",\n fontSize: 14,\n },\n toolCallIndicator: {\n alignSelf: \"flex-start\",\n backgroundColor: \"#F0F0F0\",\n borderRadius: 12,\n paddingHorizontal: 12,\n paddingVertical: 6,\n marginBottom: 8,\n },\n toolCallText: {\n fontSize: 12,\n color: \"#999999\",\n fontStyle: \"italic\",\n },\n errorContainer: {\n backgroundColor: \"#FEE2E2\",\n paddingHorizontal: 12,\n paddingVertical: 8,\n marginHorizontal: 8,\n borderRadius: 8,\n },\n errorText: {\n color: \"#DC2626\",\n fontSize: 13,\n },\n});\n","/**\n * CopilotModal — a bottom-sheet chat overlay for React Native.\n *\n * Mobile equivalent of CopilotPopup on web. Wraps CopilotChat inside\n * @gorhom/bottom-sheet so the chat can slide up over any screen.\n */\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport { StyleSheet, View } from \"react-native\";\nimport BottomSheet, {\n BottomSheetBackdrop,\n BottomSheetFlatList,\n BottomSheetView,\n} from \"@gorhom/bottom-sheet\";\nimport type { BottomSheetBackdropProps } from \"@gorhom/bottom-sheet\";\nimport { CopilotChat } from \"./CopilotChat\";\nimport type { CopilotChatProps } from \"./CopilotChat\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface CopilotModalProps {\n /** Controlled visibility — when true the sheet opens, when false it closes. */\n visible?: boolean;\n\n /** Called when the sheet is dismissed (via backdrop tap, swipe-down, or close()). */\n onDismiss?: () => void;\n\n /**\n * Bottom-sheet snap points.\n * @default ['50%', '90%']\n */\n snapPoints?: (string | number)[];\n\n /**\n * Which snap-point index to open at.\n * @default 0\n */\n initialSnapIndex?: number;\n\n /**\n * Whether closing the sheet fires onDismiss.\n * @default true\n */\n enableDismissOnClose?: boolean;\n\n /**\n * Backdrop opacity when the sheet is open.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n // -- Pass-through to CopilotChat ------------------------------------------\n\n /** Which agent to connect to. */\n agentName?: string;\n\n /** Input placeholder text. */\n placeholder?: string;\n\n /** Seed messages shown on first render. */\n initialMessages?: string[];\n\n /** Title shown in the CopilotChat header area. */\n headerTitle?: string;\n}\n\n/** Imperative handle exposed via ref. */\nexport interface CopilotModalRef {\n /** Programmatically open the bottom sheet. */\n open: () => void;\n /** Programmatically close the bottom sheet. */\n close: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\nexport const CopilotModal = forwardRef<CopilotModalRef, CopilotModalProps>(\n function CopilotModal(\n {\n visible,\n onDismiss,\n snapPoints: snapPointsProp,\n initialSnapIndex = 0,\n enableDismissOnClose = true,\n backdropOpacity = 0.5,\n agentName,\n placeholder,\n initialMessages,\n headerTitle,\n },\n ref,\n ) {\n const bottomSheetRef = useRef<BottomSheet>(null);\n\n // Stable snap-points array\n const snapPoints = useMemo(\n () => snapPointsProp ?? [\"50%\", \"90%\"],\n [snapPointsProp],\n );\n\n // ── Imperative API ────────────────────────────────────────────────────\n useImperativeHandle(\n ref,\n () => ({\n open() {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n },\n close() {\n bottomSheetRef.current?.close();\n },\n }),\n [initialSnapIndex],\n );\n\n // ── Controlled visibility ─────────────────────────────────────────────\n useEffect(() => {\n if (visible === undefined) return;\n if (visible) {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n } else {\n bottomSheetRef.current?.close();\n }\n }, [visible, initialSnapIndex]);\n\n // ── Backdrop renderer ─────────────────────────────────────────────────\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n disappearsOnIndex={-1}\n appearsOnIndex={0}\n opacity={backdropOpacity}\n pressBehavior=\"close\"\n />\n ),\n [backdropOpacity],\n );\n\n // ── Sheet close handler ───────────────────────────────────────────────\n const handleClose = useCallback(() => {\n if (enableDismissOnClose) {\n onDismiss?.();\n }\n }, [enableDismissOnClose, onDismiss]);\n\n // ── Build CopilotChat props ───────────────────────────────────────────\n const chatProps = useMemo(() => {\n const props: Partial<CopilotChatProps> = {};\n if (agentName !== undefined) props.agentName = agentName;\n if (placeholder !== undefined) props.placeholder = placeholder;\n if (initialMessages !== undefined)\n props.initialMessages = initialMessages;\n if (headerTitle !== undefined) props.headerTitle = headerTitle;\n return props;\n }, [agentName, placeholder, initialMessages, headerTitle]);\n\n return (\n <BottomSheet\n ref={bottomSheetRef}\n index={-1}\n snapPoints={snapPoints}\n enablePanDownToClose\n backdropComponent={renderBackdrop}\n onClose={handleClose}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n backgroundStyle={styles.sheetBackground}\n handleIndicatorStyle={styles.handleIndicator}\n >\n <BottomSheetView style={styles.contentContainer}>\n <CopilotChat\n {...chatProps}\n FlatListComponent={BottomSheetFlatList}\n disableKeyboardAvoiding\n />\n </BottomSheetView>\n </BottomSheet>\n );\n },\n);\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst styles = StyleSheet.create({\n sheetBackground: {\n backgroundColor: \"#FFFFFF\",\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n },\n handleIndicator: {\n width: 40,\n height: 4,\n backgroundColor: \"#DDDDDD\",\n },\n contentContainer: {\n flex: 1,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,wBAAuC;CAClD,WAAW;EACT,UAAU;EACV,YAAY;EACZ,OAAO;EACP,WAAW;EACX,cAAc;EACf;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WAAW;EACX,cAAc;EACd,OAAO;EACR;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WA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cAAa;IAEd,CAAC,sBAAsB,UAAU,CAAC;CAGrC,MAAM,qCAA0B;EAC9B,MAAM,QAAmC,EAAE;AAC3C,MAAI,cAAc,OAAW,OAAM,YAAY;AAC/C,MAAI,gBAAgB,OAAW,OAAM,cAAc;AACnD,MAAI,oBAAoB,OACtB,OAAM,kBAAkB;AAC1B,MAAI,gBAAgB,OAAW,OAAM,cAAc;AACnD,SAAO;IACN;EAAC;EAAW;EAAa;EAAiB;EAAY,CAAC;AAE1D,QACE,2CAACC;EACC,KAAK;EACL,OAAO;EACK;EACZ;EACA,mBAAmB;EACnB,SAAS;EACT,kBAAiB;EACjB,sBAAqB;EACrB,iBAAiB,OAAO;EACxB,sBAAsB,OAAO;YAE7B,2CAACC;GAAgB,OAAO,OAAO;aAC7B,2CAAC;IACC,GAAI;IACJ,mBAAmBC;IACnB;KACA;IACc;GACN;EAGnB;AAMD,MAAM,SAASC,wBAAW,OAAO;CAC/B,iBAAiB;EACf,iBAAiB;EACjB,qBAAqB;EACrB,sBAAsB;EACvB;CACD,iBAAiB;EACf,OAAO;EACP,QAAQ;EACR,iBAAiB;EAClB;CACD,kBAAkB,EAChB,MAAM,GACP;CACF,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { r as useRenderToolRegistry } from "../RenderToolContext-D8M-JhD1.mjs";
|
|
|
2
2
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useCopilotKit } from "@copilotkit/react-core/v2/context";
|
|
4
4
|
import { useAgent } from "@copilotkit/react-core/v2/headless";
|
|
5
|
+
import { partialJSONParse } from "@copilotkit/shared";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { Animated, FlatList, KeyboardAvoidingView, Platform, Pressable, StyleSheet, Text, TextInput, TouchableOpacity, View } from "react-native";
|
|
7
8
|
import { StreamdownText } from "react-native-streamdown";
|
|
@@ -397,16 +398,17 @@ function CopilotChat({ agentName = "default", placeholder = "Type a message...",
|
|
|
397
398
|
const tc = item.toolCalls[0];
|
|
398
399
|
const renderer = toolRenderers.get(tc.function.name);
|
|
399
400
|
if (renderer) {
|
|
400
|
-
|
|
401
|
+
const raw = tc.function.arguments || "{}";
|
|
402
|
+
const args = partialJSONParse(raw);
|
|
403
|
+
let argsComplete = true;
|
|
401
404
|
try {
|
|
402
|
-
|
|
403
|
-
} catch
|
|
404
|
-
|
|
405
|
+
JSON.parse(raw);
|
|
406
|
+
} catch {
|
|
407
|
+
argsComplete = false;
|
|
405
408
|
}
|
|
406
|
-
const status = executingToolCallIds.has(tc.id) ? "executing" : "complete";
|
|
407
409
|
return renderer({
|
|
408
410
|
args,
|
|
409
|
-
status
|
|
411
|
+
status: !argsComplete ? "inProgress" : executingToolCallIds.has(tc.id) ? "executing" : "complete"
|
|
410
412
|
});
|
|
411
413
|
}
|
|
412
414
|
return /* @__PURE__ */ jsx(View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["styles","TIMESTAMP_COLOR","styles","styles","styles"],"sources":["../../src/components/Markdown.tsx","../../src/components/messages/TypingIndicator.tsx","../../src/components/messages/utils.ts","../../src/components/messages/AssistantMessage.tsx","../../src/components/messages/UserMessage.tsx","../../src/components/CopilotChat.tsx","../../src/components/CopilotModal.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { StreamdownText } from \"react-native-streamdown\";\n\n/**\n * Style object accepted by `react-native-enriched-markdown` (and therefore\n * `react-native-streamdown`). Each key targets a markdown element; the\n * available properties vary per element — see the enriched-markdown style\n * reference for the full list.\n */\nexport type MarkdownStyle = Record<string, Record<string, unknown>>;\n\n/**\n * Props for the CopilotMarkdown component.\n */\nexport interface CopilotMarkdownProps {\n /** Markdown string to render. */\n content: string;\n /** Optional style overrides merged on top of the defaults. */\n style?: MarkdownStyle;\n /** Whether to enable the streaming fade-in animation (default: true). */\n streamingAnimation?: boolean;\n}\n\n/**\n * Default markdown styles tuned for chat bubble display.\n *\n * Exported so consumers can spread and extend:\n * ```ts\n * import { defaultMarkdownStyles } from \"@copilotkit/react-native\";\n * const custom = { ...defaultMarkdownStyles, h1: { fontSize: 28 } };\n * ```\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n paragraph: {\n fontSize: 16,\n lineHeight: 24,\n color: \"#1a1a1a\",\n marginTop: 4,\n marginBottom: 4,\n },\n h1: {\n fontSize: 24,\n fontWeight: \"bold\",\n marginTop: 12,\n marginBottom: 8,\n color: \"#111111\",\n },\n h2: {\n fontSize: 20,\n fontWeight: \"bold\",\n marginTop: 10,\n marginBottom: 6,\n color: \"#111111\",\n },\n h3: {\n fontSize: 18,\n fontWeight: \"600\",\n marginTop: 8,\n marginBottom: 4,\n color: \"#222222\",\n },\n strong: {\n fontWeight: \"bold\",\n },\n em: {\n fontStyle: \"italic\",\n },\n link: {\n color: \"#0066cc\",\n underline: true,\n },\n blockquote: {\n backgroundColor: \"#f5f5f5\",\n borderWidth: 4,\n borderColor: \"#cccccc\",\n gapWidth: 12,\n },\n code: {\n backgroundColor: \"#f0f0f0\",\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n codeBlock: {\n backgroundColor: \"#f0f0f0\",\n borderRadius: 8,\n padding: 12,\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n list: {\n marginTop: 4,\n marginBottom: 4,\n },\n};\n\n/**\n * Renders markdown content using `react-native-streamdown` with\n * pre-configured styles suited for CopilotKit chat bubbles.\n *\n * `react-native-streamdown` processes incomplete streaming markdown in the\n * background, rendering incrementally without visual glitches — ideal for\n * displaying LLM output as it arrives.\n *\n * Custom styles are merged on top of the defaults so callers only need\n * to override what they want to change.\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = true,\n}: CopilotMarkdownProps) {\n const mergedStyles = useMemo(() => {\n if (!style) return defaultMarkdownStyles;\n return { ...defaultMarkdownStyles, ...style };\n }, [style]);\n\n return (\n <StreamdownText\n markdown={content}\n markdownStyle={mergedStyles}\n streamingAnimation={streamingAnimation}\n />\n );\n}\n","import React, { useEffect, useRef } from \"react\";\nimport { View, Animated, StyleSheet } from \"react-native\";\nimport type { ViewStyle } from \"react-native\";\n\n/**\n * Props for the TypingIndicator component.\n */\nexport interface TypingIndicatorProps {\n /** Optional style override for the container */\n style?: ViewStyle;\n}\n\nconst DOT_SIZE = 6;\nconst DOT_SPACING = 4;\nconst ANIMATION_DURATION = 400;\n\n/**\n * Three animated dots that pulse in sequence, suitable for embedding\n * inside an AssistantMessage to indicate the AI is still generating.\n *\n * Uses React Native's built-in `Animated` API (no Reanimated dependency).\n */\nexport function TypingIndicator({ style }: TypingIndicatorProps) {\n const dot1 = useRef(new Animated.Value(0)).current;\n const dot2 = useRef(new Animated.Value(0)).current;\n const dot3 = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n const createPulse = (dot: Animated.Value, delay: number) =>\n Animated.sequence([\n Animated.delay(delay),\n Animated.loop(\n Animated.sequence([\n Animated.timing(dot, {\n toValue: 1,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n Animated.timing(dot, {\n toValue: 0,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n ]),\n ),\n ]);\n\n const animation = Animated.parallel([\n createPulse(dot1, 0),\n createPulse(dot2, ANIMATION_DURATION * 0.33),\n createPulse(dot3, ANIMATION_DURATION * 0.66),\n ]);\n\n animation.start();\n\n return () => {\n animation.stop();\n };\n }, [dot1, dot2, dot3]);\n\n const dotStyle = (animatedValue: Animated.Value) => ({\n ...styles.dot,\n opacity: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.3, 1],\n }),\n transform: [\n {\n scale: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.8, 1.2],\n }),\n },\n ],\n });\n\n return (\n <View\n testID=\"copilot-loading-cursor\"\n style={[styles.container, style]}\n accessibilityLabel=\"Typing indicator\"\n accessibilityRole=\"text\"\n >\n <Animated.View style={dotStyle(dot1)} />\n <Animated.View style={dotStyle(dot2)} />\n <Animated.View style={dotStyle(dot3)} />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: \"row\",\n alignItems: \"center\",\n paddingVertical: 4,\n paddingHorizontal: 2,\n },\n dot: {\n width: DOT_SIZE,\n height: DOT_SIZE,\n borderRadius: DOT_SIZE / 2,\n backgroundColor: \"#999999\",\n marginHorizontal: DOT_SPACING / 2,\n },\n});\n","/**\n * Format a Date as a 12-hour time string (e.g. \"2:05 PM\").\n */\nexport function formatTimestamp(date: Date): string {\n const hours = date.getHours();\n const minutes = date.getMinutes();\n const ampm = hours >= 12 ? \"PM\" : \"AM\";\n const displayHours = hours % 12 || 12;\n const displayMinutes = minutes.toString().padStart(2, \"0\");\n return `${displayHours}:${displayMinutes} ${ampm}`;\n}\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { CopilotMarkdown } from \"../Markdown\";\nimport { TypingIndicator } from \"./TypingIndicator\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst ASSISTANT_BUBBLE_BG = \"#F0F0F0\";\nconst ASSISTANT_TEXT_COLOR = \"#1A1A1A\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the AssistantMessage component.\n */\nexport interface AssistantMessageProps {\n /** Markdown content to render inside the bubble */\n content: string;\n /** When true, shows a typing indicator instead of content */\n isLoading?: boolean;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Left-aligned chat bubble for AI assistant responses.\n *\n * Renders markdown content via `CopilotMarkdown` and shows an animated\n * typing indicator when `isLoading` is true.\n */\nexport function AssistantMessage({\n content,\n isLoading = false,\n timestamp,\n style,\n}: AssistantMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n {content ? <CopilotMarkdown content={content} /> : null}\n {isLoading ? <TypingIndicator /> : null}\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-start\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: ASSISTANT_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomRightRadius: 16,\n borderBottomLeftRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginLeft: 4,\n },\n});\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst USER_BUBBLE_BG = \"#0066CC\";\nconst USER_TEXT_COLOR = \"#FFFFFF\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the UserMessage component.\n */\nexport interface UserMessageProps {\n /** Plain text content to display */\n content: string;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Right-aligned chat bubble for user messages.\n *\n * Renders plain text (no markdown) with a primary-color background\n * and white text. Optionally displays a subtle timestamp below.\n */\nexport function UserMessage({ content, timestamp, style }: UserMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n <Text style={styles.text}>{content}</Text>\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-end\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: USER_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomLeftRadius: 16,\n borderBottomRightRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n text: {\n color: USER_TEXT_COLOR,\n fontSize: 16,\n lineHeight: 22,\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginRight: 4,\n },\n});\n","import React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n FlatList,\n KeyboardAvoidingView,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n type ListRenderItemInfo,\n type ViewStyle,\n} from \"react-native\";\nimport { useAgent } from \"@copilotkit/react-core/v2/headless\";\nimport { useCopilotKit } from \"@copilotkit/react-core/v2/context\";\nimport { AssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage } from \"./messages/UserMessage\";\nimport { useRenderToolRegistry } from \"../hooks/RenderToolContext\";\nimport type { Message } from \"@copilotkit/shared\";\n\n/** Shape of an assistant message with optional tool calls. */\ninterface AssistantMessageShape {\n id: string;\n role: \"assistant\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\nexport interface CopilotChatProps {\n /** Agent ID to connect to. Defaults to 'default'. */\n agentName?: string;\n /** Placeholder text for the input field. */\n placeholder?: string;\n /** Suggestion pills shown in the empty state. */\n initialMessages?: string[];\n /** Title shown when there are no messages. */\n emptyStateTitle?: string;\n /** Subtitle shown when there are no messages. */\n emptyStateSubtitle?: string;\n /** Title for the optional header bar. */\n headerTitle?: string;\n /** Whether to show the header bar. Defaults to true. */\n showHeader?: boolean;\n /** Style override for the outermost container. */\n style?: ViewStyle;\n /** Style override for the message list container. */\n messageContainerStyle?: ViewStyle;\n /** Style override for the input bar container. */\n inputContainerStyle?: ViewStyle;\n /** Callback fired when the user sends a message. */\n onSendMessage?: (text: string) => void;\n /** Custom FlatList component (e.g. BottomSheetFlatList for use inside a bottom sheet). */\n FlatListComponent?: React.ComponentType<any>;\n /** When true, skip the KeyboardAvoidingView wrapper (useful when a parent already handles keyboard). */\n disableKeyboardAvoiding?: boolean;\n}\n\ninterface ChatListItem {\n id: string;\n type: \"user\" | \"assistant\" | \"tool-call\" | \"loading\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\n/**\n * Full-screen chat UI component for React Native.\n *\n * Connects to a CopilotKit agent via `useAgent` and renders messages\n * using platform-appropriate AssistantMessage / UserMessage components.\n *\n * Usage:\n * ```tsx\n * <CopilotChat agentName=\"my-agent\" headerTitle=\"Assistant\" />\n * ```\n */\nexport function CopilotChat({\n agentName = \"default\",\n placeholder = \"Type a message...\",\n initialMessages = [],\n emptyStateTitle = \"How can I help?\",\n emptyStateSubtitle = \"Ask me anything or try a suggestion below.\",\n headerTitle = \"Chat\",\n showHeader = true,\n style,\n messageContainerStyle,\n inputContainerStyle,\n onSendMessage,\n FlatListComponent = FlatList,\n disableKeyboardAvoiding = false,\n}: CopilotChatProps) {\n const [inputText, setInputText] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n const flatListRef = useRef<FlatList>(null);\n const messageIdCounter = useRef(0);\n\n const { copilotkit, executingToolCallIds } = useCopilotKit();\n const { agent } = useAgent({ agentId: agentName });\n\n const messages = agent.messages ?? [];\n const isRunning = agent.isRunning;\n\n const toolRenderers = useRenderToolRegistry();\n\n // Stable extraData for FlatList to avoid re-creating the object every render\n const extraData = useMemo(\n () => ({ isRunning, executingToolCallIds, toolRenderers }),\n [isRunning, executingToolCallIds, toolRenderers],\n );\n\n // Build flat list items from messages\n const listItems: ChatListItem[] = useMemo(() => {\n const items: ChatListItem[] = [];\n\n for (const msg of messages) {\n if (msg.role === \"user\") {\n items.push({\n id: msg.id,\n type: \"user\",\n content: typeof msg.content === \"string\" ? msg.content : \"\",\n });\n } else if (msg.role === \"assistant\") {\n const assistantMsg = msg as AssistantMessageShape;\n // Add text content if present\n if (assistantMsg.content) {\n items.push({\n id: msg.id,\n type: \"assistant\",\n content: assistantMsg.content,\n });\n }\n // Add tool calls if present\n if (assistantMsg.toolCalls && assistantMsg.toolCalls.length > 0) {\n for (const tc of assistantMsg.toolCalls) {\n items.push({\n id: `${msg.id}-tc-${tc.id}`,\n type: \"tool-call\",\n toolCalls: [tc],\n });\n }\n }\n }\n }\n\n // Show loading indicator when agent is running and the last message\n // is not already the assistant streaming\n if (isRunning) {\n const lastItem = items[items.length - 1];\n if (!lastItem || lastItem.type !== \"assistant\") {\n items.push({ id: \"__loading__\", type: \"loading\" });\n }\n }\n\n return items;\n }, [messages, isRunning]);\n\n // Shared logic for sending a message to the agent\n const sendMessage = useCallback(\n async (text: string) => {\n if (!text || isRunning || !agent) return;\n\n setError(null);\n onSendMessage?.(text);\n\n const id = `user-${++messageIdCounter.current}`;\n agent.addMessage({\n id,\n role: \"user\",\n content: text,\n } as Message);\n\n try {\n await copilotkit.runAgent({ agent });\n } catch (err) {\n const message =\n err instanceof Error ? err.message : \"An unexpected error occurred\";\n console.error(\"[CopilotChat] runAgent failed:\", err);\n setError(message);\n }\n },\n [isRunning, agent, copilotkit, onSendMessage],\n );\n\n // Send from the input field\n const handleSend = useCallback(async () => {\n const text = inputText.trim();\n if (!text) return;\n setInputText(\"\");\n await sendMessage(text);\n }, [inputText, sendMessage]);\n\n // Handle suggestion pill press\n const handleSuggestion = useCallback(\n (text: string) => {\n void sendMessage(text);\n },\n [sendMessage],\n );\n\n // Auto-scroll when content changes\n const handleContentSizeChange = useCallback(() => {\n flatListRef.current?.scrollToEnd({ animated: true });\n }, []);\n\n // Render a single list item\n const renderItem = useCallback(\n ({ item }: ListRenderItemInfo<ChatListItem>) => {\n if (item.type === \"user\") {\n return <UserMessage content={item.content ?? \"\"} />;\n }\n\n if (item.type === \"assistant\") {\n return (\n <AssistantMessage\n content={item.content ?? \"\"}\n isLoading={\n isRunning && item.id === listItems[listItems.length - 1]?.id\n }\n />\n );\n }\n\n if (item.type === \"tool-call\" && item.toolCalls) {\n const tc = item.toolCalls[0];\n const renderer = toolRenderers.get(tc.function.name);\n if (renderer) {\n let args: Record<string, unknown> = {};\n try {\n args = JSON.parse(tc.function.arguments || \"{}\");\n } catch (e) {\n console.warn(\n `[CopilotChat] Failed to parse tool call arguments for ${tc.function.name}:`,\n e,\n );\n }\n const status = executingToolCallIds.has(tc.id)\n ? \"executing\"\n : \"complete\";\n return renderer({ args, status });\n }\n // Subtle indicator for unregistered tool calls\n return (\n <View style={styles.toolCallIndicator}>\n <Text style={styles.toolCallText}>Called: {tc.function.name}</Text>\n </View>\n );\n }\n\n if (item.type === \"loading\") {\n return <AssistantMessage content=\"\" isLoading />;\n }\n\n return null;\n },\n [isRunning, listItems, toolRenderers, executingToolCallIds],\n );\n\n const keyExtractor = useCallback((item: ChatListItem) => item.id, []);\n\n // Empty state component\n const emptyComponent = useMemo(\n () => (\n <View style={styles.emptyState}>\n <Text style={styles.emptyTitle}>{emptyStateTitle}</Text>\n <Text style={styles.emptySubtitle}>{emptyStateSubtitle}</Text>\n {initialMessages.map((suggestion, i) => (\n <Pressable\n key={`suggestion-${i}`}\n style={styles.suggestionPill}\n onPress={() => handleSuggestion(suggestion)}\n >\n <Text style={styles.suggestionText}>{suggestion}</Text>\n </Pressable>\n ))}\n </View>\n ),\n [emptyStateTitle, emptyStateSubtitle, initialMessages, handleSuggestion],\n );\n\n const sendDisabled = !inputText.trim() || isRunning;\n\n const content = (\n <>\n {showHeader && (\n <View style={styles.header}>\n <Text style={styles.headerTitle}>{headerTitle}</Text>\n </View>\n )}\n\n <FlatListComponent\n ref={flatListRef}\n data={listItems}\n renderItem={renderItem}\n keyExtractor={keyExtractor}\n extraData={extraData}\n contentContainerStyle={[styles.messageList, messageContainerStyle]}\n onContentSizeChange={handleContentSizeChange}\n ListEmptyComponent={emptyComponent}\n />\n\n {error && (\n <View style={styles.errorContainer} testID=\"error-message\">\n <Text style={styles.errorText}>{error}</Text>\n </View>\n )}\n\n <View style={[styles.inputContainer, inputContainerStyle]}>\n <TextInput\n style={styles.input}\n value={inputText}\n onChangeText={setInputText}\n placeholder={placeholder}\n placeholderTextColor=\"#999\"\n multiline\n numberOfLines={4}\n returnKeyType=\"send\"\n onSubmitEditing={handleSend}\n />\n <TouchableOpacity\n style={[styles.sendButton, sendDisabled && styles.sendButtonDisabled]}\n onPress={handleSend}\n disabled={sendDisabled}\n testID=\"send-button\"\n >\n <Text style={styles.sendButtonIcon}>{\"↑\"}</Text>\n </TouchableOpacity>\n </View>\n </>\n );\n\n if (disableKeyboardAvoiding) {\n return <View style={[styles.container, style]}>{content}</View>;\n }\n\n return (\n <KeyboardAvoidingView\n style={[styles.container, style]}\n behavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n keyboardVerticalOffset={0}\n >\n {content}\n </KeyboardAvoidingView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"#FFFFFF\",\n },\n header: {\n height: 56,\n justifyContent: \"center\",\n alignItems: \"center\",\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderBottomColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n headerTitle: {\n fontSize: 17,\n fontWeight: \"600\",\n color: \"#1A1A1A\",\n },\n messageList: {\n paddingHorizontal: 16,\n flexGrow: 1,\n },\n inputContainer: {\n flexDirection: \"row\",\n alignItems: \"flex-end\",\n paddingHorizontal: 8,\n paddingVertical: 8,\n borderTopWidth: StyleSheet.hairlineWidth,\n borderTopColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n input: {\n flex: 1,\n backgroundColor: \"#F5F5F5\",\n borderRadius: 20,\n paddingHorizontal: 12,\n paddingVertical: 8,\n fontSize: 15,\n maxHeight: 100,\n color: \"#1A1A1A\",\n },\n sendButton: {\n width: 36,\n height: 36,\n borderRadius: 18,\n backgroundColor: \"#0066CC\",\n justifyContent: \"center\",\n alignItems: \"center\",\n marginLeft: 8,\n },\n sendButtonDisabled: {\n opacity: 0.4,\n },\n sendButtonIcon: {\n color: \"#FFFFFF\",\n fontSize: 18,\n fontWeight: \"700\",\n },\n emptyState: {\n flex: 1,\n justifyContent: \"center\",\n alignItems: \"center\",\n paddingTop: 100,\n gap: 12,\n },\n emptyTitle: {\n fontSize: 22,\n fontWeight: \"700\",\n color: \"#1A1A1A\",\n marginBottom: 4,\n },\n emptySubtitle: {\n fontSize: 15,\n color: \"#666666\",\n marginBottom: 16,\n },\n suggestionPill: {\n backgroundColor: \"#E8F0FE\",\n borderRadius: 20,\n paddingHorizontal: 16,\n paddingVertical: 10,\n },\n suggestionText: {\n color: \"#0066CC\",\n fontWeight: \"600\",\n fontSize: 14,\n },\n toolCallIndicator: {\n alignSelf: \"flex-start\",\n backgroundColor: \"#F0F0F0\",\n borderRadius: 12,\n paddingHorizontal: 12,\n paddingVertical: 6,\n marginBottom: 8,\n },\n toolCallText: {\n fontSize: 12,\n color: \"#999999\",\n fontStyle: \"italic\",\n },\n errorContainer: {\n backgroundColor: \"#FEE2E2\",\n paddingHorizontal: 12,\n paddingVertical: 8,\n marginHorizontal: 8,\n borderRadius: 8,\n },\n errorText: {\n color: \"#DC2626\",\n fontSize: 13,\n },\n});\n","/**\n * CopilotModal — a bottom-sheet chat overlay for React Native.\n *\n * Mobile equivalent of CopilotPopup on web. Wraps CopilotChat inside\n * @gorhom/bottom-sheet so the chat can slide up over any screen.\n */\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport { StyleSheet, View } from \"react-native\";\nimport BottomSheet, {\n BottomSheetBackdrop,\n BottomSheetFlatList,\n BottomSheetView,\n} from \"@gorhom/bottom-sheet\";\nimport type { BottomSheetBackdropProps } from \"@gorhom/bottom-sheet\";\nimport { CopilotChat } from \"./CopilotChat\";\nimport type { CopilotChatProps } from \"./CopilotChat\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface CopilotModalProps {\n /** Controlled visibility — when true the sheet opens, when false it closes. */\n visible?: boolean;\n\n /** Called when the sheet is dismissed (via backdrop tap, swipe-down, or close()). */\n onDismiss?: () => void;\n\n /**\n * Bottom-sheet snap points.\n * @default ['50%', '90%']\n */\n snapPoints?: (string | number)[];\n\n /**\n * Which snap-point index to open at.\n * @default 0\n */\n initialSnapIndex?: number;\n\n /**\n * Whether closing the sheet fires onDismiss.\n * @default true\n */\n enableDismissOnClose?: boolean;\n\n /**\n * Backdrop opacity when the sheet is open.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n // -- Pass-through to CopilotChat ------------------------------------------\n\n /** Which agent to connect to. */\n agentName?: string;\n\n /** Input placeholder text. */\n placeholder?: string;\n\n /** Seed messages shown on first render. */\n initialMessages?: string[];\n\n /** Title shown in the CopilotChat header area. */\n headerTitle?: string;\n}\n\n/** Imperative handle exposed via ref. */\nexport interface CopilotModalRef {\n /** Programmatically open the bottom sheet. */\n open: () => void;\n /** Programmatically close the bottom sheet. */\n close: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\nexport const CopilotModal = forwardRef<CopilotModalRef, CopilotModalProps>(\n function CopilotModal(\n {\n visible,\n onDismiss,\n snapPoints: snapPointsProp,\n initialSnapIndex = 0,\n enableDismissOnClose = true,\n backdropOpacity = 0.5,\n agentName,\n placeholder,\n initialMessages,\n headerTitle,\n },\n ref,\n ) {\n const bottomSheetRef = useRef<BottomSheet>(null);\n\n // Stable snap-points array\n const snapPoints = useMemo(\n () => snapPointsProp ?? [\"50%\", \"90%\"],\n [snapPointsProp],\n );\n\n // ── Imperative API ────────────────────────────────────────────────────\n useImperativeHandle(\n ref,\n () => ({\n open() {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n },\n close() {\n bottomSheetRef.current?.close();\n },\n }),\n [initialSnapIndex],\n );\n\n // ── Controlled visibility ─────────────────────────────────────────────\n useEffect(() => {\n if (visible === undefined) return;\n if (visible) {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n } else {\n bottomSheetRef.current?.close();\n }\n }, [visible, initialSnapIndex]);\n\n // ── Backdrop renderer ─────────────────────────────────────────────────\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n disappearsOnIndex={-1}\n appearsOnIndex={0}\n opacity={backdropOpacity}\n pressBehavior=\"close\"\n />\n ),\n [backdropOpacity],\n );\n\n // ── Sheet close handler ───────────────────────────────────────────────\n const handleClose = useCallback(() => {\n if (enableDismissOnClose) {\n onDismiss?.();\n }\n }, [enableDismissOnClose, onDismiss]);\n\n // ── Build CopilotChat props ───────────────────────────────────────────\n const chatProps = useMemo(() => {\n const props: Partial<CopilotChatProps> = {};\n if (agentName !== undefined) props.agentName = agentName;\n if (placeholder !== undefined) props.placeholder = placeholder;\n if (initialMessages !== undefined)\n props.initialMessages = initialMessages;\n if (headerTitle !== undefined) props.headerTitle = headerTitle;\n return props;\n }, [agentName, placeholder, initialMessages, headerTitle]);\n\n return (\n <BottomSheet\n ref={bottomSheetRef}\n index={-1}\n snapPoints={snapPoints}\n enablePanDownToClose\n backdropComponent={renderBackdrop}\n onClose={handleClose}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n backgroundStyle={styles.sheetBackground}\n handleIndicatorStyle={styles.handleIndicator}\n >\n <BottomSheetView style={styles.contentContainer}>\n <CopilotChat\n {...chatProps}\n FlatListComponent={BottomSheetFlatList}\n disableKeyboardAvoiding\n />\n </BottomSheetView>\n </BottomSheet>\n );\n },\n);\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst styles = StyleSheet.create({\n sheetBackground: {\n backgroundColor: \"#FFFFFF\",\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n },\n handleIndicator: {\n width: 40,\n height: 4,\n backgroundColor: \"#DDDDDD\",\n },\n contentContainer: {\n flex: 1,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAa,wBAAuC;CAClD,WAAW;EACT,UAAU;EACV,YAAY;EACZ,OAAO;EACP,WAAW;EACX,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SAAS,OAAO;IAEhC,CAAC,SAAS,iBAAiB,CAAC;CAG/B,MAAM,iBAAiB,aACpB,UACC,oBAAC;EACC,GAAI;EACJ,mBAAmB;EACnB,gBAAgB;EAChB,SAAS;EACT,eAAc;GACd,EAEJ,CAAC,gBAAgB,CAClB;CAGD,MAAM,cAAc,kBAAkB;AACpC,MAAI,qBACF,cAAa;IAEd,CAAC,sBAAsB,UAAU,CAAC;CAGrC,MAAM,YAAY,cAAc;EAC9B,MAAM,QAAmC,EAAE;AAC3C,MAAI,cAAc,OAAW,OAAM,YAAY;AAC/C,MAAI,gBAAgB,OAAW,OAAM,cAAc;AACnD,MAAI,oBAAoB,OACtB,OAAM,kBAAkB;AAC1B,MAAI,gBAAgB,OAAW,OAAM,cAAc;AACnD,SAAO;IACN;EAAC;EAAW;EAAa;EAAiB;EAAY,CAAC;AAE1D,QACE,oBAAC;EACC,KAAK;EACL,OAAO;EACK;EACZ;EACA,mBAAmB;EACnB,SAAS;EACT,kBAAiB;EACjB,sBAAqB;EACrB,iBAAiB,OAAO;EACxB,sBAAsB,OAAO;YAE7B,oBAAC;GAAgB,OAAO,OAAO;aAC7B,oBAAC;IACC,GAAI;IACJ,mBAAmB;IACnB;KACA;IACc;GACN;EAGnB;AAMD,MAAM,SAAS,WAAW,OAAO;CAC/B,iBAAiB;EACf,iBAAiB;EACjB,qBAAqB;EACrB,sBAAsB;EACvB;CACD,iBAAiB;EACf,OAAO;EACP,QAAQ;EACR,iBAAiB;EAClB;CACD,kBAAkB,EAChB,MAAM,GACP;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["styles","TIMESTAMP_COLOR","styles","styles","styles"],"sources":["../../src/components/Markdown.tsx","../../src/components/messages/TypingIndicator.tsx","../../src/components/messages/utils.ts","../../src/components/messages/AssistantMessage.tsx","../../src/components/messages/UserMessage.tsx","../../src/components/CopilotChat.tsx","../../src/components/CopilotModal.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { StreamdownText } from \"react-native-streamdown\";\n\n/**\n * Style object accepted by `react-native-enriched-markdown` (and therefore\n * `react-native-streamdown`). Each key targets a markdown element; the\n * available properties vary per element — see the enriched-markdown style\n * reference for the full list.\n */\nexport type MarkdownStyle = Record<string, Record<string, unknown>>;\n\n/**\n * Props for the CopilotMarkdown component.\n */\nexport interface CopilotMarkdownProps {\n /** Markdown string to render. */\n content: string;\n /** Optional style overrides merged on top of the defaults. */\n style?: MarkdownStyle;\n /** Whether to enable the streaming fade-in animation (default: true). */\n streamingAnimation?: boolean;\n}\n\n/**\n * Default markdown styles tuned for chat bubble display.\n *\n * Exported so consumers can spread and extend:\n * ```ts\n * import { defaultMarkdownStyles } from \"@copilotkit/react-native\";\n * const custom = { ...defaultMarkdownStyles, h1: { fontSize: 28 } };\n * ```\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n paragraph: {\n fontSize: 16,\n lineHeight: 24,\n color: \"#1a1a1a\",\n marginTop: 4,\n marginBottom: 4,\n },\n h1: {\n fontSize: 24,\n fontWeight: \"bold\",\n marginTop: 12,\n marginBottom: 8,\n color: \"#111111\",\n },\n h2: {\n fontSize: 20,\n fontWeight: \"bold\",\n marginTop: 10,\n marginBottom: 6,\n color: \"#111111\",\n },\n h3: {\n fontSize: 18,\n fontWeight: \"600\",\n marginTop: 8,\n marginBottom: 4,\n color: \"#222222\",\n },\n strong: {\n fontWeight: \"bold\",\n },\n em: {\n fontStyle: \"italic\",\n },\n link: {\n color: \"#0066cc\",\n underline: true,\n },\n blockquote: {\n backgroundColor: \"#f5f5f5\",\n borderWidth: 4,\n borderColor: \"#cccccc\",\n gapWidth: 12,\n },\n code: {\n backgroundColor: \"#f0f0f0\",\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n codeBlock: {\n backgroundColor: \"#f0f0f0\",\n borderRadius: 8,\n padding: 12,\n fontFamily: \"monospace\",\n fontSize: 14,\n },\n list: {\n marginTop: 4,\n marginBottom: 4,\n },\n};\n\n/**\n * Renders markdown content using `react-native-streamdown` with\n * pre-configured styles suited for CopilotKit chat bubbles.\n *\n * `react-native-streamdown` processes incomplete streaming markdown in the\n * background, rendering incrementally without visual glitches — ideal for\n * displaying LLM output as it arrives.\n *\n * Custom styles are merged on top of the defaults so callers only need\n * to override what they want to change.\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = true,\n}: CopilotMarkdownProps) {\n const mergedStyles = useMemo(() => {\n if (!style) return defaultMarkdownStyles;\n return { ...defaultMarkdownStyles, ...style };\n }, [style]);\n\n return (\n <StreamdownText\n markdown={content}\n markdownStyle={mergedStyles}\n streamingAnimation={streamingAnimation}\n />\n );\n}\n","import React, { useEffect, useRef } from \"react\";\nimport { View, Animated, StyleSheet } from \"react-native\";\nimport type { ViewStyle } from \"react-native\";\n\n/**\n * Props for the TypingIndicator component.\n */\nexport interface TypingIndicatorProps {\n /** Optional style override for the container */\n style?: ViewStyle;\n}\n\nconst DOT_SIZE = 6;\nconst DOT_SPACING = 4;\nconst ANIMATION_DURATION = 400;\n\n/**\n * Three animated dots that pulse in sequence, suitable for embedding\n * inside an AssistantMessage to indicate the AI is still generating.\n *\n * Uses React Native's built-in `Animated` API (no Reanimated dependency).\n */\nexport function TypingIndicator({ style }: TypingIndicatorProps) {\n const dot1 = useRef(new Animated.Value(0)).current;\n const dot2 = useRef(new Animated.Value(0)).current;\n const dot3 = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n const createPulse = (dot: Animated.Value, delay: number) =>\n Animated.sequence([\n Animated.delay(delay),\n Animated.loop(\n Animated.sequence([\n Animated.timing(dot, {\n toValue: 1,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n Animated.timing(dot, {\n toValue: 0,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }),\n ]),\n ),\n ]);\n\n const animation = Animated.parallel([\n createPulse(dot1, 0),\n createPulse(dot2, ANIMATION_DURATION * 0.33),\n createPulse(dot3, ANIMATION_DURATION * 0.66),\n ]);\n\n animation.start();\n\n return () => {\n animation.stop();\n };\n }, [dot1, dot2, dot3]);\n\n const dotStyle = (animatedValue: Animated.Value) => ({\n ...styles.dot,\n opacity: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.3, 1],\n }),\n transform: [\n {\n scale: animatedValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0.8, 1.2],\n }),\n },\n ],\n });\n\n return (\n <View\n testID=\"copilot-loading-cursor\"\n style={[styles.container, style]}\n accessibilityLabel=\"Typing indicator\"\n accessibilityRole=\"text\"\n >\n <Animated.View style={dotStyle(dot1)} />\n <Animated.View style={dotStyle(dot2)} />\n <Animated.View style={dotStyle(dot3)} />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: \"row\",\n alignItems: \"center\",\n paddingVertical: 4,\n paddingHorizontal: 2,\n },\n dot: {\n width: DOT_SIZE,\n height: DOT_SIZE,\n borderRadius: DOT_SIZE / 2,\n backgroundColor: \"#999999\",\n marginHorizontal: DOT_SPACING / 2,\n },\n});\n","/**\n * Format a Date as a 12-hour time string (e.g. \"2:05 PM\").\n */\nexport function formatTimestamp(date: Date): string {\n const hours = date.getHours();\n const minutes = date.getMinutes();\n const ampm = hours >= 12 ? \"PM\" : \"AM\";\n const displayHours = hours % 12 || 12;\n const displayMinutes = minutes.toString().padStart(2, \"0\");\n return `${displayHours}:${displayMinutes} ${ampm}`;\n}\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { CopilotMarkdown } from \"../Markdown\";\nimport { TypingIndicator } from \"./TypingIndicator\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst ASSISTANT_BUBBLE_BG = \"#F0F0F0\";\nconst ASSISTANT_TEXT_COLOR = \"#1A1A1A\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the AssistantMessage component.\n */\nexport interface AssistantMessageProps {\n /** Markdown content to render inside the bubble */\n content: string;\n /** When true, shows a typing indicator instead of content */\n isLoading?: boolean;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Left-aligned chat bubble for AI assistant responses.\n *\n * Renders markdown content via `CopilotMarkdown` and shows an animated\n * typing indicator when `isLoading` is true.\n */\nexport function AssistantMessage({\n content,\n isLoading = false,\n timestamp,\n style,\n}: AssistantMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n {content ? <CopilotMarkdown content={content} /> : null}\n {isLoading ? <TypingIndicator /> : null}\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-start\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: ASSISTANT_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomRightRadius: 16,\n borderBottomLeftRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginLeft: 4,\n },\n});\n","import React from \"react\";\nimport { View, Text, StyleSheet, type ViewStyle } from \"react-native\";\nimport { formatTimestamp } from \"./utils\";\n\n// ─── Colors ──────────────────────────────────────────────────────────────────\nconst USER_BUBBLE_BG = \"#0066CC\";\nconst USER_TEXT_COLOR = \"#FFFFFF\";\nconst TIMESTAMP_COLOR = \"#999999\";\n\n/**\n * Props for the UserMessage component.\n */\nexport interface UserMessageProps {\n /** Plain text content to display */\n content: string;\n /** Optional timestamp displayed below the bubble */\n timestamp?: Date;\n /** Optional style override for the outer container */\n style?: ViewStyle;\n}\n\n/**\n * Right-aligned chat bubble for user messages.\n *\n * Renders plain text (no markdown) with a primary-color background\n * and white text. Optionally displays a subtle timestamp below.\n */\nexport function UserMessage({ content, timestamp, style }: UserMessageProps) {\n return (\n <View style={[styles.container, style]}>\n <View style={styles.bubble}>\n <Text style={styles.text}>{content}</Text>\n </View>\n {timestamp && (\n <Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n alignItems: \"flex-end\",\n marginVertical: 4,\n paddingHorizontal: 12,\n },\n bubble: {\n backgroundColor: USER_BUBBLE_BG,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n borderBottomLeftRadius: 16,\n borderBottomRightRadius: 4,\n paddingHorizontal: 12,\n paddingVertical: 8,\n maxWidth: \"80%\",\n },\n text: {\n color: USER_TEXT_COLOR,\n fontSize: 16,\n lineHeight: 22,\n },\n timestamp: {\n color: TIMESTAMP_COLOR,\n fontSize: 11,\n marginTop: 2,\n marginRight: 4,\n },\n});\n","import React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n FlatList,\n KeyboardAvoidingView,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n} from \"react-native\";\nimport type { ListRenderItemInfo, ViewStyle } from \"react-native\";\nimport { useAgent } from \"@copilotkit/react-core/v2/headless\";\nimport { useCopilotKit } from \"@copilotkit/react-core/v2/context\";\nimport { AssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage } from \"./messages/UserMessage\";\nimport { useRenderToolRegistry } from \"../hooks/RenderToolContext\";\nimport type { Message } from \"@copilotkit/shared\";\nimport { partialJSONParse } from \"@copilotkit/shared\";\n\n/** Shape of an assistant message with optional tool calls. */\ninterface AssistantMessageShape {\n id: string;\n role: \"assistant\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\nexport interface CopilotChatProps {\n /** Agent ID to connect to. Defaults to 'default'. */\n agentName?: string;\n /** Placeholder text for the input field. */\n placeholder?: string;\n /** Suggestion pills shown in the empty state. */\n initialMessages?: string[];\n /** Title shown when there are no messages. */\n emptyStateTitle?: string;\n /** Subtitle shown when there are no messages. */\n emptyStateSubtitle?: string;\n /** Title for the optional header bar. */\n headerTitle?: string;\n /** Whether to show the header bar. Defaults to true. */\n showHeader?: boolean;\n /** Style override for the outermost container. */\n style?: ViewStyle;\n /** Style override for the message list container. */\n messageContainerStyle?: ViewStyle;\n /** Style override for the input bar container. */\n inputContainerStyle?: ViewStyle;\n /** Callback fired when the user sends a message. */\n onSendMessage?: (text: string) => void;\n /** Custom FlatList component (e.g. BottomSheetFlatList for use inside a bottom sheet). */\n FlatListComponent?: React.ComponentType<any>;\n /** When true, skip the KeyboardAvoidingView wrapper (useful when a parent already handles keyboard). */\n disableKeyboardAvoiding?: boolean;\n}\n\ninterface ChatListItem {\n id: string;\n type: \"user\" | \"assistant\" | \"tool-call\" | \"loading\";\n content?: string;\n toolCalls?: Array<{\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n }>;\n}\n\n/**\n * Full-screen chat UI component for React Native.\n *\n * Connects to a CopilotKit agent via `useAgent` and renders messages\n * using platform-appropriate AssistantMessage / UserMessage components.\n *\n * Usage:\n * ```tsx\n * <CopilotChat agentName=\"my-agent\" headerTitle=\"Assistant\" />\n * ```\n */\nexport function CopilotChat({\n agentName = \"default\",\n placeholder = \"Type a message...\",\n initialMessages = [],\n emptyStateTitle = \"How can I help?\",\n emptyStateSubtitle = \"Ask me anything or try a suggestion below.\",\n headerTitle = \"Chat\",\n showHeader = true,\n style,\n messageContainerStyle,\n inputContainerStyle,\n onSendMessage,\n FlatListComponent = FlatList,\n disableKeyboardAvoiding = false,\n}: CopilotChatProps) {\n const [inputText, setInputText] = useState(\"\");\n const [error, setError] = useState<string | null>(null);\n const flatListRef = useRef<FlatList>(null);\n const messageIdCounter = useRef(0);\n\n const { copilotkit, executingToolCallIds } = useCopilotKit();\n const { agent } = useAgent({ agentId: agentName });\n\n const messages = agent.messages ?? [];\n const isRunning = agent.isRunning;\n\n const toolRenderers = useRenderToolRegistry();\n\n // Stable extraData for FlatList to avoid re-creating the object every render\n const extraData = useMemo(\n () => ({ isRunning, executingToolCallIds, toolRenderers }),\n [isRunning, executingToolCallIds, toolRenderers],\n );\n\n // Build flat list items from messages\n const listItems: ChatListItem[] = useMemo(() => {\n const items: ChatListItem[] = [];\n\n for (const msg of messages) {\n if (msg.role === \"user\") {\n items.push({\n id: msg.id,\n type: \"user\",\n content: typeof msg.content === \"string\" ? msg.content : \"\",\n });\n } else if (msg.role === \"assistant\") {\n const assistantMsg = msg as AssistantMessageShape;\n // Add text content if present\n if (assistantMsg.content) {\n items.push({\n id: msg.id,\n type: \"assistant\",\n content: assistantMsg.content,\n });\n }\n // Add tool calls if present\n if (assistantMsg.toolCalls && assistantMsg.toolCalls.length > 0) {\n for (const tc of assistantMsg.toolCalls) {\n items.push({\n id: `${msg.id}-tc-${tc.id}`,\n type: \"tool-call\",\n toolCalls: [tc],\n });\n }\n }\n }\n }\n\n // Show loading indicator when agent is running and the last message\n // is not already the assistant streaming\n if (isRunning) {\n const lastItem = items[items.length - 1];\n if (!lastItem || lastItem.type !== \"assistant\") {\n items.push({ id: \"__loading__\", type: \"loading\" });\n }\n }\n\n return items;\n }, [messages, isRunning]);\n\n // Shared logic for sending a message to the agent\n const sendMessage = useCallback(\n async (text: string) => {\n if (!text || isRunning || !agent) return;\n\n setError(null);\n onSendMessage?.(text);\n\n const id = `user-${++messageIdCounter.current}`;\n agent.addMessage({\n id,\n role: \"user\",\n content: text,\n } as Message);\n\n try {\n await copilotkit.runAgent({ agent });\n } catch (err) {\n const message =\n err instanceof Error ? err.message : \"An unexpected error occurred\";\n console.error(\"[CopilotChat] runAgent failed:\", err);\n setError(message);\n }\n },\n [isRunning, agent, copilotkit, onSendMessage],\n );\n\n // Send from the input field\n const handleSend = useCallback(async () => {\n const text = inputText.trim();\n if (!text) return;\n setInputText(\"\");\n await sendMessage(text);\n }, [inputText, sendMessage]);\n\n // Handle suggestion pill press\n const handleSuggestion = useCallback(\n (text: string) => {\n void sendMessage(text);\n },\n [sendMessage],\n );\n\n // Auto-scroll when content changes\n const handleContentSizeChange = useCallback(() => {\n flatListRef.current?.scrollToEnd({ animated: true });\n }, []);\n\n // Render a single list item\n const renderItem = useCallback(\n ({ item }: ListRenderItemInfo<ChatListItem>) => {\n if (item.type === \"user\") {\n return <UserMessage content={item.content ?? \"\"} />;\n }\n\n if (item.type === \"assistant\") {\n return (\n <AssistantMessage\n content={item.content ?? \"\"}\n isLoading={\n isRunning && item.id === listItems[listItems.length - 1]?.id\n }\n />\n );\n }\n\n if (item.type === \"tool-call\" && item.toolCalls) {\n const tc = item.toolCalls[0];\n const renderer = toolRenderers.get(tc.function.name);\n if (renderer) {\n // Partial parse, NOT JSON.parse: while the model is still writing the call, the argument\n // string is incomplete JSON. JSON.parse threw on every streamed delta, warned, and fell\n // back to {} — so a registered component rendered nothing until the call finished. Partial\n // parsing lets it paint as the arguments arrive, which is what the web renderer does.\n const raw = tc.function.arguments || \"{}\";\n const args = partialJSONParse(raw);\n // Incomplete JSON IS the signal that the model is still writing this call — no extra\n // stream state needed. Once it parses strictly, fall back to the previous semantics.\n let argsComplete = true;\n try {\n JSON.parse(raw);\n } catch {\n argsComplete = false;\n }\n const status = !argsComplete\n ? \"inProgress\"\n : executingToolCallIds.has(tc.id)\n ? \"executing\"\n : \"complete\";\n return renderer({ args, status });\n }\n // Subtle indicator for unregistered tool calls\n return (\n <View style={styles.toolCallIndicator}>\n <Text style={styles.toolCallText}>Called: {tc.function.name}</Text>\n </View>\n );\n }\n\n if (item.type === \"loading\") {\n return <AssistantMessage content=\"\" isLoading />;\n }\n\n return null;\n },\n [isRunning, listItems, toolRenderers, executingToolCallIds],\n );\n\n const keyExtractor = useCallback((item: ChatListItem) => item.id, []);\n\n // Empty state component\n const emptyComponent = useMemo(\n () => (\n <View style={styles.emptyState}>\n <Text style={styles.emptyTitle}>{emptyStateTitle}</Text>\n <Text style={styles.emptySubtitle}>{emptyStateSubtitle}</Text>\n {initialMessages.map((suggestion, i) => (\n <Pressable\n key={`suggestion-${i}`}\n style={styles.suggestionPill}\n onPress={() => handleSuggestion(suggestion)}\n >\n <Text style={styles.suggestionText}>{suggestion}</Text>\n </Pressable>\n ))}\n </View>\n ),\n [emptyStateTitle, emptyStateSubtitle, initialMessages, handleSuggestion],\n );\n\n const sendDisabled = !inputText.trim() || isRunning;\n\n const content = (\n <>\n {showHeader && (\n <View style={styles.header}>\n <Text style={styles.headerTitle}>{headerTitle}</Text>\n </View>\n )}\n\n <FlatListComponent\n ref={flatListRef}\n data={listItems}\n renderItem={renderItem}\n keyExtractor={keyExtractor}\n extraData={extraData}\n contentContainerStyle={[styles.messageList, messageContainerStyle]}\n onContentSizeChange={handleContentSizeChange}\n ListEmptyComponent={emptyComponent}\n />\n\n {error && (\n <View style={styles.errorContainer} testID=\"error-message\">\n <Text style={styles.errorText}>{error}</Text>\n </View>\n )}\n\n <View style={[styles.inputContainer, inputContainerStyle]}>\n <TextInput\n style={styles.input}\n value={inputText}\n onChangeText={setInputText}\n placeholder={placeholder}\n placeholderTextColor=\"#999\"\n multiline\n numberOfLines={4}\n returnKeyType=\"send\"\n onSubmitEditing={handleSend}\n />\n <TouchableOpacity\n style={[styles.sendButton, sendDisabled && styles.sendButtonDisabled]}\n onPress={handleSend}\n disabled={sendDisabled}\n testID=\"send-button\"\n >\n <Text style={styles.sendButtonIcon}>{\"↑\"}</Text>\n </TouchableOpacity>\n </View>\n </>\n );\n\n if (disableKeyboardAvoiding) {\n return <View style={[styles.container, style]}>{content}</View>;\n }\n\n return (\n <KeyboardAvoidingView\n style={[styles.container, style]}\n behavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n keyboardVerticalOffset={0}\n >\n {content}\n </KeyboardAvoidingView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"#FFFFFF\",\n },\n header: {\n height: 56,\n justifyContent: \"center\",\n alignItems: \"center\",\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderBottomColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n headerTitle: {\n fontSize: 17,\n fontWeight: \"600\",\n color: \"#1A1A1A\",\n },\n messageList: {\n paddingHorizontal: 16,\n flexGrow: 1,\n },\n inputContainer: {\n flexDirection: \"row\",\n alignItems: \"flex-end\",\n paddingHorizontal: 8,\n paddingVertical: 8,\n borderTopWidth: StyleSheet.hairlineWidth,\n borderTopColor: \"#E0E0E0\",\n backgroundColor: \"#FFFFFF\",\n },\n input: {\n flex: 1,\n backgroundColor: \"#F5F5F5\",\n borderRadius: 20,\n paddingHorizontal: 12,\n paddingVertical: 8,\n fontSize: 15,\n maxHeight: 100,\n color: \"#1A1A1A\",\n },\n sendButton: {\n width: 36,\n height: 36,\n borderRadius: 18,\n backgroundColor: \"#0066CC\",\n justifyContent: \"center\",\n alignItems: \"center\",\n marginLeft: 8,\n },\n sendButtonDisabled: {\n opacity: 0.4,\n },\n sendButtonIcon: {\n color: \"#FFFFFF\",\n fontSize: 18,\n fontWeight: \"700\",\n },\n emptyState: {\n flex: 1,\n justifyContent: \"center\",\n alignItems: \"center\",\n paddingTop: 100,\n gap: 12,\n },\n emptyTitle: {\n fontSize: 22,\n fontWeight: \"700\",\n color: \"#1A1A1A\",\n marginBottom: 4,\n },\n emptySubtitle: {\n fontSize: 15,\n color: \"#666666\",\n marginBottom: 16,\n },\n suggestionPill: {\n backgroundColor: \"#E8F0FE\",\n borderRadius: 20,\n paddingHorizontal: 16,\n paddingVertical: 10,\n },\n suggestionText: {\n color: \"#0066CC\",\n fontWeight: \"600\",\n fontSize: 14,\n },\n toolCallIndicator: {\n alignSelf: \"flex-start\",\n backgroundColor: \"#F0F0F0\",\n borderRadius: 12,\n paddingHorizontal: 12,\n paddingVertical: 6,\n marginBottom: 8,\n },\n toolCallText: {\n fontSize: 12,\n color: \"#999999\",\n fontStyle: \"italic\",\n },\n errorContainer: {\n backgroundColor: \"#FEE2E2\",\n paddingHorizontal: 12,\n paddingVertical: 8,\n marginHorizontal: 8,\n borderRadius: 8,\n },\n errorText: {\n color: \"#DC2626\",\n fontSize: 13,\n },\n});\n","/**\n * CopilotModal — a bottom-sheet chat overlay for React Native.\n *\n * Mobile equivalent of CopilotPopup on web. Wraps CopilotChat inside\n * @gorhom/bottom-sheet so the chat can slide up over any screen.\n */\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport { StyleSheet, View } from \"react-native\";\nimport BottomSheet, {\n BottomSheetBackdrop,\n BottomSheetFlatList,\n BottomSheetView,\n} from \"@gorhom/bottom-sheet\";\nimport type { BottomSheetBackdropProps } from \"@gorhom/bottom-sheet\";\nimport { CopilotChat } from \"./CopilotChat\";\nimport type { CopilotChatProps } from \"./CopilotChat\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface CopilotModalProps {\n /** Controlled visibility — when true the sheet opens, when false it closes. */\n visible?: boolean;\n\n /** Called when the sheet is dismissed (via backdrop tap, swipe-down, or close()). */\n onDismiss?: () => void;\n\n /**\n * Bottom-sheet snap points.\n * @default ['50%', '90%']\n */\n snapPoints?: (string | number)[];\n\n /**\n * Which snap-point index to open at.\n * @default 0\n */\n initialSnapIndex?: number;\n\n /**\n * Whether closing the sheet fires onDismiss.\n * @default true\n */\n enableDismissOnClose?: boolean;\n\n /**\n * Backdrop opacity when the sheet is open.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n // -- Pass-through to CopilotChat ------------------------------------------\n\n /** Which agent to connect to. */\n agentName?: string;\n\n /** Input placeholder text. */\n placeholder?: string;\n\n /** Seed messages shown on first render. */\n initialMessages?: string[];\n\n /** Title shown in the CopilotChat header area. */\n headerTitle?: string;\n}\n\n/** Imperative handle exposed via ref. */\nexport interface CopilotModalRef {\n /** Programmatically open the bottom sheet. */\n open: () => void;\n /** Programmatically close the bottom sheet. */\n close: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\nexport const CopilotModal = forwardRef<CopilotModalRef, CopilotModalProps>(\n function CopilotModal(\n {\n visible,\n onDismiss,\n snapPoints: snapPointsProp,\n initialSnapIndex = 0,\n enableDismissOnClose = true,\n backdropOpacity = 0.5,\n agentName,\n placeholder,\n initialMessages,\n headerTitle,\n },\n ref,\n ) {\n const bottomSheetRef = useRef<BottomSheet>(null);\n\n // Stable snap-points array\n const snapPoints = useMemo(\n () => snapPointsProp ?? [\"50%\", \"90%\"],\n [snapPointsProp],\n );\n\n // ── Imperative API ────────────────────────────────────────────────────\n useImperativeHandle(\n ref,\n () => ({\n open() {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n },\n close() {\n bottomSheetRef.current?.close();\n },\n }),\n [initialSnapIndex],\n );\n\n // ── Controlled visibility ─────────────────────────────────────────────\n useEffect(() => {\n if (visible === undefined) return;\n if (visible) {\n bottomSheetRef.current?.snapToIndex(initialSnapIndex);\n } else {\n bottomSheetRef.current?.close();\n }\n }, [visible, initialSnapIndex]);\n\n // ── Backdrop renderer ─────────────────────────────────────────────────\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n disappearsOnIndex={-1}\n appearsOnIndex={0}\n opacity={backdropOpacity}\n pressBehavior=\"close\"\n />\n ),\n [backdropOpacity],\n );\n\n // ── Sheet close handler ───────────────────────────────────────────────\n const handleClose = useCallback(() => {\n if (enableDismissOnClose) {\n onDismiss?.();\n }\n }, [enableDismissOnClose, onDismiss]);\n\n // ── Build CopilotChat props ───────────────────────────────────────────\n const chatProps = useMemo(() => {\n const props: Partial<CopilotChatProps> = {};\n if (agentName !== undefined) props.agentName = agentName;\n if (placeholder !== undefined) props.placeholder = placeholder;\n if (initialMessages !== undefined)\n props.initialMessages = initialMessages;\n if (headerTitle !== undefined) props.headerTitle = headerTitle;\n return props;\n }, [agentName, placeholder, initialMessages, headerTitle]);\n\n return (\n <BottomSheet\n ref={bottomSheetRef}\n index={-1}\n snapPoints={snapPoints}\n enablePanDownToClose\n backdropComponent={renderBackdrop}\n onClose={handleClose}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n backgroundStyle={styles.sheetBackground}\n handleIndicatorStyle={styles.handleIndicator}\n >\n <BottomSheetView style={styles.contentContainer}>\n <CopilotChat\n {...chatProps}\n FlatListComponent={BottomSheetFlatList}\n disableKeyboardAvoiding\n />\n </BottomSheetView>\n </BottomSheet>\n );\n },\n);\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst styles = StyleSheet.create({\n sheetBackground: {\n backgroundColor: \"#FFFFFF\",\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n },\n handleIndicator: {\n width: 40,\n height: 4,\n backgroundColor: \"#DDDDDD\",\n },\n contentContainer: {\n flex: 1,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,wBAAuC;CAClD,WAAW;EACT,UAAU;EACV,YAAY;EACZ,OAAO;EACP,WAAW;EACX,cAAc;EACf;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WAAW;EACX,cAAc;EACd,OAAO;EACR;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WAAW;EACX,cAAc;EACd,OAAO;EACR;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACZ,WAAW;EACX,cAAc;EACd,OAAO;EACR;CACD,QAAQ,EACN,YAAY,QACb;CACD,IAAI,EACF,WAAW,UACZ;CACD,MAAM;EACJ,OAAO;EACP,WAAW;EACZ;CACD,YAAY;EACV,iBAAiB;EACjB,aAAa;EACb,aAAa;EACb,UAAU;EACX;CACD,MAAM;EACJ,iBAAiB;EACjB,YAAY;EACZ,UAAU;EACX;CACD,WAAW;EACT,iBAAiB;EACjB,cAAc;EACd,SAAS;EACT,YAAY;EACZ,UAAU;EACX;CACD,MAAM;EACJ,WAAW;EACX,cAAc;EACf;CACF;;;;;;;;;;;;AAaD,SAAgB,gBAAgB,EAC9B,SACA,OACA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BAAiB;EACjB,sBAAqB;EACrB,iBAAiB,OAAO;EACxB,sBAAsB,OAAO;YAE7B,oBAAC;GAAgB,OAAO,OAAO;aAC7B,oBAAC;IACC,GAAI;IACJ,mBAAmB;IACnB;KACA;IACc;GACN;EAGnB;AAMD,MAAM,SAAS,WAAW,OAAO;CAC/B,iBAAiB;EACf,iBAAiB;EACjB,qBAAqB;EACrB,sBAAsB;EACvB;CACD,iBAAiB;EACf,OAAO;EACP,QAAQ;EACR,iBAAiB;EAClB;CACD,kBAAkB,EAChB,MAAM,GACP;CACF,CAAC"}
|
package/dist/headless.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_RenderToolContext = require('./RenderToolContext-CBNKcJqz.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_useRenderToolCall = require('./useRenderToolCall-DawGeFfu.cjs');
|
|
4
4
|
let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
|
|
5
5
|
let _copilotkit_react_core_v2_headless = require("@copilotkit/react-core/v2/headless");
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, 'CopilotKitContext', {
|
|
|
16
16
|
return _copilotkit_react_core_v2_context.CopilotKitContext;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
exports.CopilotKitProvider =
|
|
19
|
+
exports.CopilotKitProvider = require_useRenderToolCall.CopilotKitProvider;
|
|
20
20
|
exports.RenderToolProvider = require_RenderToolContext.RenderToolProvider;
|
|
21
21
|
Object.defineProperty(exports, 'defineToolCallRenderer', {
|
|
22
22
|
enumerable: true,
|
|
@@ -42,12 +42,7 @@ Object.defineProperty(exports, 'useCapabilities', {
|
|
|
42
42
|
return _copilotkit_react_core_v2_headless.useCapabilities;
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () {
|
|
48
|
-
return _copilotkit_react_core_v2_headless.useComponent;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
45
|
+
exports.useComponent = require_useRenderToolCall.useComponent;
|
|
51
46
|
Object.defineProperty(exports, 'useConfigureSuggestions', {
|
|
52
47
|
enumerable: true,
|
|
53
48
|
get: function () {
|
|
@@ -84,7 +79,8 @@ Object.defineProperty(exports, 'useLicenseContext', {
|
|
|
84
79
|
return _copilotkit_react_core_v2_context.useLicenseContext;
|
|
85
80
|
}
|
|
86
81
|
});
|
|
87
|
-
exports.useRenderTool =
|
|
82
|
+
exports.useRenderTool = require_useRenderToolCall.useRenderTool;
|
|
83
|
+
exports.useRenderToolCall = require_useRenderToolCall.useRenderToolCall;
|
|
88
84
|
exports.useRenderToolRegistry = require_RenderToolContext.useRenderToolRegistry;
|
|
89
85
|
Object.defineProperty(exports, 'useSuggestions', {
|
|
90
86
|
enumerable: true,
|