@copilotkit/react-core 2.0.0-rc.4 → 2.0.0-rc.40
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/README.md +1 -1
- package/dist/MarkdownRendererContext-BL8ct_3U.d.mts +34 -0
- package/dist/MarkdownRendererContext-BL8ct_3U.d.mts.map +1 -0
- package/dist/MarkdownRendererContext-C2J_lgqF.d.cts +34 -0
- package/dist/MarkdownRendererContext-C2J_lgqF.d.cts.map +1 -0
- package/dist/MarkdownSurfaces-Byz821bg.mjs +324 -0
- package/dist/MarkdownSurfaces-Byz821bg.mjs.map +1 -0
- package/dist/MarkdownSurfaces-D2Ck-cbb.cjs +378 -0
- package/dist/MarkdownSurfaces-D2Ck-cbb.cjs.map +1 -0
- package/dist/chat-Bf0vVdo7.mjs +1600 -0
- package/dist/chat-Bf0vVdo7.mjs.map +1 -0
- package/dist/chat-D3fxo6Ah.cjs +1784 -0
- package/dist/chat-D3fxo6Ah.cjs.map +1 -0
- package/dist/chat-DgP2N7bD.d.mts +233 -0
- package/dist/chat-DgP2N7bD.d.mts.map +1 -0
- package/dist/chat-DtHs4alO.d.cts +233 -0
- package/dist/chat-DtHs4alO.d.cts.map +1 -0
- package/dist/context.cjs +75 -63
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +62 -107
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +62 -107
- package/dist/context.d.mts.map +1 -1
- package/dist/context.mjs +76 -64
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui/native.cjs +66 -0
- package/dist/generative-ui/native.cjs.map +1 -0
- package/dist/generative-ui/native.d.cts +155 -0
- package/dist/generative-ui/native.d.cts.map +1 -0
- package/dist/generative-ui/native.d.mts +155 -0
- package/dist/generative-ui/native.d.mts.map +1 -0
- package/dist/generative-ui/native.mjs +24 -0
- package/dist/generative-ui/native.mjs.map +1 -0
- package/dist/generative-ui.cjs +757 -3056
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +2470 -4788
- package/dist/generative-ui.d.cts.map +1 -1
- package/dist/generative-ui.d.mts +2470 -4788
- package/dist/generative-ui.d.mts.map +1 -1
- package/dist/generative-ui.mjs +327 -2636
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +289 -1054
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +145 -370
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +119 -235
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +283 -1054
- package/dist/headless.mjs.map +1 -1
- package/dist/hooks-2Ur8NQhj.d.cts +84 -0
- package/dist/hooks-2Ur8NQhj.d.cts.map +1 -0
- package/dist/hooks-BRYonCVu.d.mts +84 -0
- package/dist/hooks-BRYonCVu.d.mts.map +1 -0
- package/dist/index.cjs +6960 -11012
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +337 -831
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +334 -828
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1896 -7582
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +6319 -11463
- package/dist/index.umd.js.map +1 -1
- package/dist/refs-BIUfn1wb.cjs +43 -0
- package/dist/refs-BIUfn1wb.cjs.map +1 -0
- package/dist/refs-CMrRm3ta.mjs +31 -0
- package/dist/refs-CMrRm3ta.mjs.map +1 -0
- package/dist/use-generative-ui-root-C12htqbK.cjs +390 -0
- package/dist/use-generative-ui-root-C12htqbK.cjs.map +1 -0
- package/dist/use-generative-ui-root-CVgsDy1f.mjs +385 -0
- package/dist/use-generative-ui-root-CVgsDy1f.mjs.map +1 -0
- package/package.json +45 -23
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts +0 -954
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts +0 -954
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
- package/dist/MarkdownSurfaces-Bd--93O1.mjs +0 -3676
- package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs +0 -3991
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
package/dist/context.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.mjs","names":[],"sources":["../src/lib/react-core.ts","../src/context.ts"],"sourcesContent":["import React from \"react\";\nimport type {\n ReactActivityMessageRenderer,\n ReactToolCallRenderer,\n} from \"../types\";\nimport type { ReactCustomMessageRenderer } from \"../types/react-custom-message-renderer\";\nimport { CopilotKitCore } from \"@copilotkit/core\";\nimport type {\n CopilotKitCoreConfig,\n CopilotKitCoreSubscriber,\n CopilotKitCoreSubscription,\n} from \"@copilotkit/core\";\n\nexport interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {\n // Add any additional configuration properties specific to the React implementation\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n\n // Add custom message renderers\n renderCustomMessages?: ReactCustomMessageRenderer[];\n}\n\nexport interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {\n onRenderToolCallsChanged?: (event: {\n copilotkit: CopilotKitCore;\n renderToolCalls: ReactToolCallRenderer<any>[];\n }) => void | Promise<void>;\n onInterruptElementChanged?: (event: {\n copilotkit: CopilotKitCore;\n interruptElement: React.ReactElement | null;\n }) => void | Promise<void>;\n}\n\nexport class CopilotKitCoreReact extends CopilotKitCore {\n private _renderToolCalls: ReactToolCallRenderer<any>[] = [];\n private _hookRenderToolCalls: Map<string, ReactToolCallRenderer<any>> =\n new Map();\n private _cachedMergedRenderToolCalls: ReactToolCallRenderer<any>[] | null =\n null;\n private _renderCustomMessages: ReactCustomMessageRenderer[] = [];\n private _renderActivityMessages: ReactActivityMessageRenderer<any>[] = [];\n private _interruptElement: React.ReactElement | null = null;\n\n constructor(config: CopilotKitCoreReactConfig) {\n super(config);\n this._renderToolCalls = config.renderToolCalls ?? [];\n this._renderCustomMessages = config.renderCustomMessages ?? [];\n this._renderActivityMessages = config.renderActivityMessages ?? [];\n }\n\n get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]> {\n return this._renderCustomMessages;\n }\n\n get renderActivityMessages(): Readonly<ReactActivityMessageRenderer<any>>[] {\n return this._renderActivityMessages;\n }\n\n get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[] {\n if (this._hookRenderToolCalls.size === 0) {\n return this._renderToolCalls;\n }\n if (this._cachedMergedRenderToolCalls) {\n return this._cachedMergedRenderToolCalls;\n }\n // Merge: hook entries override prop entries with the same key\n const merged = new Map<string, ReactToolCallRenderer<any>>();\n for (const rc of this._renderToolCalls) {\n merged.set(`${rc.agentId ?? \"\"}:${rc.name}`, rc);\n }\n for (const [key, rc] of this._hookRenderToolCalls) {\n merged.set(key, rc);\n }\n this._cachedMergedRenderToolCalls = Array.from(merged.values());\n return this._cachedMergedRenderToolCalls;\n }\n\n setRenderActivityMessages(\n renderers: ReactActivityMessageRenderer<any>[],\n ): void {\n this._renderActivityMessages = renderers;\n }\n\n setRenderCustomMessages(renderers: ReactCustomMessageRenderer[]): void {\n this._renderCustomMessages = renderers;\n }\n\n setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void {\n this._renderToolCalls = renderToolCalls;\n this._cachedMergedRenderToolCalls = null;\n this._notifyRenderToolCallsChanged();\n }\n\n addHookRenderToolCall(entry: ReactToolCallRenderer<any>): void {\n const key = `${entry.agentId ?? \"\"}:${entry.name}`;\n this._hookRenderToolCalls.set(key, entry);\n this._cachedMergedRenderToolCalls = null;\n this._notifyRenderToolCallsChanged();\n }\n\n removeHookRenderToolCall(name: string, agentId?: string): void {\n const key = `${agentId ?? \"\"}:${name}`;\n if (this._hookRenderToolCalls.delete(key)) {\n this._cachedMergedRenderToolCalls = null;\n this._notifyRenderToolCallsChanged();\n }\n }\n\n private _notifyRenderToolCallsChanged(): void {\n void this.notifySubscribers((subscriber) => {\n const reactSubscriber = subscriber as CopilotKitCoreReactSubscriber;\n if (reactSubscriber.onRenderToolCallsChanged) {\n reactSubscriber.onRenderToolCallsChanged({\n copilotkit: this,\n renderToolCalls: this.renderToolCalls,\n });\n }\n }, \"Subscriber onRenderToolCallsChanged error:\");\n }\n\n get interruptElement(): React.ReactElement | null {\n return this._interruptElement;\n }\n\n setInterruptElement(element: React.ReactElement | null): void {\n this._interruptElement = element;\n void this.notifySubscribers((subscriber) => {\n const reactSubscriber = subscriber as CopilotKitCoreReactSubscriber;\n reactSubscriber.onInterruptElementChanged?.({\n copilotkit: this,\n interruptElement: this._interruptElement,\n });\n }, \"Subscriber onInterruptElementChanged error:\");\n }\n\n // Override to accept React-specific subscriber type\n subscribe(\n subscriber: CopilotKitCoreReactSubscriber,\n ): CopilotKitCoreSubscription {\n return super.subscribe(subscriber);\n }\n\n /**\n * Wait for pending React state updates before the follow-up agent run.\n *\n * When a frontend tool handler calls setState(), React 18 batches the update\n * and schedules a commit via its internal scheduler (MessageChannel). The\n * useAgentContext hook registers context via useLayoutEffect, which runs\n * synchronously after React commits that batch.\n *\n * Awaiting a zero-delay timeout yields to the macrotask queue. React's\n * MessageChannel task runs first, committing the pending state and running\n * useLayoutEffect (which updates the context store). The follow-up runAgent\n * call then reads fresh context.\n */\n async waitForPendingFrameworkUpdates(): Promise<void> {\n await new Promise<void>((resolve) => setTimeout(resolve, 0));\n }\n}\n","\"use client\";\n\nimport { createContext, useContext, useEffect, useReducer } from \"react\";\nimport { CopilotKitCoreReact } from \"./lib/react-core\";\nimport type { CopilotKitCoreReactConfig } from \"./lib/react-core\";\nimport type { LicenseContextValue } from \"@copilotkit/shared\";\n\n// Re-export so headless.ts (and consumers) reference the same type declaration.\nexport { CopilotKitCoreReact };\nexport type { CopilotKitCoreReactConfig };\n\nexport interface CopilotKitContextValue {\n copilotkit: CopilotKitCoreReact;\n /**\n * Whether CopilotKit should automatically mount Intelligence indicators.\n * Defaults to true when omitted for compatibility with custom providers.\n */\n showIntelligenceIndicator?: boolean;\n /**\n * Set of tool call IDs currently being executed.\n * This is tracked at the provider level to ensure tool execution events\n * are captured even before child components mount.\n */\n executingToolCallIds: ReadonlySet<string>;\n}\n\nexport const EMPTY_SET: ReadonlySet<string> = new Set();\n\nexport const CopilotKitContext = createContext<CopilotKitContextValue | null>(\n null,\n);\n\nexport const useCopilotKit = (): CopilotKitContextValue => {\n const context = useContext(CopilotKitContext);\n const [, forceUpdate] = useReducer((x: number) => x + 1, 0);\n\n if (!context) {\n throw new Error(\"useCopilotKit must be used within CopilotKitProvider\");\n }\n useEffect(() => {\n const subscription = context.copilotkit.subscribe({\n onRuntimeConnectionStatusChanged: () => {\n forceUpdate();\n },\n onHeadersChanged: () => {\n forceUpdate();\n },\n });\n return () => {\n subscription.unsubscribe();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return context;\n};\n\n// License context — shared between web and RN providers.\n// Default is permissive (all features allowed) — providers override via createLicenseContextValue.\n// Inlined here to avoid a runtime import from @copilotkit/shared, which pulls in\n// Node-only deps (jose) that break React Native's Metro bundler.\nexport const LicenseContext = createContext<LicenseContextValue>({\n status: null,\n license: null,\n checkFeature: () => true,\n getLimit: () => null,\n} as LicenseContextValue);\n\nexport const useLicenseContext = (): LicenseContextValue =>\n useContext(LicenseContext);\n\n// Provider-level default agent id, published by `<CopilotKitProvider agentId>`.\n//\n// This is a context of its own rather than a `CopilotChatConfigurationProvider`\n// rendered at the root, because that provider also owns a thread: it resolves a\n// threadId (minting a UUID when none is given) and the top-most one owns the\n// imperative active-thread override. Rendering it around the whole application\n// would hand every `<CopilotChat>` the same inherited threadId, so two sibling\n// chats would share one transcript. A bare string context carries the agent\n// default and nothing else.\n//\n// It is the LAST fallback before `DEFAULT_AGENT_ID`, so an explicit `agentId`\n// argument, a `<CopilotChat agentId>`, and a `<CopilotChatConfigurationProvider\n// agentId>` all still win.\nexport const CopilotKitAgentIdContext = createContext<string | undefined>(\n undefined,\n);\n\nexport const useDefaultAgentId = (): string | undefined =>\n useContext(CopilotKitAgentIdContext);\n"],"mappings":";;;;;;AAiCA,IAAa,sBAAb,cAAyC,eAAe;CAUtD,YAAY,QAAmC;AAC7C,QAAM,OAAO;0BAV0C,EAAE;8CAEzD,IAAI,KAAK;sCAET;+BAC4D,EAAE;iCACO,EAAE;2BAClB;AAIrD,OAAK,mBAAmB,OAAO,mBAAmB,EAAE;AACpD,OAAK,wBAAwB,OAAO,wBAAwB,EAAE;AAC9D,OAAK,0BAA0B,OAAO,0BAA0B,EAAE;;CAGpE,IAAI,uBAA+D;AACjE,SAAO,KAAK;;CAGd,IAAI,yBAAwE;AAC1E,SAAO,KAAK;;CAGd,IAAI,kBAA0D;AAC5D,MAAI,KAAK,qBAAqB,SAAS,EACrC,QAAO,KAAK;AAEd,MAAI,KAAK,6BACP,QAAO,KAAK;EAGd,MAAM,yBAAS,IAAI,KAAyC;AAC5D,OAAK,MAAM,MAAM,KAAK,iBACpB,QAAO,IAAI,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG,QAAQ,GAAG;AAElD,OAAK,MAAM,CAAC,KAAK,OAAO,KAAK,qBAC3B,QAAO,IAAI,KAAK,GAAG;AAErB,OAAK,+BAA+B,MAAM,KAAK,OAAO,QAAQ,CAAC;AAC/D,SAAO,KAAK;;CAGd,0BACE,WACM;AACN,OAAK,0BAA0B;;CAGjC,wBAAwB,WAA+C;AACrE,OAAK,wBAAwB;;CAG/B,mBAAmB,iBAAqD;AACtE,OAAK,mBAAmB;AACxB,OAAK,+BAA+B;AACpC,OAAK,+BAA+B;;CAGtC,sBAAsB,OAAyC;EAC7D,MAAM,MAAM,GAAG,MAAM,WAAW,GAAG,GAAG,MAAM;AAC5C,OAAK,qBAAqB,IAAI,KAAK,MAAM;AACzC,OAAK,+BAA+B;AACpC,OAAK,+BAA+B;;CAGtC,yBAAyB,MAAc,SAAwB;EAC7D,MAAM,MAAM,GAAG,WAAW,GAAG,GAAG;AAChC,MAAI,KAAK,qBAAqB,OAAO,IAAI,EAAE;AACzC,QAAK,+BAA+B;AACpC,QAAK,+BAA+B;;;CAIxC,AAAQ,gCAAsC;AAC5C,EAAK,KAAK,mBAAmB,eAAe;GAC1C,MAAM,kBAAkB;AACxB,OAAI,gBAAgB,yBAClB,iBAAgB,yBAAyB;IACvC,YAAY;IACZ,iBAAiB,KAAK;IACvB,CAAC;KAEH,6CAA6C;;CAGlD,IAAI,mBAA8C;AAChD,SAAO,KAAK;;CAGd,oBAAoB,SAA0C;AAC5D,OAAK,oBAAoB;AACzB,EAAK,KAAK,mBAAmB,eAAe;AAE1C,GADwB,WACR,4BAA4B;IAC1C,YAAY;IACZ,kBAAkB,KAAK;IACxB,CAAC;KACD,8CAA8C;;CAInD,UACE,YAC4B;AAC5B,SAAO,MAAM,UAAU,WAAW;;;;;;;;;;;;;;;CAgBpC,MAAM,iCAAgD;AACpD,QAAM,IAAI,SAAe,YAAY,WAAW,SAAS,EAAE,CAAC;;;;;;AClIhE,MAAa,4BAAiC,IAAI,KAAK;AAEvD,MAAa,oBAAoB,cAC/B,KACD;AAED,MAAa,sBAA8C;CACzD,MAAM,UAAU,WAAW,kBAAkB;CAC7C,MAAM,GAAG,eAAe,YAAY,MAAc,IAAI,GAAG,EAAE;AAE3D,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,uDAAuD;AAEzE,iBAAgB;EACd,MAAM,eAAe,QAAQ,WAAW,UAAU;GAChD,wCAAwC;AACtC,iBAAa;;GAEf,wBAAwB;AACtB,iBAAa;;GAEhB,CAAC;AACF,eAAa;AACX,gBAAa,aAAa;;IAG3B,EAAE,CAAC;AAEN,QAAO;;AAOT,MAAa,iBAAiB,cAAmC;CAC/D,QAAQ;CACR,SAAS;CACT,oBAAoB;CACpB,gBAAgB;CACjB,CAAwB;AAEzB,MAAa,0BACX,WAAW,eAAe;AAe5B,MAAa,2BAA2B,cACtC,OACD;AAED,MAAa,0BACX,WAAW,yBAAyB"}
|
|
1
|
+
{"version":3,"file":"context.mjs","names":[],"sources":["../src/lib/react-core.ts","../src/context.ts"],"sourcesContent":["import React from \"react\";\nimport type {\n ReactActivityMessageRenderer,\n ReactToolCallRenderer,\n} from \"../types\";\nimport type { ReactCustomMessageRenderer } from \"../types/react-custom-message-renderer\";\nimport { CopilotKitCore, ɵRendererRegistry } from \"@copilotkit/core\";\nimport type {\n CopilotKitCoreConfig,\n CopilotKitCoreSubscriber,\n CopilotKitCoreSubscription,\n ɵRendererKind,\n} from \"@copilotkit/core\";\n\nexport interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {\n // Add any additional configuration properties specific to the React implementation\n renderToolCalls?: ReactToolCallRenderer<any>[];\n renderActivityMessages?: ReactActivityMessageRenderer<any>[];\n\n // Add custom message renderers\n renderCustomMessages?: ReactCustomMessageRenderer[];\n}\n\nexport interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {\n onRenderToolCallsChanged?: (event: {\n copilotkit: CopilotKitCore;\n renderToolCalls: readonly ReactToolCallRenderer<any>[];\n }) => void | Promise<void>;\n onRenderActivityMessagesChanged?: (event: {\n copilotkit: CopilotKitCore;\n renderActivityMessages: readonly ReactActivityMessageRenderer<any>[];\n }) => void | Promise<void>;\n onRenderCustomMessagesChanged?: (event: {\n copilotkit: CopilotKitCore;\n renderCustomMessages: readonly ReactCustomMessageRenderer[];\n }) => void | Promise<void>;\n onInterruptElementChanged?: (event: {\n copilotkit: CopilotKitCore;\n interruptElement: React.ReactElement | null;\n }) => void | Promise<void>;\n}\n\n/**\n * Wait for pending React state updates before the follow-up agent run.\n *\n * When a frontend tool handler calls setState(), React 18 batches the update\n * and schedules a commit via its internal scheduler (MessageChannel). The\n * useAgentContext hook registers context via useLayoutEffect, which runs\n * synchronously after React commits that batch.\n *\n * Awaiting a zero-delay timeout yields to the macrotask queue. React's\n * MessageChannel task runs first, committing the pending state and running\n * useLayoutEffect (which updates the context store). The follow-up runAgent\n * call then reads fresh context.\n */\nfunction waitForReactCommit() {\n return new Promise<void>((resolve) => setTimeout(resolve, 0));\n}\n\nexport class CopilotKitCoreReact extends CopilotKitCore {\n private readonly _renderers: ɵRendererRegistry<\n ReactToolCallRenderer<any>,\n ReactActivityMessageRenderer<any>,\n ReactCustomMessageRenderer\n >;\n\n constructor(config: CopilotKitCoreReactConfig) {\n super({\n ...config,\n ɵwaitForFrameworkUpdates: waitForReactCommit,\n });\n this._renderers = new ɵRendererRegistry({\n toolCalls: config.renderToolCalls,\n activity: config.renderActivityMessages,\n custom: config.renderCustomMessages,\n });\n this._renderers.subscribe((kind) => this.notifyRenderersChanged(kind));\n // The element lives in core's generic interrupt slot; keep the React\n // subscriber event for existing listeners.\n this.ɵsubscribeToInterruptPayload(() => {\n void this.notifySubscribers((subscriber) => {\n const reactSubscriber = subscriber as CopilotKitCoreReactSubscriber;\n return reactSubscriber.onInterruptElementChanged?.({\n copilotkit: this,\n interruptElement: this.interruptElement,\n });\n }, \"Subscriber onInterruptElementChanged error:\");\n });\n }\n\n get renderCustomMessages() {\n return this._renderers.custom;\n }\n\n get renderActivityMessages() {\n return this._renderers.activity;\n }\n\n /**\n * Prop, hook and built-in renderers merged. For one name and agentId, a\n * hook renderer wins over a prop one, and both win over a built-in one.\n */\n get renderToolCalls() {\n return this._renderers.toolCalls;\n }\n\n setRenderActivityMessages(\n renderers: ReactActivityMessageRenderer<any>[],\n ): void {\n this._renderers.setActivity(renderers);\n }\n\n setRenderCustomMessages(renderers: ReactCustomMessageRenderer[]): void {\n this._renderers.setCustom(renderers);\n }\n\n setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void {\n this._renderers.setPropToolCalls(renderToolCalls);\n }\n\n addHookRenderToolCall(entry: ReactToolCallRenderer<any>): void {\n this._renderers.addHookToolCall(entry);\n }\n\n removeHookRenderToolCall(name: string, agentId?: string): void {\n this._renderers.removeHookToolCall(name, agentId);\n }\n\n /**\n * @internal Add a renderer for a tool a built-in feature owns (A2UI,\n * generative UI). Prop and hook renderers with the same name and agent win\n * over it, and `setRenderToolCalls` never removes it.\n *\n * @returns A function that removes the renderer.\n */\n ɵaddBuiltInRenderToolCall(entry: ReactToolCallRenderer): () => void {\n return this._renderers.addBuiltInToolCall(entry);\n }\n\n private notifyRenderersChanged(kind: ɵRendererKind): void {\n void this.notifySubscribers((subscriber) => {\n const reactSubscriber = subscriber as CopilotKitCoreReactSubscriber;\n switch (kind) {\n case \"toolCalls\":\n return reactSubscriber.onRenderToolCallsChanged?.({\n copilotkit: this,\n renderToolCalls: this.renderToolCalls,\n });\n case \"activity\":\n return reactSubscriber.onRenderActivityMessagesChanged?.({\n copilotkit: this,\n renderActivityMessages: this.renderActivityMessages,\n });\n case \"custom\":\n return reactSubscriber.onRenderCustomMessagesChanged?.({\n copilotkit: this,\n renderCustomMessages: this.renderCustomMessages,\n });\n }\n }, `Subscriber renderer change (${kind}) error:`);\n }\n\n get interruptElement(): React.ReactElement | null {\n return this.ɵinterruptPayload as React.ReactElement | null;\n }\n\n setInterruptElement(element: React.ReactElement | null): void {\n this.ɵsetInterruptPayload(element);\n }\n\n // Override to accept React-specific subscriber type\n subscribe(\n subscriber: CopilotKitCoreReactSubscriber,\n ): CopilotKitCoreSubscription {\n return super.subscribe(subscriber);\n }\n}\n","\"use client\";\n\nimport { createContext, useContext, useEffect, useReducer } from \"react\";\nimport { CopilotKitCoreReact } from \"./lib/react-core\";\nimport type { CopilotKitCoreReactConfig } from \"./lib/react-core\";\nimport type { LicenseContextValue } from \"@copilotkit/shared\";\n\n// Re-export so headless.ts (and consumers) reference the same type declaration.\nexport { CopilotKitCoreReact };\nexport type { CopilotKitCoreReactConfig };\n\nexport interface CopilotKitContextValue {\n copilotkit: CopilotKitCoreReact;\n /**\n * Whether CopilotKit should automatically mount Intelligence indicators.\n * Defaults to true when omitted for compatibility with custom providers.\n */\n showIntelligenceIndicator?: boolean;\n /**\n * Set of tool call IDs currently being executed.\n * This is tracked at the provider level to ensure tool execution events\n * are captured even before child components mount.\n */\n executingToolCallIds: ReadonlySet<string>;\n}\n\nexport const EMPTY_SET: ReadonlySet<string> = new Set();\n\nexport const CopilotKitContext = createContext<CopilotKitContextValue | null>(\n null,\n);\n\nexport const useCopilotKit = (): CopilotKitContextValue => {\n const context = useContext(CopilotKitContext);\n const [, forceUpdate] = useReducer((x: number) => x + 1, 0);\n\n if (!context) {\n throw new Error(\"useCopilotKit must be used within CopilotKitProvider\");\n }\n useEffect(() => {\n const subscription = context.copilotkit.subscribe({\n onRuntimeConnectionStatusChanged: () => {\n forceUpdate();\n },\n onHeadersChanged: () => {\n forceUpdate();\n },\n });\n return () => {\n subscription.unsubscribe();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return context;\n};\n\n// License context — shared between web and RN providers.\n// Default is permissive (all features allowed) — providers override via createLicenseContextValue.\n// Inlined here to avoid a runtime import from @copilotkit/shared, which pulls in\n// Node-only deps (jose) that break React Native's Metro bundler.\nexport const LicenseContext = createContext<LicenseContextValue>({\n status: null,\n license: null,\n checkFeature: () => true,\n getLimit: () => null,\n} as LicenseContextValue);\n\nexport const useLicenseContext = (): LicenseContextValue =>\n useContext(LicenseContext);\n\n// Provider-level default agent id, published by `<CopilotKitProvider agentId>`.\n//\n// This is a context of its own rather than a `CopilotChatConfigurationProvider`\n// rendered at the root, because that provider also owns a thread: it resolves a\n// threadId (minting a UUID when none is given) and the top-most one owns the\n// imperative active-thread override. Rendering it around the whole application\n// would hand every `<CopilotChat>` the same inherited threadId, so two sibling\n// chats would share one transcript. A bare string context carries the agent\n// default and nothing else.\n//\n// It is the LAST fallback before `DEFAULT_AGENT_ID`, so an explicit `agentId`\n// argument, a `<CopilotChat agentId>`, and a `<CopilotChatConfigurationProvider\n// agentId>` all still win.\nexport const CopilotKitAgentIdContext = createContext<string | undefined>(\n undefined,\n);\n\nexport const useDefaultAgentId = (): string | undefined =>\n useContext(CopilotKitAgentIdContext);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,SAAS,qBAAqB;AAC5B,QAAO,IAAI,SAAe,YAAY,WAAW,SAAS,EAAE,CAAC;;AAG/D,IAAa,sBAAb,cAAyC,eAAe;CACtD,AAAiB;CAMjB,YAAY,QAAmC;AAC7C,QAAM;GACJ,GAAG;GACH,0BAA0B;GAC3B,CAAC;AACF,OAAK,aAAa,IAAI,kBAAkB;GACtC,WAAW,OAAO;GAClB,UAAU,OAAO;GACjB,QAAQ,OAAO;GAChB,CAAC;AACF,OAAK,WAAW,WAAW,SAAS,KAAK,uBAAuB,KAAK,CAAC;AAGtE,OAAK,mCAAmC;AACtC,GAAK,KAAK,mBAAmB,eAAe;AAE1C,WADwB,WACD,4BAA4B;KACjD,YAAY;KACZ,kBAAkB,KAAK;KACxB,CAAC;MACD,8CAA8C;IACjD;;CAGJ,IAAI,uBAAuB;AACzB,SAAO,KAAK,WAAW;;CAGzB,IAAI,yBAAyB;AAC3B,SAAO,KAAK,WAAW;;;;;;CAOzB,IAAI,kBAAkB;AACpB,SAAO,KAAK,WAAW;;CAGzB,0BACE,WACM;AACN,OAAK,WAAW,YAAY,UAAU;;CAGxC,wBAAwB,WAA+C;AACrE,OAAK,WAAW,UAAU,UAAU;;CAGtC,mBAAmB,iBAAqD;AACtE,OAAK,WAAW,iBAAiB,gBAAgB;;CAGnD,sBAAsB,OAAyC;AAC7D,OAAK,WAAW,gBAAgB,MAAM;;CAGxC,yBAAyB,MAAc,SAAwB;AAC7D,OAAK,WAAW,mBAAmB,MAAM,QAAQ;;;;;;;;;CAUnD,0BAA0B,OAA0C;AAClE,SAAO,KAAK,WAAW,mBAAmB,MAAM;;CAGlD,AAAQ,uBAAuB,MAA2B;AACxD,EAAK,KAAK,mBAAmB,eAAe;GAC1C,MAAM,kBAAkB;AACxB,WAAQ,MAAR;IACE,KAAK,YACH,QAAO,gBAAgB,2BAA2B;KAChD,YAAY;KACZ,iBAAiB,KAAK;KACvB,CAAC;IACJ,KAAK,WACH,QAAO,gBAAgB,kCAAkC;KACvD,YAAY;KACZ,wBAAwB,KAAK;KAC9B,CAAC;IACJ,KAAK,SACH,QAAO,gBAAgB,gCAAgC;KACrD,YAAY;KACZ,sBAAsB,KAAK;KAC5B,CAAC;;KAEL,+BAA+B,KAAK,UAAU;;CAGnD,IAAI,mBAA8C;AAChD,SAAO,KAAK;;CAGd,oBAAoB,SAA0C;AAC5D,OAAK,qBAAqB,QAAQ;;CAIpC,UACE,YAC4B;AAC5B,SAAO,MAAM,UAAU,WAAW;;;;;;ACpJtC,MAAa,4BAAiC,IAAI,KAAK;AAEvD,MAAa,oBAAoB,cAC/B,KACD;AAED,MAAa,sBAA8C;CACzD,MAAM,UAAU,WAAW,kBAAkB;CAC7C,MAAM,GAAG,eAAe,YAAY,MAAc,IAAI,GAAG,EAAE;AAE3D,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,uDAAuD;AAEzE,iBAAgB;EACd,MAAM,eAAe,QAAQ,WAAW,UAAU;GAChD,wCAAwC;AACtC,iBAAa;;GAEf,wBAAwB;AACtB,iBAAa;;GAEhB,CAAC;AACF,eAAa;AACX,gBAAa,aAAa;;IAG3B,EAAE,CAAC;AAEN,QAAO;;AAOT,MAAa,iBAAiB,cAAmC;CAC/D,QAAQ;CACR,SAAS;CACT,oBAAoB;CACpB,gBAAgB;CACjB,CAAwB;AAEzB,MAAa,0BACX,WAAW,eAAe;AAe5B,MAAa,2BAA2B,cACtC,OACD;AAED,MAAa,0BACX,WAAW,yBAAyB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_chat = require('../chat-D3fxo6Ah.cjs');
|
|
3
|
+
const require_use_generative_ui_root = require('../use-generative-ui-root-C12htqbK.cjs');
|
|
4
|
+
const require_refs = require('../refs-BIUfn1wb.cjs');
|
|
5
|
+
let _copilotkit_shared_generative_ui = require("@copilotkit/shared/generative-ui");
|
|
6
|
+
let _copilotkit_core_generative_ui = require("@copilotkit/core/generative-ui");
|
|
7
|
+
|
|
8
|
+
//#region src/generative-ui/native.ts
|
|
9
|
+
/**
|
|
10
|
+
* Provider-side wiring: the surface manager, the agent subscriptions and the
|
|
11
|
+
* envelope of each run. Typed with the `CopilotKitCoreReact` of
|
|
12
|
+
* `/context`, which is the instance a React Native provider holds.
|
|
13
|
+
*
|
|
14
|
+
* In source it is the same class that `use-generative-ui-root.ts` imports
|
|
15
|
+
* from `../lib/react-core`, so no cast is needed. The annotation is for the
|
|
16
|
+
* emitted declarations: `../context` is external to the build, so they import
|
|
17
|
+
* the class from `@copilotkit/react-core/context`. Re-exported as is, the
|
|
18
|
+
* hook would be declared with a copy of the class from a bundled chunk, which
|
|
19
|
+
* the `/context` instance is not assignable to (the class has private
|
|
20
|
+
* members). `scripts/assert-dist-context-types.mjs` checks this.
|
|
21
|
+
*/
|
|
22
|
+
const useGenerativeUIRoot = require_use_generative_ui_root.useGenerativeUIRoot;
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
Object.defineProperty(exports, 'GenerativeUIError', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _copilotkit_shared_generative_ui.GenerativeUIError;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
exports.GenerativeUIHostContext = require_chat.GenerativeUIHostContext;
|
|
32
|
+
exports.GenerativeUIRuntimeContext = require_chat.GenerativeUIRuntimeContext;
|
|
33
|
+
Object.defineProperty(exports, 'GenerativeUISurfaceContentSchema', {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _copilotkit_core_generative_ui.GenerativeUISurfaceContentSchema;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
exports.GenerativeUIToolCallRenderer = require_chat.GenerativeUIToolCallRenderer;
|
|
40
|
+
exports.SurfaceView = require_chat.SurfaceView;
|
|
41
|
+
exports.child = require_refs.child;
|
|
42
|
+
exports.childList = require_refs.childList;
|
|
43
|
+
exports.createGenerativeUI = require_chat.createGenerativeUI;
|
|
44
|
+
Object.defineProperty(exports, 'exportA2UICatalog', {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _copilotkit_shared_generative_ui.exportA2UICatalog;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, 'parseGenerativeUISurfaceContent', {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return _copilotkit_core_generative_ui.parseGenerativeUISurfaceContent;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
exports.useGenerativeUIAccessibility = require_chat.useGenerativeUIAccessibility;
|
|
57
|
+
exports.useGenerativeUIActivitySurface = require_chat.useGenerativeUIActivitySurface;
|
|
58
|
+
exports.useGenerativeUIFunction = require_chat.useGenerativeUIFunction;
|
|
59
|
+
exports.useGenerativeUIHost = require_chat.useGenerativeUIHost;
|
|
60
|
+
exports.useGenerativeUIRejected = require_chat.useGenerativeUIRejected;
|
|
61
|
+
exports.useGenerativeUIRoot = useGenerativeUIRoot;
|
|
62
|
+
exports.useGenerativeUIRuntime = require_chat.useGenerativeUIRuntime;
|
|
63
|
+
exports.useGenerativeUIState = require_chat.useGenerativeUIState;
|
|
64
|
+
exports.useManagerVersion = require_chat.useManagerVersion;
|
|
65
|
+
exports.useRequiredGenerativeUIRuntime = require_chat.useRequiredGenerativeUIRuntime;
|
|
66
|
+
//# sourceMappingURL=native.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.cjs","names":["useGenerativeUIRootImpl"],"sources":["../../src/generative-ui/native.ts"],"sourcesContent":["// The `@copilotkit/react-core/generative-ui/native` entry: generative UI\n// without the DOM. It has the catalog API, the hooks and the surface\n// renderer, and leaves out what only a browser can run: the standard\n// catalog (DOM components, portals, KaTeX), the markdown surfaces\n// (streamdown) and the DOM `<GenerativeUISurface>` mount. A platform gives\n// its host elements through `GenerativeUIHostContext`. That context defaults\n// to the DOM host, which renders HTML elements, so a platform\n// without a DOM MUST provide its own host above every surface it renders.\n// Nothing checks that it did: without one, on React Native, the `<div>` of\n// the surface root fails to render, the surface fallback (a `<div>` too)\n// fails as well, and the surface renders nothing; only the reported errors\n// show it. `@copilotkit/react-native/generative-ui` is built on this entry,\n// and its `GenerativeUIProvider` provides the native host.\n//\n// It is built together with the root entry and `/generative-ui`, so the three\n// entries share one copy of each React context.\n\n// The catalog API, as in `/generative-ui`.\nexport { createGenerativeUI } from \"./catalog\";\nexport type {\n CreateGenerativeUIConfig,\n GenerativeUI,\n GenerativeUIComponentDefinition,\n GenerativeUIComponentName,\n GenerativeUIComponentProps,\n GenerativeUIEventDefinition,\n GenerativeUIFunctionArgs,\n GenerativeUIFunctionDefinition,\n GenerativeUIFunctionInput,\n GenerativeUIFunctionName,\n GenerativeUISlotKind,\n GenerativeUIStateOf,\n} from \"./catalog\";\nexport { child, childList } from \"./refs\";\nexport { exportA2UICatalog } from \"@copilotkit/shared/generative-ui\";\nexport type { ExportA2UICatalogOptions } from \"@copilotkit/shared/generative-ui\";\nexport { useGenerativeUIAccessibility } from \"./accessibility\";\nexport type {\n GenerativeUIAccessibility,\n GenerativeUIAriaAttributes,\n} from \"./accessibility\";\nexport { GenerativeUIError } from \"@copilotkit/shared/generative-ui\";\nexport type {\n GenerativeUIErrorCode,\n GenerativeUIErrorInfo,\n GenerativeUIEventHandler,\n GenerativeUIInvokeResult,\n} from \"@copilotkit/shared/generative-ui\";\nexport type {\n GenerativeUIConfig,\n GenerativeUIErrorBoundaryConfig,\n GenerativeUIMarkdownConfig,\n GenerativeUITheme,\n GenerativeUIToolConfig,\n} from \"./runtime-context\";\nexport { useGenerativeUIRuntime } from \"./runtime-context\";\nexport { useGenerativeUIFunction, useGenerativeUIState } from \"./hooks\";\n\n// The plumbing that a platform package uses to build its provider and\n// surfaces.\nimport { useGenerativeUIRoot as useGenerativeUIRootImpl } from \"./use-generative-ui-root\";\nimport type { CopilotKitCoreReact } from \"../context\";\nimport type {\n GenerativeUIConfig,\n GenerativeUIRuntime,\n} from \"./runtime-context\";\n/**\n * Provider-side wiring: the surface manager, the agent subscriptions and the\n * envelope of each run. Typed with the `CopilotKitCoreReact` of\n * `/context`, which is the instance a React Native provider holds.\n *\n * In source it is the same class that `use-generative-ui-root.ts` imports\n * from `../lib/react-core`, so no cast is needed. The annotation is for the\n * emitted declarations: `../context` is external to the build, so they import\n * the class from `@copilotkit/react-core/context`. Re-exported as is, the\n * hook would be declared with a copy of the class from a bundled chunk, which\n * the `/context` instance is not assignable to (the class has private\n * members). `scripts/assert-dist-context-types.mjs` checks this.\n */\nexport const useGenerativeUIRoot: (\n copilotkit: CopilotKitCoreReact,\n config: GenerativeUIConfig | undefined,\n) => GenerativeUIRuntime | null = useGenerativeUIRootImpl;\nexport {\n GenerativeUIRuntimeContext,\n useRequiredGenerativeUIRuntime,\n} from \"./runtime-context\";\nexport type { GenerativeUIRuntime } from \"./runtime-context\";\nexport { useManagerVersion } from \"./hooks\";\nexport { SurfaceView } from \"./SurfaceView\";\nexport { GenerativeUIToolCallRenderer } from \"./chat\";\nexport {\n GenerativeUISurfaceContentSchema,\n parseGenerativeUISurfaceContent,\n useGenerativeUIActivitySurface,\n useGenerativeUIRejected,\n} from \"./activity\";\nexport type { ParsedGenerativeUISurfaceContent } from \"./activity\";\nexport type { GenerativeUIChatSurfaceProps } from \"./chat\";\nexport { GenerativeUIHostContext, useGenerativeUIHost } from \"./host\";\nexport type {\n GenerativeUIAccessibilityWrapperProps,\n GenerativeUIHost,\n GenerativeUINodeFallbackProps,\n GenerativeUISurfaceRootProps,\n} from \"./host\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+EA,MAAa,sBAGqBA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { A as createGenerativeUI, C as GenerativeUIEventDefinition, D as GenerativeUIFunctionName, E as GenerativeUIFunctionInput, O as GenerativeUISlotKind, T as GenerativeUIFunctionDefinition, _ as CreateGenerativeUIConfig, a as GenerativeUIConfig, b as GenerativeUIComponentName, c as GenerativeUIRuntime, d as GenerativeUIToolConfig, f as useGenerativeUIRuntime, g as useGenerativeUIAccessibility, h as GenerativeUIAriaAttributes, k as GenerativeUIStateOf, l as GenerativeUIRuntimeContext, m as GenerativeUIAccessibility, n as GenerativeUIChatSurfaceProps, o as GenerativeUIErrorBoundaryConfig, p as useRequiredGenerativeUIRuntime, r as GenerativeUIToolCallRenderer, s as GenerativeUIMarkdownConfig, u as GenerativeUITheme, v as GenerativeUI, w as GenerativeUIFunctionArgs, x as GenerativeUIComponentProps, y as GenerativeUIComponentDefinition } from "../chat-DtHs4alO.cjs";
|
|
2
|
+
import { a as childList, i as child, n as useGenerativeUIState, r as useManagerVersion, t as useGenerativeUIFunction } from "../hooks-2Ur8NQhj.cjs";
|
|
3
|
+
import React, { ComponentType, ReactNode } from "react";
|
|
4
|
+
import { ExportA2UICatalogOptions, GenerativeUIError, GenerativeUIErrorCode, GenerativeUIErrorInfo, GenerativeUIEventHandler, GenerativeUIInvokeResult, exportA2UICatalog } from "@copilotkit/shared/generative-ui";
|
|
5
|
+
import { GenerativeUISurfaceContentSchema, ManagedSurface, ParsedGenerativeUISurfaceContent, parseGenerativeUISurfaceContent } from "@copilotkit/core/generative-ui";
|
|
6
|
+
import { GenerativeUIRejectedOperation, GenerativeUISurfaceContent } from "@copilotkit/shared";
|
|
7
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
8
|
+
import { CopilotKitCoreReact } from "@copilotkit/react-core/context";
|
|
9
|
+
|
|
10
|
+
//#region src/generative-ui/SurfaceView.d.ts
|
|
11
|
+
declare function SurfaceView({
|
|
12
|
+
surface
|
|
13
|
+
}: {
|
|
14
|
+
surface: ManagedSurface;
|
|
15
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/generative-ui/activity.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* The rejected operations of a surface (the runtime's first, then the
|
|
20
|
+
* client's) and the error that goes with them, for a wrapper: a generic
|
|
21
|
+
* message, with the same list as its `cause`. The `cause` is not enumerable,
|
|
22
|
+
* so `JSON.stringify`, a spread and error reporters leave the list out.
|
|
23
|
+
* `clientRejected` is appended to in place by the manager, so its length is
|
|
24
|
+
* part of the key.
|
|
25
|
+
*/
|
|
26
|
+
declare function useGenerativeUIRejected(serverRejected: readonly GenerativeUIRejectedOperation[] | undefined, clientRejected: readonly GenerativeUIRejectedOperation[] | undefined): {
|
|
27
|
+
rejected: GenerativeUIRejectedOperation[];
|
|
28
|
+
error: Error | undefined;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* What a renderer of one surface activity message shows: the surface (or the
|
|
32
|
+
* failed surface whose `createSurface` was rejected), and its rejected
|
|
33
|
+
* operations with their error (see {@link useGenerativeUIRejected}). It
|
|
34
|
+
* ingests `content` into the manager (idempotent: the root ingests the
|
|
35
|
+
* agent's messages too, and this covers an agent the root has not seen yet),
|
|
36
|
+
* and renders again on every change of the manager.
|
|
37
|
+
*
|
|
38
|
+
* `surface` is undefined when there is no runtime, thread or content, when
|
|
39
|
+
* the surface's target is not `target`, or when the surface does not exist
|
|
40
|
+
* (the agent deleted it). Both rejected lists cover only the latest
|
|
41
|
+
* `render_ui` call (see the manager's ingest).
|
|
42
|
+
*/
|
|
43
|
+
declare function useGenerativeUIActivitySurface({
|
|
44
|
+
runtime,
|
|
45
|
+
threadId,
|
|
46
|
+
agentId,
|
|
47
|
+
content,
|
|
48
|
+
target
|
|
49
|
+
}: {
|
|
50
|
+
runtime: GenerativeUIRuntime | null;
|
|
51
|
+
threadId: string | undefined;
|
|
52
|
+
agentId: string | undefined; /** The parsed content; undefined when it is malformed. */
|
|
53
|
+
content: GenerativeUISurfaceContent | undefined; /** The target whose surfaces this renderer shows. */
|
|
54
|
+
target: string;
|
|
55
|
+
}): {
|
|
56
|
+
surface: ManagedSurface | undefined;
|
|
57
|
+
rejected: GenerativeUIRejectedOperation[];
|
|
58
|
+
error: Error | undefined;
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/generative-ui/host.d.ts
|
|
62
|
+
/** Props of {@link GenerativeUIHost.SurfaceRoot}. */
|
|
63
|
+
interface GenerativeUISurfaceRootProps {
|
|
64
|
+
surfaceId: string;
|
|
65
|
+
/** The theme of the provider (`generativeUI.theme`). */
|
|
66
|
+
theme: GenerativeUITheme | undefined;
|
|
67
|
+
children: ReactNode;
|
|
68
|
+
}
|
|
69
|
+
/** Props of {@link GenerativeUIHost.AccessibilityWrapper}. */
|
|
70
|
+
interface GenerativeUIAccessibilityWrapperProps {
|
|
71
|
+
/**
|
|
72
|
+
* The hidden state and live region of the component's envelope. A label
|
|
73
|
+
* or a description needs an element with a role, so the component applies
|
|
74
|
+
* those itself.
|
|
75
|
+
*/
|
|
76
|
+
attributes: Pick<GenerativeUIAriaAttributes, "aria-hidden" | "aria-live">;
|
|
77
|
+
children: ReactNode;
|
|
78
|
+
}
|
|
79
|
+
/** Props of {@link GenerativeUIHost.NodeFallback}. */
|
|
80
|
+
interface GenerativeUINodeFallbackProps {
|
|
81
|
+
message: string;
|
|
82
|
+
/**
|
|
83
|
+
* The node that cannot be shown, or `"surface"` for a whole surface that
|
|
84
|
+
* failed. The marker is in the id space: a node the model named
|
|
85
|
+
* `"surface"` looks the same. The error report tells the two apart (a
|
|
86
|
+
* surface failure has no `componentId`).
|
|
87
|
+
*/
|
|
88
|
+
componentId: string;
|
|
89
|
+
/** Renders the node again. Given for render failures only. */
|
|
90
|
+
retry?: () => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The few host elements that a surface draws itself, around the catalog's
|
|
94
|
+
* components. The defaults are DOM elements, so a platform without a DOM
|
|
95
|
+
* must supply its own host through `GenerativeUIHostContext`, above every
|
|
96
|
+
* surface it renders. React Native does
|
|
97
|
+
* (`@copilotkit/react-native/generative-ui`), so that the same renderer runs
|
|
98
|
+
* on both.
|
|
99
|
+
*
|
|
100
|
+
* The host and its components must keep their identity across renders:
|
|
101
|
+
* define them at module scope, or memoize them. React takes a new component
|
|
102
|
+
* type for a different element: a `SurfaceRoot` written inline (for example
|
|
103
|
+
* `host={{ ...base, SurfaceRoot: (p) => ... }}`) remounts every surface on
|
|
104
|
+
* each render of its provider, and a new `AccessibilityWrapper` remounts
|
|
105
|
+
* every wrapped component, so what the user typed into them is lost.
|
|
106
|
+
*/
|
|
107
|
+
interface GenerativeUIHost {
|
|
108
|
+
/** Wraps a whole surface. Must not remount when the theme changes. */
|
|
109
|
+
SurfaceRoot: ComponentType<GenerativeUISurfaceRootProps>;
|
|
110
|
+
/**
|
|
111
|
+
* Wraps every component that has an accessibility envelope, unless its
|
|
112
|
+
* definition applies the envelope itself (`accessibility: "self"`). It
|
|
113
|
+
* wraps the component whatever the envelope's values, even with no
|
|
114
|
+
* `hidden` or live region set, so it must render its children in the same
|
|
115
|
+
* place in either case: a bound `hidden` that toggles must not remount
|
|
116
|
+
* the component and lose its local state.
|
|
117
|
+
*/
|
|
118
|
+
AccessibilityWrapper: ComponentType<GenerativeUIAccessibilityWrapperProps>;
|
|
119
|
+
/**
|
|
120
|
+
* Shown in place of a component that cannot be shown: it failed to render
|
|
121
|
+
* (with `retry`), its props are invalid, its type is unknown, or it is a
|
|
122
|
+
* cyclic reference. It also stands in for a whole surface that failed,
|
|
123
|
+
* with `componentId: "surface"`. When the app sets
|
|
124
|
+
* `errorBoundary.fallback`, that replaces it for render failures, and this
|
|
125
|
+
* stands in only if the app's fallback throws. If this throws, the node
|
|
126
|
+
* renders nothing and the error is reported, once for each message; it is
|
|
127
|
+
* tried again with a new message, a new revision of the node or Retry.
|
|
128
|
+
*/
|
|
129
|
+
NodeFallback: ComponentType<GenerativeUINodeFallbackProps>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The host elements of the surfaces below. Defaults to the DOM host, so a
|
|
133
|
+
* web app never sets it.
|
|
134
|
+
*/
|
|
135
|
+
declare const GenerativeUIHostContext: React.Context<GenerativeUIHost>;
|
|
136
|
+
declare function useGenerativeUIHost(): GenerativeUIHost;
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/generative-ui/native.d.ts
|
|
139
|
+
/**
|
|
140
|
+
* Provider-side wiring: the surface manager, the agent subscriptions and the
|
|
141
|
+
* envelope of each run. Typed with the `CopilotKitCoreReact` of
|
|
142
|
+
* `/context`, which is the instance a React Native provider holds.
|
|
143
|
+
*
|
|
144
|
+
* In source it is the same class that `use-generative-ui-root.ts` imports
|
|
145
|
+
* from `../lib/react-core`, so no cast is needed. The annotation is for the
|
|
146
|
+
* emitted declarations: `../context` is external to the build, so they import
|
|
147
|
+
* the class from `@copilotkit/react-core/context`. Re-exported as is, the
|
|
148
|
+
* hook would be declared with a copy of the class from a bundled chunk, which
|
|
149
|
+
* the `/context` instance is not assignable to (the class has private
|
|
150
|
+
* members). `scripts/assert-dist-context-types.mjs` checks this.
|
|
151
|
+
*/
|
|
152
|
+
declare const useGenerativeUIRoot: (copilotkit: CopilotKitCoreReact, config: GenerativeUIConfig | undefined) => GenerativeUIRuntime | null;
|
|
153
|
+
//#endregion
|
|
154
|
+
export { type CreateGenerativeUIConfig, type ExportA2UICatalogOptions, type GenerativeUI, type GenerativeUIAccessibility, type GenerativeUIAccessibilityWrapperProps, type GenerativeUIAriaAttributes, type GenerativeUIChatSurfaceProps, type GenerativeUIComponentDefinition, type GenerativeUIComponentName, type GenerativeUIComponentProps, type GenerativeUIConfig, GenerativeUIError, type GenerativeUIErrorBoundaryConfig, type GenerativeUIErrorCode, type GenerativeUIErrorInfo, type GenerativeUIEventDefinition, type GenerativeUIEventHandler, type GenerativeUIFunctionArgs, type GenerativeUIFunctionDefinition, type GenerativeUIFunctionInput, type GenerativeUIFunctionName, type GenerativeUIHost, GenerativeUIHostContext, type GenerativeUIInvokeResult, type GenerativeUIMarkdownConfig, type GenerativeUINodeFallbackProps, type GenerativeUIRuntime, GenerativeUIRuntimeContext, type GenerativeUISlotKind, type GenerativeUIStateOf, GenerativeUISurfaceContentSchema, type GenerativeUISurfaceRootProps, type GenerativeUITheme, GenerativeUIToolCallRenderer, type GenerativeUIToolConfig, type ParsedGenerativeUISurfaceContent, SurfaceView, child, childList, createGenerativeUI, exportA2UICatalog, parseGenerativeUISurfaceContent, useGenerativeUIAccessibility, useGenerativeUIActivitySurface, useGenerativeUIFunction, useGenerativeUIHost, useGenerativeUIRejected, useGenerativeUIRoot, useGenerativeUIRuntime, useGenerativeUIState, useManagerVersion, useRequiredGenerativeUIRuntime };
|
|
155
|
+
//# sourceMappingURL=native.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.cts","names":[],"sources":["../../src/generative-ui/SurfaceView.tsx","../../src/generative-ui/activity.ts","../../src/generative-ui/host.tsx","../../src/generative-ui/native.ts"],"mappings":";;;;;;;;;;iBAgGgB,WAAA,CAAA;EAAc;AAAA;EAAa,OAAA,EAAS,cAAA;AAAA,IAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;AAApE;;;iBCxEgB,uBAAA,CACd,cAAA,WAAyB,6BAAA,gBACzB,cAAA,WAAyB,6BAAA;EACtB,QAAA,EAAU,6BAAA;EAAiC,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;;AAHvD;iBAoCgB,8BAAA,CAAA;EACd,OAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA;AAAA;EAEA,OAAA,EAAS,mBAAA;EACT,QAAA;EACA,OAAA,sBA1Ca;EA4Cb,OAAA,EAAS,0BAAA,cA5CiD;EA8C1D,MAAA;AAAA;EAEA,OAAA,EAAS,cAAA;EACT,QAAA,EAAU,6BAAA;EACV,KAAA,EAAO,KAAA;AAAA;;;;UCtEQ,4BAAA;EACf,SAAA;;EAEA,KAAA,EAAO,iBAAA;EACP,QAAA,EAAU,SAAA;AAAA;;UAIK,qCAAA;EFiFa;;;;;EE3E5B,UAAA,EAAY,IAAA,CAAK,0BAAA;EACjB,QAAA,EAAU,SAAA;AAAA;;UAIK,6BAAA;EACf,OAAA;EFqEkE;;;;;ACxEpE;ECUE,WAAA;;EAEA,KAAA;AAAA;;;;;;;;;;;;;;;ADwBF;UCNiB,gBAAA;;EAEf,WAAA,EAAa,aAAA,CAAc,4BAAA;EDM3B;;;;;;;;ECGA,oBAAA,EAAsB,aAAA,CAAc,qCAAA;EDYxB;;;;;;;;;;ECDZ,YAAA,EAAc,aAAA,CAAc,6BAAA;AAAA;;;;;cAuFjB,uBAAA,EAAuB,KAAA,CAAA,OAAA,CAAA,gBAAA;AAAA,iBAGpB,mBAAA,CAAA,GAAuB,gBAAA;;;;;;;;;;;;;;;;cCvF1B,mBAAA,GACX,UAAA,EAAY,mBAAA,EACZ,MAAA,EAAQ,kBAAA,iBACL,mBAAA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { A as createGenerativeUI, C as GenerativeUIEventDefinition, D as GenerativeUIFunctionName, E as GenerativeUIFunctionInput, O as GenerativeUISlotKind, T as GenerativeUIFunctionDefinition, _ as CreateGenerativeUIConfig, a as GenerativeUIConfig, b as GenerativeUIComponentName, c as GenerativeUIRuntime, d as GenerativeUIToolConfig, f as useGenerativeUIRuntime, g as useGenerativeUIAccessibility, h as GenerativeUIAriaAttributes, k as GenerativeUIStateOf, l as GenerativeUIRuntimeContext, m as GenerativeUIAccessibility, n as GenerativeUIChatSurfaceProps, o as GenerativeUIErrorBoundaryConfig, p as useRequiredGenerativeUIRuntime, r as GenerativeUIToolCallRenderer, s as GenerativeUIMarkdownConfig, u as GenerativeUITheme, v as GenerativeUI, w as GenerativeUIFunctionArgs, x as GenerativeUIComponentProps, y as GenerativeUIComponentDefinition } from "../chat-DgP2N7bD.mjs";
|
|
2
|
+
import { a as childList, i as child, n as useGenerativeUIState, r as useManagerVersion, t as useGenerativeUIFunction } from "../hooks-BRYonCVu.mjs";
|
|
3
|
+
import React, { ComponentType, ReactNode } from "react";
|
|
4
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
import { GenerativeUIRejectedOperation, GenerativeUISurfaceContent } from "@copilotkit/shared";
|
|
6
|
+
import { GenerativeUISurfaceContentSchema, ManagedSurface, ParsedGenerativeUISurfaceContent, parseGenerativeUISurfaceContent } from "@copilotkit/core/generative-ui";
|
|
7
|
+
import { ExportA2UICatalogOptions, GenerativeUIError, GenerativeUIErrorCode, GenerativeUIErrorInfo, GenerativeUIEventHandler, GenerativeUIInvokeResult, exportA2UICatalog } from "@copilotkit/shared/generative-ui";
|
|
8
|
+
import { CopilotKitCoreReact } from "@copilotkit/react-core/context";
|
|
9
|
+
|
|
10
|
+
//#region src/generative-ui/SurfaceView.d.ts
|
|
11
|
+
declare function SurfaceView({
|
|
12
|
+
surface
|
|
13
|
+
}: {
|
|
14
|
+
surface: ManagedSurface;
|
|
15
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/generative-ui/activity.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* The rejected operations of a surface (the runtime's first, then the
|
|
20
|
+
* client's) and the error that goes with them, for a wrapper: a generic
|
|
21
|
+
* message, with the same list as its `cause`. The `cause` is not enumerable,
|
|
22
|
+
* so `JSON.stringify`, a spread and error reporters leave the list out.
|
|
23
|
+
* `clientRejected` is appended to in place by the manager, so its length is
|
|
24
|
+
* part of the key.
|
|
25
|
+
*/
|
|
26
|
+
declare function useGenerativeUIRejected(serverRejected: readonly GenerativeUIRejectedOperation[] | undefined, clientRejected: readonly GenerativeUIRejectedOperation[] | undefined): {
|
|
27
|
+
rejected: GenerativeUIRejectedOperation[];
|
|
28
|
+
error: Error | undefined;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* What a renderer of one surface activity message shows: the surface (or the
|
|
32
|
+
* failed surface whose `createSurface` was rejected), and its rejected
|
|
33
|
+
* operations with their error (see {@link useGenerativeUIRejected}). It
|
|
34
|
+
* ingests `content` into the manager (idempotent: the root ingests the
|
|
35
|
+
* agent's messages too, and this covers an agent the root has not seen yet),
|
|
36
|
+
* and renders again on every change of the manager.
|
|
37
|
+
*
|
|
38
|
+
* `surface` is undefined when there is no runtime, thread or content, when
|
|
39
|
+
* the surface's target is not `target`, or when the surface does not exist
|
|
40
|
+
* (the agent deleted it). Both rejected lists cover only the latest
|
|
41
|
+
* `render_ui` call (see the manager's ingest).
|
|
42
|
+
*/
|
|
43
|
+
declare function useGenerativeUIActivitySurface({
|
|
44
|
+
runtime,
|
|
45
|
+
threadId,
|
|
46
|
+
agentId,
|
|
47
|
+
content,
|
|
48
|
+
target
|
|
49
|
+
}: {
|
|
50
|
+
runtime: GenerativeUIRuntime | null;
|
|
51
|
+
threadId: string | undefined;
|
|
52
|
+
agentId: string | undefined; /** The parsed content; undefined when it is malformed. */
|
|
53
|
+
content: GenerativeUISurfaceContent | undefined; /** The target whose surfaces this renderer shows. */
|
|
54
|
+
target: string;
|
|
55
|
+
}): {
|
|
56
|
+
surface: ManagedSurface | undefined;
|
|
57
|
+
rejected: GenerativeUIRejectedOperation[];
|
|
58
|
+
error: Error | undefined;
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/generative-ui/host.d.ts
|
|
62
|
+
/** Props of {@link GenerativeUIHost.SurfaceRoot}. */
|
|
63
|
+
interface GenerativeUISurfaceRootProps {
|
|
64
|
+
surfaceId: string;
|
|
65
|
+
/** The theme of the provider (`generativeUI.theme`). */
|
|
66
|
+
theme: GenerativeUITheme | undefined;
|
|
67
|
+
children: ReactNode;
|
|
68
|
+
}
|
|
69
|
+
/** Props of {@link GenerativeUIHost.AccessibilityWrapper}. */
|
|
70
|
+
interface GenerativeUIAccessibilityWrapperProps {
|
|
71
|
+
/**
|
|
72
|
+
* The hidden state and live region of the component's envelope. A label
|
|
73
|
+
* or a description needs an element with a role, so the component applies
|
|
74
|
+
* those itself.
|
|
75
|
+
*/
|
|
76
|
+
attributes: Pick<GenerativeUIAriaAttributes, "aria-hidden" | "aria-live">;
|
|
77
|
+
children: ReactNode;
|
|
78
|
+
}
|
|
79
|
+
/** Props of {@link GenerativeUIHost.NodeFallback}. */
|
|
80
|
+
interface GenerativeUINodeFallbackProps {
|
|
81
|
+
message: string;
|
|
82
|
+
/**
|
|
83
|
+
* The node that cannot be shown, or `"surface"` for a whole surface that
|
|
84
|
+
* failed. The marker is in the id space: a node the model named
|
|
85
|
+
* `"surface"` looks the same. The error report tells the two apart (a
|
|
86
|
+
* surface failure has no `componentId`).
|
|
87
|
+
*/
|
|
88
|
+
componentId: string;
|
|
89
|
+
/** Renders the node again. Given for render failures only. */
|
|
90
|
+
retry?: () => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The few host elements that a surface draws itself, around the catalog's
|
|
94
|
+
* components. The defaults are DOM elements, so a platform without a DOM
|
|
95
|
+
* must supply its own host through `GenerativeUIHostContext`, above every
|
|
96
|
+
* surface it renders. React Native does
|
|
97
|
+
* (`@copilotkit/react-native/generative-ui`), so that the same renderer runs
|
|
98
|
+
* on both.
|
|
99
|
+
*
|
|
100
|
+
* The host and its components must keep their identity across renders:
|
|
101
|
+
* define them at module scope, or memoize them. React takes a new component
|
|
102
|
+
* type for a different element: a `SurfaceRoot` written inline (for example
|
|
103
|
+
* `host={{ ...base, SurfaceRoot: (p) => ... }}`) remounts every surface on
|
|
104
|
+
* each render of its provider, and a new `AccessibilityWrapper` remounts
|
|
105
|
+
* every wrapped component, so what the user typed into them is lost.
|
|
106
|
+
*/
|
|
107
|
+
interface GenerativeUIHost {
|
|
108
|
+
/** Wraps a whole surface. Must not remount when the theme changes. */
|
|
109
|
+
SurfaceRoot: ComponentType<GenerativeUISurfaceRootProps>;
|
|
110
|
+
/**
|
|
111
|
+
* Wraps every component that has an accessibility envelope, unless its
|
|
112
|
+
* definition applies the envelope itself (`accessibility: "self"`). It
|
|
113
|
+
* wraps the component whatever the envelope's values, even with no
|
|
114
|
+
* `hidden` or live region set, so it must render its children in the same
|
|
115
|
+
* place in either case: a bound `hidden` that toggles must not remount
|
|
116
|
+
* the component and lose its local state.
|
|
117
|
+
*/
|
|
118
|
+
AccessibilityWrapper: ComponentType<GenerativeUIAccessibilityWrapperProps>;
|
|
119
|
+
/**
|
|
120
|
+
* Shown in place of a component that cannot be shown: it failed to render
|
|
121
|
+
* (with `retry`), its props are invalid, its type is unknown, or it is a
|
|
122
|
+
* cyclic reference. It also stands in for a whole surface that failed,
|
|
123
|
+
* with `componentId: "surface"`. When the app sets
|
|
124
|
+
* `errorBoundary.fallback`, that replaces it for render failures, and this
|
|
125
|
+
* stands in only if the app's fallback throws. If this throws, the node
|
|
126
|
+
* renders nothing and the error is reported, once for each message; it is
|
|
127
|
+
* tried again with a new message, a new revision of the node or Retry.
|
|
128
|
+
*/
|
|
129
|
+
NodeFallback: ComponentType<GenerativeUINodeFallbackProps>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The host elements of the surfaces below. Defaults to the DOM host, so a
|
|
133
|
+
* web app never sets it.
|
|
134
|
+
*/
|
|
135
|
+
declare const GenerativeUIHostContext: React.Context<GenerativeUIHost>;
|
|
136
|
+
declare function useGenerativeUIHost(): GenerativeUIHost;
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/generative-ui/native.d.ts
|
|
139
|
+
/**
|
|
140
|
+
* Provider-side wiring: the surface manager, the agent subscriptions and the
|
|
141
|
+
* envelope of each run. Typed with the `CopilotKitCoreReact` of
|
|
142
|
+
* `/context`, which is the instance a React Native provider holds.
|
|
143
|
+
*
|
|
144
|
+
* In source it is the same class that `use-generative-ui-root.ts` imports
|
|
145
|
+
* from `../lib/react-core`, so no cast is needed. The annotation is for the
|
|
146
|
+
* emitted declarations: `../context` is external to the build, so they import
|
|
147
|
+
* the class from `@copilotkit/react-core/context`. Re-exported as is, the
|
|
148
|
+
* hook would be declared with a copy of the class from a bundled chunk, which
|
|
149
|
+
* the `/context` instance is not assignable to (the class has private
|
|
150
|
+
* members). `scripts/assert-dist-context-types.mjs` checks this.
|
|
151
|
+
*/
|
|
152
|
+
declare const useGenerativeUIRoot: (copilotkit: CopilotKitCoreReact, config: GenerativeUIConfig | undefined) => GenerativeUIRuntime | null;
|
|
153
|
+
//#endregion
|
|
154
|
+
export { type CreateGenerativeUIConfig, type ExportA2UICatalogOptions, type GenerativeUI, type GenerativeUIAccessibility, type GenerativeUIAccessibilityWrapperProps, type GenerativeUIAriaAttributes, type GenerativeUIChatSurfaceProps, type GenerativeUIComponentDefinition, type GenerativeUIComponentName, type GenerativeUIComponentProps, type GenerativeUIConfig, GenerativeUIError, type GenerativeUIErrorBoundaryConfig, type GenerativeUIErrorCode, type GenerativeUIErrorInfo, type GenerativeUIEventDefinition, type GenerativeUIEventHandler, type GenerativeUIFunctionArgs, type GenerativeUIFunctionDefinition, type GenerativeUIFunctionInput, type GenerativeUIFunctionName, type GenerativeUIHost, GenerativeUIHostContext, type GenerativeUIInvokeResult, type GenerativeUIMarkdownConfig, type GenerativeUINodeFallbackProps, type GenerativeUIRuntime, GenerativeUIRuntimeContext, type GenerativeUISlotKind, type GenerativeUIStateOf, GenerativeUISurfaceContentSchema, type GenerativeUISurfaceRootProps, type GenerativeUITheme, GenerativeUIToolCallRenderer, type GenerativeUIToolConfig, type ParsedGenerativeUISurfaceContent, SurfaceView, child, childList, createGenerativeUI, exportA2UICatalog, parseGenerativeUISurfaceContent, useGenerativeUIAccessibility, useGenerativeUIActivitySurface, useGenerativeUIFunction, useGenerativeUIHost, useGenerativeUIRejected, useGenerativeUIRoot, useGenerativeUIRuntime, useGenerativeUIState, useManagerVersion, useRequiredGenerativeUIRuntime };
|
|
155
|
+
//# sourceMappingURL=native.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.mts","names":[],"sources":["../../src/generative-ui/SurfaceView.tsx","../../src/generative-ui/activity.ts","../../src/generative-ui/host.tsx","../../src/generative-ui/native.ts"],"mappings":";;;;;;;;;;iBAgGgB,WAAA,CAAA;EAAc;AAAA;EAAa,OAAA,EAAS,cAAA;AAAA,IAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;AAApE;;;iBCxEgB,uBAAA,CACd,cAAA,WAAyB,6BAAA,gBACzB,cAAA,WAAyB,6BAAA;EACtB,QAAA,EAAU,6BAAA;EAAiC,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;;AAHvD;iBAoCgB,8BAAA,CAAA;EACd,OAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA;AAAA;EAEA,OAAA,EAAS,mBAAA;EACT,QAAA;EACA,OAAA,sBA1Ca;EA4Cb,OAAA,EAAS,0BAAA,cA5CiD;EA8C1D,MAAA;AAAA;EAEA,OAAA,EAAS,cAAA;EACT,QAAA,EAAU,6BAAA;EACV,KAAA,EAAO,KAAA;AAAA;;;;UCtEQ,4BAAA;EACf,SAAA;;EAEA,KAAA,EAAO,iBAAA;EACP,QAAA,EAAU,SAAA;AAAA;;UAIK,qCAAA;EFiFa;;;;;EE3E5B,UAAA,EAAY,IAAA,CAAK,0BAAA;EACjB,QAAA,EAAU,SAAA;AAAA;;UAIK,6BAAA;EACf,OAAA;EFqEkE;;;;;ACxEpE;ECUE,WAAA;;EAEA,KAAA;AAAA;;;;;;;;;;;;;;;ADwBF;UCNiB,gBAAA;;EAEf,WAAA,EAAa,aAAA,CAAc,4BAAA;EDM3B;;;;;;;;ECGA,oBAAA,EAAsB,aAAA,CAAc,qCAAA;EDYxB;;;;;;;;;;ECDZ,YAAA,EAAc,aAAA,CAAc,6BAAA;AAAA;;;;;cAuFjB,uBAAA,EAAuB,KAAA,CAAA,OAAA,CAAA,gBAAA;AAAA,iBAGpB,mBAAA,CAAA,GAAuB,gBAAA;;;;;;;;;;;;;;;;cCvF1B,mBAAA,GACX,UAAA,EAAY,mBAAA,EACZ,MAAA,EAAQ,kBAAA,iBACL,mBAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { C as GenerativeUIRuntimeContext, T as useRequiredGenerativeUIRuntime, _ as useGenerativeUIActivitySurface, b as useGenerativeUIState, d as GenerativeUIHostContext, f as useGenerativeUIHost, g as parseGenerativeUISurfaceContent, h as GenerativeUISurfaceContentSchema, l as useGenerativeUIAccessibility, m as createGenerativeUI, o as SurfaceView, r as GenerativeUIToolCallRenderer, v as useGenerativeUIRejected, w as useGenerativeUIRuntime, x as useManagerVersion, y as useGenerativeUIFunction } from "../chat-Bf0vVdo7.mjs";
|
|
2
|
+
import { t as useGenerativeUIRoot$1 } from "../use-generative-ui-root-CVgsDy1f.mjs";
|
|
3
|
+
import { n as childList, t as child } from "../refs-CMrRm3ta.mjs";
|
|
4
|
+
import { GenerativeUIError, exportA2UICatalog } from "@copilotkit/shared/generative-ui";
|
|
5
|
+
|
|
6
|
+
//#region src/generative-ui/native.ts
|
|
7
|
+
/**
|
|
8
|
+
* Provider-side wiring: the surface manager, the agent subscriptions and the
|
|
9
|
+
* envelope of each run. Typed with the `CopilotKitCoreReact` of
|
|
10
|
+
* `/context`, which is the instance a React Native provider holds.
|
|
11
|
+
*
|
|
12
|
+
* In source it is the same class that `use-generative-ui-root.ts` imports
|
|
13
|
+
* from `../lib/react-core`, so no cast is needed. The annotation is for the
|
|
14
|
+
* emitted declarations: `../context` is external to the build, so they import
|
|
15
|
+
* the class from `@copilotkit/react-core/context`. Re-exported as is, the
|
|
16
|
+
* hook would be declared with a copy of the class from a bundled chunk, which
|
|
17
|
+
* the `/context` instance is not assignable to (the class has private
|
|
18
|
+
* members). `scripts/assert-dist-context-types.mjs` checks this.
|
|
19
|
+
*/
|
|
20
|
+
const useGenerativeUIRoot = useGenerativeUIRoot$1;
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { GenerativeUIError, GenerativeUIHostContext, GenerativeUIRuntimeContext, GenerativeUISurfaceContentSchema, GenerativeUIToolCallRenderer, SurfaceView, child, childList, createGenerativeUI, exportA2UICatalog, parseGenerativeUISurfaceContent, useGenerativeUIAccessibility, useGenerativeUIActivitySurface, useGenerativeUIFunction, useGenerativeUIHost, useGenerativeUIRejected, useGenerativeUIRoot, useGenerativeUIRuntime, useGenerativeUIState, useManagerVersion, useRequiredGenerativeUIRuntime };
|
|
24
|
+
//# sourceMappingURL=native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.mjs","names":["useGenerativeUIRootImpl"],"sources":["../../src/generative-ui/native.ts"],"sourcesContent":["// The `@copilotkit/react-core/generative-ui/native` entry: generative UI\n// without the DOM. It has the catalog API, the hooks and the surface\n// renderer, and leaves out what only a browser can run: the standard\n// catalog (DOM components, portals, KaTeX), the markdown surfaces\n// (streamdown) and the DOM `<GenerativeUISurface>` mount. A platform gives\n// its host elements through `GenerativeUIHostContext`. That context defaults\n// to the DOM host, which renders HTML elements, so a platform\n// without a DOM MUST provide its own host above every surface it renders.\n// Nothing checks that it did: without one, on React Native, the `<div>` of\n// the surface root fails to render, the surface fallback (a `<div>` too)\n// fails as well, and the surface renders nothing; only the reported errors\n// show it. `@copilotkit/react-native/generative-ui` is built on this entry,\n// and its `GenerativeUIProvider` provides the native host.\n//\n// It is built together with the root entry and `/generative-ui`, so the three\n// entries share one copy of each React context.\n\n// The catalog API, as in `/generative-ui`.\nexport { createGenerativeUI } from \"./catalog\";\nexport type {\n CreateGenerativeUIConfig,\n GenerativeUI,\n GenerativeUIComponentDefinition,\n GenerativeUIComponentName,\n GenerativeUIComponentProps,\n GenerativeUIEventDefinition,\n GenerativeUIFunctionArgs,\n GenerativeUIFunctionDefinition,\n GenerativeUIFunctionInput,\n GenerativeUIFunctionName,\n GenerativeUISlotKind,\n GenerativeUIStateOf,\n} from \"./catalog\";\nexport { child, childList } from \"./refs\";\nexport { exportA2UICatalog } from \"@copilotkit/shared/generative-ui\";\nexport type { ExportA2UICatalogOptions } from \"@copilotkit/shared/generative-ui\";\nexport { useGenerativeUIAccessibility } from \"./accessibility\";\nexport type {\n GenerativeUIAccessibility,\n GenerativeUIAriaAttributes,\n} from \"./accessibility\";\nexport { GenerativeUIError } from \"@copilotkit/shared/generative-ui\";\nexport type {\n GenerativeUIErrorCode,\n GenerativeUIErrorInfo,\n GenerativeUIEventHandler,\n GenerativeUIInvokeResult,\n} from \"@copilotkit/shared/generative-ui\";\nexport type {\n GenerativeUIConfig,\n GenerativeUIErrorBoundaryConfig,\n GenerativeUIMarkdownConfig,\n GenerativeUITheme,\n GenerativeUIToolConfig,\n} from \"./runtime-context\";\nexport { useGenerativeUIRuntime } from \"./runtime-context\";\nexport { useGenerativeUIFunction, useGenerativeUIState } from \"./hooks\";\n\n// The plumbing that a platform package uses to build its provider and\n// surfaces.\nimport { useGenerativeUIRoot as useGenerativeUIRootImpl } from \"./use-generative-ui-root\";\nimport type { CopilotKitCoreReact } from \"../context\";\nimport type {\n GenerativeUIConfig,\n GenerativeUIRuntime,\n} from \"./runtime-context\";\n/**\n * Provider-side wiring: the surface manager, the agent subscriptions and the\n * envelope of each run. Typed with the `CopilotKitCoreReact` of\n * `/context`, which is the instance a React Native provider holds.\n *\n * In source it is the same class that `use-generative-ui-root.ts` imports\n * from `../lib/react-core`, so no cast is needed. The annotation is for the\n * emitted declarations: `../context` is external to the build, so they import\n * the class from `@copilotkit/react-core/context`. Re-exported as is, the\n * hook would be declared with a copy of the class from a bundled chunk, which\n * the `/context` instance is not assignable to (the class has private\n * members). `scripts/assert-dist-context-types.mjs` checks this.\n */\nexport const useGenerativeUIRoot: (\n copilotkit: CopilotKitCoreReact,\n config: GenerativeUIConfig | undefined,\n) => GenerativeUIRuntime | null = useGenerativeUIRootImpl;\nexport {\n GenerativeUIRuntimeContext,\n useRequiredGenerativeUIRuntime,\n} from \"./runtime-context\";\nexport type { GenerativeUIRuntime } from \"./runtime-context\";\nexport { useManagerVersion } from \"./hooks\";\nexport { SurfaceView } from \"./SurfaceView\";\nexport { GenerativeUIToolCallRenderer } from \"./chat\";\nexport {\n GenerativeUISurfaceContentSchema,\n parseGenerativeUISurfaceContent,\n useGenerativeUIActivitySurface,\n useGenerativeUIRejected,\n} from \"./activity\";\nexport type { ParsedGenerativeUISurfaceContent } from \"./activity\";\nexport type { GenerativeUIChatSurfaceProps } from \"./chat\";\nexport { GenerativeUIHostContext, useGenerativeUIHost } from \"./host\";\nexport type {\n GenerativeUIAccessibilityWrapperProps,\n GenerativeUIHost,\n GenerativeUINodeFallbackProps,\n GenerativeUISurfaceRootProps,\n} from \"./host\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+EA,MAAa,sBAGqBA"}
|