@copilotkit/react-core 1.57.1 → 1.57.3
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/{copilotkit-sQWiKtxA.d.cts → copilotkit-BK9CVq9A.d.cts} +6 -1
- package/dist/{copilotkit-sQWiKtxA.d.cts.map → copilotkit-BK9CVq9A.d.cts.map} +1 -1
- package/dist/{copilotkit-DjxXMYHG.mjs → copilotkit-CC8DjOiC.mjs} +404 -367
- package/dist/copilotkit-CC8DjOiC.mjs.map +1 -0
- package/dist/{copilotkit-C3k13WZn.cjs → copilotkit-CtXcs1ea.cjs} +403 -366
- package/dist/copilotkit-CtXcs1ea.cjs.map +1 -0
- package/dist/{copilotkit-BN4I_y1n.d.mts → copilotkit-WlmeVijs.d.mts} +6 -1
- package/dist/{copilotkit-BN4I_y1n.d.mts.map → copilotkit-WlmeVijs.d.mts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +191 -15
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +110 -3
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +142 -2
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +142 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +108 -4
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +403 -364
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/v2/components/chat/CopilotSidebar.tsx +5 -1
- package/src/v2/components/chat/CopilotSidebarView.tsx +24 -10
- package/src/v2/components/chat/__tests__/CopilotChatPerf.e2e.test.tsx +68 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.tsx +159 -0
- package/src/v2/headless.ts +23 -1
- package/src/v2/hooks/__tests__/use-component.test.tsx +4 -1
- package/src/v2/hooks/use-component.tsx +2 -0
- package/src/v2/hooks/use-default-render-tool.tsx +18 -1
- package/src/v2/hooks/use-render-tool-call.tsx +35 -5
- package/dist/copilotkit-C3k13WZn.cjs.map +0 -1
- package/dist/copilotkit-DjxXMYHG.mjs.map +0 -1
package/dist/v2/headless.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React$1, { ComponentType, ReactNode } from "react";
|
|
2
2
|
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
3
3
|
import { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, DynamicSuggestionsConfig, FrontendTool, StaticSuggestionsConfig, Suggestion, ToolCallStatus } from "@copilotkit/core";
|
|
4
|
-
import { ActivityMessage, Message } from "@ag-ui/core";
|
|
4
|
+
import { ActivityMessage, AgentCapabilities, Message } from "@ag-ui/core";
|
|
5
5
|
import { AbstractAgent } from "@ag-ui/client";
|
|
6
6
|
|
|
7
7
|
//#region src/v2/types/react-tool-call-renderer.d.ts
|
|
@@ -106,6 +106,45 @@ type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unkn
|
|
|
106
106
|
}>;
|
|
107
107
|
};
|
|
108
108
|
//#endregion
|
|
109
|
+
//#region src/v2/types/defineToolCallRenderer.d.ts
|
|
110
|
+
/**
|
|
111
|
+
* Helper to define a type-safe tool call renderer entry.
|
|
112
|
+
* - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
|
|
113
|
+
* - Derives `args` type from the provided schema (any Standard Schema V1 compatible library).
|
|
114
|
+
* - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
|
|
115
|
+
* - For wildcard tools (name: "*"), args is optional and defaults to z.any()
|
|
116
|
+
*/
|
|
117
|
+
type RenderProps<T> = {
|
|
118
|
+
name: string;
|
|
119
|
+
toolCallId: string;
|
|
120
|
+
args: Partial<T>;
|
|
121
|
+
status: ToolCallStatus.InProgress;
|
|
122
|
+
result: undefined;
|
|
123
|
+
} | {
|
|
124
|
+
name: string;
|
|
125
|
+
toolCallId: string;
|
|
126
|
+
args: T;
|
|
127
|
+
status: ToolCallStatus.Executing;
|
|
128
|
+
result: undefined;
|
|
129
|
+
} | {
|
|
130
|
+
name: string;
|
|
131
|
+
toolCallId: string;
|
|
132
|
+
args: T;
|
|
133
|
+
status: ToolCallStatus.Complete;
|
|
134
|
+
result: string;
|
|
135
|
+
};
|
|
136
|
+
declare function defineToolCallRenderer(def: {
|
|
137
|
+
name: "*";
|
|
138
|
+
render: (props: RenderProps<any>) => React$1.ReactElement;
|
|
139
|
+
agentId?: string;
|
|
140
|
+
}): ReactToolCallRenderer<any>;
|
|
141
|
+
declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
142
|
+
name: string;
|
|
143
|
+
args: S;
|
|
144
|
+
render: (props: RenderProps<InferSchemaOutput<S>>) => React$1.ReactElement;
|
|
145
|
+
agentId?: string;
|
|
146
|
+
}): ReactToolCallRenderer<InferSchemaOutput<S>>;
|
|
147
|
+
//#endregion
|
|
109
148
|
//#region src/v2/types/interrupt.d.ts
|
|
110
149
|
interface InterruptEvent<TValue = unknown> {
|
|
111
150
|
name: string;
|
|
@@ -318,6 +357,7 @@ declare function useComponent<TSchema extends StandardSchemaV1 | undefined = und
|
|
|
318
357
|
parameters?: TSchema;
|
|
319
358
|
render: ComponentType<NoInfer<InferRenderProps<TSchema>>>;
|
|
320
359
|
agentId?: string;
|
|
360
|
+
followUp?: boolean;
|
|
321
361
|
}, deps?: ReadonlyArray<unknown>): void;
|
|
322
362
|
//#endregion
|
|
323
363
|
//#region src/v2/hooks/use-human-in-the-loop.d.ts
|
|
@@ -601,5 +641,105 @@ declare function useThreads({
|
|
|
601
641
|
limit
|
|
602
642
|
}: UseThreadsInput): UseThreadsResult;
|
|
603
643
|
//#endregion
|
|
604
|
-
|
|
644
|
+
//#region src/v2/hooks/use-render-tool.d.ts
|
|
645
|
+
interface RenderToolInProgressProps<S extends StandardSchemaV1> {
|
|
646
|
+
name: string;
|
|
647
|
+
toolCallId: string;
|
|
648
|
+
parameters: Partial<InferSchemaOutput<S>>;
|
|
649
|
+
status: "inProgress";
|
|
650
|
+
result: undefined;
|
|
651
|
+
}
|
|
652
|
+
interface RenderToolExecutingProps<S extends StandardSchemaV1> {
|
|
653
|
+
name: string;
|
|
654
|
+
toolCallId: string;
|
|
655
|
+
parameters: InferSchemaOutput<S>;
|
|
656
|
+
status: "executing";
|
|
657
|
+
result: undefined;
|
|
658
|
+
}
|
|
659
|
+
interface RenderToolCompleteProps<S extends StandardSchemaV1> {
|
|
660
|
+
name: string;
|
|
661
|
+
toolCallId: string;
|
|
662
|
+
parameters: InferSchemaOutput<S>;
|
|
663
|
+
status: "complete";
|
|
664
|
+
result: string;
|
|
665
|
+
}
|
|
666
|
+
type RenderToolProps<S extends StandardSchemaV1> = RenderToolInProgressProps<S> | RenderToolExecutingProps<S> | RenderToolCompleteProps<S>;
|
|
667
|
+
/**
|
|
668
|
+
* Registers a wildcard (`"*"`) renderer for tool calls.
|
|
669
|
+
*
|
|
670
|
+
* The wildcard renderer is used as a fallback when no exact name-matched
|
|
671
|
+
* renderer is registered for a tool call.
|
|
672
|
+
*
|
|
673
|
+
* @param config - Wildcard renderer configuration.
|
|
674
|
+
* @param deps - Optional dependencies to refresh registration.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```tsx
|
|
678
|
+
* useRenderTool(
|
|
679
|
+
* {
|
|
680
|
+
* name: "*",
|
|
681
|
+
* render: ({ name, status }) => (
|
|
682
|
+
* <div>
|
|
683
|
+
* {status === "complete" ? "✓" : "⏳"} {name}
|
|
684
|
+
* </div>
|
|
685
|
+
* ),
|
|
686
|
+
* },
|
|
687
|
+
* [],
|
|
688
|
+
* );
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
declare function useRenderTool(config: {
|
|
692
|
+
name: "*";
|
|
693
|
+
render: (props: any) => React.ReactElement;
|
|
694
|
+
agentId?: string;
|
|
695
|
+
}, deps?: ReadonlyArray<unknown>): void;
|
|
696
|
+
/**
|
|
697
|
+
* Registers a name-scoped renderer for tool calls.
|
|
698
|
+
*
|
|
699
|
+
* The provided `parameters` schema defines the typed shape of `props.parameters`
|
|
700
|
+
* in `render` for `executing` and `complete` states. Accepts any Standard Schema V1
|
|
701
|
+
* compatible library (Zod, Valibot, ArkType, etc.).
|
|
702
|
+
*
|
|
703
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
704
|
+
* @param config - Named renderer configuration.
|
|
705
|
+
* @param deps - Optional dependencies to refresh registration.
|
|
706
|
+
*
|
|
707
|
+
* @example
|
|
708
|
+
* ```tsx
|
|
709
|
+
* useRenderTool(
|
|
710
|
+
* {
|
|
711
|
+
* name: "searchDocs",
|
|
712
|
+
* parameters: z.object({ query: z.string() }),
|
|
713
|
+
* render: ({ status, parameters, result }) => {
|
|
714
|
+
* if (status === "inProgress") return <div>Preparing...</div>;
|
|
715
|
+
* if (status === "executing") return <div>Searching {parameters.query}</div>;
|
|
716
|
+
* return <div>{result}</div>;
|
|
717
|
+
* },
|
|
718
|
+
* },
|
|
719
|
+
* [],
|
|
720
|
+
* );
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
723
|
+
declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
724
|
+
name: string;
|
|
725
|
+
parameters: S;
|
|
726
|
+
render: (props: RenderToolProps<S>) => React.ReactElement;
|
|
727
|
+
agentId?: string;
|
|
728
|
+
}, deps?: ReadonlyArray<unknown>): void;
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region src/v2/hooks/use-capabilities.d.ts
|
|
731
|
+
/**
|
|
732
|
+
* Returns the capabilities declared by the given agent (or the default agent).
|
|
733
|
+
* Capabilities are populated from the runtime `/info` response at connection
|
|
734
|
+
* time. The hook reads them synchronously from the agent instance — there is
|
|
735
|
+
* no separate loading state, but the value will be `undefined` until the
|
|
736
|
+
* runtime handshake completes.
|
|
737
|
+
*
|
|
738
|
+
* @param agentId - Optional agent ID. If omitted, uses the default agent.
|
|
739
|
+
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
740
|
+
* declare capabilities.
|
|
741
|
+
*/
|
|
742
|
+
declare function useCapabilities(agentId?: string): AgentCapabilities | undefined;
|
|
743
|
+
//#endregion
|
|
744
|
+
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type Thread, type UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
605
745
|
//# sourceMappingURL=headless.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;EACA,IAAA,EAAM,gBAAA,MAAsB,CAAA;;;AAF9B;;EAOE,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAER,IAAA;IACA,UAAA;IACA,IAAA,EAAM,OAAA,CAAQ,CAAA;IACd,MAAA,EAAQ,cAAA,CAAe,UAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,SAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,QAAA;IACvB,MAAA;EAAA;AAAA;;;UC3BS,4BAAA;;;;EAIf,YAAA;EDLoC;;;ECSpC,OAAA;EDGoB;;;ECCpB,OAAA,EAAS,gBAAA,MAAsB,gBAAA;EDOjB;;;ECHd,MAAA,EAAQ,KAAA,CAAM,aAAA;IACZ,YAAA;IACA,OAAA,EAAS,gBAAA;IACT,OAAA,EAAS,eAAA;IACT,KAAA,EAAO,aAAA;EAAA;AAAA;;;KCtBC,kCAAA;AAAA,UAEK,0BAAA;EACf,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IACZ,OAAA,EAAS,OAAA;IACT,QAAA,EAAU,kCAAA;IACV,KAAA;IACA,YAAA;IACA,iBAAA;IACA,qBAAA;IACA,OAAA;IACA,aAAA;EAAA;AAAA;;;KCXQ,iBAAA,WACA,MAAA,oBAA0B,MAAA,qBAClC,YAAA,CAAa,CAAA;EACf,MAAA,GAAS,qBAAA,CAAsB,CAAA;AAAA;;;KCHrB,mBAAA,WACA,MAAA,oBAA0B,MAAA,qBAClC,IAAA,CAAK,YAAA,CAAa,CAAA;EACpB,MAAA,EAAQ,OAAA,CAAM,aAAA;IAER,IAAA;IACA,WAAA;IACA,IAAA,EAAM,OAAA,CAAQ,CAAA;IACd,MAAA,EAAQ,cAAA,CAAe,UAAA;IACvB,MAAA;IACA,OAAA;EAAA;IAGA,IAAA;IACA,WAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,SAAA;IACvB,MAAA;IACA,OAAA,GAAU,MAAA,cAAoB,OAAA;EAAA;IAG9B,IAAA;IACA,WAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,QAAA;IACvB,MAAA;IACA,OAAA;EAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;EACA,IAAA,EAAM,gBAAA,MAAsB,CAAA;;;AAF9B;;EAOE,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAER,IAAA;IACA,UAAA;IACA,IAAA,EAAM,OAAA,CAAQ,CAAA;IACd,MAAA,EAAQ,cAAA,CAAe,UAAA;IACvB,MAAA;EAAA;IA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AAAA,KAGU,eAAA,WAA0B,gBAAA,IAClC,yBAAA,CAA0B,CAAA,IAC1B,wBAAA,CAAyB,CAAA,IACzB,uBAAA,CAAwB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBAiCZ,aAAA,CACd,MAAA;EACE,IAAA;EACA,MAAA,GAAS,KAAA,UAAe,KAAA,CAAM,YAAA;EAC9B,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;;AjBrET;;;;;;;;;;;;;;;;;;iBiBmGgB,aAAA,WAAwB,gBAAA,CAAA,CACtC,MAAA;EACE,IAAA;EACA,UAAA,EAAY,CAAA;EACZ,MAAA,GAAS,KAAA,EAAO,eAAA,CAAgB,CAAA,MAAO,KAAA,CAAM,YAAA;EAC7C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;AlB3GT;;;;;iBmBWgB,eAAA,CACd,OAAA,YACC,iBAAA"}
|
package/dist/v2/headless.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
|
3
3
|
import { AbstractAgent } from "@ag-ui/client";
|
|
4
4
|
import { DynamicSuggestionsConfig, FrontendTool, StaticSuggestionsConfig, Suggestion, ToolCallStatus } from "@copilotkit/core";
|
|
5
5
|
import { CopilotKitCoreReact, CopilotKitCoreReactConfig } from "./context";
|
|
6
|
+
import { AgentCapabilities } from "@ag-ui/core";
|
|
6
7
|
|
|
7
8
|
//#region src/v2/providers/CopilotChatConfigurationProvider.d.ts
|
|
8
9
|
declare const CopilotChatDefaultLabels: {
|
|
@@ -184,6 +185,7 @@ declare function useComponent<TSchema extends StandardSchemaV1 | undefined = und
|
|
|
184
185
|
parameters?: TSchema;
|
|
185
186
|
render: ComponentType<NoInfer<InferRenderProps<TSchema>>>;
|
|
186
187
|
agentId?: string;
|
|
188
|
+
followUp?: boolean;
|
|
187
189
|
}, deps?: ReadonlyArray<unknown>): void;
|
|
188
190
|
//#endregion
|
|
189
191
|
//#region src/v2/types/human-in-the-loop.d.ts
|
|
@@ -508,5 +510,144 @@ declare function useThreads({
|
|
|
508
510
|
limit
|
|
509
511
|
}: UseThreadsInput): UseThreadsResult;
|
|
510
512
|
//#endregion
|
|
511
|
-
|
|
513
|
+
//#region src/v2/hooks/use-render-tool.d.ts
|
|
514
|
+
interface RenderToolInProgressProps<S extends StandardSchemaV1> {
|
|
515
|
+
name: string;
|
|
516
|
+
toolCallId: string;
|
|
517
|
+
parameters: Partial<InferSchemaOutput<S>>;
|
|
518
|
+
status: "inProgress";
|
|
519
|
+
result: undefined;
|
|
520
|
+
}
|
|
521
|
+
interface RenderToolExecutingProps<S extends StandardSchemaV1> {
|
|
522
|
+
name: string;
|
|
523
|
+
toolCallId: string;
|
|
524
|
+
parameters: InferSchemaOutput<S>;
|
|
525
|
+
status: "executing";
|
|
526
|
+
result: undefined;
|
|
527
|
+
}
|
|
528
|
+
interface RenderToolCompleteProps<S extends StandardSchemaV1> {
|
|
529
|
+
name: string;
|
|
530
|
+
toolCallId: string;
|
|
531
|
+
parameters: InferSchemaOutput<S>;
|
|
532
|
+
status: "complete";
|
|
533
|
+
result: string;
|
|
534
|
+
}
|
|
535
|
+
type RenderToolProps<S extends StandardSchemaV1> = RenderToolInProgressProps<S> | RenderToolExecutingProps<S> | RenderToolCompleteProps<S>;
|
|
536
|
+
/**
|
|
537
|
+
* Registers a wildcard (`"*"`) renderer for tool calls.
|
|
538
|
+
*
|
|
539
|
+
* The wildcard renderer is used as a fallback when no exact name-matched
|
|
540
|
+
* renderer is registered for a tool call.
|
|
541
|
+
*
|
|
542
|
+
* @param config - Wildcard renderer configuration.
|
|
543
|
+
* @param deps - Optional dependencies to refresh registration.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```tsx
|
|
547
|
+
* useRenderTool(
|
|
548
|
+
* {
|
|
549
|
+
* name: "*",
|
|
550
|
+
* render: ({ name, status }) => (
|
|
551
|
+
* <div>
|
|
552
|
+
* {status === "complete" ? "✓" : "⏳"} {name}
|
|
553
|
+
* </div>
|
|
554
|
+
* ),
|
|
555
|
+
* },
|
|
556
|
+
* [],
|
|
557
|
+
* );
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
declare function useRenderTool(config: {
|
|
561
|
+
name: "*";
|
|
562
|
+
render: (props: any) => React.ReactElement;
|
|
563
|
+
agentId?: string;
|
|
564
|
+
}, deps?: ReadonlyArray<unknown>): void;
|
|
565
|
+
/**
|
|
566
|
+
* Registers a name-scoped renderer for tool calls.
|
|
567
|
+
*
|
|
568
|
+
* The provided `parameters` schema defines the typed shape of `props.parameters`
|
|
569
|
+
* in `render` for `executing` and `complete` states. Accepts any Standard Schema V1
|
|
570
|
+
* compatible library (Zod, Valibot, ArkType, etc.).
|
|
571
|
+
*
|
|
572
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
573
|
+
* @param config - Named renderer configuration.
|
|
574
|
+
* @param deps - Optional dependencies to refresh registration.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```tsx
|
|
578
|
+
* useRenderTool(
|
|
579
|
+
* {
|
|
580
|
+
* name: "searchDocs",
|
|
581
|
+
* parameters: z.object({ query: z.string() }),
|
|
582
|
+
* render: ({ status, parameters, result }) => {
|
|
583
|
+
* if (status === "inProgress") return <div>Preparing...</div>;
|
|
584
|
+
* if (status === "executing") return <div>Searching {parameters.query}</div>;
|
|
585
|
+
* return <div>{result}</div>;
|
|
586
|
+
* },
|
|
587
|
+
* },
|
|
588
|
+
* [],
|
|
589
|
+
* );
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
593
|
+
name: string;
|
|
594
|
+
parameters: S;
|
|
595
|
+
render: (props: RenderToolProps<S>) => React.ReactElement;
|
|
596
|
+
agentId?: string;
|
|
597
|
+
}, deps?: ReadonlyArray<unknown>): void;
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region src/v2/types/defineToolCallRenderer.d.ts
|
|
600
|
+
/**
|
|
601
|
+
* Helper to define a type-safe tool call renderer entry.
|
|
602
|
+
* - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
|
|
603
|
+
* - Derives `args` type from the provided schema (any Standard Schema V1 compatible library).
|
|
604
|
+
* - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
|
|
605
|
+
* - For wildcard tools (name: "*"), args is optional and defaults to z.any()
|
|
606
|
+
*/
|
|
607
|
+
type RenderProps<T> = {
|
|
608
|
+
name: string;
|
|
609
|
+
toolCallId: string;
|
|
610
|
+
args: Partial<T>;
|
|
611
|
+
status: ToolCallStatus.InProgress;
|
|
612
|
+
result: undefined;
|
|
613
|
+
} | {
|
|
614
|
+
name: string;
|
|
615
|
+
toolCallId: string;
|
|
616
|
+
args: T;
|
|
617
|
+
status: ToolCallStatus.Executing;
|
|
618
|
+
result: undefined;
|
|
619
|
+
} | {
|
|
620
|
+
name: string;
|
|
621
|
+
toolCallId: string;
|
|
622
|
+
args: T;
|
|
623
|
+
status: ToolCallStatus.Complete;
|
|
624
|
+
result: string;
|
|
625
|
+
};
|
|
626
|
+
declare function defineToolCallRenderer(def: {
|
|
627
|
+
name: "*";
|
|
628
|
+
render: (props: RenderProps<any>) => React$1.ReactElement;
|
|
629
|
+
agentId?: string;
|
|
630
|
+
}): ReactToolCallRenderer<any>;
|
|
631
|
+
declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
632
|
+
name: string;
|
|
633
|
+
args: S;
|
|
634
|
+
render: (props: RenderProps<InferSchemaOutput<S>>) => React$1.ReactElement;
|
|
635
|
+
agentId?: string;
|
|
636
|
+
}): ReactToolCallRenderer<InferSchemaOutput<S>>;
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/v2/hooks/use-capabilities.d.ts
|
|
639
|
+
/**
|
|
640
|
+
* Returns the capabilities declared by the given agent (or the default agent).
|
|
641
|
+
* Capabilities are populated from the runtime `/info` response at connection
|
|
642
|
+
* time. The hook reads them synchronously from the agent instance — there is
|
|
643
|
+
* no separate loading state, but the value will be `undefined` until the
|
|
644
|
+
* runtime handshake completes.
|
|
645
|
+
*
|
|
646
|
+
* @param agentId - Optional agent ID. If omitted, uses the default agent.
|
|
647
|
+
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
648
|
+
* declare capabilities.
|
|
649
|
+
*/
|
|
650
|
+
declare function useCapabilities(agentId?: string): AgentCapabilities | undefined;
|
|
651
|
+
//#endregion
|
|
652
|
+
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type Thread, type UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
512
653
|
//# sourceMappingURL=headless.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;;cAca,wBAAA;;;;;;;;;;;;;;;;;;;;;;KAwBD,iBAAA,UAA2B,wBAAA;AAAA,UAGtB,6BAAA;EACf,MAAA,EAAQ,iBAAA;EACR,OAAA;EACA,QAAA;EACA,WAAA;EACA,YAAA,GAAe,IAAA;EAKf,mBAAA;AAAA;AAAA,UAQe,qCAAA;EACf,QAAA,EAAU,SAAA;EACV,MAAA,GAAS,OAAA,CAAQ,iBAAA;EACjB,OAAA;EACA,QAAA;EAMA,mBAAA;EACA,kBAAA;AAAA;AAAA,cAIW,gCAAA,EAAkC,OAAA,CAAM,EAAA,CACnD,qCAAA;AAAA,cAoHW,2BAAA,QACP,6BAAA;;;aCtLM,cAAA;EACV,iBAAA;EACA,cAAA;EACA,kBAAA;AAAA;AAAA,UASe,aAAA;EACf,OAAA;EACA,OAAA,GAAU,cAAA;EDYX;;;;;;;;;;;;;;;;;;;;;;ECWC,UAAA;AAAA;AAAA,iBAGc,QAAA,CAAA;EAAW,OAAA;EAAS,OAAA;EAAS;AAAA,IAAc,aAAA;;;;;UC/C1C,qBAAA;EACf,IAAA;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AAA,WAAwB,gBAAA,CAAA,CACtC,MAAA;EACE,IAAA;EACA,UAAA,EAAY,CAAA;EACZ,MAAA,GAAS,KAAA,EAAO,eAAA,CAAgB,CAAA,MAAO,KAAA,CAAM,YAAA;EAC7C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;AdhGT;;;KeDK,WAAA;EAEC,IAAA;EACA,UAAA;EACA,IAAA,EAAM,OAAA,CAAQ,CAAA;EACd,MAAA,EAAQ,cAAA,CAAe,UAAA;EACvB,MAAA;AAAA;EAGA,IAAA;EACA,UAAA;EACA,IAAA,EAAM,CAAA;EACN,MAAA,EAAQ,cAAA,CAAe,SAAA;EACvB,MAAA;AAAA;EAGA,IAAA;EACA,UAAA;EACA,IAAA,EAAM,CAAA;EACN,MAAA,EAAQ,cAAA,CAAe,QAAA;EACvB,MAAA;AAAA;AAAA,iBAIU,sBAAA,CAAuB,GAAA;EACrC,IAAA;EACA,MAAA,GAAS,KAAA,EAAO,WAAA,UAAqB,OAAA,CAAM,YAAA;EAC3C,OAAA;AAAA,IACE,qBAAA;AAAA,iBAGY,sBAAA,WAAiC,gBAAA,CAAA,CAAkB,GAAA;EACjE,IAAA;EACA,IAAA,EAAM,CAAA;EACN,MAAA,GAAS,KAAA,EAAO,WAAA,CAAY,iBAAA,CAAkB,CAAA,OAAQ,OAAA,CAAM,YAAA;EAC5D,OAAA;AAAA,IACE,qBAAA,CAAsB,iBAAA,CAAkB,CAAA;;;;;;;;;;AfnC5C;;;;iBgBAgB,eAAA,CACd,OAAA,YACC,iBAAA"}
|
package/dist/v2/headless.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { twMerge } from "tailwind-merge";
|
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { HttpAgent } from "@ag-ui/client";
|
|
7
7
|
import { CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ɵcreateThreadStore, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
|
|
8
|
+
import { z } from "zod";
|
|
8
9
|
|
|
9
10
|
//#region src/v2/lib/slots.tsx
|
|
10
11
|
/**
|
|
@@ -286,10 +287,10 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
286
287
|
|
|
287
288
|
//#endregion
|
|
288
289
|
//#region src/v2/hooks/use-frontend-tool.tsx
|
|
289
|
-
const EMPTY_DEPS = [];
|
|
290
|
+
const EMPTY_DEPS$1 = [];
|
|
290
291
|
function useFrontendTool(tool, deps) {
|
|
291
292
|
const { copilotkit } = useCopilotKit();
|
|
292
|
-
const extraDeps = deps ?? EMPTY_DEPS;
|
|
293
|
+
const extraDeps = deps ?? EMPTY_DEPS$1;
|
|
293
294
|
useEffect(() => {
|
|
294
295
|
const name = tool.name;
|
|
295
296
|
if (copilotkit.getTool({
|
|
@@ -380,7 +381,8 @@ function useComponent(config, deps) {
|
|
|
380
381
|
const Component = config.render;
|
|
381
382
|
return /* @__PURE__ */ jsx(Component, { ...args });
|
|
382
383
|
},
|
|
383
|
-
agentId: config.agentId
|
|
384
|
+
agentId: config.agentId,
|
|
385
|
+
followUp: config.followUp
|
|
384
386
|
}, deps);
|
|
385
387
|
}
|
|
386
388
|
|
|
@@ -993,5 +995,107 @@ function useThreads({ agentId, includeArchived, limit }) {
|
|
|
993
995
|
}
|
|
994
996
|
|
|
995
997
|
//#endregion
|
|
996
|
-
|
|
998
|
+
//#region src/v2/types/defineToolCallRenderer.ts
|
|
999
|
+
function defineToolCallRenderer(def) {
|
|
1000
|
+
const argsSchema = def.name === "*" && !def.args ? z.any() : def.args;
|
|
1001
|
+
return {
|
|
1002
|
+
name: def.name,
|
|
1003
|
+
args: argsSchema,
|
|
1004
|
+
render: def.render,
|
|
1005
|
+
...def.agentId ? { agentId: def.agentId } : {}
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
//#endregion
|
|
1010
|
+
//#region src/v2/hooks/use-render-tool.tsx
|
|
1011
|
+
const EMPTY_DEPS = [];
|
|
1012
|
+
/**
|
|
1013
|
+
* Registers a renderer entry in CopilotKit's `renderToolCalls` registry.
|
|
1014
|
+
*
|
|
1015
|
+
* Key behavior:
|
|
1016
|
+
* - deduplicates by `agentId:name` (latest registration wins),
|
|
1017
|
+
* - keeps renderer entries on cleanup so historical chat tool calls can still render,
|
|
1018
|
+
* - refreshes registration when `deps` change.
|
|
1019
|
+
*
|
|
1020
|
+
* @typeParam S - Schema type describing tool call parameters.
|
|
1021
|
+
* @param config - Renderer config for wildcard or named tools.
|
|
1022
|
+
* @param deps - Optional dependencies to refresh registration.
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```tsx
|
|
1026
|
+
* useRenderTool(
|
|
1027
|
+
* {
|
|
1028
|
+
* name: "searchDocs",
|
|
1029
|
+
* parameters: z.object({ query: z.string() }),
|
|
1030
|
+
* render: ({ status, parameters, result }) => {
|
|
1031
|
+
* if (status === "executing") return <div>Searching {parameters.query}</div>;
|
|
1032
|
+
* if (status === "complete") return <div>{result}</div>;
|
|
1033
|
+
* return <div>Preparing...</div>;
|
|
1034
|
+
* },
|
|
1035
|
+
* },
|
|
1036
|
+
* [],
|
|
1037
|
+
* );
|
|
1038
|
+
* ```
|
|
1039
|
+
*
|
|
1040
|
+
* @example
|
|
1041
|
+
* ```tsx
|
|
1042
|
+
* useRenderTool(
|
|
1043
|
+
* {
|
|
1044
|
+
* name: "summarize",
|
|
1045
|
+
* parameters: z.object({ text: z.string() }),
|
|
1046
|
+
* agentId: "research-agent",
|
|
1047
|
+
* render: ({ name, status }) => <div>{name}: {status}</div>,
|
|
1048
|
+
* },
|
|
1049
|
+
* [selectedAgentId],
|
|
1050
|
+
* );
|
|
1051
|
+
* ```
|
|
1052
|
+
*/
|
|
1053
|
+
function useRenderTool(config, deps) {
|
|
1054
|
+
const { copilotkit } = useCopilotKit();
|
|
1055
|
+
const extraDeps = deps ?? EMPTY_DEPS;
|
|
1056
|
+
useEffect(() => {
|
|
1057
|
+
const renderer = config.name === "*" && !config.parameters ? defineToolCallRenderer({
|
|
1058
|
+
name: "*",
|
|
1059
|
+
render: (props) => config.render({
|
|
1060
|
+
...props,
|
|
1061
|
+
parameters: props.args
|
|
1062
|
+
}),
|
|
1063
|
+
...config.agentId ? { agentId: config.agentId } : {}
|
|
1064
|
+
}) : defineToolCallRenderer({
|
|
1065
|
+
name: config.name,
|
|
1066
|
+
args: config.parameters,
|
|
1067
|
+
render: (props) => config.render({
|
|
1068
|
+
...props,
|
|
1069
|
+
parameters: props.args
|
|
1070
|
+
}),
|
|
1071
|
+
...config.agentId ? { agentId: config.agentId } : {}
|
|
1072
|
+
});
|
|
1073
|
+
copilotkit.addHookRenderToolCall(renderer);
|
|
1074
|
+
}, [
|
|
1075
|
+
config.name,
|
|
1076
|
+
copilotkit,
|
|
1077
|
+
JSON.stringify(extraDeps)
|
|
1078
|
+
]);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
//#endregion
|
|
1082
|
+
//#region src/v2/hooks/use-capabilities.tsx
|
|
1083
|
+
/**
|
|
1084
|
+
* Returns the capabilities declared by the given agent (or the default agent).
|
|
1085
|
+
* Capabilities are populated from the runtime `/info` response at connection
|
|
1086
|
+
* time. The hook reads them synchronously from the agent instance — there is
|
|
1087
|
+
* no separate loading state, but the value will be `undefined` until the
|
|
1088
|
+
* runtime handshake completes.
|
|
1089
|
+
*
|
|
1090
|
+
* @param agentId - Optional agent ID. If omitted, uses the default agent.
|
|
1091
|
+
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
1092
|
+
* declare capabilities.
|
|
1093
|
+
*/
|
|
1094
|
+
function useCapabilities(agentId) {
|
|
1095
|
+
const { agent } = useAgent({ agentId });
|
|
1096
|
+
if (agent && "capabilities" in agent) return agent.capabilities;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
//#endregion
|
|
1100
|
+
export { CopilotChatConfigurationProvider, CopilotChatDefaultLabels, CopilotKitCoreReact, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
997
1101
|
//# sourceMappingURL=headless.mjs.map
|