llmz 0.9.0 → 1.0.2

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 (238) hide show
  1. package/DOCS.md +232 -1794
  2. package/ERRORS.md +101 -0
  3. package/README.md +96 -582
  4. package/dist/chat/chat.d.ts +63 -0
  5. package/dist/chat/component.d.ts +31 -0
  6. package/dist/chat/component.default.d.ts +58 -0
  7. package/dist/chat/response.d.ts +15 -0
  8. package/dist/compiler/compiler.d.ts +2 -7
  9. package/dist/compiler/plugins/dynamic-code.d.ts +7 -0
  10. package/dist/compiler/plugins/replace-comment.d.ts +2 -3
  11. package/dist/compiler/plugins/return-async.d.ts +5 -4
  12. package/dist/compiler/plugins/termination.d.ts +8 -0
  13. package/dist/compiler/plugins/tool-resolution.d.ts +4 -0
  14. package/dist/compiler/plugins/variable-extraction.d.ts +2 -8
  15. package/dist/component-CMFoCHyu.cjs +649 -0
  16. package/dist/component-DncqP4fB.js +614 -0
  17. package/dist/context.d.ts +71 -378
  18. package/dist/custom-client-C-WXvLD9.js +1655 -0
  19. package/dist/custom-client-Cgt9_0r1.cjs +1732 -0
  20. package/dist/custom-client.d.ts +12 -2
  21. package/dist/errors/catalog.d.ts +294 -0
  22. package/dist/errors/hooks.d.ts +2 -0
  23. package/dist/errors-C6ppQUZX.cjs +893 -0
  24. package/dist/errors-Crk5P8jo.js +636 -0
  25. package/dist/errors.d.ts +24 -36
  26. package/dist/execute-CiYvPs5Q.js +2061 -0
  27. package/dist/execute-DTTfacsi.cjs +2062 -0
  28. package/dist/{exit-DUM96DN1.cjs → exit-BOtKWPuT.cjs} +38 -28
  29. package/dist/{exit-CDdxDBRT.js → exit-DMPwCSba.js} +37 -27
  30. package/dist/exit.d.ts +19 -16
  31. package/dist/index.cjs +177 -1237
  32. package/dist/index.d.ts +25 -28
  33. package/dist/index.js +137 -1213
  34. package/dist/index.workerd.js +8974 -11145
  35. package/dist/inspect.d.ts +18 -4
  36. package/dist/inspection.d.ts +40 -0
  37. package/dist/native-0bq5ATZM.cjs +212 -0
  38. package/dist/native-n_718Z-T.js +177 -0
  39. package/dist/objects.d.ts +2 -57
  40. package/dist/prompts/native.d.ts +2 -0
  41. package/dist/prompts/prompt.d.ts +10 -101
  42. package/dist/quickjs-variant-21IO97PF.cjs +1080 -0
  43. package/dist/quickjs-variant-CtuGagsb.js +985 -0
  44. package/dist/result.d.ts +30 -861
  45. package/dist/runtime/execute.d.ts +3 -2
  46. package/dist/runtime/execution-activity.d.ts +11 -0
  47. package/dist/runtime/execution-diagnostics.d.ts +11 -0
  48. package/dist/runtime/execution-report.d.ts +51 -0
  49. package/dist/runtime/fixtures/chat.d.ts +8 -0
  50. package/dist/runtime/fixtures/long-search.d.ts +1 -1
  51. package/dist/runtime/fixtures/native-client.d.ts +33 -0
  52. package/dist/runtime/fixtures/protocol-languages.d.ts +1 -1
  53. package/dist/runtime/forced-inspection.d.ts +13 -0
  54. package/dist/runtime/forced-inspection.test.d.ts +1 -0
  55. package/dist/runtime/generate.d.ts +23 -20
  56. package/dist/runtime/generate.test.d.ts +1 -0
  57. package/dist/runtime/hook-provenance.test.d.ts +1 -0
  58. package/dist/runtime/inspection-hook.test.d.ts +1 -0
  59. package/dist/runtime/inspection-values.d.ts +14 -0
  60. package/dist/runtime/inspection-values.test.d.ts +1 -0
  61. package/dist/runtime/interruption-control-flow.test.d.ts +1 -0
  62. package/dist/runtime/interruption-settings.test.d.ts +1 -0
  63. package/dist/runtime/javascript-api.d.ts +62 -0
  64. package/dist/runtime/javascript-api.test.d.ts +1 -0
  65. package/dist/runtime/native-review.test.d.ts +1 -0
  66. package/dist/runtime/native-tools.d.ts +18 -0
  67. package/dist/runtime/native-tools.test.d.ts +1 -0
  68. package/dist/runtime/object-memory.test.d.ts +1 -0
  69. package/dist/runtime/single-tool.test.d.ts +1 -0
  70. package/dist/runtime/think-signal.test.d.ts +1 -0
  71. package/dist/runtime/token-budget.d.ts +22 -0
  72. package/dist/runtime/token-budget.test.d.ts +1 -0
  73. package/dist/runtime/tool-wrapper.d.ts +6 -5
  74. package/dist/runtime/traces.test.d.ts +1 -0
  75. package/dist/runtime/truncation.test.d.ts +1 -0
  76. package/dist/runtime/types.d.ts +47 -31
  77. package/dist/runtime/variable-recovery.test.d.ts +1 -0
  78. package/dist/runtime/vm-context.d.ts +6 -1
  79. package/dist/runtime/worker-completion.test.d.ts +1 -0
  80. package/dist/runtime-names.d.ts +4 -0
  81. package/dist/schema-CXlnbb3n.cjs +68 -0
  82. package/dist/schema-GE4ISPCR.js +45 -0
  83. package/dist/schema.d.ts +10 -0
  84. package/dist/schema.test.d.ts +1 -0
  85. package/dist/session/compactor.d.ts +51 -0
  86. package/dist/session/compactor.test.d.ts +1 -0
  87. package/dist/session/history.d.ts +36 -0
  88. package/dist/session/history.test.d.ts +1 -0
  89. package/dist/session/json.d.ts +3 -0
  90. package/dist/session/json.test.d.ts +1 -0
  91. package/dist/session/memory-codec.d.ts +9 -0
  92. package/dist/session/memory-codec.test.d.ts +1 -0
  93. package/dist/session/memory-render.d.ts +15 -0
  94. package/dist/session/memory-render.test.d.ts +1 -0
  95. package/dist/session/memory.d.ts +112 -0
  96. package/dist/session/memory.test.d.ts +1 -0
  97. package/dist/session/messages.d.ts +19 -0
  98. package/dist/session/messages.test.d.ts +1 -0
  99. package/dist/session/serialization.d.ts +36 -0
  100. package/dist/session/serialization.test.d.ts +1 -0
  101. package/dist/session/session-memory.test.d.ts +1 -0
  102. package/dist/session/session.d.ts +121 -0
  103. package/dist/session/session.test.d.ts +1 -0
  104. package/dist/session/speaker.test.d.ts +1 -0
  105. package/dist/{transcript.d.ts → session/transcript.d.ts} +4 -8
  106. package/dist/session/transcript.test.d.ts +1 -0
  107. package/dist/{tool-Bv8N4IPj.js → tool-DstssiAs.js} +144 -92
  108. package/dist/{tool-Dy6AJpJH.cjs → tool-_wK9hQOb.cjs} +146 -94
  109. package/dist/tool.d.ts +25 -17
  110. package/dist/truncate-BEKbdo3t.js +79 -0
  111. package/dist/truncate-uomAMGPs.cjs +102 -0
  112. package/dist/truncate.d.ts +24 -0
  113. package/dist/truncate.test.d.ts +1 -0
  114. package/dist/types.d.ts +33 -9
  115. package/dist/{typings-3lsqCbkn.cjs → typings-BA_XxAcY.cjs} +38 -193
  116. package/dist/{typings-CrBa7Tyy.js → typings-BEVDvtuk.js} +38 -175
  117. package/dist/typings-formatter.d.ts +1 -1
  118. package/dist/typings.d.ts +3 -0
  119. package/dist/{uniq-BYQ7GWwb.js → uniq-DfUeSNaX.js} +2 -2
  120. package/dist/{uniq-G872RWmE.cjs → uniq-DiXgysNV.cjs} +6 -18
  121. package/dist/{_baseIteratee-P_firB7b.js → utils-BOFzb8Ok.js} +1134 -16
  122. package/dist/{_baseIteratee-CF4qP2a8.cjs → utils-CTlsXvdj.cjs} +1281 -84
  123. package/dist/vm/drivers/node.d.ts +1 -1
  124. package/dist/vm/drivers/quickjs.d.ts +1 -1
  125. package/dist/vm/errors.d.ts +4 -4
  126. package/dist/vm/index.d.ts +3 -4
  127. package/dist/vm/instrument.d.ts +14 -6
  128. package/dist/vm/member-proxy.d.ts +4 -0
  129. package/dist/vm/member-proxy.test.d.ts +1 -0
  130. package/dist/vm/memory.test.d.ts +1 -0
  131. package/dist/vm/return-semantics.test.d.ts +1 -0
  132. package/dist/vm/types.d.ts +20 -3
  133. package/dist/{vm-BLsHw1da.js → vm-C7SfutHn.js} +1187 -180
  134. package/dist/{vm-D6s1zF6M.cjs → vm-gmekHc0i.cjs} +1221 -207
  135. package/package.json +13 -6
  136. package/dist/_baseForOwn-BfWDTL8L.cjs +0 -53
  137. package/dist/_baseForOwn-CFhWe_W6.js +0 -48
  138. package/dist/_getPrototype-CG7Dxrrz.js +0 -6
  139. package/dist/_getPrototype-DQDlNVVM.cjs +0 -10
  140. package/dist/_overArg-C5Hy7oCi.cjs +0 -196
  141. package/dist/_overArg-CRYbj1NH.js +0 -155
  142. package/dist/chat.d.ts +0 -401
  143. package/dist/common-BlRFtdf2.js +0 -807
  144. package/dist/common-BnvrDnIT.cjs +0 -860
  145. package/dist/compiler/plugins/track-tool-calls.d.ts +0 -33
  146. package/dist/compiler-C-OI9sim.cjs +0 -547
  147. package/dist/compiler-CW1VjQsn.js +0 -473
  148. package/dist/component-C6Agl2ns.cjs +0 -73
  149. package/dist/component-DGG7d_Mz.js +0 -44
  150. package/dist/component.d.ts +0 -88
  151. package/dist/component.default.d.ts +0 -278
  152. package/dist/custom-client-ChuZ63zp.js +0 -2658
  153. package/dist/custom-client-DAsGRnYc.cjs +0 -2729
  154. package/dist/dual-modes-DDkoCp3R.js +0 -3006
  155. package/dist/dual-modes-DPXiuvNe.cjs +0 -3090
  156. package/dist/errors-C962uJdS.cjs +0 -220
  157. package/dist/errors-Cg1G0Awu.js +0 -161
  158. package/dist/example-format.d.ts +0 -8
  159. package/dist/example.d.ts +0 -45
  160. package/dist/execute-BWcdv9so.js +0 -1059
  161. package/dist/execute-DM2-7y86.cjs +0 -1060
  162. package/dist/exit-parser.d.ts +0 -39
  163. package/dist/handlers.d.ts +0 -10
  164. package/dist/hoist.d.ts +0 -2
  165. package/dist/isEmpty-BhJRCqIF.js +0 -52
  166. package/dist/isEmpty-LY533Wmh.cjs +0 -57
  167. package/dist/isPlainObject-CSxXVKCk.cjs +0 -56
  168. package/dist/isPlainObject-D39AzPO2.js +0 -51
  169. package/dist/jsx-CIgdGGVs.js +0 -52
  170. package/dist/jsx-owqxrquU.cjs +0 -75
  171. package/dist/jsx.d.ts +0 -11
  172. package/dist/message-stream/index.d.ts +0 -9
  173. package/dist/message-stream/instructions.d.ts +0 -30
  174. package/dist/message-stream/normalizer.d.ts +0 -21
  175. package/dist/message-stream/parser.d.ts +0 -89
  176. package/dist/message-stream/registry.d.ts +0 -14
  177. package/dist/message-stream/replayable.d.ts +0 -27
  178. package/dist/message-stream/response-parser.d.ts +0 -24
  179. package/dist/message-stream/sanitize.d.ts +0 -10
  180. package/dist/message-stream/stream.d.ts +0 -54
  181. package/dist/message-stream/types.d.ts +0 -97
  182. package/dist/message-stream/validator.d.ts +0 -23
  183. package/dist/prompts/chat-mode/protocol.d.ts +0 -2
  184. package/dist/prompts/chat-mode/system.d.ts +0 -2
  185. package/dist/prompts/chat-mode/system.md.d.ts +0 -2
  186. package/dist/prompts/chat-mode/user.d.ts +0 -2
  187. package/dist/prompts/chat-mode/user.md.d.ts +0 -2
  188. package/dist/prompts/code-examples.d.ts +0 -2
  189. package/dist/prompts/common.d.ts +0 -7
  190. package/dist/prompts/dual-modes.d.ts +0 -2
  191. package/dist/prompts/execution-history.d.ts +0 -6
  192. package/dist/prompts/execution-state.d.ts +0 -3
  193. package/dist/prompts/protocol-basics.d.ts +0 -5
  194. package/dist/prompts/protocol.d.ts +0 -31
  195. package/dist/prompts/worker-mode/protocol.d.ts +0 -2
  196. package/dist/prompts/worker-mode/system.d.ts +0 -2
  197. package/dist/prompts/worker-mode/system.md.d.ts +0 -2
  198. package/dist/prompts/worker-mode/user.d.ts +0 -2
  199. package/dist/prompts/worker-mode/user.md.d.ts +0 -2
  200. package/dist/quickjs-variant-BYhMBpwU.js +0 -45
  201. package/dist/quickjs-variant-CsIwTVFC.cjs +0 -56
  202. package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
  203. package/dist/runtime/fixtures/qwen-protocol-failures.d.ts +0 -29
  204. package/dist/runtime/interpret-result.d.ts +0 -22
  205. package/dist/snapshots.d.ts +0 -249
  206. package/dist/stack-traces-BIE_5Xwf.js +0 -21
  207. package/dist/stack-traces-ntw_qhoy.cjs +0 -26
  208. package/dist/truncator-CLkouTCO.cjs +0 -276
  209. package/dist/truncator-DZqEqnpD.js +0 -253
  210. package/dist/truncator.d.ts +0 -118
  211. package/dist/utils-3ESwP3yg.cjs +0 -1075
  212. package/dist/utils-UBeAFeEI.js +0 -950
  213. /package/dist/{citations.d.ts → chat/citations.d.ts} +0 -0
  214. /package/dist/{citations.test.d.ts → chat/citations.test.d.ts} +0 -0
  215. /package/dist/{component.default.test.d.ts → chat/component.default.test.d.ts} +0 -0
  216. /package/dist/{compiler/plugins/track-tool-calls.test.d.ts → chat/component.test.d.ts} +0 -0
  217. /package/dist/{example.test.d.ts → chat/response.test.d.ts} +0 -0
  218. /package/dist/{exit-parser.test.d.ts → compiler/plugins/dynamic-code.test.d.ts} +0 -0
  219. /package/dist/{handlers.test.d.ts → compiler/plugins/tool-resolution.test.d.ts} +0 -0
  220. /package/dist/{hoist.test.d.ts → errors/catalog.test.d.ts} +0 -0
  221. /package/dist/{message-stream/instructions.test.d.ts → exit.test.d.ts} +0 -0
  222. /package/dist/{message-stream/normalizer.test.d.ts → inspection.test.d.ts} +0 -0
  223. /package/dist/{message-stream/parser.test.d.ts → prompts/native.test.d.ts} +0 -0
  224. /package/dist/{message-stream/response-parser.test.d.ts → result.test.d.ts} +0 -0
  225. /package/dist/{message-stream/stream.test.d.ts → runtime/chat-completion.test.d.ts} +0 -0
  226. /package/dist/{message-stream/validator.test.d.ts → runtime/chat-delivery.test.d.ts} +0 -0
  227. /package/dist/{prompts/adherence.test.d.ts → runtime/chat-last-speaker.test.d.ts} +0 -0
  228. /package/dist/{prompts/catalogue-examples.test.d.ts → runtime/compatibility-regressions.test.d.ts} +0 -0
  229. /package/dist/{prompts/code-examples.test.d.ts → runtime/context-registration.test.d.ts} +0 -0
  230. /package/dist/{prompts/common.test.d.ts → runtime/empty-completion.test.d.ts} +0 -0
  231. /package/dist/{prompts/concrete-patterns.test.d.ts → runtime/error-recovery.test.d.ts} +0 -0
  232. /package/dist/{prompts/long-search.test.d.ts → runtime/errors.test.d.ts} +0 -0
  233. /package/dist/{prompts/protocol-simple.test.d.ts → runtime/execution-activity.test.d.ts} +0 -0
  234. /package/dist/{prompts/protocol.test.d.ts → runtime/execution-diagnostics.test.d.ts} +0 -0
  235. /package/dist/{prompts/sections.test.d.ts → runtime/execution-report.test.d.ts} +0 -0
  236. /package/dist/runtime/{interpret-result.test.d.ts → execution-safety.test.d.ts} +0 -0
  237. /package/dist/{transcript.test.d.ts → runtime/exit-control-flow.test.d.ts} +0 -0
  238. /package/dist/{truncator.test.d.ts → runtime/fixtures/long-search.test.d.ts} +0 -0
@@ -0,0 +1,614 @@
1
+ import { A as keys, B as baseAssignValue, C as getAllKeysIn, D as Stack, E as getSymbols, F as isBuffer, G as isObjectLike, H as isObject, K as Symbol, L as isPrototype, N as nodeUtil, O as getPrototype, P as baseUnary, T as getSymbolsIn, U as isArray, Y as __exportAll, b as Uint8Array, k as keysIn, q as root, w as getAllKeys, x as _getTag_default, z as assignValue } from "./utils-BOFzb8Ok.js";
2
+ import { P as ReservedIdentifierError, d as ComponentInputError, y as InvalidComponentError } from "./errors-Crk5P8jo.js";
3
+ import { n as parseSchemaSync, r as schemaInput } from "./schema-GE4ISPCR.js";
4
+ import { n as schemaToTypeScript } from "./typings-BEVDvtuk.js";
5
+ import { z } from "@bpinternal/zui";
6
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseCreate.js
7
+ /** Built-in value references. */
8
+ var objectCreate = Object.create;
9
+ /**
10
+ * The base implementation of `_.create` without support for assigning
11
+ * properties to the created object.
12
+ *
13
+ * @private
14
+ * @param {Object} proto The object to inherit from.
15
+ * @returns {Object} Returns the new object.
16
+ */
17
+ var baseCreate = function() {
18
+ function object() {}
19
+ return function(proto) {
20
+ if (!isObject(proto)) return {};
21
+ if (objectCreate) return objectCreate(proto);
22
+ object.prototype = proto;
23
+ var result = new object();
24
+ object.prototype = void 0;
25
+ return result;
26
+ };
27
+ }();
28
+ //#endregion
29
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copyArray.js
30
+ /**
31
+ * Copies the values of `source` to `array`.
32
+ *
33
+ * @private
34
+ * @param {Array} source The array to copy values from.
35
+ * @param {Array} [array=[]] The array to copy values to.
36
+ * @returns {Array} Returns `array`.
37
+ */
38
+ function copyArray(source, array) {
39
+ var index = -1, length = source.length;
40
+ array || (array = Array(length));
41
+ while (++index < length) array[index] = source[index];
42
+ return array;
43
+ }
44
+ //#endregion
45
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayEach.js
46
+ /**
47
+ * A specialized version of `_.forEach` for arrays without support for
48
+ * iteratee shorthands.
49
+ *
50
+ * @private
51
+ * @param {Array} [array] The array to iterate over.
52
+ * @param {Function} iteratee The function invoked per iteration.
53
+ * @returns {Array} Returns `array`.
54
+ */
55
+ function arrayEach(array, iteratee) {
56
+ var index = -1, length = array == null ? 0 : array.length;
57
+ while (++index < length) if (iteratee(array[index], index, array) === false) break;
58
+ return array;
59
+ }
60
+ //#endregion
61
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copyObject.js
62
+ /**
63
+ * Copies properties of `source` to `object`.
64
+ *
65
+ * @private
66
+ * @param {Object} source The object to copy properties from.
67
+ * @param {Array} props The property identifiers to copy.
68
+ * @param {Object} [object={}] The object to copy properties to.
69
+ * @param {Function} [customizer] The function to customize copied values.
70
+ * @returns {Object} Returns `object`.
71
+ */
72
+ function copyObject(source, props, object, customizer) {
73
+ var isNew = !object;
74
+ object || (object = {});
75
+ var index = -1, length = props.length;
76
+ while (++index < length) {
77
+ var key = props[index];
78
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
79
+ if (newValue === void 0) newValue = source[key];
80
+ if (isNew) baseAssignValue(object, key, newValue);
81
+ else assignValue(object, key, newValue);
82
+ }
83
+ return object;
84
+ }
85
+ //#endregion
86
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAssign.js
87
+ /**
88
+ * The base implementation of `_.assign` without support for multiple sources
89
+ * or `customizer` functions.
90
+ *
91
+ * @private
92
+ * @param {Object} object The destination object.
93
+ * @param {Object} source The source object.
94
+ * @returns {Object} Returns `object`.
95
+ */
96
+ function baseAssign(object, source) {
97
+ return object && copyObject(source, keys(source), object);
98
+ }
99
+ //#endregion
100
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAssignIn.js
101
+ /**
102
+ * The base implementation of `_.assignIn` without support for multiple sources
103
+ * or `customizer` functions.
104
+ *
105
+ * @private
106
+ * @param {Object} object The destination object.
107
+ * @param {Object} source The source object.
108
+ * @returns {Object} Returns `object`.
109
+ */
110
+ function baseAssignIn(object, source) {
111
+ return object && copyObject(source, keysIn(source), object);
112
+ }
113
+ //#endregion
114
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneBuffer.js
115
+ /** Detect free variable `exports`. */
116
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
117
+ /** Detect free variable `module`. */
118
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
119
+ /** Built-in value references. */
120
+ var Buffer = freeModule && freeModule.exports === freeExports ? root.Buffer : void 0;
121
+ var allocUnsafe = Buffer ? Buffer.allocUnsafe : void 0;
122
+ /**
123
+ * Creates a clone of `buffer`.
124
+ *
125
+ * @private
126
+ * @param {Buffer} buffer The buffer to clone.
127
+ * @param {boolean} [isDeep] Specify a deep clone.
128
+ * @returns {Buffer} Returns the cloned buffer.
129
+ */
130
+ function cloneBuffer(buffer, isDeep) {
131
+ if (isDeep) return buffer.slice();
132
+ var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
133
+ buffer.copy(result);
134
+ return result;
135
+ }
136
+ //#endregion
137
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copySymbols.js
138
+ /**
139
+ * Copies own symbols of `source` to `object`.
140
+ *
141
+ * @private
142
+ * @param {Object} source The object to copy symbols from.
143
+ * @param {Object} [object={}] The object to copy symbols to.
144
+ * @returns {Object} Returns `object`.
145
+ */
146
+ function copySymbols(source, object) {
147
+ return copyObject(source, getSymbols(source), object);
148
+ }
149
+ //#endregion
150
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copySymbolsIn.js
151
+ /**
152
+ * Copies own and inherited symbols of `source` to `object`.
153
+ *
154
+ * @private
155
+ * @param {Object} source The object to copy symbols from.
156
+ * @param {Object} [object={}] The object to copy symbols to.
157
+ * @returns {Object} Returns `object`.
158
+ */
159
+ function copySymbolsIn(source, object) {
160
+ return copyObject(source, getSymbolsIn(source), object);
161
+ }
162
+ //#endregion
163
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_initCloneArray.js
164
+ /** Used to check objects for own properties. */
165
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
166
+ /**
167
+ * Initializes an array clone.
168
+ *
169
+ * @private
170
+ * @param {Array} array The array to clone.
171
+ * @returns {Array} Returns the initialized clone.
172
+ */
173
+ function initCloneArray(array) {
174
+ var length = array.length, result = new array.constructor(length);
175
+ if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) {
176
+ result.index = array.index;
177
+ result.input = array.input;
178
+ }
179
+ return result;
180
+ }
181
+ //#endregion
182
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneArrayBuffer.js
183
+ /**
184
+ * Creates a clone of `arrayBuffer`.
185
+ *
186
+ * @private
187
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
188
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
189
+ */
190
+ function cloneArrayBuffer(arrayBuffer) {
191
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
192
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
193
+ return result;
194
+ }
195
+ //#endregion
196
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneDataView.js
197
+ /**
198
+ * Creates a clone of `dataView`.
199
+ *
200
+ * @private
201
+ * @param {Object} dataView The data view to clone.
202
+ * @param {boolean} [isDeep] Specify a deep clone.
203
+ * @returns {Object} Returns the cloned data view.
204
+ */
205
+ function cloneDataView(dataView, isDeep) {
206
+ var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
207
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
208
+ }
209
+ //#endregion
210
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneRegExp.js
211
+ /** Used to match `RegExp` flags from their coerced string values. */
212
+ var reFlags = /\w*$/;
213
+ /**
214
+ * Creates a clone of `regexp`.
215
+ *
216
+ * @private
217
+ * @param {Object} regexp The regexp to clone.
218
+ * @returns {Object} Returns the cloned regexp.
219
+ */
220
+ function cloneRegExp(regexp) {
221
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
222
+ result.lastIndex = regexp.lastIndex;
223
+ return result;
224
+ }
225
+ //#endregion
226
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneSymbol.js
227
+ /** Used to convert symbols to primitives and strings. */
228
+ var symbolProto = Symbol ? Symbol.prototype : void 0;
229
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
230
+ /**
231
+ * Creates a clone of the `symbol` object.
232
+ *
233
+ * @private
234
+ * @param {Object} symbol The symbol object to clone.
235
+ * @returns {Object} Returns the cloned symbol object.
236
+ */
237
+ function cloneSymbol(symbol) {
238
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
239
+ }
240
+ //#endregion
241
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneTypedArray.js
242
+ /**
243
+ * Creates a clone of `typedArray`.
244
+ *
245
+ * @private
246
+ * @param {Object} typedArray The typed array to clone.
247
+ * @param {boolean} [isDeep] Specify a deep clone.
248
+ * @returns {Object} Returns the cloned typed array.
249
+ */
250
+ function cloneTypedArray(typedArray, isDeep) {
251
+ var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
252
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
253
+ }
254
+ //#endregion
255
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_initCloneByTag.js
256
+ /** `Object#toString` result references. */
257
+ var boolTag$1 = "[object Boolean]";
258
+ var dateTag$1 = "[object Date]";
259
+ var mapTag$2 = "[object Map]";
260
+ var numberTag$1 = "[object Number]";
261
+ var regexpTag$1 = "[object RegExp]";
262
+ var setTag$2 = "[object Set]";
263
+ var stringTag$1 = "[object String]";
264
+ var symbolTag$1 = "[object Symbol]";
265
+ var arrayBufferTag$1 = "[object ArrayBuffer]";
266
+ var dataViewTag$1 = "[object DataView]";
267
+ var float32Tag$1 = "[object Float32Array]";
268
+ var float64Tag$1 = "[object Float64Array]";
269
+ var int8Tag$1 = "[object Int8Array]";
270
+ var int16Tag$1 = "[object Int16Array]";
271
+ var int32Tag$1 = "[object Int32Array]";
272
+ var uint8Tag$1 = "[object Uint8Array]";
273
+ var uint8ClampedTag$1 = "[object Uint8ClampedArray]";
274
+ var uint16Tag$1 = "[object Uint16Array]";
275
+ var uint32Tag$1 = "[object Uint32Array]";
276
+ /**
277
+ * Initializes an object clone based on its `toStringTag`.
278
+ *
279
+ * **Note:** This function only supports cloning values with tags of
280
+ * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
281
+ *
282
+ * @private
283
+ * @param {Object} object The object to clone.
284
+ * @param {string} tag The `toStringTag` of the object to clone.
285
+ * @param {boolean} [isDeep] Specify a deep clone.
286
+ * @returns {Object} Returns the initialized clone.
287
+ */
288
+ function initCloneByTag(object, tag, isDeep) {
289
+ var Ctor = object.constructor;
290
+ switch (tag) {
291
+ case arrayBufferTag$1: return cloneArrayBuffer(object);
292
+ case boolTag$1:
293
+ case dateTag$1: return new Ctor(+object);
294
+ case dataViewTag$1: return cloneDataView(object, isDeep);
295
+ case float32Tag$1:
296
+ case float64Tag$1:
297
+ case int8Tag$1:
298
+ case int16Tag$1:
299
+ case int32Tag$1:
300
+ case uint8Tag$1:
301
+ case uint8ClampedTag$1:
302
+ case uint16Tag$1:
303
+ case uint32Tag$1: return cloneTypedArray(object, isDeep);
304
+ case mapTag$2: return new Ctor();
305
+ case numberTag$1:
306
+ case stringTag$1: return new Ctor(object);
307
+ case regexpTag$1: return cloneRegExp(object);
308
+ case setTag$2: return new Ctor();
309
+ case symbolTag$1: return cloneSymbol(object);
310
+ }
311
+ }
312
+ //#endregion
313
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_initCloneObject.js
314
+ /**
315
+ * Initializes an object clone.
316
+ *
317
+ * @private
318
+ * @param {Object} object The object to clone.
319
+ * @returns {Object} Returns the initialized clone.
320
+ */
321
+ function initCloneObject(object) {
322
+ return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
323
+ }
324
+ //#endregion
325
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsMap.js
326
+ /** `Object#toString` result references. */
327
+ var mapTag$1 = "[object Map]";
328
+ /**
329
+ * The base implementation of `_.isMap` without Node.js optimizations.
330
+ *
331
+ * @private
332
+ * @param {*} value The value to check.
333
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
334
+ */
335
+ function baseIsMap(value) {
336
+ return isObjectLike(value) && _getTag_default(value) == mapTag$1;
337
+ }
338
+ //#endregion
339
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isMap.js
340
+ var nodeIsMap = nodeUtil && nodeUtil.isMap;
341
+ /**
342
+ * Checks if `value` is classified as a `Map` object.
343
+ *
344
+ * @static
345
+ * @memberOf _
346
+ * @since 4.3.0
347
+ * @category Lang
348
+ * @param {*} value The value to check.
349
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
350
+ * @example
351
+ *
352
+ * _.isMap(new Map);
353
+ * // => true
354
+ *
355
+ * _.isMap(new WeakMap);
356
+ * // => false
357
+ */
358
+ var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
359
+ //#endregion
360
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsSet.js
361
+ /** `Object#toString` result references. */
362
+ var setTag$1 = "[object Set]";
363
+ /**
364
+ * The base implementation of `_.isSet` without Node.js optimizations.
365
+ *
366
+ * @private
367
+ * @param {*} value The value to check.
368
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
369
+ */
370
+ function baseIsSet(value) {
371
+ return isObjectLike(value) && _getTag_default(value) == setTag$1;
372
+ }
373
+ //#endregion
374
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSet.js
375
+ var nodeIsSet = nodeUtil && nodeUtil.isSet;
376
+ /**
377
+ * Checks if `value` is classified as a `Set` object.
378
+ *
379
+ * @static
380
+ * @memberOf _
381
+ * @since 4.3.0
382
+ * @category Lang
383
+ * @param {*} value The value to check.
384
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
385
+ * @example
386
+ *
387
+ * _.isSet(new Set);
388
+ * // => true
389
+ *
390
+ * _.isSet(new WeakSet);
391
+ * // => false
392
+ */
393
+ var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
394
+ //#endregion
395
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseClone.js
396
+ /** Used to compose bitmasks for cloning. */
397
+ var CLONE_DEEP_FLAG$1 = 1;
398
+ var CLONE_FLAT_FLAG = 2;
399
+ var CLONE_SYMBOLS_FLAG$1 = 4;
400
+ /** `Object#toString` result references. */
401
+ var argsTag = "[object Arguments]";
402
+ var arrayTag = "[object Array]";
403
+ var boolTag = "[object Boolean]";
404
+ var dateTag = "[object Date]";
405
+ var errorTag = "[object Error]";
406
+ var funcTag = "[object Function]";
407
+ var genTag = "[object GeneratorFunction]";
408
+ var mapTag = "[object Map]";
409
+ var numberTag = "[object Number]";
410
+ var objectTag = "[object Object]";
411
+ var regexpTag = "[object RegExp]";
412
+ var setTag = "[object Set]";
413
+ var stringTag = "[object String]";
414
+ var symbolTag = "[object Symbol]";
415
+ var weakMapTag = "[object WeakMap]";
416
+ var arrayBufferTag = "[object ArrayBuffer]";
417
+ var dataViewTag = "[object DataView]";
418
+ var float32Tag = "[object Float32Array]";
419
+ var float64Tag = "[object Float64Array]";
420
+ var int8Tag = "[object Int8Array]";
421
+ var int16Tag = "[object Int16Array]";
422
+ var int32Tag = "[object Int32Array]";
423
+ var uint8Tag = "[object Uint8Array]";
424
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
425
+ var uint16Tag = "[object Uint16Array]";
426
+ var uint32Tag = "[object Uint32Array]";
427
+ /** Used to identify `toStringTag` values supported by `_.clone`. */
428
+ var cloneableTags = {};
429
+ cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
430
+ cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
431
+ /**
432
+ * The base implementation of `_.clone` and `_.cloneDeep` which tracks
433
+ * traversed objects.
434
+ *
435
+ * @private
436
+ * @param {*} value The value to clone.
437
+ * @param {boolean} bitmask The bitmask flags.
438
+ * 1 - Deep clone
439
+ * 2 - Flatten inherited properties
440
+ * 4 - Clone symbols
441
+ * @param {Function} [customizer] The function to customize cloning.
442
+ * @param {string} [key] The key of `value`.
443
+ * @param {Object} [object] The parent object of `value`.
444
+ * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
445
+ * @returns {*} Returns the cloned value.
446
+ */
447
+ function baseClone(value, bitmask, customizer, key, object, stack) {
448
+ var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
449
+ if (customizer) result = object ? customizer(value, key, object, stack) : customizer(value);
450
+ if (result !== void 0) return result;
451
+ if (!isObject(value)) return value;
452
+ var isArr = isArray(value);
453
+ if (isArr) {
454
+ result = initCloneArray(value);
455
+ if (!isDeep) return copyArray(value, result);
456
+ } else {
457
+ var tag = _getTag_default(value), isFunc = tag == funcTag || tag == genTag;
458
+ if (isBuffer(value)) return cloneBuffer(value, isDeep);
459
+ if (tag == objectTag || tag == argsTag || isFunc && !object) {
460
+ result = isFlat || isFunc ? {} : initCloneObject(value);
461
+ if (!isDeep) return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
462
+ } else {
463
+ if (!cloneableTags[tag]) return object ? value : {};
464
+ result = initCloneByTag(value, tag, isDeep);
465
+ }
466
+ }
467
+ stack || (stack = new Stack());
468
+ var stacked = stack.get(value);
469
+ if (stacked) return stacked;
470
+ stack.set(value, result);
471
+ if (isSet(value)) value.forEach(function(subValue) {
472
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
473
+ });
474
+ else if (isMap(value)) value.forEach(function(subValue, key) {
475
+ result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
476
+ });
477
+ var props = isArr ? void 0 : (isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys)(value);
478
+ arrayEach(props || value, function(subValue, key) {
479
+ if (props) {
480
+ key = subValue;
481
+ subValue = value[key];
482
+ }
483
+ assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
484
+ });
485
+ return result;
486
+ }
487
+ //#endregion
488
+ //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/cloneDeep.js
489
+ /** Used to compose bitmasks for cloning. */
490
+ var CLONE_DEEP_FLAG = 1;
491
+ var CLONE_SYMBOLS_FLAG = 4;
492
+ /**
493
+ * This method is like `_.clone` except that it recursively clones `value`.
494
+ *
495
+ * @static
496
+ * @memberOf _
497
+ * @since 1.0.0
498
+ * @category Lang
499
+ * @param {*} value The value to recursively clone.
500
+ * @returns {*} Returns the deep cloned value.
501
+ * @see _.clone
502
+ * @example
503
+ *
504
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
505
+ *
506
+ * var deep = _.cloneDeep(objects);
507
+ * console.log(deep[0] === objects[0]);
508
+ * // => false
509
+ */
510
+ function cloneDeep(value) {
511
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
512
+ }
513
+ //#endregion
514
+ //#region src/chat/component.ts
515
+ var component_exports = /* @__PURE__ */ __exportAll({
516
+ Component: () => Component,
517
+ assertValidComponent: () => assertValidComponent,
518
+ createComponentRegistry: () => createComponentRegistry,
519
+ isAnyComponent: () => isAnyComponent,
520
+ isComponent: () => isComponent
521
+ });
522
+ const TEXT_NAMES = /* @__PURE__ */ new Set([
523
+ "message",
524
+ "text",
525
+ "markdown",
526
+ "md",
527
+ "speech",
528
+ "speak",
529
+ "spoken"
530
+ ]);
531
+ const RESERVED_METHOD_NAMES = /* @__PURE__ */ new Set([
532
+ "then",
533
+ "constructor",
534
+ "prototype",
535
+ "__proto__",
536
+ "button"
537
+ ]);
538
+ function isRecord(value) {
539
+ return !!value && typeof value === "object" && !Array.isArray(value);
540
+ }
541
+ function assertValidComponent(component) {
542
+ if (!isRecord(component)) throw new InvalidComponentError("Component definition must be an object");
543
+ const unknown = Object.keys(component).find((key) => ![
544
+ "name",
545
+ "description",
546
+ "props",
547
+ "handler"
548
+ ].includes(key));
549
+ if (unknown) throw new InvalidComponentError(`Unknown component option: ${unknown}`);
550
+ const name = component.name;
551
+ if (typeof name !== "string" || !/^[A-Za-z_$][\w$]{0,49}$/.test(name)) throw new InvalidComponentError("Component name must be a JavaScript identifier of 1–50 characters");
552
+ if (TEXT_NAMES.has(name.toLowerCase())) throw new ReservedIdentifierError(name, "component", true, `Component name "${name}" is reserved for native assistant responses`);
553
+ if (RESERVED_METHOD_NAMES.has(name.toLowerCase())) throw new InvalidComponentError(`Component name "${name}" is unavailable; use "buttons" for button messages`);
554
+ if (typeof component.description !== "string" || !component.description.trim()) throw new InvalidComponentError("Component must have a description");
555
+ if (!z.is.zuiType(component.props) || !z.is.zuiObject(schemaInput(component.props)) && !z.is.zuiArray(schemaInput(component.props))) throw new InvalidComponentError("Component props must be a Zod object or array schema");
556
+ if (component.handler !== void 0 && typeof component.handler !== "function") throw new InvalidComponentError("Component handler must be a function");
557
+ }
558
+ function freeze(value, seen = /* @__PURE__ */ new WeakSet()) {
559
+ if (value && typeof value === "object" && !seen.has(value)) {
560
+ seen.add(value);
561
+ for (const child of Object.values(value)) freeze(child, seen);
562
+ Object.freeze(value);
563
+ }
564
+ return value;
565
+ }
566
+ var Component = class Component {
567
+ definition;
568
+ propsType;
569
+ handler;
570
+ constructor(definition) {
571
+ assertValidComponent(definition);
572
+ this.definition = Object.freeze({ ...definition });
573
+ this.handler = definition.handler;
574
+ }
575
+ withHandler(handler) {
576
+ return new Component({
577
+ ...this.definition,
578
+ handler
579
+ });
580
+ }
581
+ /** Parse once and retain an immutable delivery value. */
582
+ render(props) {
583
+ const parsed = parseSchemaSync(this.definition.props, props, `Component "${this.definition.name}"`);
584
+ if (!parsed.success) throw new ComponentInputError(this.definition.name, parsed.error.issues, schemaToTypeScript(this.definition.props));
585
+ if (!isRecord(parsed.data) && !Array.isArray(parsed.data)) throw new InvalidComponentError(`Component "${this.definition.name}" must produce object or array props`);
586
+ return freeze({
587
+ type: "component",
588
+ name: this.definition.name,
589
+ props: cloneDeep(parsed.data)
590
+ });
591
+ }
592
+ };
593
+ /** Resolve the exact methods once and share them between the prompt and runtime. */
594
+ function createComponentRegistry(components) {
595
+ const registry = /* @__PURE__ */ new Map();
596
+ for (const component of components) {
597
+ const name = component.definition.name;
598
+ if (registry.has(name)) throw new InvalidComponentError(`Duplicate component name: ${name}`);
599
+ registry.set(name, component);
600
+ }
601
+ return registry;
602
+ }
603
+ function isComponent(rendered, component) {
604
+ return isAnyComponent(rendered) && rendered.name === component.definition.name;
605
+ }
606
+ function isAnyComponent(value) {
607
+ return isRecord(value) && value.type === "component" && typeof value.name === "string" && value.name.length > 0 && (isRecord(value.props) || Array.isArray(value.props)) && Object.keys(value).every((key) => [
608
+ "type",
609
+ "name",
610
+ "props"
611
+ ].includes(key));
612
+ }
613
+ //#endregion
614
+ export { isAnyComponent as a, createComponentRegistry as i, assertValidComponent as n, isComponent as o, component_exports as r, Component as t };