@copilotkitnext/react 0.0.13-alpha.1 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +85 -34
- package/dist/index.d.ts +85 -34
- package/dist/index.js +481 -418
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +444 -372
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -9
- package/vitest.config.mjs +5 -0
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
import React__default, { ReactNode } from 'react';
|
|
4
4
|
import { AssistantMessage, Message, UserMessage, ToolCall, ToolMessage } from '@ag-ui/core';
|
|
5
|
-
import {
|
|
5
|
+
import { Streamdown } from 'streamdown';
|
|
6
|
+
import { Suggestion, CopilotKitCore, ToolCallStatus, FrontendTool, DynamicSuggestionsConfig, StaticSuggestionsConfig, CopilotKitCoreConfig, CopilotKitCoreSubscriber } from '@copilotkitnext/core';
|
|
6
7
|
import { z } from 'zod';
|
|
8
|
+
import * as _lit_labs_react from '@lit-labs/react';
|
|
9
|
+
import { WebInspectorElement } from '@copilotkitnext/web-inspector';
|
|
7
10
|
import { AbstractAgent, Context } from '@ag-ui/client';
|
|
8
11
|
|
|
9
12
|
declare const CopilotChatDefaultLabels: {
|
|
@@ -150,7 +153,7 @@ type CopilotChatAssistantMessageProps = WithSlots<{
|
|
|
150
153
|
} & React.HTMLAttributes<HTMLDivElement>>;
|
|
151
154
|
declare function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible, markdownRenderer, toolbar, copyButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }: CopilotChatAssistantMessageProps): react_jsx_runtime.JSX.Element;
|
|
152
155
|
declare namespace CopilotChatAssistantMessage {
|
|
153
|
-
const MarkdownRenderer: React.FC<React.
|
|
156
|
+
const MarkdownRenderer: React.FC<Omit<React.ComponentProps<typeof Streamdown>, "children"> & {
|
|
154
157
|
content: string;
|
|
155
158
|
}>;
|
|
156
159
|
const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
@@ -359,7 +362,14 @@ declare namespace CopilotSidebar {
|
|
|
359
362
|
var displayName: string;
|
|
360
363
|
}
|
|
361
364
|
|
|
362
|
-
declare const WildcardToolCallRender:
|
|
365
|
+
declare const WildcardToolCallRender: ReactToolCallRenderer<any>;
|
|
366
|
+
|
|
367
|
+
declare const CopilotKitInspectorBase: _lit_labs_react.ReactWebComponent<WebInspectorElement, {}>;
|
|
368
|
+
type CopilotKitInspectorBaseProps = React$1.ComponentProps<typeof CopilotKitInspectorBase>;
|
|
369
|
+
interface CopilotKitInspectorProps extends Omit<CopilotKitInspectorBaseProps, "core"> {
|
|
370
|
+
core?: CopilotKitCore | null;
|
|
371
|
+
}
|
|
372
|
+
declare const CopilotKitInspector: React$1.ForwardRefExoticComponent<Omit<CopilotKitInspectorProps, "ref"> & React$1.RefAttributes<WebInspectorElement>>;
|
|
363
373
|
|
|
364
374
|
interface UseRenderToolCallProps {
|
|
365
375
|
toolCall: ToolCall;
|
|
@@ -373,12 +383,33 @@ interface UseRenderToolCallProps {
|
|
|
373
383
|
*/
|
|
374
384
|
declare function useRenderToolCall(): ({ toolCall, toolMessage, }: UseRenderToolCallProps) => React__default.ReactElement | null;
|
|
375
385
|
|
|
376
|
-
|
|
386
|
+
type ReactCustomMessageRendererPosition = "before" | "after";
|
|
387
|
+
interface ReactCustomMessageRenderer {
|
|
388
|
+
agentId?: string;
|
|
389
|
+
render: React.ComponentType<{
|
|
390
|
+
message: Message;
|
|
391
|
+
position: ReactCustomMessageRendererPosition;
|
|
392
|
+
runId: string;
|
|
393
|
+
messageIndex: number;
|
|
394
|
+
messageIndexInRun: number;
|
|
395
|
+
numberOfMessagesInRun: number;
|
|
396
|
+
agentId: string;
|
|
397
|
+
stateSnapshot: any;
|
|
398
|
+
}> | null;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
interface UseRenderCustomMessagesParams {
|
|
402
|
+
message: Message;
|
|
403
|
+
position: ReactCustomMessageRendererPosition;
|
|
404
|
+
}
|
|
405
|
+
declare function useRenderCustomMessages(): ((params: UseRenderCustomMessagesParams) => react_jsx_runtime.JSX.Element | null) | null;
|
|
406
|
+
|
|
407
|
+
interface ReactToolCallRenderer<T> {
|
|
377
408
|
name: string;
|
|
378
409
|
args: z.ZodSchema<T>;
|
|
379
410
|
/**
|
|
380
|
-
* Optional agent ID to constrain this tool
|
|
381
|
-
* If specified, this
|
|
411
|
+
* Optional agent ID to constrain this tool renderer to a specific agent.
|
|
412
|
+
* If specified, this renderer will only be used for the specified agent.
|
|
382
413
|
*/
|
|
383
414
|
agentId?: string;
|
|
384
415
|
render: React.ComponentType<{
|
|
@@ -400,7 +431,7 @@ interface ReactToolCallRender<T> {
|
|
|
400
431
|
}
|
|
401
432
|
|
|
402
433
|
type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = FrontendTool<T> & {
|
|
403
|
-
render?:
|
|
434
|
+
render?: ReactToolCallRenderer<T>["render"];
|
|
404
435
|
};
|
|
405
436
|
|
|
406
437
|
declare function useFrontendTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactFrontendTool<T>): void;
|
|
@@ -468,30 +499,11 @@ interface UseConfigureSuggestionsOptions {
|
|
|
468
499
|
}
|
|
469
500
|
declare function useConfigureSuggestions(config: SuggestionsConfigInput | null | undefined, options?: UseConfigureSuggestionsOptions): void;
|
|
470
501
|
|
|
471
|
-
interface CopilotKitContextValue {
|
|
472
|
-
copilotkit: CopilotKitCore;
|
|
473
|
-
renderToolCalls: ReactToolCallRender<any>[];
|
|
474
|
-
currentRenderToolCalls: ReactToolCallRender<unknown>[];
|
|
475
|
-
setCurrentRenderToolCalls: React__default.Dispatch<React__default.SetStateAction<ReactToolCallRender<unknown>[]>>;
|
|
476
|
-
}
|
|
477
|
-
interface CopilotKitProviderProps {
|
|
478
|
-
children: ReactNode;
|
|
479
|
-
runtimeUrl?: string;
|
|
480
|
-
headers?: Record<string, string>;
|
|
481
|
-
properties?: Record<string, unknown>;
|
|
482
|
-
agents__unsafe_dev_only?: Record<string, AbstractAgent>;
|
|
483
|
-
renderToolCalls?: ReactToolCallRender<any>[];
|
|
484
|
-
frontendTools?: ReactFrontendTool[];
|
|
485
|
-
humanInTheLoop?: ReactHumanInTheLoop[];
|
|
486
|
-
}
|
|
487
|
-
declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
|
|
488
|
-
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
489
|
-
|
|
490
502
|
/**
|
|
491
|
-
* Helper to define a type-safe tool call
|
|
492
|
-
* - Accepts a single object whose keys match
|
|
503
|
+
* Helper to define a type-safe tool call renderer entry.
|
|
504
|
+
* - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
|
|
493
505
|
* - Derives `args` type from the provided Zod schema.
|
|
494
|
-
* - Ensures the render function param type exactly matches
|
|
506
|
+
* - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
|
|
495
507
|
* - For wildcard tools (name: "*"), args is optional and defaults to z.any()
|
|
496
508
|
*/
|
|
497
509
|
type RenderProps<T> = {
|
|
@@ -510,16 +522,55 @@ type RenderProps<T> = {
|
|
|
510
522
|
status: ToolCallStatus.Complete;
|
|
511
523
|
result: string;
|
|
512
524
|
};
|
|
513
|
-
declare function
|
|
525
|
+
declare function defineToolCallRenderer(def: {
|
|
514
526
|
name: "*";
|
|
515
527
|
render: (props: RenderProps<any>) => React__default.ReactElement;
|
|
516
528
|
agentId?: string;
|
|
517
|
-
}):
|
|
518
|
-
declare function
|
|
529
|
+
}): ReactToolCallRenderer<any>;
|
|
530
|
+
declare function defineToolCallRenderer<S extends z.ZodTypeAny>(def: {
|
|
519
531
|
name: string;
|
|
520
532
|
args: S;
|
|
521
533
|
render: (props: RenderProps<z.infer<S>>) => React__default.ReactElement;
|
|
522
534
|
agentId?: string;
|
|
523
|
-
}):
|
|
535
|
+
}): ReactToolCallRenderer<z.infer<S>>;
|
|
536
|
+
|
|
537
|
+
interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {
|
|
538
|
+
renderToolCalls?: ReactToolCallRenderer<any>[];
|
|
539
|
+
renderCustomMessages?: ReactCustomMessageRenderer[];
|
|
540
|
+
}
|
|
541
|
+
interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {
|
|
542
|
+
onRenderToolCallsChanged?: (event: {
|
|
543
|
+
copilotkit: CopilotKitCore;
|
|
544
|
+
renderToolCalls: ReactToolCallRenderer<any>[];
|
|
545
|
+
}) => void | Promise<void>;
|
|
546
|
+
}
|
|
547
|
+
declare class CopilotKitCoreReact extends CopilotKitCore {
|
|
548
|
+
private _renderToolCalls;
|
|
549
|
+
private _renderCustomMessages;
|
|
550
|
+
constructor(config: CopilotKitCoreReactConfig);
|
|
551
|
+
get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]>;
|
|
552
|
+
get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[];
|
|
553
|
+
setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void;
|
|
554
|
+
subscribe(subscriber: CopilotKitCoreReactSubscriber): () => void;
|
|
555
|
+
unsubscribe(subscriber: CopilotKitCoreReactSubscriber): void;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
interface CopilotKitContextValue {
|
|
559
|
+
copilotkit: CopilotKitCoreReact;
|
|
560
|
+
}
|
|
561
|
+
interface CopilotKitProviderProps {
|
|
562
|
+
children: ReactNode;
|
|
563
|
+
runtimeUrl?: string;
|
|
564
|
+
headers?: Record<string, string>;
|
|
565
|
+
properties?: Record<string, unknown>;
|
|
566
|
+
agents__unsafe_dev_only?: Record<string, AbstractAgent>;
|
|
567
|
+
renderToolCalls?: ReactToolCallRenderer<any>[];
|
|
568
|
+
renderCustomMessages?: ReactCustomMessageRenderer[];
|
|
569
|
+
frontendTools?: ReactFrontendTool[];
|
|
570
|
+
humanInTheLoop?: ReactHumanInTheLoop[];
|
|
571
|
+
showDevConsole?: boolean | "auto";
|
|
572
|
+
}
|
|
573
|
+
declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
|
|
574
|
+
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
524
575
|
|
|
525
|
-
export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type ReactFrontendTool, type ReactHumanInTheLoop, type
|
|
576
|
+
export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorBaseProps, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderCustomMessages, useRenderToolCall, useSuggestions };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
import React__default, { ReactNode } from 'react';
|
|
4
4
|
import { AssistantMessage, Message, UserMessage, ToolCall, ToolMessage } from '@ag-ui/core';
|
|
5
|
-
import {
|
|
5
|
+
import { Streamdown } from 'streamdown';
|
|
6
|
+
import { Suggestion, CopilotKitCore, ToolCallStatus, FrontendTool, DynamicSuggestionsConfig, StaticSuggestionsConfig, CopilotKitCoreConfig, CopilotKitCoreSubscriber } from '@copilotkitnext/core';
|
|
6
7
|
import { z } from 'zod';
|
|
8
|
+
import * as _lit_labs_react from '@lit-labs/react';
|
|
9
|
+
import { WebInspectorElement } from '@copilotkitnext/web-inspector';
|
|
7
10
|
import { AbstractAgent, Context } from '@ag-ui/client';
|
|
8
11
|
|
|
9
12
|
declare const CopilotChatDefaultLabels: {
|
|
@@ -150,7 +153,7 @@ type CopilotChatAssistantMessageProps = WithSlots<{
|
|
|
150
153
|
} & React.HTMLAttributes<HTMLDivElement>>;
|
|
151
154
|
declare function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible, markdownRenderer, toolbar, copyButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }: CopilotChatAssistantMessageProps): react_jsx_runtime.JSX.Element;
|
|
152
155
|
declare namespace CopilotChatAssistantMessage {
|
|
153
|
-
const MarkdownRenderer: React.FC<React.
|
|
156
|
+
const MarkdownRenderer: React.FC<Omit<React.ComponentProps<typeof Streamdown>, "children"> & {
|
|
154
157
|
content: string;
|
|
155
158
|
}>;
|
|
156
159
|
const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
@@ -359,7 +362,14 @@ declare namespace CopilotSidebar {
|
|
|
359
362
|
var displayName: string;
|
|
360
363
|
}
|
|
361
364
|
|
|
362
|
-
declare const WildcardToolCallRender:
|
|
365
|
+
declare const WildcardToolCallRender: ReactToolCallRenderer<any>;
|
|
366
|
+
|
|
367
|
+
declare const CopilotKitInspectorBase: _lit_labs_react.ReactWebComponent<WebInspectorElement, {}>;
|
|
368
|
+
type CopilotKitInspectorBaseProps = React$1.ComponentProps<typeof CopilotKitInspectorBase>;
|
|
369
|
+
interface CopilotKitInspectorProps extends Omit<CopilotKitInspectorBaseProps, "core"> {
|
|
370
|
+
core?: CopilotKitCore | null;
|
|
371
|
+
}
|
|
372
|
+
declare const CopilotKitInspector: React$1.ForwardRefExoticComponent<Omit<CopilotKitInspectorProps, "ref"> & React$1.RefAttributes<WebInspectorElement>>;
|
|
363
373
|
|
|
364
374
|
interface UseRenderToolCallProps {
|
|
365
375
|
toolCall: ToolCall;
|
|
@@ -373,12 +383,33 @@ interface UseRenderToolCallProps {
|
|
|
373
383
|
*/
|
|
374
384
|
declare function useRenderToolCall(): ({ toolCall, toolMessage, }: UseRenderToolCallProps) => React__default.ReactElement | null;
|
|
375
385
|
|
|
376
|
-
|
|
386
|
+
type ReactCustomMessageRendererPosition = "before" | "after";
|
|
387
|
+
interface ReactCustomMessageRenderer {
|
|
388
|
+
agentId?: string;
|
|
389
|
+
render: React.ComponentType<{
|
|
390
|
+
message: Message;
|
|
391
|
+
position: ReactCustomMessageRendererPosition;
|
|
392
|
+
runId: string;
|
|
393
|
+
messageIndex: number;
|
|
394
|
+
messageIndexInRun: number;
|
|
395
|
+
numberOfMessagesInRun: number;
|
|
396
|
+
agentId: string;
|
|
397
|
+
stateSnapshot: any;
|
|
398
|
+
}> | null;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
interface UseRenderCustomMessagesParams {
|
|
402
|
+
message: Message;
|
|
403
|
+
position: ReactCustomMessageRendererPosition;
|
|
404
|
+
}
|
|
405
|
+
declare function useRenderCustomMessages(): ((params: UseRenderCustomMessagesParams) => react_jsx_runtime.JSX.Element | null) | null;
|
|
406
|
+
|
|
407
|
+
interface ReactToolCallRenderer<T> {
|
|
377
408
|
name: string;
|
|
378
409
|
args: z.ZodSchema<T>;
|
|
379
410
|
/**
|
|
380
|
-
* Optional agent ID to constrain this tool
|
|
381
|
-
* If specified, this
|
|
411
|
+
* Optional agent ID to constrain this tool renderer to a specific agent.
|
|
412
|
+
* If specified, this renderer will only be used for the specified agent.
|
|
382
413
|
*/
|
|
383
414
|
agentId?: string;
|
|
384
415
|
render: React.ComponentType<{
|
|
@@ -400,7 +431,7 @@ interface ReactToolCallRender<T> {
|
|
|
400
431
|
}
|
|
401
432
|
|
|
402
433
|
type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = FrontendTool<T> & {
|
|
403
|
-
render?:
|
|
434
|
+
render?: ReactToolCallRenderer<T>["render"];
|
|
404
435
|
};
|
|
405
436
|
|
|
406
437
|
declare function useFrontendTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactFrontendTool<T>): void;
|
|
@@ -468,30 +499,11 @@ interface UseConfigureSuggestionsOptions {
|
|
|
468
499
|
}
|
|
469
500
|
declare function useConfigureSuggestions(config: SuggestionsConfigInput | null | undefined, options?: UseConfigureSuggestionsOptions): void;
|
|
470
501
|
|
|
471
|
-
interface CopilotKitContextValue {
|
|
472
|
-
copilotkit: CopilotKitCore;
|
|
473
|
-
renderToolCalls: ReactToolCallRender<any>[];
|
|
474
|
-
currentRenderToolCalls: ReactToolCallRender<unknown>[];
|
|
475
|
-
setCurrentRenderToolCalls: React__default.Dispatch<React__default.SetStateAction<ReactToolCallRender<unknown>[]>>;
|
|
476
|
-
}
|
|
477
|
-
interface CopilotKitProviderProps {
|
|
478
|
-
children: ReactNode;
|
|
479
|
-
runtimeUrl?: string;
|
|
480
|
-
headers?: Record<string, string>;
|
|
481
|
-
properties?: Record<string, unknown>;
|
|
482
|
-
agents__unsafe_dev_only?: Record<string, AbstractAgent>;
|
|
483
|
-
renderToolCalls?: ReactToolCallRender<any>[];
|
|
484
|
-
frontendTools?: ReactFrontendTool[];
|
|
485
|
-
humanInTheLoop?: ReactHumanInTheLoop[];
|
|
486
|
-
}
|
|
487
|
-
declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
|
|
488
|
-
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
489
|
-
|
|
490
502
|
/**
|
|
491
|
-
* Helper to define a type-safe tool call
|
|
492
|
-
* - Accepts a single object whose keys match
|
|
503
|
+
* Helper to define a type-safe tool call renderer entry.
|
|
504
|
+
* - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
|
|
493
505
|
* - Derives `args` type from the provided Zod schema.
|
|
494
|
-
* - Ensures the render function param type exactly matches
|
|
506
|
+
* - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
|
|
495
507
|
* - For wildcard tools (name: "*"), args is optional and defaults to z.any()
|
|
496
508
|
*/
|
|
497
509
|
type RenderProps<T> = {
|
|
@@ -510,16 +522,55 @@ type RenderProps<T> = {
|
|
|
510
522
|
status: ToolCallStatus.Complete;
|
|
511
523
|
result: string;
|
|
512
524
|
};
|
|
513
|
-
declare function
|
|
525
|
+
declare function defineToolCallRenderer(def: {
|
|
514
526
|
name: "*";
|
|
515
527
|
render: (props: RenderProps<any>) => React__default.ReactElement;
|
|
516
528
|
agentId?: string;
|
|
517
|
-
}):
|
|
518
|
-
declare function
|
|
529
|
+
}): ReactToolCallRenderer<any>;
|
|
530
|
+
declare function defineToolCallRenderer<S extends z.ZodTypeAny>(def: {
|
|
519
531
|
name: string;
|
|
520
532
|
args: S;
|
|
521
533
|
render: (props: RenderProps<z.infer<S>>) => React__default.ReactElement;
|
|
522
534
|
agentId?: string;
|
|
523
|
-
}):
|
|
535
|
+
}): ReactToolCallRenderer<z.infer<S>>;
|
|
536
|
+
|
|
537
|
+
interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {
|
|
538
|
+
renderToolCalls?: ReactToolCallRenderer<any>[];
|
|
539
|
+
renderCustomMessages?: ReactCustomMessageRenderer[];
|
|
540
|
+
}
|
|
541
|
+
interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {
|
|
542
|
+
onRenderToolCallsChanged?: (event: {
|
|
543
|
+
copilotkit: CopilotKitCore;
|
|
544
|
+
renderToolCalls: ReactToolCallRenderer<any>[];
|
|
545
|
+
}) => void | Promise<void>;
|
|
546
|
+
}
|
|
547
|
+
declare class CopilotKitCoreReact extends CopilotKitCore {
|
|
548
|
+
private _renderToolCalls;
|
|
549
|
+
private _renderCustomMessages;
|
|
550
|
+
constructor(config: CopilotKitCoreReactConfig);
|
|
551
|
+
get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]>;
|
|
552
|
+
get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[];
|
|
553
|
+
setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void;
|
|
554
|
+
subscribe(subscriber: CopilotKitCoreReactSubscriber): () => void;
|
|
555
|
+
unsubscribe(subscriber: CopilotKitCoreReactSubscriber): void;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
interface CopilotKitContextValue {
|
|
559
|
+
copilotkit: CopilotKitCoreReact;
|
|
560
|
+
}
|
|
561
|
+
interface CopilotKitProviderProps {
|
|
562
|
+
children: ReactNode;
|
|
563
|
+
runtimeUrl?: string;
|
|
564
|
+
headers?: Record<string, string>;
|
|
565
|
+
properties?: Record<string, unknown>;
|
|
566
|
+
agents__unsafe_dev_only?: Record<string, AbstractAgent>;
|
|
567
|
+
renderToolCalls?: ReactToolCallRenderer<any>[];
|
|
568
|
+
renderCustomMessages?: ReactCustomMessageRenderer[];
|
|
569
|
+
frontendTools?: ReactFrontendTool[];
|
|
570
|
+
humanInTheLoop?: ReactHumanInTheLoop[];
|
|
571
|
+
showDevConsole?: boolean | "auto";
|
|
572
|
+
}
|
|
573
|
+
declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
|
|
574
|
+
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
524
575
|
|
|
525
|
-
export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type ReactFrontendTool, type ReactHumanInTheLoop, type
|
|
576
|
+
export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorBaseProps, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderCustomMessages, useRenderToolCall, useSuggestions };
|