@copilotkit/react-core 2.0.0-rc.6 → 2.0.0-rc.60

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 (115) hide show
  1. package/README.md +1 -1
  2. package/dist/MarkdownRendererContext-QFCldfW_.d.cts +34 -0
  3. package/dist/MarkdownRendererContext-QFCldfW_.d.cts.map +1 -0
  4. package/dist/MarkdownRendererContext-aK63ZFd-.d.mts +34 -0
  5. package/dist/MarkdownRendererContext-aK63ZFd-.d.mts.map +1 -0
  6. package/dist/MarkdownSurfaces-Do948N1P.cjs +141 -0
  7. package/dist/MarkdownSurfaces-Do948N1P.cjs.map +1 -0
  8. package/dist/MarkdownSurfaces-rtE9wRUP.mjs +135 -0
  9. package/dist/MarkdownSurfaces-rtE9wRUP.mjs.map +1 -0
  10. package/dist/ProviderMarkdown-D0eI0aPo.cjs +268 -0
  11. package/dist/ProviderMarkdown-D0eI0aPo.cjs.map +1 -0
  12. package/dist/ProviderMarkdown-epL7F3Vt.mjs +214 -0
  13. package/dist/ProviderMarkdown-epL7F3Vt.mjs.map +1 -0
  14. package/dist/accessibility-BLK-gE0R.mjs +129 -0
  15. package/dist/accessibility-BLK-gE0R.mjs.map +1 -0
  16. package/dist/accessibility-GnodqxkH.cjs +228 -0
  17. package/dist/accessibility-GnodqxkH.cjs.map +1 -0
  18. package/dist/chat-B1zczXUD.mjs +1476 -0
  19. package/dist/chat-B1zczXUD.mjs.map +1 -0
  20. package/dist/chat-BZ_bvAkg.d.mts +38 -0
  21. package/dist/chat-BZ_bvAkg.d.mts.map +1 -0
  22. package/dist/chat-CkFZMo5E.cjs +1579 -0
  23. package/dist/chat-CkFZMo5E.cjs.map +1 -0
  24. package/dist/chat-CpZVyF_t.d.cts +38 -0
  25. package/dist/chat-CpZVyF_t.d.cts.map +1 -0
  26. package/dist/context.cjs +75 -63
  27. package/dist/context.cjs.map +1 -1
  28. package/dist/context.d.cts +62 -107
  29. package/dist/context.d.cts.map +1 -1
  30. package/dist/context.d.mts +62 -107
  31. package/dist/context.d.mts.map +1 -1
  32. package/dist/context.mjs +76 -64
  33. package/dist/context.mjs.map +1 -1
  34. package/dist/generative-ui/map.cjs +26 -0
  35. package/dist/generative-ui/map.cjs.map +1 -0
  36. package/dist/generative-ui/map.d.cts +23 -0
  37. package/dist/generative-ui/map.d.cts.map +1 -0
  38. package/dist/generative-ui/map.d.mts +23 -0
  39. package/dist/generative-ui/map.d.mts.map +1 -0
  40. package/dist/generative-ui/map.mjs +24 -0
  41. package/dist/generative-ui/map.mjs.map +1 -0
  42. package/dist/generative-ui/native.cjs +67 -0
  43. package/dist/generative-ui/native.cjs.map +1 -0
  44. package/dist/generative-ui/native.d.cts +156 -0
  45. package/dist/generative-ui/native.d.cts.map +1 -0
  46. package/dist/generative-ui/native.d.mts +156 -0
  47. package/dist/generative-ui/native.d.mts.map +1 -0
  48. package/dist/generative-ui/native.mjs +25 -0
  49. package/dist/generative-ui/native.mjs.map +1 -0
  50. package/dist/generative-ui.cjs +33 -8088
  51. package/dist/generative-ui.cjs.map +1 -1
  52. package/dist/generative-ui.d.cts +2472 -4789
  53. package/dist/generative-ui.d.cts.map +1 -1
  54. package/dist/generative-ui.d.mts +2472 -4789
  55. package/dist/generative-ui.d.mts.map +1 -1
  56. package/dist/generative-ui.mjs +9 -8074
  57. package/dist/generative-ui.mjs.map +1 -1
  58. package/dist/headless.cjs +289 -1054
  59. package/dist/headless.cjs.map +1 -1
  60. package/dist/headless.d.cts +149 -372
  61. package/dist/headless.d.cts.map +1 -1
  62. package/dist/headless.d.mts +123 -237
  63. package/dist/headless.d.mts.map +1 -1
  64. package/dist/headless.mjs +283 -1054
  65. package/dist/headless.mjs.map +1 -1
  66. package/dist/hooks-D2H3iL0N.d.mts +84 -0
  67. package/dist/hooks-D2H3iL0N.d.mts.map +1 -0
  68. package/dist/hooks-Dy8HeEdr.d.cts +84 -0
  69. package/dist/hooks-Dy8HeEdr.d.cts.map +1 -0
  70. package/dist/index.cjs +8702 -13238
  71. package/dist/index.cjs.map +1 -1
  72. package/dist/index.d.cts +312 -872
  73. package/dist/index.d.cts.map +1 -1
  74. package/dist/index.d.mts +311 -871
  75. package/dist/index.d.mts.map +1 -1
  76. package/dist/index.mjs +1790 -7803
  77. package/dist/index.mjs.map +1 -1
  78. package/dist/index.umd.js +14075 -13828
  79. package/dist/index.umd.js.map +1 -1
  80. package/dist/refs-B5Dn59Pn.cjs +43 -0
  81. package/dist/refs-B5Dn59Pn.cjs.map +1 -0
  82. package/dist/refs-BW15wX_V.mjs +31 -0
  83. package/dist/refs-BW15wX_V.mjs.map +1 -0
  84. package/dist/runtime-context-B7f4M85q.d.mts +215 -0
  85. package/dist/runtime-context-B7f4M85q.d.mts.map +1 -0
  86. package/dist/runtime-context-CIkZS0ap.d.cts +215 -0
  87. package/dist/runtime-context-CIkZS0ap.d.cts.map +1 -0
  88. package/dist/standard-CSBR4FhM.mjs +5800 -0
  89. package/dist/standard-CSBR4FhM.mjs.map +1 -0
  90. package/dist/standard-DBjcBGyd.cjs +5796 -0
  91. package/dist/standard-DBjcBGyd.cjs.map +1 -0
  92. package/dist/use-generative-ui-root-CIp0ytE6.cjs +390 -0
  93. package/dist/use-generative-ui-root-CIp0ytE6.cjs.map +1 -0
  94. package/dist/use-generative-ui-root-oBqPa6uy.mjs +386 -0
  95. package/dist/use-generative-ui-root-oBqPa6uy.mjs.map +1 -0
  96. package/dist/v2/context.d.cts +28 -0
  97. package/dist/v2/context.d.mts +28 -0
  98. package/dist/v2/generative-ui/native.d.cts +112 -0
  99. package/dist/v2/generative-ui/native.d.mts +112 -0
  100. package/dist/v2/generative-ui.d.cts +96 -0
  101. package/dist/v2/generative-ui.d.mts +96 -0
  102. package/dist/v2/headless.d.cts +96 -0
  103. package/dist/v2/headless.d.mts +96 -0
  104. package/dist/v2/index.d.cts +2220 -0
  105. package/dist/v2/index.d.mts +2220 -0
  106. package/dist/v2/styles.css +5 -0
  107. package/package.json +116 -24
  108. package/dist/MarkdownRendererContext-B4Us6mwL.d.cts +0 -954
  109. package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
  110. package/dist/MarkdownRendererContext-CRKFzsEB.d.mts +0 -954
  111. package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
  112. package/dist/MarkdownSurfaces-Bd--93O1.mjs +0 -3676
  113. package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
  114. package/dist/MarkdownSurfaces-S4wfUl3J.cjs +0 -3991
  115. package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
@@ -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\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,26 @@
1
+ "use client";
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ //#region src/generative-ui/map.ts
6
+ /**
7
+ * Experimental. Draws the standard `Map` component with MapLibre GL. The
8
+ * library loads in its own chunk the first time a map renders. Without it,
9
+ * Map shows its markers as a list. Add `maplibre-gl` to the app.
10
+ *
11
+ * Map adds the few maplibre-gl styles that markers and popups need, so the
12
+ * app does not import `maplibre-gl.css`.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { standardUI } from "@copilotkit/react-core/generative-ui";
17
+ * import { loadMapLibre } from "@copilotkit/react-core/generative-ui/map";
18
+ *
19
+ * <CopilotKitProvider generativeUI={{ ui: standardUI, map: loadMapLibre }} />
20
+ * ```
21
+ */
22
+ const loadMapLibre = () => import("maplibre-gl");
23
+
24
+ //#endregion
25
+ exports.loadMapLibre = loadMapLibre;
26
+ //# sourceMappingURL=map.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.cjs","names":[],"sources":["../../src/generative-ui/map.ts"],"sourcesContent":["\"use client\";\n\n// The `@copilotkit/react-core/generative-ui/map` entry. It is the only module\n// that imports `maplibre-gl`, so an app that does not import this entry\n// builds without the package.\nimport type { GenerativeUILibraryLoader } from \"./runtime-context\";\n\n/**\n * Experimental. Draws the standard `Map` component with MapLibre GL. The\n * library loads in its own chunk the first time a map renders. Without it,\n * Map shows its markers as a list. Add `maplibre-gl` to the app.\n *\n * Map adds the few maplibre-gl styles that markers and popups need, so the\n * app does not import `maplibre-gl.css`.\n *\n * @example\n * ```tsx\n * import { standardUI } from \"@copilotkit/react-core/generative-ui\";\n * import { loadMapLibre } from \"@copilotkit/react-core/generative-ui/map\";\n *\n * <CopilotKitProvider generativeUI={{ ui: standardUI, map: loadMapLibre }} />\n * ```\n */\nexport const loadMapLibre: GenerativeUILibraryLoader = () =>\n import(\"maplibre-gl\");\n\nexport type { GenerativeUILibraryLoader } from \"./runtime-context\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,qBACX,OAAO"}
@@ -0,0 +1,23 @@
1
+ import { r as GenerativeUILibraryLoader } from "../runtime-context-CIkZS0ap.cjs";
2
+
3
+ //#region src/generative-ui/map.d.ts
4
+ /**
5
+ * Experimental. Draws the standard `Map` component with MapLibre GL. The
6
+ * library loads in its own chunk the first time a map renders. Without it,
7
+ * Map shows its markers as a list. Add `maplibre-gl` to the app.
8
+ *
9
+ * Map adds the few maplibre-gl styles that markers and popups need, so the
10
+ * app does not import `maplibre-gl.css`.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { standardUI } from "@copilotkit/react-core/generative-ui";
15
+ * import { loadMapLibre } from "@copilotkit/react-core/generative-ui/map";
16
+ *
17
+ * <CopilotKitProvider generativeUI={{ ui: standardUI, map: loadMapLibre }} />
18
+ * ```
19
+ */
20
+ declare const loadMapLibre: GenerativeUILibraryLoader;
21
+ //#endregion
22
+ export { type GenerativeUILibraryLoader, loadMapLibre };
23
+ //# sourceMappingURL=map.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.cts","names":[],"sources":["../../src/generative-ui/map.ts"],"mappings":";;;;;AAuBA;;;;;;;;;;;;;;cAAa,YAAA,EAAc,yBAAA"}
@@ -0,0 +1,23 @@
1
+ import { r as GenerativeUILibraryLoader } from "../runtime-context-B7f4M85q.mjs";
2
+
3
+ //#region src/generative-ui/map.d.ts
4
+ /**
5
+ * Experimental. Draws the standard `Map` component with MapLibre GL. The
6
+ * library loads in its own chunk the first time a map renders. Without it,
7
+ * Map shows its markers as a list. Add `maplibre-gl` to the app.
8
+ *
9
+ * Map adds the few maplibre-gl styles that markers and popups need, so the
10
+ * app does not import `maplibre-gl.css`.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { standardUI } from "@copilotkit/react-core/generative-ui";
15
+ * import { loadMapLibre } from "@copilotkit/react-core/generative-ui/map";
16
+ *
17
+ * <CopilotKitProvider generativeUI={{ ui: standardUI, map: loadMapLibre }} />
18
+ * ```
19
+ */
20
+ declare const loadMapLibre: GenerativeUILibraryLoader;
21
+ //#endregion
22
+ export { type GenerativeUILibraryLoader, loadMapLibre };
23
+ //# sourceMappingURL=map.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.mts","names":[],"sources":["../../src/generative-ui/map.ts"],"mappings":";;;;;AAuBA;;;;;;;;;;;;;;cAAa,YAAA,EAAc,yBAAA"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+
3
+ //#region src/generative-ui/map.ts
4
+ /**
5
+ * Experimental. Draws the standard `Map` component with MapLibre GL. The
6
+ * library loads in its own chunk the first time a map renders. Without it,
7
+ * Map shows its markers as a list. Add `maplibre-gl` to the app.
8
+ *
9
+ * Map adds the few maplibre-gl styles that markers and popups need, so the
10
+ * app does not import `maplibre-gl.css`.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { standardUI } from "@copilotkit/react-core/generative-ui";
15
+ * import { loadMapLibre } from "@copilotkit/react-core/generative-ui/map";
16
+ *
17
+ * <CopilotKitProvider generativeUI={{ ui: standardUI, map: loadMapLibre }} />
18
+ * ```
19
+ */
20
+ const loadMapLibre = () => import("maplibre-gl");
21
+
22
+ //#endregion
23
+ export { loadMapLibre };
24
+ //# sourceMappingURL=map.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.mjs","names":[],"sources":["../../src/generative-ui/map.ts"],"sourcesContent":["\"use client\";\n\n// The `@copilotkit/react-core/generative-ui/map` entry. It is the only module\n// that imports `maplibre-gl`, so an app that does not import this entry\n// builds without the package.\nimport type { GenerativeUILibraryLoader } from \"./runtime-context\";\n\n/**\n * Experimental. Draws the standard `Map` component with MapLibre GL. The\n * library loads in its own chunk the first time a map renders. Without it,\n * Map shows its markers as a list. Add `maplibre-gl` to the app.\n *\n * Map adds the few maplibre-gl styles that markers and popups need, so the\n * app does not import `maplibre-gl.css`.\n *\n * @example\n * ```tsx\n * import { standardUI } from \"@copilotkit/react-core/generative-ui\";\n * import { loadMapLibre } from \"@copilotkit/react-core/generative-ui/map\";\n *\n * <CopilotKitProvider generativeUI={{ ui: standardUI, map: loadMapLibre }} />\n * ```\n */\nexport const loadMapLibre: GenerativeUILibraryLoader = () =>\n import(\"maplibre-gl\");\n\nexport type { GenerativeUILibraryLoader } from \"./runtime-context\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAa,qBACX,OAAO"}
@@ -0,0 +1,67 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_accessibility = require('../accessibility-GnodqxkH.cjs');
3
+ const require_chat = require('../chat-CkFZMo5E.cjs');
4
+ const require_use_generative_ui_root = require('../use-generative-ui-root-CIp0ytE6.cjs');
5
+ const require_refs = require('../refs-B5Dn59Pn.cjs');
6
+ let _copilotkit_shared_generative_ui = require("@copilotkit/shared/generative-ui");
7
+ let _copilotkit_core_generative_ui = require("@copilotkit/core/generative-ui");
8
+
9
+ //#region src/generative-ui/native.ts
10
+ /**
11
+ * Provider-side wiring: the surface manager, the agent subscriptions and the
12
+ * envelope of each run. Typed with the `CopilotKitCoreReact` of
13
+ * `/context`, which is the instance a React Native provider holds.
14
+ *
15
+ * In source it is the same class that `use-generative-ui-root.ts` imports
16
+ * from `../lib/react-core`, so no cast is needed. The annotation is for the
17
+ * emitted declarations: `../context` is external to the build, so they import
18
+ * the class from `@copilotkit/react-core/context`. Re-exported as is, the
19
+ * hook would be declared with a copy of the class from a bundled chunk, which
20
+ * the `/context` instance is not assignable to (the class has private
21
+ * members). `scripts/assert-dist-context-types.mjs` checks this.
22
+ */
23
+ const useGenerativeUIRoot = require_use_generative_ui_root.useGenerativeUIRoot;
24
+
25
+ //#endregion
26
+ Object.defineProperty(exports, 'GenerativeUIError', {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _copilotkit_shared_generative_ui.GenerativeUIError;
30
+ }
31
+ });
32
+ exports.GenerativeUIHostContext = require_chat.GenerativeUIHostContext;
33
+ exports.GenerativeUIRuntimeContext = require_accessibility.GenerativeUIRuntimeContext;
34
+ Object.defineProperty(exports, 'GenerativeUISurfaceContentSchema', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return _copilotkit_core_generative_ui.GenerativeUISurfaceContentSchema;
38
+ }
39
+ });
40
+ exports.GenerativeUIToolCallRenderer = require_chat.GenerativeUIToolCallRenderer;
41
+ exports.SurfaceView = require_chat.SurfaceView;
42
+ exports.child = require_refs.child;
43
+ exports.childList = require_refs.childList;
44
+ exports.createGenerativeUI = require_accessibility.createGenerativeUI;
45
+ Object.defineProperty(exports, 'exportA2UICatalog', {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _copilotkit_shared_generative_ui.exportA2UICatalog;
49
+ }
50
+ });
51
+ Object.defineProperty(exports, 'parseGenerativeUISurfaceContent', {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _copilotkit_core_generative_ui.parseGenerativeUISurfaceContent;
55
+ }
56
+ });
57
+ exports.useGenerativeUIAccessibility = require_accessibility.useGenerativeUIAccessibility;
58
+ exports.useGenerativeUIActivitySurface = require_chat.useGenerativeUIActivitySurface;
59
+ exports.useGenerativeUIFunction = require_chat.useGenerativeUIFunction;
60
+ exports.useGenerativeUIHost = require_chat.useGenerativeUIHost;
61
+ exports.useGenerativeUIRejected = require_chat.useGenerativeUIRejected;
62
+ exports.useGenerativeUIRoot = useGenerativeUIRoot;
63
+ exports.useGenerativeUIRuntime = require_accessibility.useGenerativeUIRuntime;
64
+ exports.useGenerativeUIState = require_chat.useGenerativeUIState;
65
+ exports.useManagerVersion = require_chat.useManagerVersion;
66
+ exports.useRequiredGenerativeUIRuntime = require_accessibility.useRequiredGenerativeUIRuntime;
67
+ //# 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,156 @@
1
+ import { C as GenerativeUIFunctionInput, D as createGenerativeUI, E as GenerativeUIStateOf, S as GenerativeUIFunctionDefinition, T as GenerativeUISlotKind, _ as GenerativeUIComponentName, a as GenerativeUIRuntime, b as GenerativeUIEventDefinition, c as GenerativeUIToolConfig, d as GenerativeUIAccessibility, f as GenerativeUIAriaAttributes, g as GenerativeUIComponentDefinition, h as GenerativeUI, i as GenerativeUIMarkdownConfig, l as useGenerativeUIRuntime, m as CreateGenerativeUIConfig, n as GenerativeUIErrorBoundaryConfig, o as GenerativeUIRuntimeContext, p as useGenerativeUIAccessibility, s as GenerativeUITheme, t as GenerativeUIConfig, u as useRequiredGenerativeUIRuntime, v as GenerativeUIComponentProps, w as GenerativeUIFunctionName, x as GenerativeUIFunctionArgs } from "../runtime-context-CIkZS0ap.cjs";
2
+ import { a as childList, i as child, n as useGenerativeUIState, r as useManagerVersion, t as useGenerativeUIFunction } from "../hooks-Dy8HeEdr.cjs";
3
+ import { n as GenerativeUIChatSurfaceProps, r as GenerativeUIToolCallRenderer } from "../chat-CpZVyF_t.cjs";
4
+ import React, { ComponentType, ReactNode } from "react";
5
+ import { ExportA2UICatalogOptions, GenerativeUIError, GenerativeUIErrorCode, GenerativeUIErrorInfo, GenerativeUIEventHandler, GenerativeUIInvokeResult, exportA2UICatalog } from "@copilotkit/shared/generative-ui";
6
+ import { GenerativeUISurfaceContentSchema, ManagedSurface, ParsedGenerativeUISurfaceContent, parseGenerativeUISurfaceContent } from "@copilotkit/core/generative-ui";
7
+ import { GenerativeUIRejectedOperation, GenerativeUISurfaceContent } from "@copilotkit/shared";
8
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
9
+ import { CopilotKitCoreReact } from "@copilotkit/react-core/context";
10
+
11
+ //#region src/generative-ui/SurfaceView.d.ts
12
+ declare function SurfaceView({
13
+ surface
14
+ }: {
15
+ surface: ManagedSurface;
16
+ }): react_jsx_runtime0.JSX.Element;
17
+ //#endregion
18
+ //#region src/generative-ui/activity.d.ts
19
+ /**
20
+ * The rejected operations of a surface (the runtime's first, then the
21
+ * client's) and the error that goes with them, for a wrapper: a generic
22
+ * message, with the same list as its `cause`. The `cause` is not enumerable,
23
+ * so `JSON.stringify`, a spread and error reporters leave the list out.
24
+ * `clientRejected` is appended to in place by the manager, so its length is
25
+ * part of the key.
26
+ */
27
+ declare function useGenerativeUIRejected(serverRejected: readonly GenerativeUIRejectedOperation[] | undefined, clientRejected: readonly GenerativeUIRejectedOperation[] | undefined): {
28
+ rejected: GenerativeUIRejectedOperation[];
29
+ error: Error | undefined;
30
+ };
31
+ /**
32
+ * What a renderer of one surface activity message shows: the surface (or the
33
+ * failed surface whose `createSurface` was rejected), and its rejected
34
+ * operations with their error (see {@link useGenerativeUIRejected}). It
35
+ * ingests `content` into the manager (idempotent: the root ingests the
36
+ * agent's messages too, and this covers an agent the root has not seen yet),
37
+ * and renders again on every change of the manager.
38
+ *
39
+ * `surface` is undefined when there is no runtime, thread or content, when
40
+ * the surface's target is not `target`, or when the surface does not exist
41
+ * (the agent deleted it). Both rejected lists cover only the latest
42
+ * `render_ui` call (see the manager's ingest).
43
+ */
44
+ declare function useGenerativeUIActivitySurface({
45
+ runtime,
46
+ threadId,
47
+ agentId,
48
+ content,
49
+ target
50
+ }: {
51
+ runtime: GenerativeUIRuntime | null;
52
+ threadId: string | undefined;
53
+ agentId: string | undefined; /** The parsed content; undefined when it is malformed. */
54
+ content: GenerativeUISurfaceContent | undefined; /** The target whose surfaces this renderer shows. */
55
+ target: string;
56
+ }): {
57
+ surface: ManagedSurface | undefined;
58
+ rejected: GenerativeUIRejectedOperation[];
59
+ error: Error | undefined;
60
+ };
61
+ //#endregion
62
+ //#region src/generative-ui/host.d.ts
63
+ /** Props of {@link GenerativeUIHost.SurfaceRoot}. */
64
+ interface GenerativeUISurfaceRootProps {
65
+ surfaceId: string;
66
+ /** The theme of the provider (`generativeUI.theme`). */
67
+ theme: GenerativeUITheme | undefined;
68
+ children: ReactNode;
69
+ }
70
+ /** Props of {@link GenerativeUIHost.AccessibilityWrapper}. */
71
+ interface GenerativeUIAccessibilityWrapperProps {
72
+ /**
73
+ * The hidden state and live region of the component's envelope. A label
74
+ * or a description needs an element with a role, so the component applies
75
+ * those itself.
76
+ */
77
+ attributes: Pick<GenerativeUIAriaAttributes, "aria-hidden" | "aria-live">;
78
+ children: ReactNode;
79
+ }
80
+ /** Props of {@link GenerativeUIHost.NodeFallback}. */
81
+ interface GenerativeUINodeFallbackProps {
82
+ message: string;
83
+ /**
84
+ * The node that cannot be shown, or `"surface"` for a whole surface that
85
+ * failed. The marker is in the id space: a node the model named
86
+ * `"surface"` looks the same. The error report tells the two apart (a
87
+ * surface failure has no `componentId`).
88
+ */
89
+ componentId: string;
90
+ /** Renders the node again. Given for render failures only. */
91
+ retry?: () => void;
92
+ }
93
+ /**
94
+ * The few host elements that a surface draws itself, around the catalog's
95
+ * components. The defaults are DOM elements, so a platform without a DOM
96
+ * must supply its own host through `GenerativeUIHostContext`, above every
97
+ * surface it renders. React Native does
98
+ * (`@copilotkit/react-native/generative-ui`), so that the same renderer runs
99
+ * on both.
100
+ *
101
+ * The host and its components must keep their identity across renders:
102
+ * define them at module scope, or memoize them. React takes a new component
103
+ * type for a different element: a `SurfaceRoot` written inline (for example
104
+ * `host={{ ...base, SurfaceRoot: (p) => ... }}`) remounts every surface on
105
+ * each render of its provider, and a new `AccessibilityWrapper` remounts
106
+ * every wrapped component, so what the user typed into them is lost.
107
+ */
108
+ interface GenerativeUIHost {
109
+ /** Wraps a whole surface. Must not remount when the theme changes. */
110
+ SurfaceRoot: ComponentType<GenerativeUISurfaceRootProps>;
111
+ /**
112
+ * Wraps every component that has an accessibility envelope, unless its
113
+ * definition applies the envelope itself (`accessibility: "self"`). It
114
+ * wraps the component whatever the envelope's values, even with no
115
+ * `hidden` or live region set, so it must render its children in the same
116
+ * place in either case: a bound `hidden` that toggles must not remount
117
+ * the component and lose its local state.
118
+ */
119
+ AccessibilityWrapper: ComponentType<GenerativeUIAccessibilityWrapperProps>;
120
+ /**
121
+ * Shown in place of a component that cannot be shown: it failed to render
122
+ * (with `retry`), its props are invalid, its type is unknown, or it is a
123
+ * cyclic reference. It also stands in for a whole surface that failed,
124
+ * with `componentId: "surface"`. When the app sets
125
+ * `errorBoundary.fallback`, that replaces it for render failures, and this
126
+ * stands in only if the app's fallback throws. If this throws, the node
127
+ * renders nothing and the error is reported, once for each message; it is
128
+ * tried again with a new message, a new revision of the node or Retry.
129
+ */
130
+ NodeFallback: ComponentType<GenerativeUINodeFallbackProps>;
131
+ }
132
+ /**
133
+ * The host elements of the surfaces below. Defaults to the DOM host, so a
134
+ * web app never sets it.
135
+ */
136
+ declare const GenerativeUIHostContext: React.Context<GenerativeUIHost>;
137
+ declare function useGenerativeUIHost(): GenerativeUIHost;
138
+ //#endregion
139
+ //#region src/generative-ui/native.d.ts
140
+ /**
141
+ * Provider-side wiring: the surface manager, the agent subscriptions and the
142
+ * envelope of each run. Typed with the `CopilotKitCoreReact` of
143
+ * `/context`, which is the instance a React Native provider holds.
144
+ *
145
+ * In source it is the same class that `use-generative-ui-root.ts` imports
146
+ * from `../lib/react-core`, so no cast is needed. The annotation is for the
147
+ * emitted declarations: `../context` is external to the build, so they import
148
+ * the class from `@copilotkit/react-core/context`. Re-exported as is, the
149
+ * hook would be declared with a copy of the class from a bundled chunk, which
150
+ * the `/context` instance is not assignable to (the class has private
151
+ * members). `scripts/assert-dist-context-types.mjs` checks this.
152
+ */
153
+ declare const useGenerativeUIRoot: (copilotkit: CopilotKitCoreReact, config: GenerativeUIConfig | undefined) => GenerativeUIRuntime | null;
154
+ //#endregion
155
+ 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 };
156
+ //# 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":";;;;;;;;;;;iBAiGgB,WAAA,CAAA;EAAc;AAAA;EAAa,OAAA,EAAS,cAAA;AAAA,IAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;;AAApE;;iBCzEgB,uBAAA,CACd,cAAA,WAAyB,6BAAA,gBACzB,cAAA,WAAyB,6BAAA;EACtB,QAAA,EAAU,6BAAA;EAAiC,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;;;iBAiCvC,8BAAA,CAAA;EACd,OAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA;AAAA;EAEA,OAAA,EAAS,mBAAA;EACT,QAAA;EACA,OAAA,sBA3CyB;EA6CzB,OAAA,EAAS,0BAAA,cA5C4C;EA8CrD,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;AFsFZ;AAAA,UElFiB,qCAAA;;;;;;EAMf,UAAA,EAAY,IAAA,CAAK,0BAAA;EACjB,QAAA,EAAU,SAAA;AAAA;;UAIK,6BAAA;EACf,OAAA;EFsEkE;;;;;;EE/DlE,WAAA;EDVqC;ECYrC,KAAA;AAAA;;;;;;;;;;;;;;;;UAkBe,gBAAA;EDM6B;ECJ5C,WAAA,EAAa,aAAA,CAAc,4BAAA;EDK3B;;;;;;;;ECIA,oBAAA,EAAsB,aAAA,CAAc,qCAAA;EDY7B;;;;;;;;;;ECDP,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,156 @@
1
+ import { C as GenerativeUIFunctionInput, D as createGenerativeUI, E as GenerativeUIStateOf, S as GenerativeUIFunctionDefinition, T as GenerativeUISlotKind, _ as GenerativeUIComponentName, a as GenerativeUIRuntime, b as GenerativeUIEventDefinition, c as GenerativeUIToolConfig, d as GenerativeUIAccessibility, f as GenerativeUIAriaAttributes, g as GenerativeUIComponentDefinition, h as GenerativeUI, i as GenerativeUIMarkdownConfig, l as useGenerativeUIRuntime, m as CreateGenerativeUIConfig, n as GenerativeUIErrorBoundaryConfig, o as GenerativeUIRuntimeContext, p as useGenerativeUIAccessibility, s as GenerativeUITheme, t as GenerativeUIConfig, u as useRequiredGenerativeUIRuntime, v as GenerativeUIComponentProps, w as GenerativeUIFunctionName, x as GenerativeUIFunctionArgs } from "../runtime-context-B7f4M85q.mjs";
2
+ import { a as childList, i as child, n as useGenerativeUIState, r as useManagerVersion, t as useGenerativeUIFunction } from "../hooks-D2H3iL0N.mjs";
3
+ import { n as GenerativeUIChatSurfaceProps, r as GenerativeUIToolCallRenderer } from "../chat-BZ_bvAkg.mjs";
4
+ import React, { ComponentType, ReactNode } from "react";
5
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
6
+ import { GenerativeUIRejectedOperation, GenerativeUISurfaceContent } from "@copilotkit/shared";
7
+ import { GenerativeUISurfaceContentSchema, ManagedSurface, ParsedGenerativeUISurfaceContent, parseGenerativeUISurfaceContent } from "@copilotkit/core/generative-ui";
8
+ import { ExportA2UICatalogOptions, GenerativeUIError, GenerativeUIErrorCode, GenerativeUIErrorInfo, GenerativeUIEventHandler, GenerativeUIInvokeResult, exportA2UICatalog } from "@copilotkit/shared/generative-ui";
9
+ import { CopilotKitCoreReact } from "@copilotkit/react-core/context";
10
+
11
+ //#region src/generative-ui/SurfaceView.d.ts
12
+ declare function SurfaceView({
13
+ surface
14
+ }: {
15
+ surface: ManagedSurface;
16
+ }): react_jsx_runtime0.JSX.Element;
17
+ //#endregion
18
+ //#region src/generative-ui/activity.d.ts
19
+ /**
20
+ * The rejected operations of a surface (the runtime's first, then the
21
+ * client's) and the error that goes with them, for a wrapper: a generic
22
+ * message, with the same list as its `cause`. The `cause` is not enumerable,
23
+ * so `JSON.stringify`, a spread and error reporters leave the list out.
24
+ * `clientRejected` is appended to in place by the manager, so its length is
25
+ * part of the key.
26
+ */
27
+ declare function useGenerativeUIRejected(serverRejected: readonly GenerativeUIRejectedOperation[] | undefined, clientRejected: readonly GenerativeUIRejectedOperation[] | undefined): {
28
+ rejected: GenerativeUIRejectedOperation[];
29
+ error: Error | undefined;
30
+ };
31
+ /**
32
+ * What a renderer of one surface activity message shows: the surface (or the
33
+ * failed surface whose `createSurface` was rejected), and its rejected
34
+ * operations with their error (see {@link useGenerativeUIRejected}). It
35
+ * ingests `content` into the manager (idempotent: the root ingests the
36
+ * agent's messages too, and this covers an agent the root has not seen yet),
37
+ * and renders again on every change of the manager.
38
+ *
39
+ * `surface` is undefined when there is no runtime, thread or content, when
40
+ * the surface's target is not `target`, or when the surface does not exist
41
+ * (the agent deleted it). Both rejected lists cover only the latest
42
+ * `render_ui` call (see the manager's ingest).
43
+ */
44
+ declare function useGenerativeUIActivitySurface({
45
+ runtime,
46
+ threadId,
47
+ agentId,
48
+ content,
49
+ target
50
+ }: {
51
+ runtime: GenerativeUIRuntime | null;
52
+ threadId: string | undefined;
53
+ agentId: string | undefined; /** The parsed content; undefined when it is malformed. */
54
+ content: GenerativeUISurfaceContent | undefined; /** The target whose surfaces this renderer shows. */
55
+ target: string;
56
+ }): {
57
+ surface: ManagedSurface | undefined;
58
+ rejected: GenerativeUIRejectedOperation[];
59
+ error: Error | undefined;
60
+ };
61
+ //#endregion
62
+ //#region src/generative-ui/host.d.ts
63
+ /** Props of {@link GenerativeUIHost.SurfaceRoot}. */
64
+ interface GenerativeUISurfaceRootProps {
65
+ surfaceId: string;
66
+ /** The theme of the provider (`generativeUI.theme`). */
67
+ theme: GenerativeUITheme | undefined;
68
+ children: ReactNode;
69
+ }
70
+ /** Props of {@link GenerativeUIHost.AccessibilityWrapper}. */
71
+ interface GenerativeUIAccessibilityWrapperProps {
72
+ /**
73
+ * The hidden state and live region of the component's envelope. A label
74
+ * or a description needs an element with a role, so the component applies
75
+ * those itself.
76
+ */
77
+ attributes: Pick<GenerativeUIAriaAttributes, "aria-hidden" | "aria-live">;
78
+ children: ReactNode;
79
+ }
80
+ /** Props of {@link GenerativeUIHost.NodeFallback}. */
81
+ interface GenerativeUINodeFallbackProps {
82
+ message: string;
83
+ /**
84
+ * The node that cannot be shown, or `"surface"` for a whole surface that
85
+ * failed. The marker is in the id space: a node the model named
86
+ * `"surface"` looks the same. The error report tells the two apart (a
87
+ * surface failure has no `componentId`).
88
+ */
89
+ componentId: string;
90
+ /** Renders the node again. Given for render failures only. */
91
+ retry?: () => void;
92
+ }
93
+ /**
94
+ * The few host elements that a surface draws itself, around the catalog's
95
+ * components. The defaults are DOM elements, so a platform without a DOM
96
+ * must supply its own host through `GenerativeUIHostContext`, above every
97
+ * surface it renders. React Native does
98
+ * (`@copilotkit/react-native/generative-ui`), so that the same renderer runs
99
+ * on both.
100
+ *
101
+ * The host and its components must keep their identity across renders:
102
+ * define them at module scope, or memoize them. React takes a new component
103
+ * type for a different element: a `SurfaceRoot` written inline (for example
104
+ * `host={{ ...base, SurfaceRoot: (p) => ... }}`) remounts every surface on
105
+ * each render of its provider, and a new `AccessibilityWrapper` remounts
106
+ * every wrapped component, so what the user typed into them is lost.
107
+ */
108
+ interface GenerativeUIHost {
109
+ /** Wraps a whole surface. Must not remount when the theme changes. */
110
+ SurfaceRoot: ComponentType<GenerativeUISurfaceRootProps>;
111
+ /**
112
+ * Wraps every component that has an accessibility envelope, unless its
113
+ * definition applies the envelope itself (`accessibility: "self"`). It
114
+ * wraps the component whatever the envelope's values, even with no
115
+ * `hidden` or live region set, so it must render its children in the same
116
+ * place in either case: a bound `hidden` that toggles must not remount
117
+ * the component and lose its local state.
118
+ */
119
+ AccessibilityWrapper: ComponentType<GenerativeUIAccessibilityWrapperProps>;
120
+ /**
121
+ * Shown in place of a component that cannot be shown: it failed to render
122
+ * (with `retry`), its props are invalid, its type is unknown, or it is a
123
+ * cyclic reference. It also stands in for a whole surface that failed,
124
+ * with `componentId: "surface"`. When the app sets
125
+ * `errorBoundary.fallback`, that replaces it for render failures, and this
126
+ * stands in only if the app's fallback throws. If this throws, the node
127
+ * renders nothing and the error is reported, once for each message; it is
128
+ * tried again with a new message, a new revision of the node or Retry.
129
+ */
130
+ NodeFallback: ComponentType<GenerativeUINodeFallbackProps>;
131
+ }
132
+ /**
133
+ * The host elements of the surfaces below. Defaults to the DOM host, so a
134
+ * web app never sets it.
135
+ */
136
+ declare const GenerativeUIHostContext: React.Context<GenerativeUIHost>;
137
+ declare function useGenerativeUIHost(): GenerativeUIHost;
138
+ //#endregion
139
+ //#region src/generative-ui/native.d.ts
140
+ /**
141
+ * Provider-side wiring: the surface manager, the agent subscriptions and the
142
+ * envelope of each run. Typed with the `CopilotKitCoreReact` of
143
+ * `/context`, which is the instance a React Native provider holds.
144
+ *
145
+ * In source it is the same class that `use-generative-ui-root.ts` imports
146
+ * from `../lib/react-core`, so no cast is needed. The annotation is for the
147
+ * emitted declarations: `../context` is external to the build, so they import
148
+ * the class from `@copilotkit/react-core/context`. Re-exported as is, the
149
+ * hook would be declared with a copy of the class from a bundled chunk, which
150
+ * the `/context` instance is not assignable to (the class has private
151
+ * members). `scripts/assert-dist-context-types.mjs` checks this.
152
+ */
153
+ declare const useGenerativeUIRoot: (copilotkit: CopilotKitCoreReact, config: GenerativeUIConfig | undefined) => GenerativeUIRuntime | null;
154
+ //#endregion
155
+ 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 };
156
+ //# 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":";;;;;;;;;;;iBAiGgB,WAAA,CAAA;EAAc;AAAA;EAAa,OAAA,EAAS,cAAA;AAAA,IAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;;AAApE;;iBCzEgB,uBAAA,CACd,cAAA,WAAyB,6BAAA,gBACzB,cAAA,WAAyB,6BAAA;EACtB,QAAA,EAAU,6BAAA;EAAiC,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;;;iBAiCvC,8BAAA,CAAA;EACd,OAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA;AAAA;EAEA,OAAA,EAAS,mBAAA;EACT,QAAA;EACA,OAAA,sBA3CyB;EA6CzB,OAAA,EAAS,0BAAA,cA5C4C;EA8CrD,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;AFsFZ;AAAA,UElFiB,qCAAA;;;;;;EAMf,UAAA,EAAY,IAAA,CAAK,0BAAA;EACjB,QAAA,EAAU,SAAA;AAAA;;UAIK,6BAAA;EACf,OAAA;EFsEkE;;;;;;EE/DlE,WAAA;EDVqC;ECYrC,KAAA;AAAA;;;;;;;;;;;;;;;;UAkBe,gBAAA;EDM6B;ECJ5C,WAAA,EAAa,aAAA,CAAc,4BAAA;EDK3B;;;;;;;;ECIA,oBAAA,EAAsB,aAAA,CAAc,qCAAA;EDY7B;;;;;;;;;;ECDP,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,25 @@
1
+ import { a as useGenerativeUIAccessibility, c as createGenerativeUI, d as GenerativeUIRuntimeContext, m as useRequiredGenerativeUIRuntime, p as useGenerativeUIRuntime } from "../accessibility-BLK-gE0R.mjs";
2
+ import { c as useGenerativeUIHost, d as parseGenerativeUISurfaceContent, f as useGenerativeUIActivitySurface, g as useManagerVersion, h as useGenerativeUIState, m as useGenerativeUIFunction, o as SurfaceView, p as useGenerativeUIRejected, r as GenerativeUIToolCallRenderer, s as GenerativeUIHostContext, u as GenerativeUISurfaceContentSchema } from "../chat-B1zczXUD.mjs";
3
+ import { t as useGenerativeUIRoot$1 } from "../use-generative-ui-root-oBqPa6uy.mjs";
4
+ import { n as childList, t as child } from "../refs-BW15wX_V.mjs";
5
+ import { GenerativeUIError, exportA2UICatalog } from "@copilotkit/shared/generative-ui";
6
+
7
+ //#region src/generative-ui/native.ts
8
+ /**
9
+ * Provider-side wiring: the surface manager, the agent subscriptions and the
10
+ * envelope of each run. Typed with the `CopilotKitCoreReact` of
11
+ * `/context`, which is the instance a React Native provider holds.
12
+ *
13
+ * In source it is the same class that `use-generative-ui-root.ts` imports
14
+ * from `../lib/react-core`, so no cast is needed. The annotation is for the
15
+ * emitted declarations: `../context` is external to the build, so they import
16
+ * the class from `@copilotkit/react-core/context`. Re-exported as is, the
17
+ * hook would be declared with a copy of the class from a bundled chunk, which
18
+ * the `/context` instance is not assignable to (the class has private
19
+ * members). `scripts/assert-dist-context-types.mjs` checks this.
20
+ */
21
+ const useGenerativeUIRoot = useGenerativeUIRoot$1;
22
+
23
+ //#endregion
24
+ export { GenerativeUIError, GenerativeUIHostContext, GenerativeUIRuntimeContext, GenerativeUISurfaceContentSchema, GenerativeUIToolCallRenderer, SurfaceView, child, childList, createGenerativeUI, exportA2UICatalog, parseGenerativeUISurfaceContent, useGenerativeUIAccessibility, useGenerativeUIActivitySurface, useGenerativeUIFunction, useGenerativeUIHost, useGenerativeUIRejected, useGenerativeUIRoot, useGenerativeUIRuntime, useGenerativeUIState, useManagerVersion, useRequiredGenerativeUIRuntime };
25
+ //# 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"}