@copilotkit/react-core 2.0.0-rc.31 → 2.0.0-rc.32

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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/MarkdownRendererContext-CPfNVyde.d.mts +241 -0
  3. package/dist/MarkdownRendererContext-CPfNVyde.d.mts.map +1 -0
  4. package/dist/MarkdownRendererContext-iOl2pj9l.d.cts +241 -0
  5. package/dist/MarkdownRendererContext-iOl2pj9l.d.cts.map +1 -0
  6. package/dist/MarkdownSurfaces-BFoO6wSB.cjs +1650 -0
  7. package/dist/MarkdownSurfaces-BFoO6wSB.cjs.map +1 -0
  8. package/dist/MarkdownSurfaces-BQ1HGCzB.mjs +1442 -0
  9. package/dist/MarkdownSurfaces-BQ1HGCzB.mjs.map +1 -0
  10. package/dist/generative-ui.cjs +687 -2964
  11. package/dist/generative-ui.cjs.map +1 -1
  12. package/dist/generative-ui.d.cts +2478 -2683
  13. package/dist/generative-ui.d.cts.map +1 -1
  14. package/dist/generative-ui.d.mts +2477 -2682
  15. package/dist/generative-ui.d.mts.map +1 -1
  16. package/dist/generative-ui.mjs +299 -2585
  17. package/dist/generative-ui.mjs.map +1 -1
  18. package/dist/index.cjs +26 -1367
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.mts +1 -1
  22. package/dist/index.mjs +11 -1352
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/index.umd.js +124 -3358
  25. package/dist/index.umd.js.map +1 -1
  26. package/package.json +9 -9
  27. package/dist/MarkdownRendererContext-BX26QLwl.d.cts +0 -937
  28. package/dist/MarkdownRendererContext-BX26QLwl.d.cts.map +0 -1
  29. package/dist/MarkdownRendererContext-DAOMewji.d.mts +0 -937
  30. package/dist/MarkdownRendererContext-DAOMewji.d.mts.map +0 -1
  31. package/dist/MarkdownSurfaces-BbrHcSHN.cjs +0 -3903
  32. package/dist/MarkdownSurfaces-BbrHcSHN.cjs.map +0 -1
  33. package/dist/MarkdownSurfaces-DQbRS91-.mjs +0 -3587
  34. package/dist/MarkdownSurfaces-DQbRS91-.mjs.map +0 -1
package/README.md CHANGED
@@ -122,7 +122,7 @@ const modifiedConfig = copilotKitCustomizeConfig(config, {
122
122
  },
123
123
  ],
124
124
  });
125
- const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(
125
+ const response = await ChatOpenAI({ model: "gpt-6-luna" }).invoke(
126
126
  messages,
127
127
  modifiedConfig,
128
128
  );
@@ -0,0 +1,241 @@
1
+ import { ActivityMessageRenderProps, ActivityMessageRendererDef } from "@copilotkit/core";
2
+ import React, { ComponentType, ReactNode } from "react";
3
+ import { StreamingMarkdownRendererProps } from "@copilotkit/markdown/react";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+ import { GenerativeUIRejectedOperation, GenerativeUIUserEvent } from "@copilotkit/shared";
6
+ import { GenerativeUIAccessibility, GenerativeUIAriaAttributes, GenerativeUIAriaAttributes as GenerativeUIAriaAttributes$1, GenerativeUIDispatcher, GenerativeUISurfaceManager } from "@copilotkit/core/generative-ui";
7
+ import { AnyGenerativeUI, CreateGenerativeUIConfig, GenerativeUI, GenerativeUIBasesDefinitions, GenerativeUIComponentDefinition, GenerativeUIComponentName, GenerativeUIComponentProps, GenerativeUIDefinitions, GenerativeUIDefinitionsOf, GenerativeUIErrorInfo, GenerativeUIEventDefinition, GenerativeUIFunctionArgs, GenerativeUIFunctionDefinition, GenerativeUIFunctionDefinition as GenerativeUIFunctionDefinition$1, GenerativeUIFunctionInput, GenerativeUIFunctionName, GenerativeUIInvokeResult, GenerativeUIResultDefinitions, GenerativeUISchema, GenerativeUISlotKind, GenerativeUIStateOf, GenerativeUITheme } from "@copilotkit/shared/generative-ui";
8
+
9
+ //#region src/generative-ui/catalog.d.ts
10
+ /** One component of a generative UI, as the renderer reads it. */
11
+ type GenerativeUIComponentDefinition$1 = GenerativeUIComponentDefinition<ComponentType<any>>;
12
+ /**
13
+ * Experimental. The result of `createGenerativeUI`: the components the model
14
+ * can render, the app state they read, and the functions they call. Give it
15
+ * to the provider (`generativeUI={{ ui }}`) and to the typed hooks.
16
+ */
17
+ type GenerativeUI$1<Definitions extends GenerativeUIDefinitions = GenerativeUIDefinitions> = GenerativeUI<Definitions, ComponentType<any>>;
18
+ /**
19
+ * Props that the renderer passes to a component:
20
+ * `function CheckoutForm(props: GenerativeUIComponentProps<typeof ui, "CheckoutForm">)`.
21
+ * Data props are the parsed `props` schema, bound props included. Event and
22
+ * slot props are present only when they are bound or filled. Each writable
23
+ * prop gets a setter (`value` gets `setValue`), which is always present.
24
+ */
25
+ type GenerativeUIComponentProps$1<UI extends AnyGenerativeUI, Name extends keyof NonNullable<UI["definitions"]>["components"] & string> = GenerativeUIComponentProps<UI, Name, ReactNode>;
26
+ /** One new React component for each component of the bases that it names. */
27
+ type OverridesConfig<Bases extends readonly AnyGenerativeUI[]> = { [Name in keyof GenerativeUIBasesDefinitions<Bases>["components"] & string]?: {
28
+ component: ComponentType<GenerativeUIBasesDefinitions<Bases> extends infer Definitions extends GenerativeUIDefinitions ? GenerativeUIComponentProps$1<GenerativeUI$1<Definitions>, Name> : never>;
29
+ } };
30
+ /** The config of `createGenerativeUI`. */
31
+ type CreateGenerativeUIConfig$1<Bases extends readonly AnyGenerativeUI[], State extends Record<string, GenerativeUISchema>, Functions extends Record<string, GenerativeUIFunctionDefinition>, Props extends Record<string, unknown>, Events extends Record<string, unknown>, Slots extends Record<string, unknown>, Writable extends Record<string, unknown>> = CreateGenerativeUIConfig<Bases, State, Functions, Props, Events, Slots, Writable, OverridesConfig<Bases>>;
32
+ /**
33
+ * Experimental. Declares the components the model can render, the app state
34
+ * they read, and the functions they call.
35
+ *
36
+ * - A prop with the name of a top-level state key is bound to that state.
37
+ * - `bind: { prop: (state, props) => value }` binds a prop to a selector.
38
+ * - An event binds to the function with its name, else to the name without
39
+ * `on` (`onAddToCart` calls `addToCart`).
40
+ * - `writable: ["value"]` gives the component a `setValue` prop. See
41
+ * `GenerativeUIComponentDefinition.writable`.
42
+ *
43
+ * The model does not see bound props or matched events.
44
+ *
45
+ * @param config - `id`, then optional `extends`, `state`, `functions` and
46
+ * `overrides`, then `components`. Put `state` before `components`, so the selectors
47
+ * get typed state.
48
+ * @throws Error when a name comes from two places, an override names no
49
+ * component of the bases, `props` is not an object
50
+ * schema with a JSON Schema, a key is reserved or used
51
+ * twice on a component, an event matches two functions, an unmatched event
52
+ * has no `parameters`, a `bind` key is not a prop, a `writable` key is not
53
+ * a prop or is a bound prop, or a setter name is already a key of the
54
+ * component. Also throws when `parameterOrder` contains duplicate or unknown
55
+ * keys, or an ordered component declares integer-index keys whose JSON object
56
+ * enumeration order cannot be controlled.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const ui = createGenerativeUI({
61
+ * id: "acme/store@1",
62
+ * state: { cart: cartSchema },
63
+ * functions: { addToCart: { parameters: z.object({ productId: z.string() }) } },
64
+ * components: {
65
+ * CartSummary: {
66
+ * component: CartSummary,
67
+ * props: z.object({ count: z.number() }),
68
+ * bind: { count: (state) => state.cart.count },
69
+ * },
70
+ * },
71
+ * });
72
+ * ```
73
+ */
74
+ declare function createGenerativeUI$1<Bases extends readonly AnyGenerativeUI[] = [], State extends Record<string, GenerativeUISchema> = {}, Functions extends Record<string, GenerativeUIFunctionDefinition> = {}, Props extends Record<string, unknown> = {}, Events extends Record<string, unknown> = {}, Slots extends Record<string, unknown> = {}, Writable extends Record<string, unknown> = {}>(config: CreateGenerativeUIConfig$1<Bases, State, Functions, Props, Events, Slots, Writable>): GenerativeUI$1<GenerativeUIResultDefinitions<Bases, State, Functions, Props, Events, Slots, Writable>>;
75
+ //#endregion
76
+ //#region src/generative-ui/accessibility.d.ts
77
+ /**
78
+ * Experimental. The ARIA attributes of the `accessibility` that the model
79
+ * gave the component being rendered, to spread on its root element. The
80
+ * standard components do this; a custom component does it itself:
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function Panel({ children }: { children?: ReactNode }) {
85
+ * const aria = useGenerativeUIAccessibility();
86
+ * return <section {...aria}>{children}</section>;
87
+ * }
88
+ * ```
89
+ *
90
+ * Outside of generated UI it gives `{}`.
91
+ */
92
+ declare function useGenerativeUIAccessibility(): GenerativeUIAriaAttributes;
93
+ //#endregion
94
+ //#region src/generative-ui/runtime-context.d.ts
95
+ interface GenerativeUIErrorBoundaryConfig {
96
+ /** Replaces the default per-component fallback. */
97
+ fallback?: (props: {
98
+ error: Error;
99
+ retry: () => void;
100
+ surfaceId: string;
101
+ componentId: string;
102
+ }) => ReactNode;
103
+ /** Called for render, props, operation, function and event failures. */
104
+ onError?: (info: GenerativeUIErrorInfo) => void;
105
+ }
106
+ interface GenerativeUIBaseConfig {
107
+ /**
108
+ * The result of `createGenerativeUI`: the components the model can render,
109
+ * the app state they read and the functions they call.
110
+ */
111
+ ui: GenerativeUI$1;
112
+ /**
113
+ * The agents that get the generative UI. When omitted, every agent gets
114
+ * it. Other agents get no envelope.
115
+ */
116
+ agentIds?: string[];
117
+ /**
118
+ * Values for the `--a2ui-*` CSS variables and the map style. Top-level
119
+ * values apply in both modes. `dark` changes them in dark mode, which is
120
+ * on under a `.dark` class, like the CopilotKit chat.
121
+ */
122
+ theme?: GenerativeUITheme;
123
+ /** Fallback UI and error reporting for generated UI. */
124
+ errorBoundary?: GenerativeUIErrorBoundaryConfig;
125
+ }
126
+ /**
127
+ * The tool transport: the model calls the `render_ui` tool, and the runtime
128
+ * validates each operation before it streams it to the client.
129
+ */
130
+ interface GenerativeUIToolConfig extends GenerativeUIBaseConfig {
131
+ /** Leave it out, or set "tool". */
132
+ transport?: "tool";
133
+ sendContext?: never;
134
+ includeCatalog?: never;
135
+ }
136
+ /**
137
+ * The markdown transport: the model writes the operations in ```a2ui fences
138
+ * in its reply. The client reads and validates them.
139
+ */
140
+ interface GenerativeUIMarkdownConfig extends GenerativeUIBaseConfig {
141
+ transport: "markdown";
142
+ /**
143
+ * Send the component schema and the fence guideline as context entries.
144
+ * Set `false` when the backend builds its own prompt from the envelope.
145
+ * Default `true`.
146
+ */
147
+ sendContext?: boolean;
148
+ /**
149
+ * Send the component schemas in the envelope (`catalog.components`).
150
+ * Default `true`.
151
+ */
152
+ includeCatalog?: boolean;
153
+ }
154
+ /**
155
+ * Experimental. The `generativeUI` prop of `CopilotKitProvider`. Set
156
+ * `transport: "markdown"` to get the markdown options.
157
+ *
158
+ * @example
159
+ * ```tsx
160
+ * <CopilotKitProvider generativeUI={{ ui }} />
161
+ * <CopilotKitProvider generativeUI={{ ui, transport: "markdown", sendContext: false }} />
162
+ * ```
163
+ */
164
+ type GenerativeUIConfig = GenerativeUIToolConfig | GenerativeUIMarkdownConfig;
165
+ interface GenerativeUIRuntime {
166
+ manager: GenerativeUISurfaceManager;
167
+ dispatcher: GenerativeUIDispatcher;
168
+ /** The generative UI given to the provider as `generativeUI={{ ui }}`. */
169
+ ui: GenerativeUI$1;
170
+ /** How the model sends operations. "tool" when the config leaves it out. */
171
+ transport: "tool" | "markdown";
172
+ /** The latest `generativeUI` config of the provider. */
173
+ readonly config: GenerativeUIConfig;
174
+ /** The latest `theme`. Each surface root sets its CSS variables. */
175
+ theme?: GenerativeUITheme;
176
+ forwardEvent: (event: GenerativeUIUserEvent, agentId: string | undefined) => Promise<GenerativeUIInvokeResult>;
177
+ reportError: (info: GenerativeUIErrorInfo) => void;
178
+ readonly errorFallback?: GenerativeUIErrorBoundaryConfig["fallback"];
179
+ }
180
+ declare function useGenerativeUIRuntime(): GenerativeUIRuntime | null;
181
+ //#endregion
182
+ //#region src/types/react-activity-message-renderer.d.ts
183
+ /**
184
+ * An activity message renderer for React: a React component that draws
185
+ * activity messages of one `activityType` (or `"*"` for any type). The
186
+ * component receives {@link ActivityMessageRenderProps}.
187
+ *
188
+ * @typeParam TActivityContent - The shape of the activity content.
189
+ */
190
+ type ReactActivityMessageRenderer<TActivityContent> = ActivityMessageRendererDef<TActivityContent, React.ComponentType<ActivityMessageRenderProps<TActivityContent>>>;
191
+ //#endregion
192
+ //#region src/generative-ui/chat.d.ts
193
+ interface GenerativeUIChatSurfaceProps {
194
+ surfaceId: string;
195
+ isStreaming: boolean;
196
+ /**
197
+ * Set when operations from the latest render_ui call were rejected. The
198
+ * message is user-facing; `error.cause` holds the same list as `rejected`.
199
+ */
200
+ error?: Error;
201
+ /** Rejected operations from the latest render_ui call, with validator reasons. */
202
+ rejected: GenerativeUIRejectedOperation[];
203
+ children: ReactNode;
204
+ }
205
+ declare function DefaultGenerativeUIChatCard({
206
+ surfaceId,
207
+ error,
208
+ children
209
+ }: GenerativeUIChatSurfaceProps): react_jsx_runtime0.JSX.Element;
210
+ //#endregion
211
+ //#region src/providers/MarkdownRendererContext.d.ts
212
+ /** Props every markdown renderer (built-in or plugged-in) receives. */
213
+ interface MarkdownRendererProps {
214
+ /** Raw, possibly-partial (streaming) markdown string. */
215
+ content: string;
216
+ /** Hint that the message is still streaming, for cursor/affordance use. */
217
+ isStreaming?: boolean;
218
+ className?: string;
219
+ }
220
+ /**
221
+ * Config for the built-in default renderer. Pass this (instead of a component)
222
+ * as `markdownRenderer` to configure the built-in renderer without writing a
223
+ * wrapper — e.g. `markdownRenderer={{ nodeRenderers: { codeBlock: Shiki } }}`.
224
+ */
225
+ type DefaultMarkdownRendererProps = Pick<StreamingMarkdownRendererProps, "nodeRenderers" | "caret" | "options" | "className" | "onLinkClick" | "onCitationClick">;
226
+ /** A markdown renderer: a component, OR config for the built-in default. */
227
+ type MarkdownRenderer = React.ComponentType<MarkdownRendererProps> | DefaultMarkdownRendererProps;
228
+ declare const MarkdownRendererProvider: React.FC<{
229
+ renderer?: MarkdownRenderer;
230
+ children: React.ReactNode;
231
+ }>;
232
+ /**
233
+ * The markdown renderer set at the provider level, or `undefined` when none was
234
+ * supplied. Message components fall back to the built-in
235
+ * `StreamingMarkdownDefaultRenderer` (via `CopilotChatAssistantMessage.MarkdownRenderer`)
236
+ * when this is `undefined`.
237
+ */
238
+ declare function useMarkdownRenderer(): MarkdownRenderer | undefined;
239
+ //#endregion
240
+ export { GenerativeUIStateOf as A, GenerativeUIDefinitionsOf as C, GenerativeUIFunctionInput as D, GenerativeUIFunctionDefinition$1 as E, GenerativeUIFunctionName as O, GenerativeUIComponentProps$1 as S, GenerativeUIFunctionArgs as T, useGenerativeUIAccessibility as _, useMarkdownRenderer as a, GenerativeUIComponentDefinition$1 as b, ReactActivityMessageRenderer as c, GenerativeUIMarkdownConfig as d, GenerativeUITheme as f, GenerativeUIAriaAttributes$1 as g, GenerativeUIAccessibility as h, MarkdownRendererProvider as i, createGenerativeUI$1 as j, GenerativeUISlotKind as k, GenerativeUIConfig as l, useGenerativeUIRuntime as m, MarkdownRenderer as n, DefaultGenerativeUIChatCard as o, GenerativeUIToolConfig as p, MarkdownRendererProps as r, GenerativeUIChatSurfaceProps as s, DefaultMarkdownRendererProps as t, GenerativeUIErrorBoundaryConfig as u, CreateGenerativeUIConfig$1 as v, GenerativeUIEventDefinition as w, GenerativeUIComponentName as x, GenerativeUI$1 as y };
241
+ //# sourceMappingURL=MarkdownRendererContext-CPfNVyde.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownRendererContext-CPfNVyde.d.mts","names":[],"sources":["../src/generative-ui/catalog.ts","../src/generative-ui/accessibility.ts","../src/generative-ui/runtime-context.ts","../src/types/react-activity-message-renderer.ts","../src/generative-ui/chat.tsx","../src/providers/MarkdownRendererContext.tsx"],"mappings":";;;;;;;;;;KA2CY,iCAAA,GACV,+BAAA,CAAsC,aAAA;;AADxC;;;;KAaY,cAAA,qBACU,uBAAA,GAA0B,uBAAA,IAC5C,YAAA,CAAmB,WAAA,EAAa,aAAA;AAFpC;;;;;;;AAAA,KAWY,4BAAA,YACC,eAAA,qBACQ,WAAA,CAAY,EAAA,2CAC7B,0BAAA,CAAiC,EAAA,EAAI,IAAA,EAAM,SAAA;;KAG1C,eAAA,wBAAuC,eAAA,uBAC3B,4BAAA,CAA6B,KAAA;EAC1C,SAA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@@ -0,0 +1,241 @@
1
+ import React, { ComponentType, ReactNode } from "react";
2
+ import { AnyGenerativeUI, CreateGenerativeUIConfig, GenerativeUI, GenerativeUIBasesDefinitions, GenerativeUIComponentDefinition, GenerativeUIComponentName, GenerativeUIComponentProps, GenerativeUIDefinitions, GenerativeUIDefinitionsOf, GenerativeUIErrorInfo, GenerativeUIEventDefinition, GenerativeUIFunctionArgs, GenerativeUIFunctionDefinition, GenerativeUIFunctionDefinition as GenerativeUIFunctionDefinition$1, GenerativeUIFunctionInput, GenerativeUIFunctionName, GenerativeUIInvokeResult, GenerativeUIResultDefinitions, GenerativeUISchema, GenerativeUISlotKind, GenerativeUIStateOf, GenerativeUITheme } from "@copilotkit/shared/generative-ui";
3
+ import { GenerativeUIAccessibility, GenerativeUIAriaAttributes, GenerativeUIAriaAttributes as GenerativeUIAriaAttributes$1, GenerativeUIDispatcher, GenerativeUISurfaceManager } from "@copilotkit/core/generative-ui";
4
+ import { GenerativeUIRejectedOperation, GenerativeUIUserEvent } from "@copilotkit/shared";
5
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
6
+ import { ActivityMessageRenderProps, ActivityMessageRendererDef } from "@copilotkit/core";
7
+ import { StreamingMarkdownRendererProps } from "@copilotkit/markdown/react";
8
+
9
+ //#region src/generative-ui/catalog.d.ts
10
+ /** One component of a generative UI, as the renderer reads it. */
11
+ type GenerativeUIComponentDefinition$1 = GenerativeUIComponentDefinition<ComponentType<any>>;
12
+ /**
13
+ * Experimental. The result of `createGenerativeUI`: the components the model
14
+ * can render, the app state they read, and the functions they call. Give it
15
+ * to the provider (`generativeUI={{ ui }}`) and to the typed hooks.
16
+ */
17
+ type GenerativeUI$1<Definitions extends GenerativeUIDefinitions = GenerativeUIDefinitions> = GenerativeUI<Definitions, ComponentType<any>>;
18
+ /**
19
+ * Props that the renderer passes to a component:
20
+ * `function CheckoutForm(props: GenerativeUIComponentProps<typeof ui, "CheckoutForm">)`.
21
+ * Data props are the parsed `props` schema, bound props included. Event and
22
+ * slot props are present only when they are bound or filled. Each writable
23
+ * prop gets a setter (`value` gets `setValue`), which is always present.
24
+ */
25
+ type GenerativeUIComponentProps$1<UI extends AnyGenerativeUI, Name extends keyof NonNullable<UI["definitions"]>["components"] & string> = GenerativeUIComponentProps<UI, Name, ReactNode>;
26
+ /** One new React component for each component of the bases that it names. */
27
+ type OverridesConfig<Bases extends readonly AnyGenerativeUI[]> = { [Name in keyof GenerativeUIBasesDefinitions<Bases>["components"] & string]?: {
28
+ component: ComponentType<GenerativeUIBasesDefinitions<Bases> extends infer Definitions extends GenerativeUIDefinitions ? GenerativeUIComponentProps$1<GenerativeUI$1<Definitions>, Name> : never>;
29
+ } };
30
+ /** The config of `createGenerativeUI`. */
31
+ type CreateGenerativeUIConfig$1<Bases extends readonly AnyGenerativeUI[], State extends Record<string, GenerativeUISchema>, Functions extends Record<string, GenerativeUIFunctionDefinition>, Props extends Record<string, unknown>, Events extends Record<string, unknown>, Slots extends Record<string, unknown>, Writable extends Record<string, unknown>> = CreateGenerativeUIConfig<Bases, State, Functions, Props, Events, Slots, Writable, OverridesConfig<Bases>>;
32
+ /**
33
+ * Experimental. Declares the components the model can render, the app state
34
+ * they read, and the functions they call.
35
+ *
36
+ * - A prop with the name of a top-level state key is bound to that state.
37
+ * - `bind: { prop: (state, props) => value }` binds a prop to a selector.
38
+ * - An event binds to the function with its name, else to the name without
39
+ * `on` (`onAddToCart` calls `addToCart`).
40
+ * - `writable: ["value"]` gives the component a `setValue` prop. See
41
+ * `GenerativeUIComponentDefinition.writable`.
42
+ *
43
+ * The model does not see bound props or matched events.
44
+ *
45
+ * @param config - `id`, then optional `extends`, `state`, `functions` and
46
+ * `overrides`, then `components`. Put `state` before `components`, so the selectors
47
+ * get typed state.
48
+ * @throws Error when a name comes from two places, an override names no
49
+ * component of the bases, `props` is not an object
50
+ * schema with a JSON Schema, a key is reserved or used
51
+ * twice on a component, an event matches two functions, an unmatched event
52
+ * has no `parameters`, a `bind` key is not a prop, a `writable` key is not
53
+ * a prop or is a bound prop, or a setter name is already a key of the
54
+ * component. Also throws when `parameterOrder` contains duplicate or unknown
55
+ * keys, or an ordered component declares integer-index keys whose JSON object
56
+ * enumeration order cannot be controlled.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const ui = createGenerativeUI({
61
+ * id: "acme/store@1",
62
+ * state: { cart: cartSchema },
63
+ * functions: { addToCart: { parameters: z.object({ productId: z.string() }) } },
64
+ * components: {
65
+ * CartSummary: {
66
+ * component: CartSummary,
67
+ * props: z.object({ count: z.number() }),
68
+ * bind: { count: (state) => state.cart.count },
69
+ * },
70
+ * },
71
+ * });
72
+ * ```
73
+ */
74
+ declare function createGenerativeUI<Bases extends readonly AnyGenerativeUI[] = [], State extends Record<string, GenerativeUISchema> = {}, Functions extends Record<string, GenerativeUIFunctionDefinition> = {}, Props extends Record<string, unknown> = {}, Events extends Record<string, unknown> = {}, Slots extends Record<string, unknown> = {}, Writable extends Record<string, unknown> = {}>(config: CreateGenerativeUIConfig$1<Bases, State, Functions, Props, Events, Slots, Writable>): GenerativeUI$1<GenerativeUIResultDefinitions<Bases, State, Functions, Props, Events, Slots, Writable>>;
75
+ //#endregion
76
+ //#region src/generative-ui/accessibility.d.ts
77
+ /**
78
+ * Experimental. The ARIA attributes of the `accessibility` that the model
79
+ * gave the component being rendered, to spread on its root element. The
80
+ * standard components do this; a custom component does it itself:
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function Panel({ children }: { children?: ReactNode }) {
85
+ * const aria = useGenerativeUIAccessibility();
86
+ * return <section {...aria}>{children}</section>;
87
+ * }
88
+ * ```
89
+ *
90
+ * Outside of generated UI it gives `{}`.
91
+ */
92
+ declare function useGenerativeUIAccessibility(): GenerativeUIAriaAttributes;
93
+ //#endregion
94
+ //#region src/generative-ui/runtime-context.d.ts
95
+ interface GenerativeUIErrorBoundaryConfig {
96
+ /** Replaces the default per-component fallback. */
97
+ fallback?: (props: {
98
+ error: Error;
99
+ retry: () => void;
100
+ surfaceId: string;
101
+ componentId: string;
102
+ }) => ReactNode;
103
+ /** Called for render, props, operation, function and event failures. */
104
+ onError?: (info: GenerativeUIErrorInfo) => void;
105
+ }
106
+ interface GenerativeUIBaseConfig {
107
+ /**
108
+ * The result of `createGenerativeUI`: the components the model can render,
109
+ * the app state they read and the functions they call.
110
+ */
111
+ ui: GenerativeUI$1;
112
+ /**
113
+ * The agents that get the generative UI. When omitted, every agent gets
114
+ * it. Other agents get no envelope.
115
+ */
116
+ agentIds?: string[];
117
+ /**
118
+ * Values for the `--a2ui-*` CSS variables and the map style. Top-level
119
+ * values apply in both modes. `dark` changes them in dark mode, which is
120
+ * on under a `.dark` class, like the CopilotKit chat.
121
+ */
122
+ theme?: GenerativeUITheme;
123
+ /** Fallback UI and error reporting for generated UI. */
124
+ errorBoundary?: GenerativeUIErrorBoundaryConfig;
125
+ }
126
+ /**
127
+ * The tool transport: the model calls the `render_ui` tool, and the runtime
128
+ * validates each operation before it streams it to the client.
129
+ */
130
+ interface GenerativeUIToolConfig extends GenerativeUIBaseConfig {
131
+ /** Leave it out, or set "tool". */
132
+ transport?: "tool";
133
+ sendContext?: never;
134
+ includeCatalog?: never;
135
+ }
136
+ /**
137
+ * The markdown transport: the model writes the operations in ```a2ui fences
138
+ * in its reply. The client reads and validates them.
139
+ */
140
+ interface GenerativeUIMarkdownConfig extends GenerativeUIBaseConfig {
141
+ transport: "markdown";
142
+ /**
143
+ * Send the component schema and the fence guideline as context entries.
144
+ * Set `false` when the backend builds its own prompt from the envelope.
145
+ * Default `true`.
146
+ */
147
+ sendContext?: boolean;
148
+ /**
149
+ * Send the component schemas in the envelope (`catalog.components`).
150
+ * Default `true`.
151
+ */
152
+ includeCatalog?: boolean;
153
+ }
154
+ /**
155
+ * Experimental. The `generativeUI` prop of `CopilotKitProvider`. Set
156
+ * `transport: "markdown"` to get the markdown options.
157
+ *
158
+ * @example
159
+ * ```tsx
160
+ * <CopilotKitProvider generativeUI={{ ui }} />
161
+ * <CopilotKitProvider generativeUI={{ ui, transport: "markdown", sendContext: false }} />
162
+ * ```
163
+ */
164
+ type GenerativeUIConfig = GenerativeUIToolConfig | GenerativeUIMarkdownConfig;
165
+ interface GenerativeUIRuntime {
166
+ manager: GenerativeUISurfaceManager;
167
+ dispatcher: GenerativeUIDispatcher;
168
+ /** The generative UI given to the provider as `generativeUI={{ ui }}`. */
169
+ ui: GenerativeUI$1;
170
+ /** How the model sends operations. "tool" when the config leaves it out. */
171
+ transport: "tool" | "markdown";
172
+ /** The latest `generativeUI` config of the provider. */
173
+ readonly config: GenerativeUIConfig;
174
+ /** The latest `theme`. Each surface root sets its CSS variables. */
175
+ theme?: GenerativeUITheme;
176
+ forwardEvent: (event: GenerativeUIUserEvent, agentId: string | undefined) => Promise<GenerativeUIInvokeResult>;
177
+ reportError: (info: GenerativeUIErrorInfo) => void;
178
+ readonly errorFallback?: GenerativeUIErrorBoundaryConfig["fallback"];
179
+ }
180
+ declare function useGenerativeUIRuntime(): GenerativeUIRuntime | null;
181
+ //#endregion
182
+ //#region src/types/react-activity-message-renderer.d.ts
183
+ /**
184
+ * An activity message renderer for React: a React component that draws
185
+ * activity messages of one `activityType` (or `"*"` for any type). The
186
+ * component receives {@link ActivityMessageRenderProps}.
187
+ *
188
+ * @typeParam TActivityContent - The shape of the activity content.
189
+ */
190
+ type ReactActivityMessageRenderer<TActivityContent> = ActivityMessageRendererDef<TActivityContent, React.ComponentType<ActivityMessageRenderProps<TActivityContent>>>;
191
+ //#endregion
192
+ //#region src/generative-ui/chat.d.ts
193
+ interface GenerativeUIChatSurfaceProps {
194
+ surfaceId: string;
195
+ isStreaming: boolean;
196
+ /**
197
+ * Set when operations from the latest render_ui call were rejected. The
198
+ * message is user-facing; `error.cause` holds the same list as `rejected`.
199
+ */
200
+ error?: Error;
201
+ /** Rejected operations from the latest render_ui call, with validator reasons. */
202
+ rejected: GenerativeUIRejectedOperation[];
203
+ children: ReactNode;
204
+ }
205
+ declare function DefaultGenerativeUIChatCard({
206
+ surfaceId,
207
+ error,
208
+ children
209
+ }: GenerativeUIChatSurfaceProps): react_jsx_runtime0.JSX.Element;
210
+ //#endregion
211
+ //#region src/providers/MarkdownRendererContext.d.ts
212
+ /** Props every markdown renderer (built-in or plugged-in) receives. */
213
+ interface MarkdownRendererProps {
214
+ /** Raw, possibly-partial (streaming) markdown string. */
215
+ content: string;
216
+ /** Hint that the message is still streaming, for cursor/affordance use. */
217
+ isStreaming?: boolean;
218
+ className?: string;
219
+ }
220
+ /**
221
+ * Config for the built-in default renderer. Pass this (instead of a component)
222
+ * as `markdownRenderer` to configure the built-in renderer without writing a
223
+ * wrapper — e.g. `markdownRenderer={{ nodeRenderers: { codeBlock: Shiki } }}`.
224
+ */
225
+ type DefaultMarkdownRendererProps = Pick<StreamingMarkdownRendererProps, "nodeRenderers" | "caret" | "options" | "className" | "onLinkClick" | "onCitationClick">;
226
+ /** A markdown renderer: a component, OR config for the built-in default. */
227
+ type MarkdownRenderer = React.ComponentType<MarkdownRendererProps> | DefaultMarkdownRendererProps;
228
+ declare const MarkdownRendererProvider: React.FC<{
229
+ renderer?: MarkdownRenderer;
230
+ children: React.ReactNode;
231
+ }>;
232
+ /**
233
+ * The markdown renderer set at the provider level, or `undefined` when none was
234
+ * supplied. Message components fall back to the built-in
235
+ * `StreamingMarkdownDefaultRenderer` (via `CopilotChatAssistantMessage.MarkdownRenderer`)
236
+ * when this is `undefined`.
237
+ */
238
+ declare function useMarkdownRenderer(): MarkdownRenderer | undefined;
239
+ //#endregion
240
+ export { GenerativeUIStateOf as A, GenerativeUIDefinitionsOf as C, GenerativeUIFunctionInput as D, GenerativeUIFunctionDefinition$1 as E, GenerativeUIFunctionName as O, GenerativeUIComponentProps$1 as S, GenerativeUIFunctionArgs as T, useGenerativeUIAccessibility as _, useMarkdownRenderer as a, GenerativeUIComponentDefinition$1 as b, ReactActivityMessageRenderer as c, GenerativeUIMarkdownConfig as d, GenerativeUITheme as f, GenerativeUIAriaAttributes$1 as g, GenerativeUIAccessibility as h, MarkdownRendererProvider as i, createGenerativeUI as j, GenerativeUISlotKind as k, GenerativeUIConfig as l, useGenerativeUIRuntime as m, MarkdownRenderer as n, DefaultGenerativeUIChatCard as o, GenerativeUIToolConfig as p, MarkdownRendererProps as r, GenerativeUIChatSurfaceProps as s, DefaultMarkdownRendererProps as t, GenerativeUIErrorBoundaryConfig as u, CreateGenerativeUIConfig$1 as v, GenerativeUIEventDefinition as w, GenerativeUIComponentName as x, GenerativeUI$1 as y };
241
+ //# sourceMappingURL=MarkdownRendererContext-iOl2pj9l.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownRendererContext-iOl2pj9l.d.cts","names":[],"sources":["../src/generative-ui/catalog.ts","../src/generative-ui/accessibility.ts","../src/generative-ui/runtime-context.ts","../src/types/react-activity-message-renderer.ts","../src/generative-ui/chat.tsx","../src/providers/MarkdownRendererContext.tsx"],"mappings":";;;;;;;;;;KA2CY,iCAAA,GACV,+BAAA,CAAsC,aAAA;;AADxC;;;;KAaY,cAAA,qBACU,uBAAA,GAA0B,uBAAA,IAC5C,YAAA,CAAmB,WAAA,EAAa,aAAA;AAFpC;;;;;;;AAAA,KAWY,4BAAA,YACC,eAAA,qBACQ,WAAA,CAAY,EAAA,2CAC7B,0BAAA,CAAiC,EAAA,EAAI,IAAA,EAAM,SAAA;;KAG1C,eAAA,wBAAuC,eAAA,uBAC3B,4BAAA,CAA6B,KAAA;EAC1C,SAAA,EAAW,aAAA,CACT,4BAAA,CAA6B,KAAA,oCAC3B,uBAAA,GACE,4BAAA,CAA2B,cAAA,CAAa,WAAA,GAAc,IAAA;AAAA;;KAOpD,0BAAA,wBACa,eAAA,kBACT,MAAA,SAAe,kBAAA,qBACX,MAAA,SAAe,8BAAA,iBACnB,MAAA,kCACC,MAAA,iCACD,MAAA,oCACG,MAAA,qBACf,wBAAA,CACF,KAAA,EACA,KAAA,EACA,SAAA,EACA,KAAA,EACA,MAAA,EACA,KAAA,EACA,QAAA,EACA,eA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