import * as react from "react"; import React$1 from "react"; import { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, ToolCallStatus } from "@copilotkit/core"; import { LicenseContextValue, StandardSchemaV1 } from "@copilotkit/shared"; import { ActivityMessage, Message } from "@ag-ui/core"; import { AbstractAgent } from "@ag-ui/client"; //#region src/v2/types/react-tool-call-renderer.d.ts interface ReactToolCallRenderer { name: string; /** * Schema describing the tool arguments. Optional — renderers registered for * tools without parameters (e.g. HITL confirm dialogs) have no schema. */ args?: StandardSchemaV1; /** * Optional agent ID to constrain this tool renderer to a specific agent. * If specified, this renderer will only be used for the specified agent. */ agentId?: string; render: React.ComponentType<{ name: string; toolCallId: string; args: Partial; status: ToolCallStatus.InProgress; result: undefined; } | { name: string; toolCallId: string; args: T; status: ToolCallStatus.Executing; result: undefined; } | { name: string; toolCallId: string; args: T; status: ToolCallStatus.Complete; result: string; }>; } //#endregion //#region src/v2/types/react-activity-message-renderer.d.ts interface ReactActivityMessageRenderer { /** * Activity type to match when rendering. Use "*" as a wildcard renderer. */ activityType: string; /** * Optional agent ID to scope the renderer to a particular agent. */ agentId?: string; /** * Schema describing the activity content payload. */ content: StandardSchemaV1; /** * React component invoked to render the activity message. */ render: React.ComponentType<{ activityType: string; content: TActivityContent; message: ActivityMessage; agent: AbstractAgent | undefined; }>; } //#endregion //#region src/v2/types/react-custom-message-renderer.d.ts type ReactCustomMessageRendererPosition = "before" | "after"; interface ReactCustomMessageRenderer { agentId?: string; render: React.ComponentType<{ message: Message; position: ReactCustomMessageRendererPosition; runId: string; messageIndex: number; messageIndexInRun: number; numberOfMessagesInRun: number; agentId: string; stateSnapshot: any; }> | null; } //#endregion //#region src/v2/lib/react-core.d.ts interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig { renderToolCalls?: ReactToolCallRenderer[]; renderActivityMessages?: ReactActivityMessageRenderer[]; renderCustomMessages?: ReactCustomMessageRenderer[]; } interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber { onRenderToolCallsChanged?: (event: { copilotkit: CopilotKitCore; renderToolCalls: ReactToolCallRenderer[]; }) => void | Promise; onInterruptElementChanged?: (event: { copilotkit: CopilotKitCore; interruptElement: React$1.ReactElement | null; }) => void | Promise; } declare class CopilotKitCoreReact extends CopilotKitCore { private _renderToolCalls; private _hookRenderToolCalls; private _cachedMergedRenderToolCalls; private _renderCustomMessages; private _renderActivityMessages; private _interruptElement; constructor(config: CopilotKitCoreReactConfig); get renderCustomMessages(): Readonly; get renderActivityMessages(): Readonly>[]; get renderToolCalls(): Readonly>[]; setRenderActivityMessages(renderers: ReactActivityMessageRenderer[]): void; setRenderCustomMessages(renderers: ReactCustomMessageRenderer[]): void; setRenderToolCalls(renderToolCalls: ReactToolCallRenderer[]): void; addHookRenderToolCall(entry: ReactToolCallRenderer): void; removeHookRenderToolCall(name: string, agentId?: string): void; private _notifyRenderToolCallsChanged; get interruptElement(): React$1.ReactElement | null; setInterruptElement(element: React$1.ReactElement | null): void; subscribe(subscriber: CopilotKitCoreReactSubscriber): CopilotKitCoreSubscription; /** * Wait for pending React state updates before the follow-up agent run. * * When a frontend tool handler calls setState(), React 18 batches the update * and schedules a commit via its internal scheduler (MessageChannel). The * useAgentContext hook registers context via useLayoutEffect, which runs * synchronously after React commits that batch. * * Awaiting a zero-delay timeout yields to the macrotask queue. React's * MessageChannel task runs first, committing the pending state and running * useLayoutEffect (which updates the context store). The follow-up runAgent * call then reads fresh context. */ waitForPendingFrameworkUpdates(): Promise; } //#endregion //#region src/v2/context.d.ts interface CopilotKitContextValue { copilotkit: CopilotKitCoreReact; /** * Set of tool call IDs currently being executed. * This is tracked at the provider level to ensure tool execution events * are captured even before child components mount. */ executingToolCallIds: ReadonlySet; } declare const EMPTY_SET: ReadonlySet; declare const CopilotKitContext: react.Context; declare const useCopilotKit: () => CopilotKitContextValue; declare const LicenseContext: react.Context; declare const useLicenseContext: () => LicenseContextValue; declare const CopilotKitAgentIdContext: react.Context; declare const useDefaultAgentId: () => string | undefined; //#endregion export { CopilotKitAgentIdContext, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, EMPTY_SET, LicenseContext, useCopilotKit, useDefaultAgentId, useLicenseContext }; //# sourceMappingURL=context.d.mts.map