@copilotkit/shared 2.0.0-rc.3 → 2.0.0-rc.30

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 (287) hide show
  1. package/README.md +3 -14
  2. package/dist/a2ui-envelope.cjs +2 -2
  3. package/dist/a2ui-envelope.cjs.map +1 -1
  4. package/dist/a2ui-envelope.d.cts +1 -1
  5. package/dist/a2ui-envelope.d.cts.map +1 -1
  6. package/dist/a2ui-envelope.d.mts +1 -1
  7. package/dist/a2ui-envelope.d.mts.map +1 -1
  8. package/dist/a2ui-envelope.mjs +2 -2
  9. package/dist/a2ui-envelope.mjs.map +1 -1
  10. package/dist/a2ui-prompts.cjs +21 -62
  11. package/dist/a2ui-prompts.cjs.map +1 -1
  12. package/dist/a2ui-prompts.d.cts +8 -1
  13. package/dist/a2ui-prompts.d.cts.map +1 -1
  14. package/dist/a2ui-prompts.d.mts +8 -1
  15. package/dist/a2ui-prompts.d.mts.map +1 -1
  16. package/dist/a2ui-prompts.mjs +22 -62
  17. package/dist/a2ui-prompts.mjs.map +1 -1
  18. package/dist/attachments/types.d.cts +1 -3
  19. package/dist/attachments/types.d.cts.map +1 -1
  20. package/dist/attachments/types.d.mts +1 -3
  21. package/dist/attachments/types.d.mts.map +1 -1
  22. package/dist/attachments/utils.cjs +16 -5
  23. package/dist/attachments/utils.cjs.map +1 -1
  24. package/dist/attachments/utils.d.cts +3 -1
  25. package/dist/attachments/utils.d.cts.map +1 -1
  26. package/dist/attachments/utils.d.mts +3 -1
  27. package/dist/attachments/utils.d.mts.map +1 -1
  28. package/dist/attachments/utils.mjs +16 -5
  29. package/dist/attachments/utils.mjs.map +1 -1
  30. package/dist/finalize-events.cjs +16 -0
  31. package/dist/finalize-events.cjs.map +1 -1
  32. package/dist/finalize-events.d.cts.map +1 -1
  33. package/dist/finalize-events.d.mts.map +1 -1
  34. package/dist/finalize-events.mjs +16 -0
  35. package/dist/finalize-events.mjs.map +1 -1
  36. package/dist/generative-ui/basic-functions.cjs +1 -1
  37. package/dist/generative-ui/basic-functions.cjs.map +1 -1
  38. package/dist/generative-ui/basic-functions.mjs +1 -1
  39. package/dist/generative-ui/basic-functions.mjs.map +1 -1
  40. package/dist/generative-ui/child-refs.cjs +3 -3
  41. package/dist/generative-ui/child-refs.cjs.map +1 -1
  42. package/dist/generative-ui/child-refs.d.cts.map +1 -1
  43. package/dist/generative-ui/child-refs.d.mts.map +1 -1
  44. package/dist/generative-ui/child-refs.mjs +3 -3
  45. package/dist/generative-ui/child-refs.mjs.map +1 -1
  46. package/dist/generative-ui/compact-schema.cjs +187 -0
  47. package/dist/generative-ui/compact-schema.cjs.map +1 -0
  48. package/dist/generative-ui/compact-schema.d.cts +55 -0
  49. package/dist/generative-ui/compact-schema.d.cts.map +1 -0
  50. package/dist/generative-ui/compact-schema.d.mts +55 -0
  51. package/dist/generative-ui/compact-schema.d.mts.map +1 -0
  52. package/dist/generative-ui/compact-schema.mjs +185 -0
  53. package/dist/generative-ui/compact-schema.mjs.map +1 -0
  54. package/dist/generative-ui/prompt-spec.cjs +225 -0
  55. package/dist/generative-ui/prompt-spec.cjs.map +1 -0
  56. package/dist/generative-ui/prompt-spec.d.cts +94 -0
  57. package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
  58. package/dist/generative-ui/prompt-spec.d.mts +94 -0
  59. package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
  60. package/dist/generative-ui/prompt-spec.mjs +220 -0
  61. package/dist/generative-ui/prompt-spec.mjs.map +1 -0
  62. package/dist/generative-ui/prompt.cjs +10 -36
  63. package/dist/generative-ui/prompt.cjs.map +1 -1
  64. package/dist/generative-ui/prompt.d.cts +2 -1
  65. package/dist/generative-ui/prompt.d.cts.map +1 -1
  66. package/dist/generative-ui/prompt.d.mts +2 -1
  67. package/dist/generative-ui/prompt.d.mts.map +1 -1
  68. package/dist/generative-ui/prompt.mjs +12 -38
  69. package/dist/generative-ui/prompt.mjs.map +1 -1
  70. package/dist/generative-ui/render-ui-args.cjs +1 -0
  71. package/dist/generative-ui/render-ui-args.cjs.map +1 -1
  72. package/dist/generative-ui/render-ui-args.d.cts.map +1 -1
  73. package/dist/generative-ui/render-ui-args.d.mts.map +1 -1
  74. package/dist/generative-ui/render-ui-args.mjs +1 -0
  75. package/dist/generative-ui/render-ui-args.mjs.map +1 -1
  76. package/dist/generative-ui/schema-render.cjs +242 -0
  77. package/dist/generative-ui/schema-render.cjs.map +1 -0
  78. package/dist/generative-ui/schema-render.d.cts +44 -0
  79. package/dist/generative-ui/schema-render.d.cts.map +1 -0
  80. package/dist/generative-ui/schema-render.d.mts +44 -0
  81. package/dist/generative-ui/schema-render.d.mts.map +1 -0
  82. package/dist/generative-ui/schema-render.mjs +239 -0
  83. package/dist/generative-ui/schema-render.mjs.map +1 -0
  84. package/dist/generative-ui/types.cjs +2 -2
  85. package/dist/generative-ui/types.cjs.map +1 -1
  86. package/dist/generative-ui/types.d.cts +7 -7
  87. package/dist/generative-ui/types.d.cts.map +1 -1
  88. package/dist/generative-ui/types.d.mts +7 -7
  89. package/dist/generative-ui/types.d.mts.map +1 -1
  90. package/dist/generative-ui/types.mjs +2 -2
  91. package/dist/generative-ui/types.mjs.map +1 -1
  92. package/dist/generative-ui/validate-operation.cjs +2 -2
  93. package/dist/generative-ui/validate-operation.cjs.map +1 -1
  94. package/dist/generative-ui/validate-operation.mjs +2 -2
  95. package/dist/generative-ui/validate-operation.mjs.map +1 -1
  96. package/dist/index.cjs +16 -15
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.d.cts +10 -10
  99. package/dist/index.d.cts.map +1 -1
  100. package/dist/index.d.mts +10 -10
  101. package/dist/index.d.mts.map +1 -1
  102. package/dist/index.mjs +9 -8
  103. package/dist/index.mjs.map +1 -1
  104. package/dist/index.umd.js +866 -455
  105. package/dist/index.umd.js.map +1 -1
  106. package/dist/package.cjs +1 -1
  107. package/dist/package.mjs +1 -1
  108. package/dist/standard-schema.cjs +20 -7
  109. package/dist/standard-schema.cjs.map +1 -1
  110. package/dist/standard-schema.d.cts +15 -16
  111. package/dist/standard-schema.d.cts.map +1 -1
  112. package/dist/standard-schema.d.mts +15 -16
  113. package/dist/standard-schema.d.mts.map +1 -1
  114. package/dist/standard-schema.mjs +20 -8
  115. package/dist/standard-schema.mjs.map +1 -1
  116. package/dist/telemetry/lambda-client.cjs +1 -1
  117. package/dist/telemetry/lambda-client.cjs.map +1 -1
  118. package/dist/telemetry/lambda-client.d.cts.map +1 -1
  119. package/dist/telemetry/lambda-client.d.mts.map +1 -1
  120. package/dist/telemetry/lambda-client.mjs +1 -1
  121. package/dist/telemetry/lambda-client.mjs.map +1 -1
  122. package/dist/telemetry/telemetry-disabled.cjs +0 -5
  123. package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
  124. package/dist/telemetry/telemetry-disabled.d.cts +0 -5
  125. package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
  126. package/dist/telemetry/telemetry-disabled.d.mts +0 -5
  127. package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
  128. package/dist/telemetry/telemetry-disabled.mjs +0 -5
  129. package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
  130. package/dist/types/message.d.cts +1 -18
  131. package/dist/types/message.d.cts.map +1 -1
  132. package/dist/types/message.d.mts +1 -18
  133. package/dist/types/message.d.mts.map +1 -1
  134. package/dist/utils/errors.cjs +5 -42
  135. package/dist/utils/errors.cjs.map +1 -1
  136. package/dist/utils/errors.d.cts +16 -34
  137. package/dist/utils/errors.d.cts.map +1 -1
  138. package/dist/utils/errors.d.mts +16 -34
  139. package/dist/utils/errors.d.mts.map +1 -1
  140. package/dist/utils/errors.mjs +6 -41
  141. package/dist/utils/errors.mjs.map +1 -1
  142. package/dist/utils/index.cjs +0 -2
  143. package/dist/utils/index.cjs.map +1 -1
  144. package/dist/utils/index.d.cts +4 -6
  145. package/dist/utils/index.d.cts.map +1 -1
  146. package/dist/utils/index.d.mts +4 -6
  147. package/dist/utils/index.d.mts.map +1 -1
  148. package/dist/utils/index.mjs +4 -6
  149. package/dist/utils/index.mjs.map +1 -1
  150. package/dist/utils/inspector-visibility.cjs +25 -3
  151. package/dist/utils/inspector-visibility.cjs.map +1 -1
  152. package/dist/utils/inspector-visibility.d.cts +26 -3
  153. package/dist/utils/inspector-visibility.d.cts.map +1 -1
  154. package/dist/utils/inspector-visibility.d.mts +26 -3
  155. package/dist/utils/inspector-visibility.d.mts.map +1 -1
  156. package/dist/utils/inspector-visibility.mjs +25 -4
  157. package/dist/utils/inspector-visibility.mjs.map +1 -1
  158. package/dist/utils/json-schema.cjs +4 -79
  159. package/dist/utils/json-schema.cjs.map +1 -1
  160. package/dist/utils/json-schema.d.cts +1 -4
  161. package/dist/utils/json-schema.d.cts.map +1 -1
  162. package/dist/utils/json-schema.d.mts +1 -4
  163. package/dist/utils/json-schema.d.mts.map +1 -1
  164. package/dist/utils/json-schema.mjs +5 -78
  165. package/dist/utils/json-schema.mjs.map +1 -1
  166. package/dist/utils/random-id.cjs +13 -26
  167. package/dist/utils/random-id.cjs.map +1 -1
  168. package/dist/utils/random-id.d.cts +6 -3
  169. package/dist/utils/random-id.d.cts.map +1 -1
  170. package/dist/utils/random-id.d.mts +6 -3
  171. package/dist/utils/random-id.d.mts.map +1 -1
  172. package/dist/utils/random-id.mjs +14 -25
  173. package/dist/utils/random-id.mjs.map +1 -1
  174. package/package.json +10 -34
  175. package/scripts/verify-cjs-exports.cjs +1 -1
  176. package/src/__tests__/a2ui-envelope.test.ts +18 -13
  177. package/src/__tests__/a2ui-prompts.test.ts +47 -14
  178. package/src/__tests__/fixtures/prompt-goldens.json +354 -0
  179. package/src/__tests__/prompt-spec.test.ts +191 -0
  180. package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
  181. package/src/__tests__/schema-render.test.ts +245 -0
  182. package/src/__tests__/standard-schema.test.ts +61 -101
  183. package/src/a2ui-envelope.ts +7 -6
  184. package/src/a2ui-prompts.ts +47 -96
  185. package/src/attachments/__tests__/utils.test.ts +22 -0
  186. package/src/attachments/types.ts +1 -3
  187. package/src/attachments/utils.ts +23 -5
  188. package/src/finalize-events.ts +16 -0
  189. package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
  190. package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
  191. package/src/generative-ui/basic-functions.ts +1 -1
  192. package/src/generative-ui/child-refs.ts +5 -4
  193. package/src/generative-ui/compact-schema.ts +277 -0
  194. package/src/generative-ui/index.ts +3 -0
  195. package/src/generative-ui/prompt-spec.ts +335 -0
  196. package/src/generative-ui/prompt.ts +25 -75
  197. package/src/generative-ui/render-ui-args.ts +3 -0
  198. package/src/generative-ui/schema-render.ts +377 -0
  199. package/src/generative-ui/types.ts +10 -7
  200. package/src/generative-ui/validate-operation.ts +2 -2
  201. package/src/index.ts +3 -16
  202. package/src/standard-schema.ts +24 -27
  203. package/src/telemetry/lambda-client.ts +8 -3
  204. package/src/telemetry/model-host.test.ts +2 -5
  205. package/src/telemetry/telemetry-disabled.ts +0 -5
  206. package/src/types/message.ts +1 -19
  207. package/src/utils/__tests__/errors.test.ts +44 -0
  208. package/src/utils/__tests__/json-schema.test.ts +3 -479
  209. package/src/utils/__tests__/random-id.test.ts +37 -0
  210. package/src/utils/errors.ts +28 -85
  211. package/src/utils/index.ts +0 -2
  212. package/src/utils/inspector-visibility.test.ts +26 -0
  213. package/src/utils/inspector-visibility.ts +35 -3
  214. package/src/utils/json-schema.ts +5 -152
  215. package/src/utils/random-id.ts +17 -37
  216. package/tsconfig.json +3 -1
  217. package/tsdown.config.ts +2 -19
  218. package/dist/event-transforms/index.cjs +0 -15
  219. package/dist/event-transforms/index.d.cts +0 -4
  220. package/dist/event-transforms/index.d.mts +0 -4
  221. package/dist/event-transforms/index.mjs +0 -5
  222. package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
  223. package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
  224. package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
  225. package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
  226. package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
  227. package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
  228. package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
  229. package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
  230. package/dist/event-transforms/recorded-events.cjs +0 -59
  231. package/dist/event-transforms/recorded-events.cjs.map +0 -1
  232. package/dist/event-transforms/recorded-events.d.cts +0 -23
  233. package/dist/event-transforms/recorded-events.d.cts.map +0 -1
  234. package/dist/event-transforms/recorded-events.d.mts +0 -23
  235. package/dist/event-transforms/recorded-events.d.mts.map +0 -1
  236. package/dist/event-transforms/recorded-events.mjs +0 -58
  237. package/dist/event-transforms/recorded-events.mjs.map +0 -1
  238. package/dist/telemetry/events.d.cts +0 -72
  239. package/dist/telemetry/events.d.cts.map +0 -1
  240. package/dist/telemetry/events.d.mts +0 -72
  241. package/dist/telemetry/events.d.mts.map +0 -1
  242. package/dist/telemetry/index.cjs +0 -18
  243. package/dist/telemetry/index.d.cts +0 -5
  244. package/dist/telemetry/index.d.mts +0 -5
  245. package/dist/telemetry/index.mjs +0 -6
  246. package/dist/telemetry/telemetry-client.cjs +0 -165
  247. package/dist/telemetry/telemetry-client.cjs.map +0 -1
  248. package/dist/telemetry/telemetry-client.d.cts +0 -87
  249. package/dist/telemetry/telemetry-client.d.cts.map +0 -1
  250. package/dist/telemetry/telemetry-client.d.mts +0 -87
  251. package/dist/telemetry/telemetry-client.d.mts.map +0 -1
  252. package/dist/telemetry/telemetry-client.mjs +0 -164
  253. package/dist/telemetry/telemetry-client.mjs.map +0 -1
  254. package/dist/telemetry/utils.cjs +0 -14
  255. package/dist/telemetry/utils.cjs.map +0 -1
  256. package/dist/telemetry/utils.mjs +0 -13
  257. package/dist/telemetry/utils.mjs.map +0 -1
  258. package/dist/utils/conditions.cjs +0 -32
  259. package/dist/utils/conditions.cjs.map +0 -1
  260. package/dist/utils/conditions.d.cts +0 -31
  261. package/dist/utils/conditions.d.cts.map +0 -1
  262. package/dist/utils/conditions.d.mts +0 -31
  263. package/dist/utils/conditions.d.mts.map +0 -1
  264. package/dist/utils/conditions.mjs +0 -31
  265. package/dist/utils/conditions.mjs.map +0 -1
  266. package/dist/utils/console-styling.cjs +0 -91
  267. package/dist/utils/console-styling.cjs.map +0 -1
  268. package/dist/utils/console-styling.d.cts +0 -65
  269. package/dist/utils/console-styling.d.cts.map +0 -1
  270. package/dist/utils/console-styling.d.mts +0 -65
  271. package/dist/utils/console-styling.d.mts.map +0 -1
  272. package/dist/utils/console-styling.mjs +0 -85
  273. package/dist/utils/console-styling.mjs.map +0 -1
  274. package/src/__tests__/zod-regression.test.ts +0 -319
  275. package/src/event-transforms/index.ts +0 -5
  276. package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
  277. package/src/event-transforms/recorded-events.test.ts +0 -166
  278. package/src/event-transforms/recorded-events.ts +0 -74
  279. package/src/telemetry/events.ts +0 -68
  280. package/src/telemetry/index.ts +0 -9
  281. package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
  282. package/src/telemetry/telemetry-client.test.ts +0 -798
  283. package/src/telemetry/telemetry-client.ts +0 -328
  284. package/src/telemetry/utils.ts +0 -15
  285. package/src/utils/__tests__/conditions.test.ts +0 -161
  286. package/src/utils/conditions.ts +0 -116
  287. package/src/utils/console-styling.ts +0 -126
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function(global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('graphql'), require('zod'), require('uuid'), require('partial-json'), require('@ag-ui/client')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'graphql', 'zod', 'uuid', 'partial-json', '@ag-ui/client'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitShared = {}), global.GraphQL,global.Zod,global.UUID,global.PartialJSON,global.AgUIClient));
5
- })(this, function(exports, graphql, zod, uuid, partial_json, _ag_ui_client) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('partial-json'), require('@ag-ui/client')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'partial-json', '@ag-ui/client'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitShared = {}), global.PartialJSON,global.AgUIClient));
5
+ })(this, function(exports, partial_json, _ag_ui_client) {
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
7
7
  //#region \0rolldown/runtime.js
8
8
  var __create = Object.create;
@@ -58,118 +58,6 @@ partial_json = __toESM(partial_json);
58
58
  }
59
59
  }
60
60
 
61
- //#endregion
62
- //#region src/utils/conditions.ts
63
- function executeConditions({ conditions, value }) {
64
- if (!(conditions === null || conditions === void 0 ? void 0 : conditions.length)) return true;
65
- return conditions.every((condition) => executeCondition(condition, value));
66
- }
67
- function executeCondition(condition, value) {
68
- const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
69
- switch (condition.rule) {
70
- case "AND": return condition.conditions.every((c) => executeCondition(c, value));
71
- case "OR": return condition.conditions.some((c) => executeCondition(c, value));
72
- case "NOT": return !condition.conditions.every((c) => executeCondition(c, value));
73
- case "EQUALS": return targetValue === condition.value;
74
- case "NOT_EQUALS": return targetValue !== condition.value;
75
- case "GREATER_THAN": return targetValue > condition.value;
76
- case "LESS_THAN": return targetValue < condition.value;
77
- case "CONTAINS": return Array.isArray(targetValue) && targetValue.includes(condition.value);
78
- case "NOT_CONTAINS": return Array.isArray(targetValue) && !targetValue.includes(condition.value);
79
- case "MATCHES": return new RegExp(condition.value).test(String(targetValue));
80
- case "STARTS_WITH": return String(targetValue).startsWith(condition.value);
81
- case "ENDS_WITH": return String(targetValue).endsWith(condition.value);
82
- case "EXISTS": return targetValue !== void 0 && targetValue !== null;
83
- case "NOT_EXISTS": return targetValue === void 0 || targetValue === null;
84
- }
85
- }
86
- function getValueFromPath(obj, path) {
87
- return path.split(".").reduce((acc, part) => acc === null || acc === void 0 ? void 0 : acc[part], obj);
88
- }
89
-
90
- //#endregion
91
- //#region src/utils/console-styling.ts
92
- /**
93
- * Console styling utilities for CopilotKit branded messages
94
- * Provides consistent, readable colors across light and dark console themes
95
- */
96
- /**
97
- * Color palette optimized for console readability
98
- */
99
- const ConsoleColors = {
100
- primary: "#007acc",
101
- success: "#22c55e",
102
- feature: "#a855f7",
103
- cta: "#ef4444",
104
- info: "#06b6d4",
105
- inherit: "inherit",
106
- warning: "#f59e0b"
107
- };
108
- /**
109
- * Console style templates for common patterns
110
- */
111
- const ConsoleStyles = {
112
- header: `color: ${ConsoleColors.warning}; font-weight: bold; font-size: 16px;`,
113
- section: `color: ${ConsoleColors.success}; font-weight: bold;`,
114
- highlight: `color: ${ConsoleColors.feature}; font-weight: bold;`,
115
- cta: `color: ${ConsoleColors.success}; font-weight: bold;`,
116
- info: `color: ${ConsoleColors.info}; font-weight: bold;`,
117
- link: `color: ${ConsoleColors.primary}; text-decoration: underline;`,
118
- body: `color: ${ConsoleColors.inherit};`,
119
- warning: `color: ${ConsoleColors.cta}; font-weight: bold;`
120
- };
121
- /**
122
- * Styled console message for CopilotKit Platform promotion
123
- * Displays a beautiful, branded advertisement in the console
124
- */
125
- function logCopilotKitPlatformMessage() {
126
- console.log(`%cCopilotKit Warning%c
127
-
128
- useCopilotChatHeadless_c provides full compatibility with CopilotKit's newly released Headless UI feature set. Headless UI requires a CopilotKit Intelligence license key, available for free at:
129
-
130
- %chttps://dashboard.operations.copilotkit.ai%c
131
-
132
- Alternatively, useCopilotChat is available for basic programmatic control, and does not require a license key.
133
-
134
- To learn more about CopilotKit Intelligence, read the documentation here:
135
-
136
- %chttps://docs.copilotkit.ai/intelligence/overview%c`, ConsoleStyles.header, ConsoleStyles.body, ConsoleStyles.cta, ConsoleStyles.body, ConsoleStyles.link, ConsoleStyles.body);
137
- }
138
- function publicApiKeyRequired(feature) {
139
- console.log(`
140
- %cCopilotKit Warning%c \n
141
- In order to use ${feature}, you need to add your CopilotKit license key, available for free at https://dashboard.operations.copilotkit.ai.
142
- `.trim(), ConsoleStyles.header, ConsoleStyles.body);
143
- }
144
- /**
145
- * Create a styled console message with custom content
146
- *
147
- * @param template - Template string with %c placeholders
148
- * @param styles - Array of style strings matching the %c placeholders
149
- *
150
- * @example
151
- * ```typescript
152
- * logStyled(
153
- * '%cCopilotKit%c Welcome to the platform!',
154
- * [ConsoleStyles.header, ConsoleStyles.body]
155
- * );
156
- * ```
157
- */
158
- function logStyled(template, styles) {
159
- console.log(template, ...styles);
160
- }
161
- /**
162
- * Quick styled console methods for common use cases
163
- */
164
- const styledConsole = {
165
- success: (message) => logStyled(`%c✅ ${message}`, [ConsoleStyles.section]),
166
- info: (message) => logStyled(`%cℹ️ ${message}`, [ConsoleStyles.info]),
167
- feature: (message) => logStyled(`%c✨ ${message}`, [ConsoleStyles.highlight]),
168
- cta: (message) => logStyled(`%c🚀 ${message}`, [ConsoleStyles.cta]),
169
- logCopilotKitPlatformMessage,
170
- publicApiKeyRequired
171
- };
172
-
173
61
  //#endregion
174
62
  //#region src/utils/errors.ts
175
63
  let Severity = /* @__PURE__ */ function(Severity) {
@@ -191,7 +79,6 @@ In order to use ${feature}, you need to add your CopilotKit license key, availab
191
79
  COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError",
192
80
  COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError",
193
81
  COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError",
194
- COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError",
195
82
  RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError",
196
83
  CONFIGURATION_ERROR: "ConfigurationError",
197
84
  MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
@@ -296,7 +183,7 @@ In order to use ${feature}, you need to add your CopilotKit license key, availab
296
183
  severity: Severity.INFO
297
184
  }
298
185
  };
299
- var CopilotKitError = class extends graphql.GraphQLError {
186
+ var CopilotKitError = class extends Error {
300
187
  constructor({ message = "Unknown error occurred", code, severity, visibility }) {
301
188
  var _ref;
302
189
  const name = ERROR_NAMES.COPILOT_ERROR;
@@ -304,7 +191,8 @@ In order to use ${feature}, you need to add your CopilotKit license key, availab
304
191
  const { statusCode } = config;
305
192
  const resolvedVisibility = (_ref = visibility !== null && visibility !== void 0 ? visibility : config.visibility) !== null && _ref !== void 0 ? _ref : ErrorVisibility.TOAST;
306
193
  const resolvedSeverity = severity !== null && severity !== void 0 ? severity : "severity" in config ? config.severity : void 0;
307
- super(message, { extensions: {
194
+ super(message);
195
+ this.extensions = {
308
196
  name,
309
197
  statusCode,
310
198
  code,
@@ -315,7 +203,7 @@ In order to use ${feature}, you need to add your CopilotKit license key, availab
315
203
  message,
316
204
  stack: (/* @__PURE__ */ new Error()).stack
317
205
  }
318
- } });
206
+ };
319
207
  this.code = code;
320
208
  this.name = name;
321
209
  this.statusCode = statusCode;
@@ -340,26 +228,6 @@ In order to use ${feature}, you need to add your CopilotKit license key, availab
340
228
  this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;
341
229
  }
342
230
  };
343
- const getVersionMismatchErrorMessage = ({ reactCoreVersion, runtimeVersion, runtimeClientGqlVersion }) => `Version mismatch detected: @copilotkit/runtime@${runtimeVersion !== null && runtimeVersion !== void 0 ? runtimeVersion : ""} is not compatible with @copilotkit/react-core@${reactCoreVersion} and @copilotkit/runtime-client-gql@${runtimeClientGqlVersion}. Please ensure all installed copilotkit packages are on the same version.`;
344
- /**
345
- * Error thrown when CPK versions does not match
346
- *
347
- * @extends CopilotKitError
348
- */
349
- var CopilotKitVersionMismatchError = class extends CopilotKitError {
350
- constructor({ reactCoreVersion, runtimeVersion, runtimeClientGqlVersion }) {
351
- const code = CopilotKitErrorCode.VERSION_MISMATCH;
352
- super({
353
- message: getVersionMismatchErrorMessage({
354
- reactCoreVersion,
355
- runtimeVersion,
356
- runtimeClientGqlVersion
357
- }),
358
- code
359
- });
360
- this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;
361
- }
362
- };
363
231
  /**
364
232
  * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
365
233
  * This typically occurs when:
@@ -550,19 +418,6 @@ In order to use ${feature}, you need to add your CopilotKit license key, availab
550
418
  function ensureStructuredError(error, converter) {
551
419
  return isStructuredCopilotKitError(error) ? error : converter(error);
552
420
  }
553
- async function getPossibleVersionMismatch({ runtimeVersion, runtimeClientGqlVersion }) {
554
- if (!runtimeVersion || runtimeVersion === "" || !runtimeClientGqlVersion) return;
555
- if (COPILOTKIT_VERSION !== runtimeVersion || COPILOTKIT_VERSION !== runtimeClientGqlVersion || runtimeVersion !== runtimeClientGqlVersion) return {
556
- runtimeVersion,
557
- runtimeClientGqlVersion,
558
- reactCoreVersion: COPILOTKIT_VERSION,
559
- message: getVersionMismatchErrorMessage({
560
- runtimeVersion,
561
- runtimeClientGqlVersion,
562
- reactCoreVersion: COPILOTKIT_VERSION
563
- })
564
- };
565
- }
566
421
  const resolveLowLevelErrorMessage = ({ errorCode, url }) => {
567
422
  const troubleshootingLink = ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;
568
423
  const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.
@@ -583,6 +438,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
583
438
  case "ECONNREFUSED": return `Connection to ${url} was refused. Ensure the server is running and accessible.\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;
584
439
  case "ENOTFOUND": return `The server on ${url} could not be found. Check the URL or your network configuration.\n\n${getSeeMoreMarkdown(ERROR_CONFIG[CopilotKitErrorCode.NOT_FOUND].troubleshootingUrl)}`;
585
440
  case "ETIMEDOUT": return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;
441
+ case void 0:
586
442
  default: return;
587
443
  }
588
444
  };
@@ -707,6 +563,10 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
707
563
  ...properties && { properties },
708
564
  ...required && required.length > 0 && { required }
709
565
  };
566
+ case "string[]":
567
+ case "number[]":
568
+ case "boolean[]":
569
+ case void 0:
710
570
  default:
711
571
  var _attribute$type;
712
572
  if ((_attribute$type = attribute.type) === null || _attribute$type === void 0 ? void 0 : _attribute$type.endsWith("[]")) return {
@@ -720,82 +580,6 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
720
580
  };
721
581
  }
722
582
  }
723
- function convertJsonSchemaToZodSchema(jsonSchema, required, definitions, visitedRefs) {
724
- var _ref, _jsonSchema$anyOf, _jsonSchema$type;
725
- if (jsonSchema.$ref && definitions) {
726
- const refPath = jsonSchema.$ref.replace(/^#\/\$defs\/|^#\/definitions\//, "");
727
- const refs = visitedRefs !== null && visitedRefs !== void 0 ? visitedRefs : /* @__PURE__ */ new Set();
728
- if (refs.has(refPath)) {
729
- console.warn(`[CopilotKit] Circular $ref detected for "${refPath}" — falling back to z.any()`);
730
- let schema = zod.z.any();
731
- if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
732
- return required ? schema : schema.optional();
733
- }
734
- const resolved = definitions[refPath];
735
- if (resolved) {
736
- const nextRefs = new Set(refs);
737
- nextRefs.add(refPath);
738
- return convertJsonSchemaToZodSchema(resolved, required, definitions, nextRefs);
739
- }
740
- }
741
- const defs = (_ref = definitions !== null && definitions !== void 0 ? definitions : jsonSchema.$defs) !== null && _ref !== void 0 ? _ref : jsonSchema.definitions;
742
- if (Array.isArray(jsonSchema.type)) {
743
- const types = jsonSchema.type;
744
- const hasNull = types.includes("null");
745
- const nonNullTypes = types.filter((t) => t !== "null");
746
- const resolvedType = nonNullTypes.length > 0 ? nonNullTypes[0] : "string";
747
- const innerSchema = convertJsonSchemaToZodSchema({
748
- ...jsonSchema,
749
- type: resolvedType
750
- }, true, defs, visitedRefs);
751
- let schema = hasNull ? zod.z.union([innerSchema, zod.z.null()]) : innerSchema;
752
- if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
753
- return required ? schema : schema.optional();
754
- }
755
- const unionVariants = (_jsonSchema$anyOf = jsonSchema.anyOf) !== null && _jsonSchema$anyOf !== void 0 ? _jsonSchema$anyOf : jsonSchema.oneOf;
756
- if (Array.isArray(unionVariants) && unionVariants.length > 0) {
757
- if (unionVariants.length === 1) return convertJsonSchemaToZodSchema(unionVariants[0], required, defs, visitedRefs);
758
- const schemas = unionVariants.map((v) => convertJsonSchemaToZodSchema(v, true, defs, visitedRefs));
759
- let schema = zod.z.union(schemas);
760
- if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
761
- return required ? schema : schema.optional();
762
- }
763
- if (jsonSchema.type === "object") {
764
- const spec = {};
765
- if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) return !required ? zod.z.object(spec).optional() : zod.z.object(spec);
766
- for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false, defs, visitedRefs);
767
- let schema = zod.z.object(spec).describe(jsonSchema.description);
768
- return required ? schema : schema.optional();
769
- } else if (jsonSchema.type === "string") {
770
- if (jsonSchema.enum && jsonSchema.enum.length > 0) {
771
- let schema = zod.z.enum(jsonSchema.enum).describe(jsonSchema.description);
772
- return required ? schema : schema.optional();
773
- }
774
- let schema = zod.z.string().describe(jsonSchema.description);
775
- return required ? schema : schema.optional();
776
- } else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
777
- let schema = zod.z.number().describe(jsonSchema.description);
778
- return required ? schema : schema.optional();
779
- } else if (jsonSchema.type === "boolean") {
780
- let schema = zod.z.boolean().describe(jsonSchema.description);
781
- return required ? schema : schema.optional();
782
- } else if (jsonSchema.type === "array") {
783
- let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true, defs, visitedRefs);
784
- let schema = zod.z.array(itemSchema).describe(jsonSchema.description);
785
- return required ? schema : schema.optional();
786
- } else if (jsonSchema.type === "null") {
787
- let schema = zod.z.null().describe(jsonSchema.description);
788
- return required ? schema : schema.optional();
789
- }
790
- console.warn(`[CopilotKit] Unsupported JSON schema type "${(_jsonSchema$type = jsonSchema.type) !== null && _jsonSchema$type !== void 0 ? _jsonSchema$type : "unknown"}" — falling back to z.any()`);
791
- let schema = zod.z.any();
792
- if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
793
- return required ? schema : schema.optional();
794
- }
795
- function getZodParameters(parameters) {
796
- if (!parameters) return zod.z.object({});
797
- return convertJsonSchemaToZodSchema(actionParametersToJsonSchema(parameters), true);
798
- }
799
583
 
800
584
  //#endregion
801
585
  //#region src/utils/dashboard-url.ts
@@ -815,7 +599,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
815
599
 
816
600
  //#endregion
817
601
  //#region src/utils/inspector-metadata.ts
818
- function isRecord$1(value) {
602
+ function isRecord$3(value) {
819
603
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
820
604
  try {
821
605
  const prototype = Object.getPrototypeOf(value);
@@ -838,7 +622,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
838
622
  return parsed.length > 0 ? parsed : void 0;
839
623
  }
840
624
  function parseIdentity(value) {
841
- if (!isRecord$1(value)) return;
625
+ if (!isRecord$3(value)) return;
842
626
  const organizationName = parseNonBlankString(value.organizationName);
843
627
  const projectName = parseNonBlankString(value.projectName);
844
628
  if (organizationName === void 0 || projectName === void 0) return;
@@ -848,7 +632,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
848
632
  };
849
633
  }
850
634
  function parsePlan(value) {
851
- if (!isRecord$1(value)) return;
635
+ if (!isRecord$3(value)) return;
852
636
  const code = parseNonBlankString(value.code);
853
637
  const label = parseNonBlankString(value.label);
854
638
  if (code === void 0 || label === void 0) return;
@@ -858,7 +642,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
858
642
  };
859
643
  }
860
644
  function parseLicense(value) {
861
- if (!isRecord$1(value)) return;
645
+ if (!isRecord$3(value)) return;
862
646
  switch (value.state) {
863
647
  case "valid":
864
648
  case "none":
@@ -893,7 +677,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
893
677
  return isSafeDashboardUrl(parsed) ? url : void 0;
894
678
  }
895
679
  function parseAction(value) {
896
- if (!isRecord$1(value)) return;
680
+ if (!isRecord$3(value)) return;
897
681
  const kind = parseActionKind(value.kind);
898
682
  const url = parseSafeActionUrl(value.url);
899
683
  if (kind === void 0 || url === void 0) return;
@@ -906,7 +690,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
906
690
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
907
691
  }
908
692
  function parseUsageLimit(value) {
909
- if (!isRecord$1(value)) return;
693
+ if (!isRecord$3(value)) return;
910
694
  if (value.kind === "finite") {
911
695
  if (typeof value.value !== "number" || !Number.isSafeInteger(value.value) || value.value < 1) return;
912
696
  return {
@@ -918,7 +702,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
918
702
  if (value.kind === "unknown") return { kind: "unknown" };
919
703
  }
920
704
  function parseUsage(value) {
921
- if (!isRecord$1(value)) return;
705
+ if (!isRecord$3(value)) return;
922
706
  const limit = parseUsageLimit(value.limit);
923
707
  const used = value.used;
924
708
  if (!isFiniteNonnegativeInteger(used) || limit === void 0) return;
@@ -939,7 +723,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
939
723
  * top-level payload.
940
724
  */
941
725
  function parseInspectorMetadataV1(value) {
942
- if (!isRecord$1(value) || value.schemaVersion !== 1) return;
726
+ if (!isRecord$3(value) || value.schemaVersion !== 1) return;
943
727
  const identity = parseIdentity(value.identity);
944
728
  const plan = parsePlan(value.plan);
945
729
  const license = parseLicense(value.license);
@@ -1169,11 +953,32 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1169
953
  //#endregion
1170
954
  //#region src/utils/inspector-visibility.ts
1171
955
  /**
956
+ * Hosts the Inspector runs on. The Inspector reads agent state, messages and
957
+ * request headers, so it only mounts on a page served from this machine.
958
+ *
959
+ * @internal Framework adapters use this list. Applications must not depend on it.
960
+ */
961
+ const ɵINSPECTOR_LOOPBACK_HOSTS = Object.freeze([
962
+ "localhost",
963
+ "127.0.0.1",
964
+ "[::1]"
965
+ ]);
966
+ /**
1172
967
  * The Inspector is a development-only browser tool. Consumers may disable it,
1173
- * but an explicit `true` never overrides a production or server environment.
968
+ * but an explicit `true` never overrides a production or server environment,
969
+ * or a page served from a non-loopback host.
970
+ *
971
+ * @example
972
+ * shouldEnableInspector({
973
+ * enableInspector,
974
+ * isBrowser: true,
975
+ * isDevelopment: process.env.NODE_ENV === "development",
976
+ * hostname: window.location.hostname,
977
+ * });
1174
978
  */
1175
- function shouldEnableInspector({ enableInspector, isBrowser, isDevelopment }) {
1176
- return isBrowser && isDevelopment && enableInspector !== false;
979
+ function shouldEnableInspector({ enableInspector, isBrowser, isDevelopment, hostname }) {
980
+ const isAllowedHost = hostname === void 0 || ɵINSPECTOR_LOOPBACK_HOSTS.includes(hostname);
981
+ return isBrowser && isDevelopment && enableInspector !== false && isAllowedHost;
1177
982
  }
1178
983
 
1179
984
  //#endregion
@@ -1184,31 +989,22 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1184
989
  //#endregion
1185
990
  //#region src/utils/random-id.ts
1186
991
  function randomId() {
1187
- return "ck-" + (0, uuid.v4)();
1188
- }
1189
- function randomUUID() {
1190
- return (0, uuid.v4)();
992
+ return "ck-" + randomUUID();
1191
993
  }
1192
994
  /**
1193
- * Recursively converts an object to a serializable form by converting functions to their string representation.
995
+ * Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it
996
+ * exists, and builds the UUID from `crypto.getRandomValues()` when it does not
997
+ * (React Native's Hermes has no `randomUUID`).
1194
998
  */
1195
- function toSerializable(value) {
1196
- if (typeof value === "function") return value.toString();
1197
- if (Array.isArray(value)) return value.map(toSerializable);
1198
- if (value !== null && typeof value === "object") {
1199
- const result = {};
1200
- for (const key of Object.keys(value)) result[key] = toSerializable(value[key]);
1201
- return result;
1202
- }
1203
- return value;
1204
- }
1205
- function dataToUUID(input, namespace) {
1206
- const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
1207
- const boundNamespace = namespace ? (0, uuid.v5)(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
1208
- return (0, uuid.v5)(typeof input === "string" ? input : JSON.stringify(toSerializable(input)), boundNamespace);
1209
- }
1210
- function isValidUUID(uuid$1) {
1211
- return (0, uuid.validate)(uuid$1);
999
+ function randomUUID() {
1000
+ const crypto = globalThis.crypto;
1001
+ if (typeof (crypto === null || crypto === void 0 ? void 0 : crypto.randomUUID) === "function") return crypto.randomUUID();
1002
+ if (typeof (crypto === null || crypto === void 0 ? void 0 : crypto.getRandomValues) !== "function") throw new Error("crypto.getRandomValues() is not available. In React Native, install a polyfill such as react-native-get-random-values.");
1003
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
1004
+ bytes[6] = bytes[6] & 15 | 64;
1005
+ bytes[8] = bytes[8] & 63 | 128;
1006
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
1007
+ return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
1212
1008
  }
1213
1009
 
1214
1010
  //#endregion
@@ -1587,11 +1383,6 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1587
1383
  * Users can opt out by setting:
1588
1384
  * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
1589
1385
  * - DO_NOT_TRACK=true or DO_NOT_TRACK=1
1590
- *
1591
- * Lives in its own module so that the browser-facing root entry can
1592
- * re-export it without pulling in `telemetry-client.ts`, whose
1593
- * `@segment/analytics-node` import drags Node built-ins into browser
1594
- * bundler module graphs. See the note in `../index.ts`.
1595
1386
  */
1596
1387
  function isTelemetryDisabled() {
1597
1388
  const env = processEnv();
@@ -1777,7 +1568,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1777
1568
  try {
1778
1569
  var _firstNonBlankTelemet;
1779
1570
  const payload = parts[1];
1780
- if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) return null;
1571
+ if (payload === void 0 || !/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) return null;
1781
1572
  let b64 = payload.replace(/-/g, "+").replace(/_/g, "/");
1782
1573
  const padding = (4 - b64.length % 4) % 4;
1783
1574
  b64 += "=".repeat(padding);
@@ -1867,6 +1658,18 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1867
1658
  //#endregion
1868
1659
  //#region src/standard-schema.ts
1869
1660
  /**
1661
+ * A Standard Schema that accepts any value and returns it unchanged.
1662
+ *
1663
+ * Wildcard tool call renderers use it when they declare no `args` schema.
1664
+ *
1665
+ * @internal Application authors must not depend on this contract.
1666
+ */
1667
+ const ɵanySchema = { "~standard": {
1668
+ version: 1,
1669
+ vendor: "copilotkit",
1670
+ validate: (value) => ({ value })
1671
+ } };
1672
+ /**
1870
1673
  * Check whether a schema implements the Standard JSON Schema V1 protocol.
1871
1674
  */
1872
1675
  function hasStandardJsonSchema(schema) {
@@ -1879,17 +1682,17 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1879
1682
  * Strategy:
1880
1683
  * 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
1881
1684
  * call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
1882
- * 2. If the schema exposes a `toJSONSchema()` method (Zod v4), call it directly.
1883
- * 3. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the
1884
- * injected `zodToJsonSchema()` function.
1885
- * 4. Otherwise throw a descriptive error.
1685
+ * Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.
1686
+ * 2. If the schema exposes a `toJSONSchema()` method, call it directly.
1687
+ * 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they
1688
+ * implement Standard Schema validation but cannot describe themselves as
1689
+ * JSON Schema.
1886
1690
  */
1887
- function schemaToJsonSchema(schema, options) {
1691
+ function schemaToJsonSchema(schema) {
1888
1692
  if (hasStandardJsonSchema(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-07" });
1889
1693
  if (typeof schema.toJSONSchema === "function") return schema.toJSONSchema();
1890
1694
  const vendor = schema["~standard"].vendor;
1891
- if (vendor === "zod" && (options === null || options === void 0 ? void 0 : options.zodToJsonSchema)) return options.zodToJsonSchema(schema, { $refStrategy: "none" });
1892
- throw new Error(`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1 and no zodToJsonSchema fallback is available. Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) or pass a zodToJsonSchema function in options.`);
1695
+ throw new Error(`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1. Use a library that does: Zod 4.2+ (Zod 3 is not supported), Valibot v1+ wrapped with toStandardJsonSchema() from @valibot/to-json-schema, or ArkType v2.1.28+.`);
1893
1696
  }
1894
1697
 
1895
1698
  //#endregion
@@ -1951,15 +1754,26 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1951
1754
  }
1952
1755
  /**
1953
1756
  * Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).
1954
- * Returns undefined if thumbnail generation fails or if called outside a browser environment.
1757
+ * Returns undefined if thumbnail generation fails, if called outside a browser environment,
1758
+ * or if `file` is not a `Blob` the browser can read (React Native for web passes a
1759
+ * native file's description). Never rejects.
1955
1760
  */
1956
1761
  function generateVideoThumbnail(file) {
1957
- if (typeof document === "undefined") return Promise.resolve(void 0);
1762
+ if (typeof document === "undefined" || typeof Blob === "undefined" || !(file instanceof Blob)) return Promise.resolve(void 0);
1958
1763
  return new Promise((resolve) => {
1959
1764
  let resolved = false;
1960
- const video = document.createElement("video");
1961
- const canvas = document.createElement("canvas");
1962
- const url = URL.createObjectURL(file);
1765
+ let url;
1766
+ let video;
1767
+ let canvas;
1768
+ try {
1769
+ video = document.createElement("video");
1770
+ canvas = document.createElement("canvas");
1771
+ url = URL.createObjectURL(file);
1772
+ } catch (error) {
1773
+ console.warn(`[CopilotKit] generateVideoThumbnail: could not read file "${file.name}"`, error);
1774
+ resolve(void 0);
1775
+ return;
1776
+ }
1963
1777
  const cleanup = (result) => {
1964
1778
  if (resolved) return;
1965
1779
  resolved = true;
@@ -2136,6 +1950,22 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2136
1950
  terminalEventObserved = true;
2137
1951
  clearOpen();
2138
1952
  break;
1953
+ case _ag_ui_client.EventType.TEXT_MESSAGE_CONTENT:
1954
+ case _ag_ui_client.EventType.TEXT_MESSAGE_CHUNK:
1955
+ case _ag_ui_client.EventType.TOOL_CALL_ARGS:
1956
+ case _ag_ui_client.EventType.TOOL_CALL_CHUNK:
1957
+ case _ag_ui_client.EventType.STATE_SNAPSHOT:
1958
+ case _ag_ui_client.EventType.STATE_DELTA:
1959
+ case _ag_ui_client.EventType.MESSAGES_SNAPSHOT:
1960
+ case _ag_ui_client.EventType.ACTIVITY_SNAPSHOT:
1961
+ case _ag_ui_client.EventType.ACTIVITY_DELTA:
1962
+ case _ag_ui_client.EventType.RAW:
1963
+ case _ag_ui_client.EventType.CUSTOM:
1964
+ case _ag_ui_client.EventType.STEP_STARTED:
1965
+ case _ag_ui_client.EventType.STEP_FINISHED:
1966
+ case _ag_ui_client.EventType.REASONING_MESSAGE_CONTENT:
1967
+ case _ag_ui_client.EventType.REASONING_MESSAGE_CHUNK:
1968
+ case _ag_ui_client.EventType.REASONING_ENCRYPTED_VALUE:
2139
1969
  default: break;
2140
1970
  }
2141
1971
  };
@@ -2336,7 +2166,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2336
2166
 
2337
2167
  //#endregion
2338
2168
  //#region package.json
2339
- var version = "2.0.0-rc.3";
2169
+ var version = "2.0.0-rc.30";
2340
2170
 
2341
2171
  //#endregion
2342
2172
  //#region src/generative-ui/basic-functions.ts
@@ -2464,7 +2294,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2464
2294
  */
2465
2295
  const COPILOTKIT_FUNCTIONS = rendererOnly({
2466
2296
  calc: {
2467
- description: "The value of an arithmetic expression over the other args, by name: + - * / % ( ), comparisons, && || !, cond ? a : b, min max round floor ceil abs, 'text' + name",
2297
+ description: "The value of an arithmetic expression over the other args, by name: + - * / % ( ), x ^ y (power), comparisons, && || !, cond ? a : b, min max round floor ceil abs pow sqrt exp ln log10, the constants pi and e, 'text' + name",
2468
2298
  parameters: "{ expression: string; [name: string]: number | string | boolean }",
2469
2299
  returnType: "any",
2470
2300
  extension: true
@@ -2507,7 +2337,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2507
2337
  //#endregion
2508
2338
  //#region src/generative-ui/is-record.ts
2509
2339
  /** True for a plain object: not null, not an array. Internal, not exported. */
2510
- function isRecord(value) {
2340
+ function isRecord$2(value) {
2511
2341
  return typeof value === "object" && value !== null && !Array.isArray(value);
2512
2342
  }
2513
2343
 
@@ -2553,7 +2383,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2553
2383
  const visit = (node) => {
2554
2384
  var _marked;
2555
2385
  if (Array.isArray(node)) return node.map(visit);
2556
- if (!isRecord(node)) return node;
2386
+ if (!isRecord$2(node)) return node;
2557
2387
  const reference = (_marked = marked(node.description, A2UI_COMPONENT_ID_MARK, A2UI_COMPONENT_ID_REF)) !== null && _marked !== void 0 ? _marked : marked(node.description, A2UI_CHILD_LIST_MARK, A2UI_CHILD_LIST_REF);
2558
2388
  if (reference) return reference;
2559
2389
  return Object.fromEntries(Object.entries(node).map(([key, value]) => [key, visit(value)]));
@@ -2580,12 +2410,12 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2580
2410
  });
2581
2411
  };
2582
2412
  const visit = (node, path) => {
2583
- if (!isRecord(node)) return;
2413
+ if (!isRecord$2(node)) return;
2584
2414
  const kind = childRefKind(node);
2585
2415
  if (kind) return add(path, kind);
2586
2416
  for (const list of [node.anyOf, node.oneOf]) {
2587
2417
  if (!Array.isArray(list) || list.length === 0) continue;
2588
- const kinds = list.map((variant) => isRecord(variant) ? childRefKind(variant) : void 0);
2418
+ const kinds = list.map((variant) => isRecord$2(variant) ? childRefKind(variant) : void 0);
2589
2419
  const [first] = kinds;
2590
2420
  if (first && kinds.every((k) => k === first)) add(path, first);
2591
2421
  else if (kinds.every((k) => k === void 0)) {
@@ -2595,8 +2425,8 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2595
2425
  }
2596
2426
  }
2597
2427
  if (Array.isArray(node.allOf)) node.allOf.forEach((variant) => visit(variant, path));
2598
- if (isRecord(node.properties)) for (const [key, value] of Object.entries(node.properties)) visit(value, [...path, key]);
2599
- if (isRecord(node.items)) visit(node.items, [...path, "*"]);
2428
+ if (isRecord$2(node.properties)) for (const [key, value] of Object.entries(node.properties)) visit(value, [...path, key]);
2429
+ if (isRecord$2(node.items)) visit(node.items, [...path, "*"]);
2600
2430
  };
2601
2431
  visit(schema, []);
2602
2432
  return refs;
@@ -2611,16 +2441,16 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2611
2441
  const collect = (value) => {
2612
2442
  if (typeof value === "string") ids.push(value);
2613
2443
  else if (Array.isArray(value)) value.forEach((id) => typeof id === "string" && ids.push(id));
2614
- else if (isRecord(value) && typeof value.componentId === "string") ids.push(value.componentId);
2444
+ else if (isRecord$2(value) && typeof value.componentId === "string") ids.push(value.componentId);
2615
2445
  };
2616
2446
  const visit = (value, path) => {
2617
- if (path.length === 0) return collect(value);
2618
2447
  const [head, ...rest] = path;
2448
+ if (head === void 0) return collect(value);
2619
2449
  if (head === "*") {
2620
2450
  if (Array.isArray(value)) value.forEach((item) => visit(item, rest));
2621
2451
  return;
2622
2452
  }
2623
- if (isRecord(value) && Object.prototype.hasOwnProperty.call(value, head)) visit(value[head], rest);
2453
+ if (isRecord$2(value) && Object.prototype.hasOwnProperty.call(value, head)) visit(value[head], rest);
2624
2454
  };
2625
2455
  for (const ref of refs) visit(component, ref.path);
2626
2456
  return ids;
@@ -2631,13 +2461,13 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2631
2461
  * at render time.
2632
2462
  */
2633
2463
  function hasBoundChildRef(component, refs) {
2634
- const isDynamic = (value) => isRecord(value) && ("@path" in value || "@call" in value);
2464
+ const isDynamic = (value) => isRecord$2(value) && ("@path" in value || "@call" in value);
2635
2465
  const visit = (value, path) => {
2636
2466
  if (isDynamic(value)) return true;
2637
- if (path.length === 0) return false;
2638
2467
  const [head, ...rest] = path;
2468
+ if (head === void 0) return false;
2639
2469
  if (head === "*") return Array.isArray(value) && value.some((item) => visit(item, rest));
2640
- return isRecord(value) && Object.prototype.hasOwnProperty.call(value, head) && visit(value[head], rest);
2470
+ return isRecord$2(value) && Object.prototype.hasOwnProperty.call(value, head) && visit(value[head], rest);
2641
2471
  };
2642
2472
  return refs.some((ref) => visit(component, ref.path));
2643
2473
  }
@@ -2647,13 +2477,13 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2647
2477
  * else keeps its identity. Missing keys are left alone.
2648
2478
  */
2649
2479
  function mapAtChildRef(value, path, replace) {
2650
- if (path.length === 0) return replace(value);
2651
2480
  const [head, ...rest] = path;
2481
+ if (head === void 0) return replace(value);
2652
2482
  if (head === "*") {
2653
2483
  if (!Array.isArray(value)) return value;
2654
2484
  return value.map((item) => mapAtChildRef(item, rest, replace));
2655
2485
  }
2656
- if (!isRecord(value) || !Object.prototype.hasOwnProperty.call(value, head)) return value;
2486
+ if (!isRecord$2(value) || !Object.prototype.hasOwnProperty.call(value, head)) return value;
2657
2487
  return {
2658
2488
  ...value,
2659
2489
  [head]: mapAtChildRef(value[head], rest, replace)
@@ -2663,7 +2493,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2663
2493
  //#endregion
2664
2494
  //#region src/generative-ui/types.ts
2665
2495
  /** A2UI protocol version used on the wire. */
2666
- const A2UI_VERSION = "v1.0";
2496
+ const A2UI_VERSION = "1.0";
2667
2497
  /** Activity type of a generated surface message. */
2668
2498
  const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
2669
2499
  /** Activity type of a function call that the agent asks the client to run. */
@@ -2727,7 +2557,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2727
2557
  * @example
2728
2558
  * ```ts
2729
2559
  * toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
2730
- * // { version: "v1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
2560
+ * // { version: "1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
2731
2561
  * ```
2732
2562
  */
2733
2563
  function toA2UIActionMessage(event) {
@@ -2745,6 +2575,222 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
2745
2575
  };
2746
2576
  }
2747
2577
 
2578
+ //#endregion
2579
+ //#region src/generative-ui/prompt-spec.ts
2580
+ /**
2581
+ * When UI helps the user, for both transports: a light nudge to reach for UI
2582
+ * where it conveys the answer better than prose, and to stay in prose
2583
+ * otherwise.
2584
+ */
2585
+ const GENERATIVE_UI_WHEN_TO_SHOW = "Show UI when it conveys the answer better than prose: to illustrate a concept (a diagram, a chart of how something changes), to compare options side by side, to let the user explore or adjust values, or to collect input. A small, focused surface next to your explanation often lands better than a long description. Reply in prose alone for a quick fact, a short answer, or conversation, and never add UI only as decoration.";
2586
+ /**
2587
+ * When and how to show UI in the markdown transport: the answer first, a
2588
+ * map from tasks to components, real interactivity, honest data and
2589
+ * restraint. Measured with tools/genui-eval against the earlier text.
2590
+ */
2591
+ const GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW = "Answer first: lead with the result or the recommendation in a sentence or two, then show the UI that supports it.\n\nShow UI whenever it makes the answer easier to use, and do not wait for the user to ask for a chart, a calculator or a form. A markdown table or list is not enough when the user would want to change a value, see a shape or a trend, or pick between options. Reply in prose alone only for a greeting or thanks, a one-line fact, a definition, code, or a text the user asked you to write (an email, a message, an update).\n\nMatch the UI to the task:\n- A number that depends on inputs (a price, a loan or mortgage, savings, a conversion, a recipe for N people): a calculator, always. Bind a Slider, TextField or SegmentedControl to the data model and compute the results with calc, so they follow the input. calc has powers, roots and logs, so every input can be a control, also a rate or a term: a monthly payment is rate == 0 ? loan / (years * 12) : loan * (rate / 1200) / (1 - (1 + rate / 1200) ^ -(years * 12)).\n- Choosing between options that share attributes: a Table, or a Grid of EntityCards when each option has a photo, a price or a rating. Plans or offers to pick from: one card each, ending with a Button to choose it.\n- Items with a status, a category or a level: a Badge on each item.\n- Shares, patterns, trends, change over time: a Chart.\n- Places, routes, what is nearby: a Map with the places as markers, next to cards or a List with their details.\n- A sequence or a history: a timeline surface, a List of dated items with a Badge for each era, not a markdown list.\n- How something works, a process, a structure: a diagram drawn with Svg. Draw the real objects as shapes (a cylinder and its piston, a leaf, a server), with arrows for movement or flow and short labels. Labelled boxes of text are not a diagram.\n- A formula or an equation: Math. Solving a math problem: the steps in prose with Math, plus a Chart of the function and a Slider to try values of x.\n- A broad topic (\"tell me about X\"): an overview surface with the key facts, an Image, and a Table or Chart that compares the parts, ending with FollowUp suggestions for what to ask next.\n- Options to choose from (algorithms, products, plans): a Table, plus a SegmentedControl or Select that shows the best option for the user's situation.\n- Research or evidence: a Table of the studies, with a Citation for each source.\n- Things whose look matters (places, products, food): an Image, or the image of an EntityCard.\n- Several inputs, or an action with a side effect (sign-up, booking, contact, scheduling): a Form with fields, checks and a Button. A field with a fixed list of answers (a team size, a topic, a country) is a Select.\n- Practice and learning: a quiz with RadioGroup or ChoicePicker that gives feedback as soon as the user answers, or FlashcardFlip cards. Ask in one language and offer the answers in the other.\n- A plan to follow or tick off: CheckBox items with a progress count that updates as items are ticked.\n- Parallel views (the days of a trip, alternatives): Tabs.\n\nMake interactivity real:\n- Expose the few inputs that change the outcome, with sensible defaults from what the user said.\n- Bind every control to the data model and derive what depends on it with calc or formatString. Controls about the same scenario share the same paths.\n- Every Button does what its label says, and a Link takes \"href\".\n- Never pretend an action happened. For booking, sending or subscribing, show the form and let the user confirm, and say that nothing is sent until they do.\n\nKeep the data honest:\n- Use the facts, places, photos and numbers of the app context when it has them. Never invent prices, availability, ratings, sources or image URLs.\n- Label estimates and assumptions, keep units and currencies consistent, and cite the sources you rely on with Citation.\n\nDesign with restraint:\n- One clear surface beats several. Put the most important result first and make it stand out with a Title, or a Text with size \"lg\". Text sizes go from \"3xs\" to \"lg\"; there is no \"xl\" or \"2xl\".\n- Keep explanations in prose around the surface, not inside it. No decoration, and no surface that only holds text.\n\nBefore you reply, check: does the UI answer the actual question, does every control do something, are the numbers right?";
2592
+ /** The prompts that ship, as a spec. A new object on each call. */
2593
+ /**
2594
+ * The standard components that the default markdown guide names. A guide
2595
+ * line that names one the catalog lacks is left out of the prompt.
2596
+ */
2597
+ const GUIDE_COMPONENTS = new Set([
2598
+ "Grid",
2599
+ "Card",
2600
+ "Tabs",
2601
+ "Title",
2602
+ "Text",
2603
+ "Label",
2604
+ "Badge",
2605
+ "Math",
2606
+ "Link",
2607
+ "Button",
2608
+ "Form",
2609
+ "TextField",
2610
+ "Select",
2611
+ "CheckBox",
2612
+ "RadioGroup",
2613
+ "Slider",
2614
+ "SegmentedControl",
2615
+ "ChoicePicker",
2616
+ "FlashcardFlip",
2617
+ "Table",
2618
+ "List",
2619
+ "Chart",
2620
+ "Map",
2621
+ "Image",
2622
+ "Svg",
2623
+ "Citation",
2624
+ "FollowUp",
2625
+ "EntityCard"
2626
+ ]);
2627
+ function defaultGenerativeUIPromptSpec() {
2628
+ return {
2629
+ markdown: {
2630
+ intro: "You can show interactive UI in your reply. Write A2UI operations inside a fenced code block tagged a2ui.",
2631
+ whenToShow: GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW,
2632
+ rules: [
2633
+ "Write explanations as normal markdown prose outside the fences.",
2634
+ "Open a fence with ```a2ui to show the surface in the chat, at the place of the fence.",
2635
+ "Open a fence with ```a2ui target=<id> to show the surface in a named target. Use only target ids from the schema. When a target limits its components, its surfaces can use only those components.",
2636
+ "Inside a fence, write one JSON object per line and nothing else. No comments, no trailing commas, no pretty-printing.",
2637
+ "Keep each operation whole on its line.",
2638
+ "Give every operation \"version\":\"1.0\".",
2639
+ "Start a surface with one createSurface. Put all the initial data in \"dataModel\" and the \"root\" component in \"components\". Then write the children in updateComponents lines, so that they show while you write:\n ```a2ui\n {\"version\":\"1.0\",\"createSurface\":{\"surfaceId\":\"plan-picker\",\"dataModel\":{ ...initial data... },\"components\":[{\"id\":\"root\",\"component\":\"<Name>\",\"children\":[\"seats\",\"pick\"]}]}}\n {\"version\":\"1.0\",\"updateComponents\":{\"surfaceId\":\"plan-picker\",\"components\":[ ...the children... ]}}\n ```",
2640
+ "Keep \"dataModel\" flat: top-level keys such as \"seats\" or \"form\", never one wrapper object around everything. Check that every { and [ you open in a line is closed.",
2641
+ "Every surface renders from the component with id \"root\". Make every other component reachable from \"root\" through slots.",
2642
+ "Send every component you reference in the same reply. If a surface gets long, make it smaller rather than leave components out.",
2643
+ "Use unique ids. Do not make cycles. A component cannot be its own child.",
2644
+ "Write a component as one flat object: {\"id\":\"title\",\"component\":\"<Name>\",\"text\":\"Hello\"}.",
2645
+ "Close each component with exactly one }, also when its last prop is a list: {\"id\":\"map\",\"component\":\"Map\",\"markers\":[{\"label\":\"A\",\"lat\":48.2,\"lng\":16.4}]}. A createSurface or updateComponents line ends with }]}} : the last component, the \"components\" list, the operation, the line.",
2646
+ "A prop that holds a call closes with }} : its \"args\", then the call. The component closes with its own single } after its last prop. With a prop after the call: {\"id\":\"count\",\"component\":\"Text\",\"text\":{\"@call\":\"formatString\",\"args\":{\"value\":\"${/qty} items\"}},\"size\":\"lg\"}. With the call last: {\"id\":\"count\",\"component\":\"Text\",\"size\":\"lg\",\"text\":{\"@call\":\"formatString\",\"args\":{\"value\":\"${/qty} items\"}}}.",
2647
+ "Deep props close every level they open, then the component closes with its own }. An event with a context: \"onSubmit\":{\"event\":{\"name\":\"send\",\"context\":{\"email\":{\"@path\":\"/email\"}}}}} ends with }}}}} : the path, \"context\", \"event\", the prop, the component. A Table: \"rows\":[[\"Mon\",\"9°C\"],[\"Tue\",\"7°C\"]]} ends with ]]} : the last row, \"rows\", the component, and nothing more. A list item with a call: \"items\":[{\"label\":{\"@call\":\"formatString\",\"args\":{\"value\":\"${/qty} cups\"}}}]} ends with }}}]} : \"args\", the call, the item, the list, the component.",
2648
+ "Put the component name in \"component\" (never \"type\"). Put props next to it, never inside a \"props\" object.",
2649
+ "A component may take \"accessibility\":{\"label\":\"<1 to 3 words>\",\"description\":\"<what it does>\"} for screen readers: on the component it describes, when nothing visible names it. Not on every component. \"live\":\"polite\" goes only inside \"accessibility\" ({\"accessibility\":{\"live\":\"polite\"}}), only on text that changes by itself, never as a prop of the component.",
2650
+ "Use only the components, props, events, and slots in the schema. A component marked +common also takes every common prop. A component with a prop that is not in its schema, or a value outside its enum, is dropped with everything inside it, so check each prop against the schema.",
2651
+ "Give a prop a literal value, or bind it to the data model with {\"@path\":\"/x\"}. Never write {\"path\":\"/x\"} as a binding.",
2652
+ "A prop can also be a function value that updates with the data: {\"@call\":\"formatCurrency\",\"args\":{\"value\":{\"@path\":\"/total\"},\"currency\":\"EUR\"}}. Use only the functions in the schema. Write a literal when the value never changes.",
2653
+ "formatString interpolates ${...}: {\"@call\":\"formatString\",\"args\":{\"value\":\"${/qty} × ${formatCurrency(value: /price, currency: 'EUR')}\"}}. Inside ${...}, a path has no quotes, a string has single quotes, and a function takes named args.",
2654
+ "${...} is evaluated only in the value of formatString and in the item of series; in other strings it stays literal text. Inside formatString, ${...} does not support operators. For arithmetic use calc, with the values as named args: {\"@call\":\"calc\",\"args\":{\"expression\":\"seats * 29 * (annual ? 0.8 : 1)\",\"seats\":{\"@path\":\"/seats\"},\"annual\":{\"@path\":\"/annual\"}}}. Inside formatString: ${formatCurrency(value: calc(expression: 'seats * 29', seats: /seats), currency: 'USD')}. The UI then follows the user's input with no round trip.",
2655
+ "Inside ${...}, close every ( you open, and write no operators and no ?: : compute with calc. To round a computed number, round inside calc instead of wrapping it in formatNumber: ${calc(expression: 'round(servings * 0.5 * 10) / 10', servings: /servings)} cups. calc has ^ (power), sqrt, exp and ln.",
2656
+ "To show one of two texts, let calc choose: \"text\":{\"@call\":\"calc\",\"args\":{\"expression\":\"billing == 'yearly' ? 'per year' : 'per month'\",\"billing\":{\"@path\":\"/billing\"}}}.",
2657
+ "For a computed list (chart data, template items) use series. Its description under Functions in the schema gives the rules and an example. Bind the \"data\" of a Chart or the \"items\" of a List to it; a template path stays a literal path.",
2658
+ "Bind a writable prop to let the user edit it: \"value\":{\"@path\":\"/form/email\"}. The user's input goes to that path.",
2659
+ "The value of a ChoicePicker is a list of strings, also for one choice. SegmentedControl, RadioGroup and Select take one string. Option values are always strings: for a yes/no choice use \"yes\" and \"no\", not true and false.",
2660
+ "To change data, write updateDataModel with a \"path\" and a \"value\": {\"version\":\"1.0\",\"updateDataModel\":{\"surfaceId\":\"plan-picker\",\"path\":\"/seats\",\"value\":12}}. Always give \"value\".",
2661
+ "Set \"value\":null to delete the key at \"path\".",
2662
+ {
2663
+ when: ["events"],
2664
+ items: ["Give an event prop an object: {\"event\":{\"name\":\"<name>\",\"userMessage\":\"<text>\",\"context\":{...}}} or {\"functionCall\":{\"@call\":\"<function>\",\"args\":{...}}}. Never a flat {\"event\":\"<name>\"}.", "Put the action of a Button in its \"onClick\": {\"event\":{...}} to send it back to you, or {\"functionCall\":{\"@call\":\"openUrl\",\"args\":{\"url\":\"...\"}}}. Never write \"event\" or \"functionCall\" as a prop of its own."]
2665
+ },
2666
+ {
2667
+ when: ["events", "functions"],
2668
+ items: ["Use {\"functionCall\": ...} to run a function in the browser when the user clicks: an app function from the schema, or openUrl: {\"functionCall\":{\"@call\":\"openUrl\",\"args\":{\"url\":\"https://example.com\"}}}. You are not told about the call."]
2669
+ },
2670
+ {
2671
+ when: ["events", "noFunctions"],
2672
+ items: ["Use {\"functionCall\": ...} to open a URL when the user clicks: {\"functionCall\":{\"@call\":\"openUrl\",\"args\":{\"url\":\"https://example.com\"}}}. You are not told about the call."]
2673
+ },
2674
+ {
2675
+ when: ["events"],
2676
+ items: [
2677
+ "Use {\"event\": ...} to send the interaction back to you as a user message. Put the text of that message in \"userMessage\": {\"event\":{\"name\":\"choose\",\"userMessage\":\"Show me the Team plan\"}}. \"userMessage\" is plain text: ${...} is not interpolated in it; put values in \"context\".",
2678
+ "To send input values with an event, bind them in the context: \"context\":{\"email\":{\"@path\":\"/form/email\"}}.",
2679
+ "A button or other event prop without an event or functionCall does nothing."
2680
+ ]
2681
+ },
2682
+ {
2683
+ when: ["checks"],
2684
+ items: ["Validate an input with \"checks\": [{\"condition\":{\"@call\":\"email\",\"args\":{\"value\":{\"@path\":\"/form/email\"}}},\"message\":\"Enter a valid email\"}]. The check functions are required, regex, length, numeric and email; a condition can also be a boolean {\"@path\"}. A failed check shows the message under the input and disables a Button that has the same checks."]
2685
+ },
2686
+ "A prop typed componentId takes the id of another component, and a childList takes ids [\"a\",\"b\"]: \"child\":\"card\", \"children\":[\"a\",\"b\"], \"tabs\":[{\"title\":\"Specs\",\"child\":\"specs\"}].",
2687
+ {
2688
+ when: ["templates"],
2689
+ items: [
2690
+ "To repeat a component for each item of a list, give a childList a template: \"children\":{\"componentId\":\"row\",\"path\":\"/items\"}.",
2691
+ "Inside a template, paths are relative to the item (\"name\", not \"/name\").",
2692
+ "Inside a template, {\"@call\":\"@index\"} gives the position of the item, from 0. To count from 1, write {\"@call\":\"@index\",\"args\":{\"offset\":1}}."
2693
+ ]
2694
+ },
2695
+ "Updating a component replaces all of its props. Send every prop again.",
2696
+ "To change a surface in this reply, write another fence with the same surfaceId. Do not send createSurface again. The surface changes where it already is. A surface in a target can also be changed from a later reply; a chat surface cannot, because the chat is a transcript: a later reply with the same surfaceId makes a new surface.",
2697
+ "Use a new surfaceId for a different view. Never use a surfaceId again, also after the surface is deleted.",
2698
+ {
2699
+ when: ["agentCalls"],
2700
+ items: [
2701
+ "To run an app function now, with no click, write a callRendererFunction line in a fence: {\"version\":\"1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}. It needs no surface.",
2702
+ "Give every callRendererFunction a new functionCallId. Call only a function that the schema marks UI or agent, or agent only; a function with no mark is for the UI only. A function marked agent only is only for callRendererFunction: do not bind an event to it.",
2703
+ "The result of a callRendererFunction comes back to you as a developer message: {\"version\":\"1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Then you get a new turn.",
2704
+ "Do not guess the result of a callRendererFunction. Wait for the developer message."
2705
+ ]
2706
+ },
2707
+ "The schema lists the surfaces that already exist. \"dataModel\" holds the values that the user entered: read them, and do not write those paths. \"rejected\" lists operations that the client dropped: send corrected operations in a new fence for that surfaceId. \"status\":\"deleted\" means the surface is gone: never use its id again. \"status\":\"failed\" means its createSurface was rejected: send a corrected createSurface with that id.",
2708
+ "Never make a surface that is only prose. Write headings, paragraphs, lists of text, intros, and summaries as markdown outside the fences, also between two fences.",
2709
+ "Put in a fence only what markdown cannot show: charts, tables, maps, images, badges, inputs, buttons, cards with controls.",
2710
+ "Use Card only for an interactive panel (controls, a form, a configurator). Put everything else in a plain layout component.",
2711
+ "Never wrap the whole reply in a fence."
2712
+ ]
2713
+ },
2714
+ tool: {
2715
+ intro: `Call \`${GENERATIVE_UI_RENDER_TOOL}\` to show UI. Arguments: \`target\` first, then \`operations\` (A2UI v1.0 operations, applied in order).`,
2716
+ whenToShow: GENERATIVE_UI_WHEN_TO_SHOW,
2717
+ operations: [
2718
+ "{\"version\":\"1.0\",\"createSurface\":{\"surfaceId\":\"<new id>\",\"dataModel\":{...},\"components\":[{\"id\":\"root\",\"component\":\"<Name>\",\"children\":[\"<child id>\"]}]}}: the first operation of a new surface. \"dataModel\" and \"components\" are optional.",
2719
+ "{\"version\":\"1.0\",\"updateComponents\":{\"surfaceId\":\"<id>\",\"components\":[<component>, ...]}}: add or replace components by id.",
2720
+ "{\"version\":\"1.0\",\"updateDataModel\":{\"surfaceId\":\"<id>\",\"path\":\"/some/path\",\"value\":<json>}}: set the value at \"path\". Always give \"value\". \"value\":null deletes the key at \"path\".",
2721
+ "{\"version\":\"1.0\",\"deleteSurface\":{\"surfaceId\":\"<id>\"}}: remove the surface.",
2722
+ {
2723
+ when: ["agentCalls"],
2724
+ items: ["{\"version\":\"1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}: run an app function now, with no click. It needs no surface."]
2725
+ }
2726
+ ],
2727
+ rules: [
2728
+ "Components are flat objects: {\"id\":\"...\",\"component\":\"<Name>\", ...props}. Every surface renders from the component with id \"root\". Reference children by id in slot props.",
2729
+ "A component may take \"accessibility\":{\"label\":\"<1 to 3 words>\",\"description\":\"<what it does>\"} for screen readers: on the component it describes, when nothing visible names it. Not on every component, and \"live\":\"polite\" only on text that changes by itself.",
2730
+ "Stream progressively: put the initial data in \"dataModel\" and the root in \"components\" of the createSurface operation, then send one updateComponents operation per child, so the UI appears while you are still writing. The root must already list the ids of its children in its slot props (for example \"children\":[\"card-1\",\"card-2\"]), even though the children come later. A component that no slot references is never shown.",
2731
+ "Updating a component replaces all of its props, so resend every prop.",
2732
+ "Prop values are literals or data bindings {\"@path\":\"/data/path\"}. Never write {\"path\":\"/data/path\"} as a binding.",
2733
+ {
2734
+ when: ["events", "functions"],
2735
+ items: ["Event props take an action. {\"functionCall\":{\"@call\":\"<function>\",\"args\":{...}}} runs an app function in the browser immediately, and you are not told about it. {\"event\":{\"name\":\"<name>\",\"userMessage\":\"<text>\",\"context\":{...}}} sends the interaction back to you as a user message, with \"userMessage\" as its first line. \"userMessage\" is plain text: ${...} is not interpolated in it; put values in \"context\". Only call functions listed below."]
2736
+ },
2737
+ {
2738
+ when: ["events", "noFunctions"],
2739
+ items: ["Event props take an action: {\"event\":{\"name\":\"<name>\",\"userMessage\":\"<text>\",\"context\":{...}}} sends the interaction back to you as a user message, with \"userMessage\" as its first line. \"userMessage\" is plain text: ${...} is not interpolated in it; put values in \"context\"."]
2740
+ },
2741
+ "To show a different view, create a new surface with a new surfaceId (for example, a checkout form after a cart summary). Update an existing surface only when the user asks to change that same view: then do not send createSurface, use its surfaceId, and pass its existing target. Never reuse an earlier chat surface for a different view, because that replaces the earlier UI and anything the user typed into it.",
2742
+ "Never use a surfaceId again, also after deleteSurface.",
2743
+ "A prop can also be a function value that updates with the data: {\"@call\":\"formatCurrency\",\"args\":{\"value\":{\"@path\":\"/total\"},\"currency\":\"EUR\"}}. Only call functions listed below. formatString interpolates ${/path} and ${fn(arg: value)} in its value.",
2744
+ "${...} is evaluated only in the value of formatString and in the item of series; in other strings it stays literal text. Inside formatString, ${...} does not support operators. For arithmetic use calc, with the values as named args: {\"@call\":\"calc\",\"args\":{\"expression\":\"seats * 29 * (annual ? 0.8 : 1)\",\"seats\":{\"@path\":\"/seats\"},\"annual\":{\"@path\":\"/annual\"}}}.",
2745
+ "For a computed list (chart data, template items) use series. Its description under Functions gives the rules and an example.",
2746
+ {
2747
+ when: ["checks"],
2748
+ items: ["Validate an input with \"checks\": [{\"condition\":{\"@call\":\"email\",\"args\":{\"value\":{\"@path\":\"/form/email\"}}},\"message\":\"Enter a valid email\"}]. The check functions are required, regex, length, numeric and email. A failed check shows the message under the input and disables a Button that has the same checks."]
2749
+ },
2750
+ {
2751
+ when: ["templates"],
2752
+ items: ["To repeat a component for each item of a list, give a multiple slot a template: \"children\":{\"componentId\":\"row\",\"path\":\"/items\"}. Inside the template, paths are relative to the item (\"name\", not \"/name\"). {\"@call\":\"@index\"} gives the position of the item, from 0; {\"@call\":\"@index\",\"args\":{\"offset\":1}} counts from 1."]
2753
+ },
2754
+ {
2755
+ when: ["agentCalls"],
2756
+ items: ["Give every callRendererFunction a new functionCallId. Call only a function marked (UI or agent) or (agent only); a function with no mark is for the UI only. A function marked (agent only) is only for callRendererFunction: do not bind an event to it.", "The result of a callRendererFunction comes back to you in a new turn, as a developer message: {\"version\":\"1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Do not wait for the result in this reply, and do not guess it."]
2757
+ }
2758
+ ]
2759
+ },
2760
+ schema: {
2761
+ markdown: {
2762
+ notation: "lines",
2763
+ propDescriptions: true,
2764
+ commonProps: true
2765
+ },
2766
+ tool: {
2767
+ notation: "json-schema",
2768
+ propDescriptions: true,
2769
+ commonProps: false
2770
+ }
2771
+ },
2772
+ descriptions: {}
2773
+ };
2774
+ }
2775
+ /** The rules of `items` whose block conditions hold, in order. */
2776
+ function selectPromptItems(items, features) {
2777
+ return items.flatMap((item) => typeof item === "string" ? [item] : item.when.every((feature) => features[feature]) ? item.items : []);
2778
+ }
2779
+ /**
2780
+ * The prompt features of a run, from the guide features of its manifest
2781
+ * (`generativeUIGuideFeatures`).
2782
+ */
2783
+ function generativeUIPromptFeatures(guide) {
2784
+ return {
2785
+ functions: guide.functions,
2786
+ noFunctions: !guide.functions,
2787
+ events: guide.events,
2788
+ templates: guide.templates,
2789
+ checks: guide.checks,
2790
+ agentCalls: guide.functions && GENERATIVE_UI_AGENT_FUNCTION_CALLS
2791
+ };
2792
+ }
2793
+
2748
2794
  //#endregion
2749
2795
  //#region src/a2ui-prompts.ts
2750
2796
  /**
@@ -2860,12 +2906,6 @@ Design principles:
2860
2906
  action context should reference the same paths to capture user input.
2861
2907
 
2862
2908
  Use the SAME surfaceId as the main surface. Match action names to button action event names.`;
2863
- /**
2864
- * When UI helps the user, for both transports: a light nudge to reach for UI
2865
- * where it conveys the answer better than prose, and to stay in prose
2866
- * otherwise.
2867
- */
2868
- const GENERATIVE_UI_WHEN_TO_SHOW = "Show UI when it conveys the answer better than prose: to illustrate a concept (a diagram, a chart of how something changes), to compare options side by side, to let the user explore or adjust values, or to collect input. A small, focused surface next to your explanation often lands better than a long description. Reply in prose alone for a quick fact, a short answer, or conversation, and never add UI only as decoration.";
2869
2909
  /** Description of the context entry that carries `GENERATIVE_UI_MARKDOWN_GUIDELINES`. */
2870
2910
  const GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION = "Generative UI markdown guide: how to write UI surfaces inside ```a2ui code fences in a normal markdown reply.";
2871
2911
  /**
@@ -2911,6 +2951,7 @@ Use the SAME surfaceId as the main surface. Match action names to button action
2911
2951
  return Object.values(node).some(hasChildList);
2912
2952
  };
2913
2953
  return {
2954
+ components: Object.keys(manifest.components),
2914
2955
  functions: Object.keys(manifest.functions).some((name) => !isA2UIBasicFunction(name)),
2915
2956
  events: components.some((c) => {
2916
2957
  var _c$events;
@@ -2926,43 +2967,21 @@ Use the SAME surfaceId as the main surface. Match action names to button action
2926
2967
  })
2927
2968
  };
2928
2969
  }
2929
- /** The first rules of every markdown guideline, before the optional groups. */
2930
- const MARKDOWN_BASE_RULES = [
2931
- "Write explanations as normal markdown prose outside the fences.",
2932
- "Open a fence with ```a2ui to show the surface in the chat, at the place of the fence.",
2933
- "Open a fence with ```a2ui target=<id> to show the surface in a named target. Use only target ids from the schema. When a target has \"components\", its surfaces can use only those components.",
2934
- "Inside a fence, write one JSON object per line and nothing else. No comments, no trailing commas, no pretty-printing.",
2935
- "Keep each operation whole on its line.",
2936
- "Give every operation \"version\":\"v1.0\".",
2937
- `Start a surface with one createSurface. Put all the initial data in "dataModel" and the "root" component in "components". Then write the children in updateComponents lines, so that they show while you write:
2938
- \`\`\`a2ui
2939
- {"version":"v1.0","createSurface":{"surfaceId":"plan-picker","dataModel":{ ...initial data... },"components":[{"id":"root","component":"<Name>","children":["seats","pick"]}]}}
2940
- {"version":"v1.0","updateComponents":{"surfaceId":"plan-picker","components":[ ...the children... ]}}
2941
- \`\`\``,
2942
- "Keep \"dataModel\" flat: top-level keys such as \"seats\" or \"form\", never one wrapper object around everything. Check that every { and [ you open in a line is closed.",
2943
- "Every surface renders from the component with id \"root\". Make every other component reachable from \"root\" through slots.",
2944
- "Use unique ids. Do not make cycles. A component cannot be its own child.",
2945
- "Write a component as one flat object: {\"id\":\"title\",\"component\":\"<Name>\",\"text\":\"Hello\"}.",
2946
- "Put the component name in \"component\" (never \"type\"). Put props next to it, never inside a \"props\" object.",
2947
- "A component may take \"accessibility\":{\"label\":\"<1 to 3 words>\",\"description\":\"<what it does>\"} for screen readers: on the component it describes, when nothing visible names it. Not on every component, and \"live\":\"polite\" only on text that changes by itself.",
2948
- "Use only the components, props, events, and slots in the schema. A component with \"includesCommonProps\" also takes every prop in \"commonProps\".",
2949
- "Give a prop a literal value, or bind it to the data model with {\"@path\":\"/x\"}. Never write {\"path\":\"/x\"} as a binding.",
2950
- "A prop can also be a function value that updates with the data: {\"@call\":\"formatCurrency\",\"args\":{\"value\":{\"@path\":\"/total\"},\"currency\":\"EUR\"}}. Use only the functions under \"functions\" in the schema. Write a literal when the value never changes.",
2951
- "formatString interpolates ${...}: {\"@call\":\"formatString\",\"args\":{\"value\":\"${/qty} × ${formatCurrency(value: /price, currency: 'EUR')}\"}}. Inside ${...}, a path has no quotes, a string has single quotes, and a function takes named args.",
2952
- "${...} is evaluated only in the value of formatString and in the item of series; in other strings it stays literal text. Inside formatString, ${...} does not support operators. For arithmetic use calc, with the values as named args: {\"@call\":\"calc\",\"args\":{\"expression\":\"seats * 29 * (annual ? 0.8 : 1)\",\"seats\":{\"@path\":\"/seats\"},\"annual\":{\"@path\":\"/annual\"}}}. Inside formatString: ${formatCurrency(value: calc(expression: 'seats * 29', seats: /seats), currency: 'USD')}. The UI then follows the user's input with no round trip.",
2953
- "For a computed list (chart data, template items) use series. Its description under \"functions\" in the schema gives the rules and an example. Bind the \"data\" of a Chart or the \"items\" of a List to it; a template path stays a literal path.",
2954
- "Bind a writable prop to let the user edit it: \"value\":{\"@path\":\"/form/email\"}. The user's input goes to that path.",
2955
- "To change data, write updateDataModel with a \"path\" and a \"value\": {\"version\":\"v1.0\",\"updateDataModel\":{\"surfaceId\":\"plan-picker\",\"path\":\"/seats\",\"value\":12}}. Always give \"value\".",
2956
- "Set \"value\":null to delete the key at \"path\"."
2957
- ];
2958
- /** The last rules of every markdown guideline, after the optional groups. */
2959
- const MARKDOWN_CLOSING_RULES = [
2960
- "The schema lists the surfaces that already exist under \"surfaces\". \"dataModel\" holds the values that the user entered: read them, and do not write those paths. \"rejected\" lists operations that the client dropped: send corrected operations in a new fence for that surfaceId. \"status\":\"deleted\" means the surface is gone: never use its id again. \"status\":\"failed\" means its createSurface was rejected: send a corrected createSurface with that id.",
2961
- "Never make a surface that is only prose. Write headings, paragraphs, lists of text, intros, and summaries as markdown outside the fences, also between two fences.",
2962
- "Put in a fence only what markdown cannot show: charts, tables, maps, images, badges, inputs, buttons, cards with controls.",
2963
- "Use Card only for an interactive panel (controls, a form, a configurator). Put everything else in a plain layout component.",
2964
- "Never wrap the whole reply in a fence."
2965
- ];
2970
+ /**
2971
+ * Whether a guide line names only standard components (`GUIDE_COMPONENTS`,
2972
+ * also in the plural) that the catalog has. With no catalog, every line fits.
2973
+ */
2974
+ function namesOnlyCatalogComponents(catalog) {
2975
+ if (!catalog) return () => true;
2976
+ const has = new Set(catalog);
2977
+ return (line) => {
2978
+ var _line$match;
2979
+ return ((_line$match = line.match(/\b[A-Z][A-Za-z0-9]*\b/g)) !== null && _line$match !== void 0 ? _line$match : []).every((word) => {
2980
+ const name = !GUIDE_COMPONENTS.has(word) && word.endsWith("s") ? word.slice(0, -1) : word;
2981
+ return !GUIDE_COMPONENTS.has(name) || has.has(name);
2982
+ });
2983
+ };
2984
+ }
2966
2985
  /**
2967
2986
  * Builds the markdown-transport guideline. The model writes A2UI v1.0
2968
2987
  * operations inside ```a2ui fences between normal markdown prose. The rules
@@ -2970,25 +2989,15 @@ Use the SAME surfaceId as the main surface. Match action names to button action
2970
2989
  * none of them, so the guideline stays small.
2971
2990
  *
2972
2991
  * @param features - The optional rule groups to include. Defaults to all.
2992
+ * @param spec - The wording. Defaults to the prompts that ship.
2973
2993
  * @returns The guideline text, one rule per line.
2974
2994
  */
2975
- function buildGenerativeUIMarkdownGuidelines(features = ALL_GENERATIVE_UI_GUIDE_FEATURES) {
2976
- const { functions, events, templates, checks } = features;
2977
- const rules = [...MARKDOWN_BASE_RULES];
2978
- if (events) rules.push("Give an event prop an object: {\"event\":{\"name\":\"<name>\",\"userMessage\":\"<text>\",\"context\":{...}}} or {\"functionCall\":{\"@call\":\"<function>\",\"args\":{...}}}. Never a flat {\"event\":\"<name>\"}.", functions ? "Use {\"functionCall\": ...} to run a function in the browser when the user clicks: an app function from the schema, or openUrl: {\"functionCall\":{\"@call\":\"openUrl\",\"args\":{\"url\":\"https://example.com\"}}}. You are not told about the call." : "Use {\"functionCall\": ...} to open a URL when the user clicks: {\"functionCall\":{\"@call\":\"openUrl\",\"args\":{\"url\":\"https://example.com\"}}}. You are not told about the call.", "Use {\"event\": ...} to send the interaction back to you as a user message. Put the text of that message in \"userMessage\": {\"event\":{\"name\":\"choose\",\"userMessage\":\"Show me the Team plan\"}}. \"userMessage\" is plain text: ${...} is not interpolated in it; put values in \"context\".", "To send input values with an event, bind them in the context: \"context\":{\"email\":{\"@path\":\"/form/email\"}}.", "A button or other event prop without an event or functionCall does nothing.");
2979
- if (checks) rules.push("Validate an input with \"checks\": [{\"condition\":{\"@call\":\"email\",\"args\":{\"value\":{\"@path\":\"/form/email\"}}},\"message\":\"Enter a valid email\"}]. The check functions are required, regex, length, numeric and email; a condition can also be a boolean {\"@path\"}. A failed check shows the message under the input and disables a Button that has the same checks.");
2980
- rules.push("A prop typed componentId takes the id of another component, and a childList takes ids [\"a\",\"b\"]: \"child\":\"card\", \"children\":[\"a\",\"b\"], \"tabs\":[{\"title\":\"Specs\",\"child\":\"specs\"}].");
2981
- if (templates) rules.push("To repeat a component for each item of a list, give a childList a template: \"children\":{\"componentId\":\"row\",\"path\":\"/items\"}.", "Inside a template, paths are relative to the item (\"name\", not \"/name\").", "Inside a template, {\"@call\":\"@index\"} gives the position of the item, from 0. To count from 1, write {\"@call\":\"@index\",\"args\":{\"offset\":1}}.");
2982
- rules.push("Updating a component replaces all of its props. Send every prop again.", "To change a surface in this reply, write another fence with the same surfaceId. Do not send createSurface again. The surface changes where it already is. A surface in a target can also be changed from a later reply; a chat surface cannot, because the chat is a transcript: a later reply with the same surfaceId makes a new surface.", "Use a new surfaceId for a different view. Never use a surfaceId again, also after the surface is deleted.");
2983
- if (functions && GENERATIVE_UI_AGENT_FUNCTION_CALLS) rules.push("To run an app function now, with no click, write a callRendererFunction line in a fence: {\"version\":\"v1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}. It needs no surface.", "Give every callRendererFunction a new functionCallId. Call only a function from the schema with \"callers\": \"UI or agent\" or \"agent only\"; a function without \"callers\" is for the UI only. A function with \"callers\": \"agent only\" is only for callRendererFunction: do not bind an event to it.", "The result of a callRendererFunction comes back to you as a developer message: {\"version\":\"v1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Then you get a new turn.", "Do not guess the result of a callRendererFunction. Wait for the developer message.");
2984
- rules.push(...MARKDOWN_CLOSING_RULES);
2985
- return `You can show interactive UI in your reply. Write A2UI operations inside a fenced code block tagged a2ui.
2986
-
2987
- ${GENERATIVE_UI_WHEN_TO_SHOW}
2988
-
2989
- RULES
2990
- ${rules.map((rule) => `- ${rule}`).join("\n")}
2991
- `;
2995
+ function buildGenerativeUIMarkdownGuidelines(features = ALL_GENERATIVE_UI_GUIDE_FEATURES, spec = defaultGenerativeUIPromptSpec()) {
2996
+ const { intro, rules } = spec.markdown;
2997
+ const fits = namesOnlyCatalogComponents(features.components);
2998
+ const selected = selectPromptItems(rules, generativeUIPromptFeatures(features)).filter(fits);
2999
+ const whenToShow = spec.markdown.whenToShow.split("\n").filter(fits).join("\n");
3000
+ return `${intro}\n\n${whenToShow ? `${whenToShow}\n\n` : ""}RULES\n${selected.map((rule) => `- ${rule}`).join("\n")}\n`;
2992
3001
  }
2993
3002
  /**
2994
3003
  * The markdown-transport guideline with every rule group. A run sends
@@ -3016,11 +3025,11 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3016
3025
  return typeof value === "string" && value !== "";
3017
3026
  }
3018
3027
  function isRecordOf(value, isEntry) {
3019
- return isRecord(value) && Object.values(value).every(isEntry);
3028
+ return isRecord$2(value) && Object.values(value).every(isEntry);
3020
3029
  }
3021
3030
  /** A function, or an event of a component: a description and a parameter schema. */
3022
3031
  function isSchemaEntry(value) {
3023
- return isRecord(value) && isRecord(value.parameters) && isOptionalString(value.description);
3032
+ return isRecord$2(value) && isRecord$2(value.parameters) && isOptionalString(value.description);
3024
3033
  }
3025
3034
  function isSlotKind(value) {
3026
3035
  return value === "single" || value === "multiple";
@@ -3030,11 +3039,11 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3030
3039
  * so those two must have the right shape when they are there.
3031
3040
  */
3032
3041
  function isPropsSchema(value) {
3033
- return isRecord(value) && (value.properties === void 0 || isRecord(value.properties)) && (value.required === void 0 || Array.isArray(value.required) && value.required.every((name) => typeof name === "string"));
3042
+ return isRecord$2(value) && (value.properties === void 0 || isRecord$2(value.properties)) && (value.required === void 0 || Array.isArray(value.required) && value.required.every((name) => typeof name === "string"));
3034
3043
  }
3035
3044
  function isComponentManifest(value) {
3036
3045
  var _value$props$properti, _value$slots, _value$events;
3037
- if (!isRecord(value) || !isPropsSchema(value.props) || !isOptionalString(value.description) || value.events !== void 0 && !isRecordOf(value.events, isSchemaEntry) || value.slots !== void 0 && !isRecordOf(value.slots, isSlotKind)) return false;
3046
+ if (!isRecord$2(value) || !isPropsSchema(value.props) || !isOptionalString(value.description) || value.events !== void 0 && !isRecordOf(value.events, isSchemaEntry) || value.slots !== void 0 && !isRecordOf(value.slots, isSlotKind)) return false;
3038
3047
  const order = value.parameterOrder;
3039
3048
  if (order === void 0) return true;
3040
3049
  const keys = new Set([
@@ -3045,31 +3054,31 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3045
3054
  return Array.isArray(order) && new Set(order).size === order.length && order.every((key) => typeof key === "string" && keys.has(key));
3046
3055
  }
3047
3056
  function isInlineCatalog(value) {
3048
- return isRecord(value) && isNonEmptyString(value.catalogId) && value.protocolVersion === "1.0" && (value.components === void 0 || isRecordOf(value.components, isComponentManifest)) && isRecordOf(value.functions, isSchemaEntry) && isOptionalString(value.instructions);
3057
+ return isRecord$2(value) && isNonEmptyString(value.catalogId) && value.protocolVersion === "1.0" && (value.components === void 0 || isRecordOf(value.components, isComponentManifest)) && isRecordOf(value.functions, isSchemaEntry) && isOptionalString(value.instructions);
3049
3058
  }
3050
3059
  function isCapabilities(value) {
3051
- return isRecord(value) && Array.isArray(value.supportedCatalogIds) && value.supportedCatalogIds.length > 0 && value.supportedCatalogIds.every(isNonEmptyString) && (value.inlineCatalogs === void 0 || Array.isArray(value.inlineCatalogs) && value.inlineCatalogs.every(isInlineCatalog));
3060
+ return isRecord$2(value) && Array.isArray(value.supportedCatalogIds) && value.supportedCatalogIds.length > 0 && value.supportedCatalogIds.every(isNonEmptyString) && (value.inlineCatalogs === void 0 || Array.isArray(value.inlineCatalogs) && value.inlineCatalogs.every(isInlineCatalog));
3052
3061
  }
3053
3062
  /** A short list of component names. */
3054
3063
  function isComponentNameList(value) {
3055
3064
  return Array.isArray(value) && value.length <= GENERATIVE_UI_MAX_TARGET_COMPONENTS && value.every(isNonEmptyString);
3056
3065
  }
3057
3066
  function isTarget(value) {
3058
- return isRecord(value) && isNonEmptyString(value.id) && (value.kind === "chat" || value.kind === "inline") && isOptionalString(value.description) && (value.components === void 0 || isComponentNameList(value.components));
3067
+ return isRecord$2(value) && isNonEmptyString(value.id) && (value.kind === "chat" || value.kind === "inline") && isOptionalString(value.description) && (value.components === void 0 || isComponentNameList(value.components));
3059
3068
  }
3060
3069
  /** A short list of short strings. The summary limits keep the guide small. */
3061
3070
  function isRejectionList(value) {
3062
3071
  return Array.isArray(value) && value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS && value.every((entry) => typeof entry === "string" && entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH);
3063
3072
  }
3064
3073
  function isSurfaceEntry(value) {
3065
- return isRecord(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || isRecord(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed");
3074
+ return isRecord$2(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || isRecord$2(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed");
3066
3075
  }
3067
3076
  /** Checks the `copilotkit_` keys only. Other extensions can be there too. */
3068
3077
  function isExtensions(value) {
3069
- return isRecord(value) && value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT && (value.copilotkit_transport === "tool" || value.copilotkit_transport === "markdown") && Array.isArray(value.copilotkit_targets) && value.copilotkit_targets.every(isTarget) && isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) && typeof value.copilotkit_contextSent === "boolean";
3078
+ return isRecord$2(value) && value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT && (value.copilotkit_transport === "tool" || value.copilotkit_transport === "markdown") && Array.isArray(value.copilotkit_targets) && value.copilotkit_targets.every(isTarget) && isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) && typeof value.copilotkit_contextSent === "boolean";
3070
3079
  }
3071
3080
  function isEnvelope(value) {
3072
- return isRecord(value) && isCapabilities(value["v1.0"]) && isRecord(value.metadata) && isExtensions(value.metadata.extensions);
3081
+ return isRecord$2(value) && isCapabilities(value["1.0"]) && isRecord$2(value.metadata) && isExtensions(value.metadata.extensions);
3073
3082
  }
3074
3083
  /**
3075
3084
  * Reads the generative UI envelope from the `forwardedProps` of a run.
@@ -3090,9 +3099,9 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3090
3099
  * ```
3091
3100
  */
3092
3101
  function readCopilotKitUIEnvelope(forwardedProps) {
3093
- if (!isRecord(forwardedProps)) return void 0;
3102
+ if (!isRecord$2(forwardedProps)) return void 0;
3094
3103
  const namespace = forwardedProps[COPILOTKIT_FORWARDED_PROPS_KEY];
3095
- if (!isRecord(namespace)) return void 0;
3104
+ if (!isRecord$2(namespace)) return void 0;
3096
3105
  const envelope = namespace.ui;
3097
3106
  return isEnvelope(envelope) ? envelope : void 0;
3098
3107
  }
@@ -3125,7 +3134,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3125
3134
  */
3126
3135
  function envelopeToManifest(envelope) {
3127
3136
  var _catalog$components, _catalog$functions;
3128
- const { supportedCatalogIds, inlineCatalogs } = envelope["v1.0"];
3137
+ const { supportedCatalogIds, inlineCatalogs } = envelope["1.0"];
3129
3138
  const catalogId = supportedCatalogIds[0];
3130
3139
  const catalog = inlineCatalogs === null || inlineCatalogs === void 0 ? void 0 : inlineCatalogs.find((entry) => entry.catalogId === catalogId);
3131
3140
  const extensions = envelope.metadata.extensions;
@@ -3165,7 +3174,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3165
3174
  });
3166
3175
  /** Models write the v0.9 binding from habit. The reason names the v1.0 form. */
3167
3176
  const V09_PATH_REASON = "bind data with {\"@path\": \"/x\"}, not {\"path\": \"/x\"}";
3168
- function hasOwn(record, key) {
3177
+ function hasOwn$1(record, key) {
3169
3178
  return Object.prototype.hasOwnProperty.call(record, key);
3170
3179
  }
3171
3180
  /**
@@ -3173,42 +3182,42 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3173
3182
  * "toString" must not resolve to Object.prototype members.
3174
3183
  */
3175
3184
  function ownValue(record, key) {
3176
- return record && hasOwn(record, key) ? record[key] : void 0;
3185
+ return record && hasOwn$1(record, key) ? record[key] : void 0;
3177
3186
  }
3178
3187
  function getOperationKind(op) {
3179
- if (!isRecord(op)) return void 0;
3188
+ if (!isRecord$2(op)) return void 0;
3180
3189
  const kinds = OPERATION_KINDS.filter((kind) => kind in op);
3181
3190
  return kinds.length === 1 ? kinds[0] : void 0;
3182
3191
  }
3183
3192
  /** The `surfaceId` of a surface operation. `callRendererFunction` has none. */
3184
3193
  function getOperationSurfaceId(op) {
3185
- if (!isRecord(op)) return void 0;
3194
+ if (!isRecord$2(op)) return void 0;
3186
3195
  const kind = getOperationKind(op);
3187
3196
  if (!kind) return void 0;
3188
3197
  const payload = op[kind];
3189
- return isRecord(payload) && typeof payload.surfaceId === "string" ? payload.surfaceId : void 0;
3198
+ return isRecord$2(payload) && typeof payload.surfaceId === "string" ? payload.surfaceId : void 0;
3190
3199
  }
3191
3200
  /** `{ "@path": "/x" }`: a data-model binding. */
3192
3201
  function isPathBinding(value) {
3193
- return isRecord(value) && typeof value["@path"] === "string" && Object.keys(value).length === 1;
3202
+ return isRecord$2(value) && typeof value["@path"] === "string" && Object.keys(value).length === 1;
3194
3203
  }
3195
3204
  /** `{ "path": "/x" }`: the v0.9 binding, which v1.0 does not accept. */
3196
3205
  function isV09PathBinding(value) {
3197
- return isRecord(value) && typeof value.path === "string" && Object.keys(value).length === 1;
3206
+ return isRecord$2(value) && typeof value.path === "string" && Object.keys(value).length === 1;
3198
3207
  }
3199
3208
  /**
3200
3209
  * `{ "@call": "@index" }` or `{ "@call": "@index", "args": { "offset": 1 } }`:
3201
3210
  * the 0-based position of the item in a template, plus `offset`.
3202
3211
  */
3203
3212
  function isIndexCall(value) {
3204
- if (!isRecord(value) || value["@call"] !== "@index") return false;
3213
+ if (!isRecord$2(value) || value["@call"] !== "@index") return false;
3205
3214
  if (!Object.keys(value).every((key) => key === "@call" || key === "args")) return false;
3206
3215
  const { args } = value;
3207
3216
  if (args === void 0) return true;
3208
- return isRecord(args) && Object.keys(args).every((key) => key === "offset") && (args.offset === void 0 || Number.isFinite(args.offset));
3217
+ return isRecord$2(args) && Object.keys(args).every((key) => key === "offset") && (args.offset === void 0 || Number.isFinite(args.offset));
3209
3218
  }
3210
3219
  function isActionBinding(value) {
3211
- return isRecord(value) && Object.keys(value).length === 1 && (isRecord(value.functionCall) || isRecord(value.event));
3220
+ return isRecord$2(value) && Object.keys(value).length === 1 && (isRecord$2(value.functionCall) || isRecord$2(value.event));
3212
3221
  }
3213
3222
  /**
3214
3223
  * Checks one A2UI v1.0 operation against the catalog and the surfaces that
@@ -3226,7 +3235,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3226
3235
  * ```
3227
3236
  */
3228
3237
  function validateOperation(op, options) {
3229
- if (!isRecord(op)) return fail("operation must be a JSON object");
3238
+ if (!isRecord$2(op)) return fail("operation must be a JSON object");
3230
3239
  if (op.version !== A2UI_VERSION) return fail(versionProblem(op.version));
3231
3240
  const kind = getOperationKind(op);
3232
3241
  if (!kind) return fail(`operation must contain exactly one of ${OPERATION_KINDS.join(", ")}`);
@@ -3235,7 +3244,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3235
3244
  if (!GENERATIVE_UI_AGENT_FUNCTION_CALLS) return fail(GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON);
3236
3245
  return validateRendererFunctionCall(payload, options);
3237
3246
  }
3238
- if (!isRecord(payload) || typeof payload.surfaceId !== "string" || !payload.surfaceId) return fail(`${kind}.surfaceId is required`);
3247
+ if (!isRecord$2(payload) || typeof payload.surfaceId !== "string" || !payload.surfaceId) return fail(`${kind}.surfaceId is required`);
3239
3248
  const surfaceId = payload.surfaceId;
3240
3249
  if (kind === "createSurface") return validateCreateSurface(payload, surfaceId, options);
3241
3250
  if (!options.knownSurfaces.has(surfaceId)) return fail(`surface "${surfaceId}" does not exist; send createSurface first`);
@@ -3264,12 +3273,12 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3264
3273
  const catalogReason = catalogProblem(payload.catalogId, options.manifest);
3265
3274
  if (catalogReason) return fail(catalogReason);
3266
3275
  const { dataModel, components } = payload;
3267
- if (dataModel !== void 0 && !isRecord(dataModel)) return fail("createSurface.dataModel must be a JSON object");
3276
+ if (dataModel !== void 0 && !isRecord$2(dataModel)) return fail("createSurface.dataModel must be a JSON object");
3268
3277
  if (components === void 0) return OK;
3269
3278
  return validateComponents(components, "createSurface.components", options);
3270
3279
  }
3271
3280
  function validateRendererFunctionCall(payload, options) {
3272
- if (!(isRecord(payload) && typeof payload.functionCallId === "string" && payload.functionCallId !== "")) return fail("callRendererFunction.functionCallId must be a non-empty string");
3281
+ if (!(isRecord$2(payload) && typeof payload.functionCallId === "string" && payload.functionCallId !== "")) return fail("callRendererFunction.functionCallId must be a non-empty string");
3273
3282
  const reason = functionCallProblem(payload.callFunction, "callRendererFunction.callFunction", options);
3274
3283
  return reason ? fail(reason) : OK;
3275
3284
  }
@@ -3287,7 +3296,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3287
3296
  const path = (_payload$path = payload.path) !== null && _payload$path !== void 0 ? _payload$path : "/";
3288
3297
  if (typeof path !== "string" || !path.startsWith("/")) return fail("updateDataModel.path must be an absolute JSON pointer");
3289
3298
  if (path === "/") {
3290
- if (!isRecord(payload.value)) return fail("a root updateDataModel value must be a JSON object");
3299
+ if (!isRecord$2(payload.value)) return fail("a root updateDataModel value must be a JSON object");
3291
3300
  return OK;
3292
3301
  }
3293
3302
  const reason = pathProblem(path, "updateDataModel.path");
@@ -3307,7 +3316,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3307
3316
  if (!Array.isArray(components) || components.length === 0) return fail(`${label} must be a non-empty array`);
3308
3317
  const ids = /* @__PURE__ */ new Set();
3309
3318
  for (const node of components) {
3310
- if (!isRecord(node)) return fail("component must be a JSON object");
3319
+ if (!isRecord$2(node)) return fail("component must be a JSON object");
3311
3320
  const { id } = node;
3312
3321
  if (typeof id !== "string" || !id) return fail("id is required");
3313
3322
  const reason = nodeProblem(node, id, options);
@@ -3327,7 +3336,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3327
3336
  return `"${node.component}" is not allowed in target "${allowedComponents.target}"; use one of: ${names}`;
3328
3337
  }
3329
3338
  const { properties, required } = entry.props;
3330
- const propNames = isRecord(properties) ? Object.keys(properties) : [];
3339
+ const propNames = isRecord$2(properties) ? Object.keys(properties) : [];
3331
3340
  const props = Object.entries(node);
3332
3341
  for (const [key, value] of props) {
3333
3342
  if (key === "id" || key === "component") continue;
@@ -3337,7 +3346,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3337
3346
  continue;
3338
3347
  }
3339
3348
  if (key === "metadata") {
3340
- if (!(isRecord(value) && (value.extensions === void 0 || isRecord(value.extensions)))) return "metadata must be { \"extensions\": { ... } }";
3349
+ if (!(isRecord$2(value) && (value.extensions === void 0 || isRecord$2(value.extensions)))) return "metadata must be { \"extensions\": { ... } }";
3341
3350
  continue;
3342
3351
  }
3343
3352
  if (key === "accessibility") {
@@ -3385,7 +3394,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3385
3394
  * values, `hidden` is a boolean or a dynamic value.
3386
3395
  */
3387
3396
  function accessibilityProblem(value) {
3388
- if (!isRecord(value)) return "must be { \"label\": \"...\", \"description\": \"...\", \"live\": \"polite\", \"hidden\": false }";
3397
+ if (!isRecord$2(value)) return "must be { \"label\": \"...\", \"description\": \"...\", \"live\": \"polite\", \"hidden\": false }";
3389
3398
  const isDynamic = (field) => isPathBinding(field) || isCallBinding(field);
3390
3399
  for (const [key, field] of Object.entries(value)) {
3391
3400
  if (!ACCESSIBILITY_KEYS.includes(key)) return `unknown key "${key}"`;
@@ -3403,7 +3412,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3403
3412
  }
3404
3413
  }
3405
3414
  function actionBindingProblem(value, options) {
3406
- if (!isRecord(value)) return "must be an action object";
3415
+ if (!isRecord$2(value)) return "must be an action object";
3407
3416
  const keys = Object.keys(value);
3408
3417
  if (!(keys.length === 1 && (keys[0] === "functionCall" || keys[0] === "event"))) return "must be { \"event\": ... } or { \"functionCall\": ... }";
3409
3418
  if (keys[0] === "functionCall") return functionCallProblem(value.functionCall, "functionCall", options);
@@ -3414,18 +3423,18 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3414
3423
  * field in the reason.
3415
3424
  */
3416
3425
  function functionCallProblem(call, label, options) {
3417
- if (!isRecord(call)) return `${label} must be { "@call": "<function>", "args": { ... } }`;
3426
+ if (!isRecord$2(call)) return `${label} must be { "@call": "<function>", "args": { ... } }`;
3418
3427
  const name = call["@call"];
3419
3428
  if (typeof name !== "string" || !name) return typeof call.call === "string" ? `${label} names the function with "@call", not "call"` : `${label}["@call"] must be a function name`;
3420
3429
  const { args } = call;
3421
- if (args !== void 0 && !isRecord(args)) return `${label}.args must be an object`;
3430
+ if (args !== void 0 && !isRecord$2(args)) return `${label}.args must be an object`;
3422
3431
  const catalogReason = catalogProblem(call.catalogId, options.manifest);
3423
3432
  if (catalogReason) return `${label}: ${catalogReason}`;
3424
3433
  const argEntries = Object.entries(args !== null && args !== void 0 ? args : {});
3425
3434
  for (const [key, arg] of argEntries) if (isV09PathBinding(arg)) return `${label}.args.${key}: ${V09_PATH_REASON}`;
3426
3435
  const appFunctions = options.functions;
3427
- const declared = appFunctions !== void 0 && hasOwn(appFunctions, name) ? appFunctions[name] : void 0;
3428
- const builtIn = declared === void 0 && hasOwn(GENERATIVE_UI_FUNCTIONS, name) ? GENERATIVE_UI_FUNCTIONS[name] : void 0;
3436
+ const declared = appFunctions !== void 0 && hasOwn$1(appFunctions, name) ? appFunctions[name] : void 0;
3437
+ const builtIn = declared === void 0 && hasOwn$1(GENERATIVE_UI_FUNCTIONS, name) ? GENERATIVE_UI_FUNCTIONS[name] : void 0;
3429
3438
  if (declared === void 0 && builtIn === void 0) return appFunctions === void 0 ? void 0 : `function "${name}" is not exposed to generative UI`;
3430
3439
  if (declared === void 0 && appFunctions === void 0) return void 0;
3431
3440
  return callerProblem(name, declared !== null && declared !== void 0 ? declared : builtIn, label.startsWith("callRendererFunction") ? "agent" : "renderer");
@@ -3441,11 +3450,11 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3441
3450
  if (caller === "renderer" && !callers.renderer) return `function "${name}" runs only for the agent (allowedCallers "agentOnly"); the UI cannot call it`;
3442
3451
  }
3443
3452
  function eventProblem(event) {
3444
- if (!isRecord(event) || typeof event.name !== "string" || !event.name) return "event.name is required";
3453
+ if (!isRecord$2(event) || typeof event.name !== "string" || !event.name) return "event.name is required";
3445
3454
  const { userMessage, context } = event;
3446
- if (!(userMessage === void 0 || typeof userMessage === "string" || isPathBinding(userMessage) || isRecord(userMessage) && typeof userMessage["@call"] === "string" && findForbiddenCall(userMessage, { allowValueFunctions: true }) === void 0)) return isV09PathBinding(userMessage) ? `event.userMessage: ${V09_PATH_REASON}` : "event.userMessage must be a string, {\"@path\": \"/x\"} or a function value";
3455
+ if (!(userMessage === void 0 || typeof userMessage === "string" || isPathBinding(userMessage) || isRecord$2(userMessage) && typeof userMessage["@call"] === "string" && findForbiddenCall(userMessage, { allowValueFunctions: true }) === void 0)) return isV09PathBinding(userMessage) ? `event.userMessage: ${V09_PATH_REASON}` : "event.userMessage must be a string, {\"@path\": \"/x\"} or a function value";
3447
3456
  if (context === void 0) return void 0;
3448
- if (!isRecord(context)) return "event.context must be an object";
3457
+ if (!isRecord$2(context)) return "event.context must be an object";
3449
3458
  const entries = Object.entries(context);
3450
3459
  for (const [key, entry] of entries) {
3451
3460
  if (isV09PathBinding(entry)) return `event.context.${key}: ${V09_PATH_REASON}`;
@@ -3454,7 +3463,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3454
3463
  }
3455
3464
  }
3456
3465
  function slotProblem(value, kind, ownId) {
3457
- const isTemplate = isRecord(value) && "componentId" in value;
3466
+ const isTemplate = isRecord$2(value) && "componentId" in value;
3458
3467
  if (kind === "single" && isTemplate) return "a template { \"componentId\", \"path\" } is only allowed in a \"multiple\" slot";
3459
3468
  if (kind === "multiple" && isTemplate) return templateProblem(value, ownId);
3460
3469
  if (kind === "multiple" && !Array.isArray(value)) return "must be an array of component ids or a template { \"componentId\", \"path\" }";
@@ -3488,7 +3497,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3488
3497
  }
3489
3498
  return;
3490
3499
  }
3491
- if (!isRecord(value)) return void 0;
3500
+ if (!isRecord$2(value)) return void 0;
3492
3501
  if (isIndexCall(value)) return void 0;
3493
3502
  if (value["@call"] === "@index") return "@index takes only an offset";
3494
3503
  if (typeof value.call === "string") return "name the function with \"@call\", not \"call\"";
@@ -3497,7 +3506,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3497
3506
  if (typeof name === "string") {
3498
3507
  if (!options.allowValueFunctions || !isA2UIValueFunction(name)) return isA2UIBasicFunction(name) ? `"${name}" runs only from an event` : `"${name}" is not a basic function`;
3499
3508
  const args = value.args;
3500
- if (args !== void 0 && !isRecord(args)) return `the args of "${name}" must be an object`;
3509
+ if (args !== void 0 && !isRecord$2(args)) return `the args of "${name}" must be an object`;
3501
3510
  return args === void 0 ? void 0 : findForbiddenCall(args, options);
3502
3511
  }
3503
3512
  for (const item of Object.values(value)) {
@@ -3522,14 +3531,14 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3522
3531
  */
3523
3532
  function childRefProblem(node, ref, ownId) {
3524
3533
  const label = ref.path.filter((step) => step !== "*").join(".");
3525
- const isDynamic = (value) => isPathBinding(value) || isRecord(value) && "@call" in value;
3534
+ const isDynamic = (value) => isPathBinding(value) || isRecord$2(value) && "@call" in value;
3526
3535
  const visit = (value, steps) => {
3527
3536
  if (isDynamic(value)) return void 0;
3528
- if (steps.length === 0) {
3537
+ const [head, ...rest] = steps;
3538
+ if (head === void 0) {
3529
3539
  const reason = slotProblem(value, ref.kind, ownId);
3530
3540
  return reason ? `${label}: ${reason}` : void 0;
3531
3541
  }
3532
- const [head, ...rest] = steps;
3533
3542
  if (head === "*") {
3534
3543
  if (!Array.isArray(value)) return void 0;
3535
3544
  for (const item of value) {
@@ -3538,7 +3547,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3538
3547
  }
3539
3548
  return;
3540
3549
  }
3541
- if (!isRecord(value) || !hasOwn(value, head)) return void 0;
3550
+ if (!isRecord$2(value) || !hasOwn$1(value, head)) return void 0;
3542
3551
  return visit(value[head], rest);
3543
3552
  };
3544
3553
  return visit(node, ref.path);
@@ -3643,6 +3652,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3643
3652
  expectingValue = false;
3644
3653
  }
3645
3654
  break;
3655
+ case void 0: break;
3646
3656
  }
3647
3657
  }
3648
3658
  this.inString = inString;
@@ -3662,7 +3672,7 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3662
3672
  function parseObject(raw) {
3663
3673
  try {
3664
3674
  const value = JSON.parse(raw);
3665
- return isRecord(value) ? value : null;
3675
+ return isRecord$2(value) ? value : null;
3666
3676
  } catch (_unused3) {
3667
3677
  return null;
3668
3678
  }
@@ -3699,6 +3709,434 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3699
3709
  }
3700
3710
  };
3701
3711
 
3712
+ //#endregion
3713
+ //#region src/generative-ui/compact-schema.ts
3714
+ /** Objects nested deeper than this show as `object`. */
3715
+ const MAX_OBJECT_DEPTH = 2;
3716
+ /** A prop must appear verbatim in at least this many components to be hoisted. */
3717
+ const COMMON_PROP_MIN_COMPONENTS = 8;
3718
+ function isRecord$1(value) {
3719
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3720
+ }
3721
+ /** A JSON Schema of a list of schemas (`anyOf`, `oneOf`), else an empty list. */
3722
+ function schemaList(value) {
3723
+ return Array.isArray(value) ? value.filter(isRecord$1) : [];
3724
+ }
3725
+ /**
3726
+ * Puts a top-level union in parentheses, so that `[]` applies to all of
3727
+ * it. A union inside braces needs none.
3728
+ */
3729
+ function asArrayItem(type) {
3730
+ let outside = type;
3731
+ for (let inner = outside.replace(/\{[^{}]*\}/g, ""); inner !== outside;) {
3732
+ outside = inner;
3733
+ inner = outside.replace(/\{[^{}]*\}/g, "");
3734
+ }
3735
+ return outside.includes(" | ") ? `(${type})[]` : `${type}[]`;
3736
+ }
3737
+ /**
3738
+ * A JSON Schema as a short TypeScript-like type, for example
3739
+ * `{ label: string; size?: "sm" | "md" }`.
3740
+ */
3741
+ function compactType(schema, depth) {
3742
+ const ref = childRefKind(schema);
3743
+ if (ref === "single") return "componentId";
3744
+ if (ref === "multiple") return "componentId[] | { componentId: string; path: string }";
3745
+ if ("const" in schema) return JSON.stringify(schema.const);
3746
+ if (Array.isArray(schema.enum)) return schema.enum.map((value) => JSON.stringify(value)).join(" | ");
3747
+ const variants = [...schemaList(schema.anyOf), ...schemaList(schema.oneOf)];
3748
+ if (variants.length > 0) return variants.map((variant) => compactType(variant, depth)).join(" | ");
3749
+ return (Array.isArray(schema.type) ? schema.type : [schema.type]).map((type) => {
3750
+ switch (type) {
3751
+ case "string":
3752
+ case "boolean":
3753
+ case "null": return type;
3754
+ case "number":
3755
+ case "integer": return "number";
3756
+ case "array": return isRecord$1(schema.items) ? asArrayItem(compactType(schema.items, depth)) : "unknown[]";
3757
+ case "object": return compactObject(schema, depth);
3758
+ default: return "unknown";
3759
+ }
3760
+ }).join(" | ");
3761
+ }
3762
+ /** An object schema as `{ key: type; other?: type }`. */
3763
+ function compactObject(schema, depth) {
3764
+ const properties = isRecord$1(schema.properties) ? schema.properties : {};
3765
+ const entries = Object.entries(properties);
3766
+ if (entries.length === 0) return isRecord$1(schema.additionalProperties) ? `Record<string, ${compactType(schema.additionalProperties, depth + 1)}>` : "object";
3767
+ if (depth >= MAX_OBJECT_DEPTH) return "object";
3768
+ const required = Array.isArray(schema.required) ? schema.required : [];
3769
+ return `{ ${entries.map(([key, value]) => {
3770
+ const type = isRecord$1(value) ? compactType(value, depth + 1) : "unknown";
3771
+ return `${key}${required.includes(key) ? "" : "?"}: ${type}`;
3772
+ }).join("; ")} }`;
3773
+ }
3774
+ /** A schema as its type, with its description after `//`. */
3775
+ function describedType(schema, depth) {
3776
+ const type = compactType(schema, depth);
3777
+ return typeof schema.description === "string" ? `${type} // ${schema.description}` : type;
3778
+ }
3779
+ /**
3780
+ * The props of a component: `{ "label": "string", "size?": "..." }`. With
3781
+ * `descriptions`, each type carries its description after `//`.
3782
+ */
3783
+ function compactProps(schema, descriptions = true) {
3784
+ const properties = isRecord$1(schema.properties) ? schema.properties : {};
3785
+ const required = Array.isArray(schema.required) ? schema.required : [];
3786
+ const props = {};
3787
+ for (const [key, value] of Object.entries(properties)) {
3788
+ if (!isRecord$1(value)) continue;
3789
+ const name = required.includes(key) ? key : `${key}?`;
3790
+ props[name] = descriptions ? describedType(value, 1) : compactType(value, 1);
3791
+ }
3792
+ return props;
3793
+ }
3794
+ /**
3795
+ * The prop set worth listing once. Candidates are (key, type) pairs that at
3796
+ * least {@link COMMON_PROP_MIN_COMPONENTS} components carry verbatim. The
3797
+ * candidate subset of each component is a possible common set, scored by
3798
+ * the characters it saves (set size times the components that contain all
3799
+ * of it). `undefined` when no set is shared by enough components.
3800
+ */
3801
+ function findCommonProps(propsList) {
3802
+ const pairKey = (key, type) => `${key}\u0000${type}`;
3803
+ const counts = /* @__PURE__ */ new Map();
3804
+ for (const props of propsList) for (const [key, type] of Object.entries(props)) {
3805
+ var _counts$get;
3806
+ const id = pairKey(key, type);
3807
+ counts.set(id, ((_counts$get = counts.get(id)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1);
3808
+ }
3809
+ let best;
3810
+ let bestScore = 0;
3811
+ const seen = /* @__PURE__ */ new Set();
3812
+ for (const props of propsList) {
3813
+ const subset = Object.entries(props).filter(([key, type]) => {
3814
+ var _counts$get2;
3815
+ return ((_counts$get2 = counts.get(pairKey(key, type))) !== null && _counts$get2 !== void 0 ? _counts$get2 : 0) >= COMMON_PROP_MIN_COMPONENTS;
3816
+ });
3817
+ if (subset.length < 2) continue;
3818
+ const signature = subset.map(([key, type]) => pairKey(key, type)).join("\n");
3819
+ if (seen.has(signature)) continue;
3820
+ seen.add(signature);
3821
+ const members = propsList.filter((other) => subset.every(([key, type]) => other[key] === type)).length;
3822
+ if (members < COMMON_PROP_MIN_COMPONENTS) continue;
3823
+ const score = subset.reduce((total, [key, type]) => total + key.length + type.length, 0) * (members - 1);
3824
+ if (score > bestScore) {
3825
+ bestScore = score;
3826
+ best = Object.fromEntries(subset);
3827
+ }
3828
+ }
3829
+ return best;
3830
+ }
3831
+ /**
3832
+ * The component schema of the markdown transport, from the per-run
3833
+ * manifest. It is smaller than the manifest: each prop is one short type,
3834
+ * and the props that many components share verbatim (the layout props of
3835
+ * the containers) are listed once in `commonProps`; a component that takes
3836
+ * them is flagged `includesCommonProps`.
3837
+ * It has the catalog id, the targets with their descriptions and their
3838
+ * component lists, the functions with their parameters, the components
3839
+ * with their props, events and slots, and the surfaces of the thread. A surface lists the
3840
+ * values that the user set and the operations that the client dropped.
3841
+ *
3842
+ * @param manifest - The manifest from `buildGenerativeUIManifest`.
3843
+ * @param options - `propDescriptions` (default true) writes each prop's
3844
+ * description; `commonProps` (default true) lists shared props once.
3845
+ * @returns A JSON-ready object.
3846
+ *
3847
+ * @example
3848
+ * ```ts
3849
+ * const value = JSON.stringify(
3850
+ * buildCompactGenerativeUISchema(buildGenerativeUIManifest(runtime, threadId)),
3851
+ * );
3852
+ * ```
3853
+ */
3854
+ function buildCompactGenerativeUISchema(manifest, options = {}) {
3855
+ const { propDescriptions = true, commonProps = true } = options;
3856
+ const components = {};
3857
+ for (const [name, component] of Object.entries(manifest.components)) {
3858
+ var _component$events;
3859
+ const events = Object.entries((_component$events = component.events) !== null && _component$events !== void 0 ? _component$events : {}).map(([event, definition]) => {
3860
+ var _definition$descripti;
3861
+ return [event, (_definition$descripti = definition.description) !== null && _definition$descripti !== void 0 ? _definition$descripti : compactType(definition.parameters, 0)];
3862
+ });
3863
+ components[name] = {
3864
+ ...component.description ? { description: component.description } : {},
3865
+ props: compactProps(component.props, propDescriptions),
3866
+ ...events.length > 0 ? { events: Object.fromEntries(events) } : {},
3867
+ ...component.slots ? { slots: component.slots } : {}
3868
+ };
3869
+ }
3870
+ const common = commonProps ? findCommonProps(Object.values(components).map((component) => component.props)) : void 0;
3871
+ if (common) {
3872
+ const commonKeys = Object.keys(common);
3873
+ for (const component of Object.values(components)) {
3874
+ if (!commonKeys.every((key) => component.props[key] === common[key])) continue;
3875
+ component.includesCommonProps = true;
3876
+ component.props = Object.fromEntries(Object.entries(component.props).filter(([key]) => !(key in common)));
3877
+ }
3878
+ }
3879
+ const functions = Object.fromEntries(Object.entries(manifest.functions).map(([name, fn]) => {
3880
+ const signature = fn.parameters.description;
3881
+ const hasSignature = typeof signature === "string" && signature.startsWith("{") && Object.keys(fn.parameters).length === 2;
3882
+ const callers = functionCallers(fn);
3883
+ return [name, {
3884
+ ...fn.description ? { description: fn.description } : {},
3885
+ parameters: hasSignature ? signature : compactType(fn.parameters, 0),
3886
+ ...callers.agent && GENERATIVE_UI_AGENT_FUNCTION_CALLS ? { callers: callers.renderer ? "UI or agent" : "agent only" } : {}
3887
+ }];
3888
+ }));
3889
+ return {
3890
+ catalogId: manifest.catalogId,
3891
+ targets: manifest.targets,
3892
+ functions,
3893
+ ...common ? { commonProps: common } : {},
3894
+ components,
3895
+ surfaces: manifest.surfaces
3896
+ };
3897
+ }
3898
+
3899
+ //#endregion
3900
+ //#region src/generative-ui/schema-render.ts
3901
+ /** An own key (shared compiles to ES2017, which has no Object.hasOwn). */
3902
+ const hasOwn = (target, key) => Object.prototype.hasOwnProperty.call(target, key);
3903
+ function isRecord(value) {
3904
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3905
+ }
3906
+ /** The props schema without the description of each prop. */
3907
+ function withoutPropDescriptions(schema) {
3908
+ if (!isRecord(schema.properties)) return schema;
3909
+ return {
3910
+ ...schema,
3911
+ properties: Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => {
3912
+ if (!isRecord(value)) return [key, value];
3913
+ const { description: _description, ...rest } = value;
3914
+ return [key, rest];
3915
+ }))
3916
+ };
3917
+ }
3918
+ /** The short signature of a function: its built-in signature, or its schema made short. */
3919
+ function functionSignature(fn) {
3920
+ const signature = fn.parameters.description;
3921
+ return typeof signature === "string" && signature.startsWith("{") && Object.keys(fn.parameters).length === 2 ? signature : compactType(fn.parameters, 0);
3922
+ }
3923
+ /**
3924
+ * A function name with its parameters: `pick{ id: string }`, `clearCart{}`
3925
+ * for no arguments, `setVolume(number)` for a parameter that is not an object.
3926
+ */
3927
+ function nameWithParameters(name, parameters) {
3928
+ if (parameters.startsWith("{")) return `${name}${parameters}`;
3929
+ if (parameters === "object") return `${name}{}`;
3930
+ return `${name}(${parameters})`;
3931
+ }
3932
+ /**
3933
+ * One component as a TypeScript-like signature line, with its events and
3934
+ * slots on the lines below:
3935
+ * `- Text(text?: string // The text): Shows text`.
3936
+ */
3937
+ function signatureLines(name, component, settings) {
3938
+ var _component$events, _component$slots;
3939
+ const lines = [`- ${name}(${Object.entries(compactProps(component.props, settings.propDescriptions)).map(([key, type]) => `${key}: ${type}`).join(", ")})${component.description ? `: ${oneLine(component.description)}` : ""}`];
3940
+ const events = Object.entries((_component$events = component.events) !== null && _component$events !== void 0 ? _component$events : {}).map(([event, definition]) => `${event}(${definition.description ? oneLine(definition.description) : compactType(definition.parameters, 0)})`);
3941
+ if (events.length > 0) lines.push(` events: ${events.join(", ")}`);
3942
+ const slots = Object.entries((_component$slots = component.slots) !== null && _component$slots !== void 0 ? _component$slots : {}).map(([slot, kind]) => `${slot} (${kind})`);
3943
+ if (slots.length > 0) lines.push(` slots: ${slots.join(", ")}`);
3944
+ return lines;
3945
+ }
3946
+ /** The whole schema as signature text: targets, functions, components, surfaces. */
3947
+ function signatureSchema(manifest, settings) {
3948
+ const targets = manifest.targets.map((t) => {
3949
+ const limit = t.components ? `; only ${t.components.join(", ")}` : "";
3950
+ return `- ${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : ""}`;
3951
+ });
3952
+ const functions = Object.entries(manifest.functions).map(([name, fn]) => {
3953
+ const callers = functionCallers(fn);
3954
+ const who = callers.agent && GENERATIVE_UI_AGENT_FUNCTION_CALLS ? callers.renderer ? " (UI or agent)" : " (agent only)" : "";
3955
+ return `- ${nameWithParameters(name, functionSignature(fn))}${who}${fn.description ? `: ${oneLine(fn.description)}` : ""}`;
3956
+ });
3957
+ const components = Object.entries(manifest.components).flatMap(([name, component]) => signatureLines(name, component, settings));
3958
+ const surfaces = Object.entries(manifest.surfaces).map(([id, s]) => {
3959
+ var _s$rejected;
3960
+ return `- ${id} (target ${s.target})${s.status ? ` status: ${s.status}` : ""}${s.dataModel ? ` user values: ${JSON.stringify(s.dataModel)}` : ""}${((_s$rejected = s.rejected) !== null && _s$rejected !== void 0 ? _s$rejected : []).map((r) => ` rejected: ${r}`).join("")}`;
3961
+ });
3962
+ return [
3963
+ `Catalog: ${manifest.catalogId}`,
3964
+ `Targets:\n${targets.join("\n") || "- none"}`,
3965
+ `Functions:\n${functions.join("\n") || "- none"}`,
3966
+ `Components:\n${components.join("\n") || "- none"}`,
3967
+ `Surfaces:\n${surfaces.join("\n") || "- none"}`
3968
+ ].join("\n\n");
3969
+ }
3970
+ /** A description on one line, so its lines cannot read as new entries. */
3971
+ function oneLine(text) {
3972
+ return text.replace(/\s*\n\s*/g, " ");
3973
+ }
3974
+ /** Values that would read as a type or a number once their quotes are gone. */
3975
+ const AMBIGUOUS_VALUE = /^(?:string|number|integer|boolean|true|false|null|object|array|unknown|any|-?\d[\d.]*)$/;
3976
+ /**
3977
+ * A compact type with bare enum values and tight unions:
3978
+ * `"sm" | "md" | "lg"` becomes `sm|md|lg`. A union keeps its quotes when it
3979
+ * also holds a type (`"sm" | number`) or a value that reads as a type or a
3980
+ * number (`"number" | "currency"`, `"1" | "2"`), and so do values that are
3981
+ * not plain words.
3982
+ */
3983
+ function bareType(type) {
3984
+ return type.replace(/"[A-Za-z0-9_#%.-]+"(?: \| "[A-Za-z0-9_#%.-]+")*(?! \|)/g, (union, offset, whole) => {
3985
+ if (whole.slice(offset - 2, offset) === "| ") return union;
3986
+ const values = union.split(" | ").map((v) => v.slice(1, -1));
3987
+ if (values.some((v) => AMBIGUOUS_VALUE.test(v))) return union;
3988
+ return values.join("|");
3989
+ }).replace(/ \| /g, "|");
3990
+ }
3991
+ /** A compact prop (`type // description`) as `name: type - description`. */
3992
+ function propLine(key, value) {
3993
+ const name = key.endsWith("?") ? key.slice(0, -1) : `${key}*`;
3994
+ const cut = value.indexOf(" // ");
3995
+ const type = bareType(cut < 0 ? value : value.slice(0, cut));
3996
+ const text = cut < 0 ? "" : value.slice(cut + 4).trim();
3997
+ return ` ${name}: ${type}${text ? ` - ${oneLine(text)}` : ""}`;
3998
+ }
3999
+ /**
4000
+ * The whole schema as plain lines: a header line per component and one
4001
+ * indented line per prop: events are `action` props and slots `componentId`
4002
+ * or `childList` props. Props are optional unless marked `*`, enum values
4003
+ * are bare, and the common props are listed once. It carries the same names, types and descriptions as
4004
+ * `compact`, in fewer tokens.
4005
+ */
4006
+ function linesSchema(manifest, settings) {
4007
+ const compact = buildCompactGenerativeUISchema(manifest, {
4008
+ propDescriptions: settings.propDescriptions,
4009
+ commonProps: settings.commonProps
4010
+ });
4011
+ const targets = compact.targets.map((t) => {
4012
+ const limit = t.components ? `, only ${t.components.join(", ")}` : "";
4013
+ return `${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : ""}`;
4014
+ }).join("; ");
4015
+ const functions = Object.entries(compact.functions).map(([name, fn]) => `${nameWithParameters(name, fn.parameters)}${"callers" in fn ? ` (${fn.callers})` : ""}${fn.description ? `: ${oneLine(fn.description)}` : ""}`);
4016
+ const common = compact.commonProps ? Object.entries(compact.commonProps).map(([k, v]) => propLine(k, v)) : [];
4017
+ const components = Object.entries(compact.components).map(([name, c]) => {
4018
+ var _c$events;
4019
+ return {
4020
+ name,
4021
+ c,
4022
+ own: [...Object.entries(c.props).map(([k, v]) => propLine(k, v)), ...Object.entries((_c$events = c.events) !== null && _c$events !== void 0 ? _c$events : {}).map(([e, d]) => ` ${e}: action - ${oneLine(d)}`)]
4023
+ };
4024
+ }).flatMap(({ name, c, own }) => {
4025
+ var _c$slots;
4026
+ const lines = [`${name}${c.includesCommonProps ? " +common" : ""}${c.description ? `: ${oneLine(c.description)}` : ""}`, ...own];
4027
+ for (const [slot, kind] of Object.entries((_c$slots = c.slots) !== null && _c$slots !== void 0 ? _c$slots : {})) lines.push(` ${slot}: ${kind === "single" ? "componentId" : "childList"}`);
4028
+ return lines;
4029
+ });
4030
+ const surfaces = Object.keys(compact.surfaces).length ? JSON.stringify(compact.surfaces) : "none";
4031
+ return [
4032
+ `Catalog ${compact.catalogId}. Targets: ${targets || "none"}`,
4033
+ "Props are optional unless marked *. a|b|c is one of those strings, quoted when one reads as a type or a number. A component marked +common also takes every common prop. A prop of type action is an event prop: give it {\"event\":{...}} or {\"functionCall\":{...}}. A componentId prop takes one component id; a childList prop takes a list of ids or a template.",
4034
+ `Functions:\n${functions.join("\n")}`,
4035
+ ...common.length ? [`Common props:\n${common.join("\n")}`] : [],
4036
+ `Components:\n${components.join("\n")}`,
4037
+ `Surfaces: ${surfaces}`
4038
+ ].join("\n\n");
4039
+ }
4040
+ /**
4041
+ * The component schema of the markdown transport, as the text of its
4042
+ * context entry, in the notation of `settings`. `compact` is the schema that
4043
+ * ships (`buildCompactGenerativeUISchema`), `json-schema` the manifest parts
4044
+ * as JSON, `ts-signature` one line per component, `lines` one line per
4045
+ * prop with bare enums (the fewest tokens).
4046
+ *
4047
+ * @example
4048
+ * ```ts
4049
+ * const value = renderGenerativeUISchema(manifest, spec.schema.markdown);
4050
+ * ```
4051
+ */
4052
+ function renderGenerativeUISchema(manifest, settings) {
4053
+ switch (settings.notation) {
4054
+ case "compact": return JSON.stringify(buildCompactGenerativeUISchema(manifest, {
4055
+ propDescriptions: settings.propDescriptions,
4056
+ commonProps: settings.commonProps
4057
+ }));
4058
+ case "json-schema": {
4059
+ const components = Object.fromEntries(Object.entries(manifest.components).map(([name, c]) => [name, settings.propDescriptions ? c : {
4060
+ ...c,
4061
+ props: withoutPropDescriptions(c.props)
4062
+ }]));
4063
+ return JSON.stringify({
4064
+ catalogId: manifest.catalogId,
4065
+ targets: manifest.targets,
4066
+ functions: manifest.functions,
4067
+ components,
4068
+ surfaces: manifest.surfaces
4069
+ });
4070
+ }
4071
+ case "ts-signature": return signatureSchema(manifest, settings);
4072
+ case "lines": return linesSchema(manifest, settings);
4073
+ }
4074
+ }
4075
+ /**
4076
+ * The component list of the tool guide, one entry per component, in the
4077
+ * notation of `settings`. `json-schema` is the list that ships.
4078
+ */
4079
+ function renderGenerativeUIComponentList(components, settings) {
4080
+ return Object.entries(components).map(([name, c]) => {
4081
+ if (settings.notation === "ts-signature" || settings.notation === "lines") return signatureLines(name, c, settings).join("\n");
4082
+ const props = settings.notation === "compact" ? compactProps(c.props, settings.propDescriptions) : settings.propDescriptions ? c.props : withoutPropDescriptions(c.props);
4083
+ const lines = [`- **${name}**${c.description ? `: ${oneLine(c.description)}` : ""}`, ` props: ${JSON.stringify(props)}`];
4084
+ if (c.events) lines.push(` event props: ${JSON.stringify(c.events)}`);
4085
+ if (c.slots) lines.push(` slot props (component ids): ${JSON.stringify(c.slots)}`);
4086
+ return lines.join("\n");
4087
+ }).join("\n");
4088
+ }
4089
+ /**
4090
+ * The manifest with replaced descriptions: `"Name"` replaces the
4091
+ * description of a component, `"Name.prop"` the description of one of its
4092
+ * props. Keys that name no component or prop are left out of the result
4093
+ * and listed in `unknown`. The manifest is not changed.
4094
+ */
4095
+ function applyDescriptionOverrides(manifest, overrides) {
4096
+ const components = structuredClone(manifest.components);
4097
+ const unknown = [];
4098
+ for (const [key, description] of Object.entries(overrides)) {
4099
+ const [name, prop, ...rest] = key.split(".");
4100
+ const component = name !== void 0 && hasOwn(components, name) ? components[name] : void 0;
4101
+ if (!component || rest.length > 0) {
4102
+ unknown.push(key);
4103
+ continue;
4104
+ }
4105
+ if (prop === void 0) {
4106
+ component.description = description;
4107
+ continue;
4108
+ }
4109
+ const properties = component.props.properties;
4110
+ const property = isRecord(properties) && hasOwn(properties, prop) ? properties[prop] : void 0;
4111
+ if (!isRecord(property)) {
4112
+ unknown.push(key);
4113
+ continue;
4114
+ }
4115
+ property.description = description;
4116
+ }
4117
+ return {
4118
+ manifest: {
4119
+ ...manifest,
4120
+ components
4121
+ },
4122
+ unknown
4123
+ };
4124
+ }
4125
+ /**
4126
+ * The components and props of `manifest` whose names do not appear in
4127
+ * `rendered`. A schema notation that leaves one out would hide part of the
4128
+ * catalog from the model.
4129
+ */
4130
+ function schemaCoverage(manifest, rendered) {
4131
+ const missing = [];
4132
+ for (const [name, component] of Object.entries(manifest.components)) {
4133
+ if (!rendered.includes(name)) missing.push(name);
4134
+ const properties = isRecord(component.props.properties) ? component.props.properties : {};
4135
+ for (const prop of Object.keys(properties)) if (!rendered.includes(prop)) missing.push(`${name}.${prop}`);
4136
+ }
4137
+ return { missing };
4138
+ }
4139
+
3702
4140
  //#endregion
3703
4141
  //#region src/generative-ui/prompt.ts
3704
4142
  const GENERATIVE_UI_CONTEXT_DESCRIPTION = "Generative UI guide: available components, functions, targets, and how to call render_ui.";
@@ -3713,19 +4151,15 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3713
4151
  * the `render_ui` rules, the targets, components, functions, and surfaces of
3714
4152
  * the manifest. It is in shared so that the inspector shows the same text.
3715
4153
  */
3716
- function buildGenerativeUIPrompt(manifest) {
4154
+ function buildGenerativeUIPrompt(manifest, spec = defaultGenerativeUIPromptSpec()) {
4155
+ var _spec$tool$operations;
3717
4156
  const targets = manifest.targets.map((t) => {
3718
4157
  const place = t.kind === "chat" ? "inside the chat transcript" : "a named area of the app";
3719
4158
  const limit = t.components ? `; only ${t.components.join(", ") || "no components"}` : "";
3720
4159
  const description = t.description ? `: ${t.description}` : "";
3721
4160
  return `- "${t.id}" (${place}${limit})${description}`;
3722
4161
  }).join("\n");
3723
- const components = Object.entries(manifest.components).map(([name, c]) => {
3724
- const lines = [`- **${name}**${c.description ? `: ${c.description}` : ""}`, ` props: ${JSON.stringify(c.props)}`];
3725
- if (c.events) lines.push(` event props: ${JSON.stringify(c.events)}`);
3726
- if (c.slots) lines.push(` slot props (component ids): ${JSON.stringify(c.slots)}`);
3727
- return lines.join("\n");
3728
- }).join("\n");
4162
+ const components = renderGenerativeUIComponentList(manifest.components, spec.schema.tool);
3729
4163
  const functions = Object.entries(manifest.functions).map(([name, f]) => {
3730
4164
  const signature = f.parameters.description;
3731
4165
  const args = typeof signature === "string" && signature.startsWith("{") && Object.keys(f.parameters).length === 2 ? signature : JSON.stringify(f.parameters);
@@ -3744,38 +4178,15 @@ ${rules.map((rule) => `- ${rule}`).join("\n")}
3744
4178
  var _s$rejected$length, _s$rejected2;
3745
4179
  return s.dataModel !== void 0 || ((_s$rejected$length = (_s$rejected2 = s.rejected) === null || _s$rejected2 === void 0 ? void 0 : _s$rejected2.length) !== null && _s$rejected$length !== void 0 ? _s$rejected$length : 0) > 0;
3746
4180
  }) ? "User values are what the user entered, by path. Your writes to those paths are ignored. Rejected operations were dropped: send them again with the problem fixed.\n" : "";
3747
- const { functions: hasFunctions, events, templates, checks } = generativeUIGuideFeatures(manifest);
3748
- const agentCalls = hasFunctions && GENERATIVE_UI_AGENT_FUNCTION_CALLS;
3749
- const operations = [
3750
- "{\"version\":\"v1.0\",\"createSurface\":{\"surfaceId\":\"<new id>\",\"dataModel\":{...},\"components\":[{\"id\":\"root\",\"component\":\"<Name>\",\"children\":[\"<child id>\"]}]}}: the first operation of a new surface. \"dataModel\" and \"components\" are optional.",
3751
- "{\"version\":\"v1.0\",\"updateComponents\":{\"surfaceId\":\"<id>\",\"components\":[<component>, ...]}}: add or replace components by id.",
3752
- "{\"version\":\"v1.0\",\"updateDataModel\":{\"surfaceId\":\"<id>\",\"path\":\"/some/path\",\"value\":<json>}}: set the value at \"path\". Always give \"value\". \"value\":null deletes the key at \"path\".",
3753
- "{\"version\":\"v1.0\",\"deleteSurface\":{\"surfaceId\":\"<id>\"}}: remove the surface.",
3754
- ...agentCalls ? ["{\"version\":\"v1.0\",\"callRendererFunction\":{\"functionCallId\":\"<unique id>\",\"callFunction\":{\"@call\":\"<function>\",\"args\":{...}}}}: run an app function now, with no click. It needs no surface."] : []
3755
- ];
3756
- const rules = [
3757
- "Components are flat objects: {\"id\":\"...\",\"component\":\"<Name>\", ...props}. Every surface renders from the component with id \"root\". Reference children by id in slot props.",
3758
- "A component may take \"accessibility\":{\"label\":\"<1 to 3 words>\",\"description\":\"<what it does>\"} for screen readers: on the component it describes, when nothing visible names it. Not on every component, and \"live\":\"polite\" only on text that changes by itself.",
3759
- "Stream progressively: put the initial data in \"dataModel\" and the root in \"components\" of the createSurface operation, then send one updateComponents operation per child, so the UI appears while you are still writing. The root must already list the ids of its children in its slot props (for example \"children\":[\"card-1\",\"card-2\"]), even though the children come later. A component that no slot references is never shown.",
3760
- "Updating a component replaces all of its props, so resend every prop.",
3761
- "Prop values are literals or data bindings {\"@path\":\"/data/path\"}. Never write {\"path\":\"/data/path\"} as a binding.",
3762
- ...events ? [hasFunctions ? "Event props take an action. {\"functionCall\":{\"@call\":\"<function>\",\"args\":{...}}} runs an app function in the browser immediately, and you are not told about it. {\"event\":{\"name\":\"<name>\",\"userMessage\":\"<text>\",\"context\":{...}}} sends the interaction back to you as a user message, with \"userMessage\" as its first line. \"userMessage\" is plain text: ${...} is not interpolated in it; put values in \"context\". Only call functions listed below." : "Event props take an action: {\"event\":{\"name\":\"<name>\",\"userMessage\":\"<text>\",\"context\":{...}}} sends the interaction back to you as a user message, with \"userMessage\" as its first line. \"userMessage\" is plain text: ${...} is not interpolated in it; put values in \"context\"."] : [],
3763
- "To show a different view, create a new surface with a new surfaceId (for example, a checkout form after a cart summary). Update an existing surface only when the user asks to change that same view: then do not send createSurface, use its surfaceId, and pass its existing target. Never reuse an earlier chat surface for a different view, because that replaces the earlier UI and anything the user typed into it.",
3764
- "Never use a surfaceId again, also after deleteSurface.",
3765
- "A prop can also be a function value that updates with the data: {\"@call\":\"formatCurrency\",\"args\":{\"value\":{\"@path\":\"/total\"},\"currency\":\"EUR\"}}. Only call functions listed below. formatString interpolates ${/path} and ${fn(arg: value)} in its value.",
3766
- "${...} is evaluated only in the value of formatString and in the item of series; in other strings it stays literal text. Inside formatString, ${...} does not support operators. For arithmetic use calc, with the values as named args: {\"@call\":\"calc\",\"args\":{\"expression\":\"seats * 29 * (annual ? 0.8 : 1)\",\"seats\":{\"@path\":\"/seats\"},\"annual\":{\"@path\":\"/annual\"}}}.",
3767
- "For a computed list (chart data, template items) use series. Its description under Functions gives the rules and an example.",
3768
- ...checks ? ["Validate an input with \"checks\": [{\"condition\":{\"@call\":\"email\",\"args\":{\"value\":{\"@path\":\"/form/email\"}}},\"message\":\"Enter a valid email\"}]. The check functions are required, regex, length, numeric and email. A failed check shows the message under the input and disables a Button that has the same checks."] : [],
3769
- ...templates ? ["To repeat a component for each item of a list, give a multiple slot a template: \"children\":{\"componentId\":\"row\",\"path\":\"/items\"}. Inside the template, paths are relative to the item (\"name\", not \"/name\"). {\"@call\":\"@index\"} gives the position of the item, from 0; {\"@call\":\"@index\",\"args\":{\"offset\":1}} counts from 1."] : [],
3770
- ...agentCalls ? ["Give every callRendererFunction a new functionCallId. Call only a function marked (UI or agent) or (agent only); a function with no mark is for the UI only. A function marked (agent only) is only for callRendererFunction: do not bind an event to it.", "The result of a callRendererFunction comes back to you in a new turn, as a developer message: {\"version\":\"v1.0\",\"rendererFunctionResponse\":{\"functionCallId\":\"<id>\",\"value\":...}}. If the call failed, it has \"error\" in place of \"value\". Do not wait for the result in this reply, and do not guess it."] : []
3771
- ];
4181
+ const features = generativeUIPromptFeatures(generativeUIGuideFeatures(manifest));
4182
+ const { intro, whenToShow } = spec.tool;
4183
+ const operations = selectPromptItems((_spec$tool$operations = spec.tool.operations) !== null && _spec$tool$operations !== void 0 ? _spec$tool$operations : [], features);
4184
+ const rules = selectPromptItems(spec.tool.rules, features);
3772
4185
  return [
3773
4186
  `## Generative UI
3774
- Call \`${GENERATIVE_UI_RENDER_TOOL}\` to show UI. Arguments: \`target\` first, then \`operations\` (A2UI v1.0 operations, applied in order).
3775
-
3776
- ${GENERATIVE_UI_WHEN_TO_SHOW}
4187
+ ${intro}
3777
4188
 
3778
- Every operation has "version":"v1.0" and exactly one of:
4189
+ ${whenToShow ? `${whenToShow}\n\n` : ""}Every operation has "version":"1.0" and exactly one of:
3779
4190
  ${operations.map((op) => `- ${op}`).join("\n")}
3780
4191
 
3781
4192
  Rules:
@@ -3857,8 +4268,6 @@ exports.COPILOT_CLOUD_ERROR_NAMES = COPILOT_CLOUD_ERROR_NAMES;
3857
4268
  exports.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = COPILOT_CLOUD_PUBLIC_API_KEY_HEADER;
3858
4269
  exports.COPILOT_CLOUD_VERSION = COPILOT_CLOUD_VERSION;
3859
4270
  exports.ConfigurationError = ConfigurationError;
3860
- exports.ConsoleColors = ConsoleColors;
3861
- exports.ConsoleStyles = ConsoleStyles;
3862
4271
  exports.CopilotKitAgentDiscoveryError = CopilotKitAgentDiscoveryError;
3863
4272
  exports.CopilotKitApiDiscoveryError = CopilotKitApiDiscoveryError;
3864
4273
  exports.CopilotKitError = CopilotKitError;
@@ -3866,7 +4275,6 @@ exports.CopilotKitErrorCode = CopilotKitErrorCode;
3866
4275
  exports.CopilotKitLowLevelError = CopilotKitLowLevelError;
3867
4276
  exports.CopilotKitMisuseError = CopilotKitMisuseError;
3868
4277
  exports.CopilotKitRemoteEndpointDiscoveryError = CopilotKitRemoteEndpointDiscoveryError;
3869
- exports.CopilotKitVersionMismatchError = CopilotKitVersionMismatchError;
3870
4278
  exports.DEFAULT_AGENT_ID = DEFAULT_AGENT_ID;
3871
4279
  exports.ERROR_CONFIG = ERROR_CONFIG;
3872
4280
  exports.ERROR_NAMES = ERROR_NAMES;
@@ -3883,11 +4291,14 @@ exports.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE = GENERATIVE_UI_FUNCTION_CALL_
3883
4291
  exports.GENERATIVE_UI_MARKDOWN_GUIDELINES = GENERATIVE_UI_MARKDOWN_GUIDELINES;
3884
4292
  exports.GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION = GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION;
3885
4293
  exports.GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION = GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION;
4294
+ exports.GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW = GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW;
3886
4295
  exports.GENERATIVE_UI_MAX_REJECTION_LENGTH = GENERATIVE_UI_MAX_REJECTION_LENGTH;
3887
4296
  exports.GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = GENERATIVE_UI_MAX_SUMMARY_REJECTIONS;
3888
4297
  exports.GENERATIVE_UI_MAX_TARGET_COMPONENTS = GENERATIVE_UI_MAX_TARGET_COMPONENTS;
3889
4298
  exports.GENERATIVE_UI_RENDER_TOOL = GENERATIVE_UI_RENDER_TOOL;
3890
4299
  exports.GENERATIVE_UI_ROOT_ID = GENERATIVE_UI_ROOT_ID;
4300
+ exports.GENERATIVE_UI_WHEN_TO_SHOW = GENERATIVE_UI_WHEN_TO_SHOW;
4301
+ exports.GUIDE_COMPONENTS = GUIDE_COMPONENTS;
3891
4302
  exports.MODEL_HOST_CLASSES = MODEL_HOST_CLASSES;
3892
4303
  exports.MissingPublicApiKeyError = MissingPublicApiKeyError;
3893
4304
  exports.RUNTIME_MODE_INTELLIGENCE = RUNTIME_MODE_INTELLIGENCE;
@@ -3906,6 +4317,8 @@ exports.UNSAMPLED_RATE = UNSAMPLED_RATE;
3906
4317
  exports.UpgradeRequiredError = UpgradeRequiredError;
3907
4318
  exports.actionParametersToJsonSchema = actionParametersToJsonSchema;
3908
4319
  exports.applyChildRefMarks = applyChildRefMarks;
4320
+ exports.applyDescriptionOverrides = applyDescriptionOverrides;
4321
+ exports.buildCompactGenerativeUISchema = buildCompactGenerativeUISchema;
3909
4322
  exports.buildGenerativeUIMarkdownGuidelines = buildGenerativeUIMarkdownGuidelines;
3910
4323
  exports.buildGenerativeUIPrompt = buildGenerativeUIPrompt;
3911
4324
  exports.callerProblem = callerProblem;
@@ -3915,17 +4328,15 @@ exports.classifyModelHost = classifyModelHost;
3915
4328
  exports.collectChildRefs = collectChildRefs;
3916
4329
  exports.commitRowKeyStore = commitRowKeyStore;
3917
4330
  exports.computeSamplingMeta = computeSamplingMeta;
3918
- exports.convertJsonSchemaToZodSchema = convertJsonSchemaToZodSchema;
3919
4331
  exports.copyToClipboard = copyToClipboard;
3920
4332
  exports.createAttachmentContent = createAttachmentContent;
3921
4333
  exports.createLicenseContextValue = createLicenseContextValue;
3922
4334
  exports.createRowKeyStore = createRowKeyStore;
3923
4335
  exports.createRunEventFinalizer = createRunEventFinalizer;
3924
- exports.dataToUUID = dataToUUID;
4336
+ exports.defaultGenerativeUIPromptSpec = defaultGenerativeUIPromptSpec;
3925
4337
  exports.ensureStructuredError = ensureStructuredError;
3926
4338
  exports.envelopeToManifest = envelopeToManifest;
3927
4339
  exports.exceedsMaxSize = exceedsMaxSize;
3928
- exports.executeConditions = executeConditions;
3929
4340
  exports.extractRenderUIArgs = extractRenderUIArgs;
3930
4341
  exports.finalizeRunEvents = finalizeRunEvents;
3931
4342
  exports.firstNonBlankTelemetryId = firstNonBlankTelemetryId;
@@ -3934,14 +4345,13 @@ exports.functionCallers = functionCallers;
3934
4345
  exports.generateVideoThumbnail = generateVideoThumbnail;
3935
4346
  exports.generativeUIFunctionCallMessageId = generativeUIFunctionCallMessageId;
3936
4347
  exports.generativeUIGuideFeatures = generativeUIGuideFeatures;
4348
+ exports.generativeUIPromptFeatures = generativeUIPromptFeatures;
3937
4349
  exports.generativeUISurfaceMessageId = generativeUISurfaceMessageId;
3938
4350
  exports.getDocumentIcon = getDocumentIcon;
3939
4351
  exports.getModalityFromMimeType = getModalityFromMimeType;
3940
4352
  exports.getOperationKind = getOperationKind;
3941
4353
  exports.getOperationSurfaceId = getOperationSurfaceId;
3942
- exports.getPossibleVersionMismatch = getPossibleVersionMismatch;
3943
4354
  exports.getSourceUrl = getSourceUrl;
3944
- exports.getZodParameters = getZodParameters;
3945
4355
  exports.hasBoundChildRef = hasBoundChildRef;
3946
4356
  exports.isA2UIBasicFunction = isA2UIBasicFunction;
3947
4357
  exports.isA2UIValueFunction = isA2UIValueFunction;
@@ -3952,12 +4362,9 @@ exports.isMacOS = isMacOS;
3952
4362
  exports.isPathBinding = isPathBinding;
3953
4363
  exports.isStructuredCopilotKitError = isStructuredCopilotKitError;
3954
4364
  exports.isTelemetryDisabled = isTelemetryDisabled;
3955
- exports.isValidUUID = isValidUUID;
3956
4365
  exports.isValidationResult = isValidationResult;
3957
4366
  exports.jsonSchemaToActionParameters = jsonSchemaToActionParameters;
3958
4367
  exports.lambdaClient = lambdaClient;
3959
- exports.logCopilotKitPlatformMessage = logCopilotKitPlatformMessage;
3960
- exports.logStyled = logStyled;
3961
4368
  exports.logger = logger;
3962
4369
  exports.mapAtChildRef = mapAtChildRef;
3963
4370
  exports.matchesAcceptFilter = matchesAcceptFilter;
@@ -3972,22 +4379,26 @@ exports.partialJSONParse = partialJSONParse;
3972
4379
  exports.phoenixExponentialBackoff = phoenixExponentialBackoff;
3973
4380
  exports.processEnv = processEnv;
3974
4381
  exports.pruneRowKeyStore = pruneRowKeyStore;
3975
- exports.publicApiKeyRequired = publicApiKeyRequired;
3976
4382
  exports.randomId = randomId;
3977
4383
  exports.randomUUID = randomUUID;
3978
4384
  exports.readBody = readBody;
3979
4385
  exports.readCopilotKitUIEnvelope = readCopilotKitUIEnvelope;
3980
4386
  exports.readFileAsBase64 = readFileAsBase64;
4387
+ exports.renderGenerativeUIComponentList = renderGenerativeUIComponentList;
4388
+ exports.renderGenerativeUISchema = renderGenerativeUISchema;
3981
4389
  exports.resolveDebugConfig = resolveDebugConfig;
3982
4390
  exports.resolveRowRenderKeys = resolveRowRenderKeys;
3983
4391
  exports.resolveRowRenderKeysById = resolveRowRenderKeysById;
3984
4392
  exports.safeParseToolArgs = safeParseToolArgs;
4393
+ exports.schemaCoverage = schemaCoverage;
3985
4394
  exports.schemaToJsonSchema = schemaToJsonSchema;
4395
+ exports.selectPromptItems = selectPromptItems;
3986
4396
  exports.shouldEnableInspector = shouldEnableInspector;
3987
4397
  exports.stripIntelligenceRoutingFields = stripIntelligenceRoutingFields;
3988
- exports.styledConsole = styledConsole;
3989
4398
  exports.toA2UIActionMessage = toA2UIActionMessage;
3990
4399
  exports.tryMap = tryMap;
3991
4400
  exports.validateOperation = validateOperation;
4401
+ exports.ɵINSPECTOR_LOOPBACK_HOSTS = ɵINSPECTOR_LOOPBACK_HOSTS;
4402
+ exports.ɵanySchema = ɵanySchema;
3992
4403
  });
3993
4404
  //# sourceMappingURL=index.umd.js.map