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
@@ -1,39 +0,0 @@
1
- import { Exit } from './exit.js';
2
- /**
3
- * Result of parsing an exit from return value
4
- */
5
- export type ParsedExit = {
6
- success: true;
7
- exit: Exit;
8
- value: unknown;
9
- } | {
10
- success: false;
11
- error: string;
12
- /** Field-level schema errors, separate from the legacy return-statement guidance. */
13
- validationErrors?: string[];
14
- returnValue: unknown;
15
- };
16
- /**
17
- * Parses and validates a return value against a list of exits.
18
- * Attempts to intelligently fit the data to the expected schema.
19
- *
20
- * @param returnValue - The raw return value from code execution
21
- * @param exits - Available exits to match against
22
- * @returns Parsed exit result with validated data or error
23
- *
24
- * @example
25
- * ```typescript
26
- * const exits = [
27
- * new Exit({ name: 'done', schema: z.object({ result: z.string() }) })
28
- * ]
29
- *
30
- * // Returns primitive value - will be smart-wrapped
31
- * const result = parseExit({ action: 'done', data: 'hello' }, exits)
32
- * // result.success === true
33
- * // result.value === { result: 'hello' }
34
- * ```
35
- */
36
- export declare function parseExit(returnValue: {
37
- action: string;
38
- [key: string]: unknown;
39
- } | null, exits: Exit[]): ParsedExit;
@@ -1,10 +0,0 @@
1
- type UnsubscribeFn = () => void;
2
- type EventHandler<T> = (event: T) => void;
3
- export type SubscribeFn<T> = (fn: EventHandler<T>) => UnsubscribeFn;
4
- export declare class HookedArray<T> extends Array<T> {
5
- #private;
6
- constructor(...items: T[]);
7
- push(...items: T[]): number;
8
- onPush(fn: EventHandler<T[]>): UnsubscribeFn;
9
- }
10
- export {};
package/dist/hoist.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { CodeFormatOptions } from './formatting.js';
2
- export declare function hoistTypings(code: string, formatOptions?: CodeFormatOptions): Promise<string>;
@@ -1,52 +0,0 @@
1
- import { n as isArray } from "./_overArg-CRYbj1NH.js";
2
- import { A as isArrayLike, D as isBuffer, O as isArguments, S as baseKeys, c as _getTag_default, k as isPrototype, w as isTypedArray } from "./_baseIteratee-P_firB7b.js";
3
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
4
- /** `Object#toString` result references. */
5
- var mapTag = "[object Map]";
6
- var setTag = "[object Set]";
7
- /** Used to check objects for own properties. */
8
- var hasOwnProperty = Object.prototype.hasOwnProperty;
9
- /**
10
- * Checks if `value` is an empty object, collection, map, or set.
11
- *
12
- * Objects are considered empty if they have no own enumerable string keyed
13
- * properties.
14
- *
15
- * Array-like values such as `arguments` objects, arrays, buffers, strings, or
16
- * jQuery-like collections are considered empty if they have a `length` of `0`.
17
- * Similarly, maps and sets are considered empty if they have a `size` of `0`.
18
- *
19
- * @static
20
- * @memberOf _
21
- * @since 0.1.0
22
- * @category Lang
23
- * @param {*} value The value to check.
24
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
25
- * @example
26
- *
27
- * _.isEmpty(null);
28
- * // => true
29
- *
30
- * _.isEmpty(true);
31
- * // => true
32
- *
33
- * _.isEmpty(1);
34
- * // => true
35
- *
36
- * _.isEmpty([1, 2, 3]);
37
- * // => false
38
- *
39
- * _.isEmpty({ 'a': 1 });
40
- * // => false
41
- */
42
- function isEmpty(value) {
43
- if (value == null) return true;
44
- if (isArrayLike(value) && (isArray(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer(value) || isTypedArray(value) || isArguments(value))) return !value.length;
45
- var tag = _getTag_default(value);
46
- if (tag == mapTag || tag == setTag) return !value.size;
47
- if (isPrototype(value)) return !baseKeys(value).length;
48
- for (var key in value) if (hasOwnProperty.call(value, key)) return false;
49
- return true;
50
- }
51
- //#endregion
52
- export { isEmpty as t };
@@ -1,57 +0,0 @@
1
- const require__overArg = require("./_overArg-C5Hy7oCi.cjs");
2
- const require__baseIteratee = require("./_baseIteratee-CF4qP2a8.cjs");
3
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
4
- /** `Object#toString` result references. */
5
- var mapTag = "[object Map]";
6
- var setTag = "[object Set]";
7
- /** Used to check objects for own properties. */
8
- var hasOwnProperty = Object.prototype.hasOwnProperty;
9
- /**
10
- * Checks if `value` is an empty object, collection, map, or set.
11
- *
12
- * Objects are considered empty if they have no own enumerable string keyed
13
- * properties.
14
- *
15
- * Array-like values such as `arguments` objects, arrays, buffers, strings, or
16
- * jQuery-like collections are considered empty if they have a `length` of `0`.
17
- * Similarly, maps and sets are considered empty if they have a `size` of `0`.
18
- *
19
- * @static
20
- * @memberOf _
21
- * @since 0.1.0
22
- * @category Lang
23
- * @param {*} value The value to check.
24
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
25
- * @example
26
- *
27
- * _.isEmpty(null);
28
- * // => true
29
- *
30
- * _.isEmpty(true);
31
- * // => true
32
- *
33
- * _.isEmpty(1);
34
- * // => true
35
- *
36
- * _.isEmpty([1, 2, 3]);
37
- * // => false
38
- *
39
- * _.isEmpty({ 'a': 1 });
40
- * // => false
41
- */
42
- function isEmpty(value) {
43
- if (value == null) return true;
44
- if (require__baseIteratee.isArrayLike(value) && (require__overArg.isArray(value) || typeof value == "string" || typeof value.splice == "function" || require__baseIteratee.isBuffer(value) || require__baseIteratee.isTypedArray(value) || require__baseIteratee.isArguments(value))) return !value.length;
45
- var tag = require__baseIteratee._getTag_default(value);
46
- if (tag == mapTag || tag == setTag) return !value.size;
47
- if (require__baseIteratee.isPrototype(value)) return !require__baseIteratee.baseKeys(value).length;
48
- for (var key in value) if (hasOwnProperty.call(value, key)) return false;
49
- return true;
50
- }
51
- //#endregion
52
- Object.defineProperty(exports, "isEmpty", {
53
- enumerable: true,
54
- get: function() {
55
- return isEmpty;
56
- }
57
- });
@@ -1,56 +0,0 @@
1
- const require__overArg = require("./_overArg-C5Hy7oCi.cjs");
2
- const require__getPrototype = require("./_getPrototype-DQDlNVVM.cjs");
3
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isPlainObject.js
4
- /** `Object#toString` result references. */
5
- var objectTag = "[object Object]";
6
- /** Used for built-in method references. */
7
- var funcProto = Function.prototype;
8
- var objectProto = Object.prototype;
9
- /** Used to resolve the decompiled source of functions. */
10
- var funcToString = funcProto.toString;
11
- /** Used to check objects for own properties. */
12
- var hasOwnProperty = objectProto.hasOwnProperty;
13
- /** Used to infer the `Object` constructor. */
14
- var objectCtorString = funcToString.call(Object);
15
- /**
16
- * Checks if `value` is a plain object, that is, an object created by the
17
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
18
- *
19
- * @static
20
- * @memberOf _
21
- * @since 0.8.0
22
- * @category Lang
23
- * @param {*} value The value to check.
24
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
25
- * @example
26
- *
27
- * function Foo() {
28
- * this.a = 1;
29
- * }
30
- *
31
- * _.isPlainObject(new Foo);
32
- * // => false
33
- *
34
- * _.isPlainObject([1, 2, 3]);
35
- * // => false
36
- *
37
- * _.isPlainObject({ 'x': 0, 'y': 0 });
38
- * // => true
39
- *
40
- * _.isPlainObject(Object.create(null));
41
- * // => true
42
- */
43
- function isPlainObject(value) {
44
- if (!require__overArg.isObjectLike(value) || require__overArg.baseGetTag(value) != objectTag) return false;
45
- var proto = require__getPrototype.getPrototype(value);
46
- if (proto === null) return true;
47
- var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
48
- return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
49
- }
50
- //#endregion
51
- Object.defineProperty(exports, "isPlainObject", {
52
- enumerable: true,
53
- get: function() {
54
- return isPlainObject;
55
- }
56
- });
@@ -1,51 +0,0 @@
1
- import { i as baseGetTag, r as isObjectLike } from "./_overArg-CRYbj1NH.js";
2
- import { t as getPrototype } from "./_getPrototype-CG7Dxrrz.js";
3
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isPlainObject.js
4
- /** `Object#toString` result references. */
5
- var objectTag = "[object Object]";
6
- /** Used for built-in method references. */
7
- var funcProto = Function.prototype;
8
- var objectProto = Object.prototype;
9
- /** Used to resolve the decompiled source of functions. */
10
- var funcToString = funcProto.toString;
11
- /** Used to check objects for own properties. */
12
- var hasOwnProperty = objectProto.hasOwnProperty;
13
- /** Used to infer the `Object` constructor. */
14
- var objectCtorString = funcToString.call(Object);
15
- /**
16
- * Checks if `value` is a plain object, that is, an object created by the
17
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
18
- *
19
- * @static
20
- * @memberOf _
21
- * @since 0.8.0
22
- * @category Lang
23
- * @param {*} value The value to check.
24
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
25
- * @example
26
- *
27
- * function Foo() {
28
- * this.a = 1;
29
- * }
30
- *
31
- * _.isPlainObject(new Foo);
32
- * // => false
33
- *
34
- * _.isPlainObject([1, 2, 3]);
35
- * // => false
36
- *
37
- * _.isPlainObject({ 'x': 0, 'y': 0 });
38
- * // => true
39
- *
40
- * _.isPlainObject(Object.create(null));
41
- * // => true
42
- */
43
- function isPlainObject(value) {
44
- if (!isObjectLike(value) || baseGetTag(value) != objectTag) return false;
45
- var proto = getPrototype(value);
46
- if (proto === null) return true;
47
- var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
48
- return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
49
- }
50
- //#endregion
51
- export { isPlainObject as t };
@@ -1,52 +0,0 @@
1
- import { n as __exportAll } from "./rolldown-runtime-EAsCxrDo.js";
2
- import { i as baseGetTag, n as isArray, r as isObjectLike } from "./_overArg-CRYbj1NH.js";
3
- import { t as isPlainObject } from "./isPlainObject-D39AzPO2.js";
4
- import { z } from "@bpinternal/zui";
5
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
6
- /** `Object#toString` result references. */
7
- var stringTag = "[object String]";
8
- /**
9
- * Checks if `value` is classified as a `String` primitive or object.
10
- *
11
- * @static
12
- * @since 0.1.0
13
- * @memberOf _
14
- * @category Lang
15
- * @param {*} value The value to check.
16
- * @returns {boolean} Returns `true` if `value` is a string, else `false`.
17
- * @example
18
- *
19
- * _.isString('abc');
20
- * // => true
21
- *
22
- * _.isString(1);
23
- * // => false
24
- */
25
- function isString(value) {
26
- return typeof value == "string" || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag;
27
- }
28
- //#endregion
29
- //#region src/jsx.ts
30
- var jsx_exports = /* @__PURE__ */ __exportAll({
31
- createJsxComponent: () => createJsxComponent,
32
- isAnyJsxComponent: () => isAnyJsxComponent,
33
- isJsxComponent: () => isJsxComponent
34
- });
35
- function isAnyJsxComponent(component) {
36
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string";
37
- }
38
- function isJsxComponent(type, component) {
39
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string" && typeof type === "string" && component.type.toUpperCase().trim() === type.toUpperCase().trim();
40
- }
41
- const createJsxComponent = (props) => ({
42
- __jsx: true,
43
- type: isString(props.type) ? props.type.toUpperCase() : "__unknown__",
44
- children: Array.isArray(props.children) ? props.children : props.children ? [props.children] : [],
45
- props: isPlainObject(props.props) ? props.props : {}
46
- });
47
- z.custom((value) => isAnyJsxComponent(value), (value) => ({
48
- params: { value },
49
- message: `Invalid JSX component: ${value}`
50
- }));
51
- //#endregion
52
- export { jsx_exports as i, isAnyJsxComponent as n, isJsxComponent as r, createJsxComponent as t };
@@ -1,75 +0,0 @@
1
- const require_compiler = require("./compiler-C-OI9sim.cjs");
2
- const require__overArg = require("./_overArg-C5Hy7oCi.cjs");
3
- const require_isPlainObject = require("./isPlainObject-CSxXVKCk.cjs");
4
- let _bpinternal_zui = require("@bpinternal/zui");
5
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
6
- /** `Object#toString` result references. */
7
- var stringTag = "[object String]";
8
- /**
9
- * Checks if `value` is classified as a `String` primitive or object.
10
- *
11
- * @static
12
- * @since 0.1.0
13
- * @memberOf _
14
- * @category Lang
15
- * @param {*} value The value to check.
16
- * @returns {boolean} Returns `true` if `value` is a string, else `false`.
17
- * @example
18
- *
19
- * _.isString('abc');
20
- * // => true
21
- *
22
- * _.isString(1);
23
- * // => false
24
- */
25
- function isString(value) {
26
- return typeof value == "string" || !require__overArg.isArray(value) && require__overArg.isObjectLike(value) && require__overArg.baseGetTag(value) == stringTag;
27
- }
28
- //#endregion
29
- //#region src/jsx.ts
30
- var jsx_exports = /* @__PURE__ */ require_compiler.__exportAll({
31
- createJsxComponent: () => createJsxComponent,
32
- isAnyJsxComponent: () => isAnyJsxComponent,
33
- isJsxComponent: () => isJsxComponent
34
- });
35
- function isAnyJsxComponent(component) {
36
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string";
37
- }
38
- function isJsxComponent(type, component) {
39
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string" && typeof type === "string" && component.type.toUpperCase().trim() === type.toUpperCase().trim();
40
- }
41
- const createJsxComponent = (props) => ({
42
- __jsx: true,
43
- type: isString(props.type) ? props.type.toUpperCase() : "__unknown__",
44
- children: Array.isArray(props.children) ? props.children : props.children ? [props.children] : [],
45
- props: require_isPlainObject.isPlainObject(props.props) ? props.props : {}
46
- });
47
- _bpinternal_zui.z.custom((value) => isAnyJsxComponent(value), (value) => ({
48
- params: { value },
49
- message: `Invalid JSX component: ${value}`
50
- }));
51
- //#endregion
52
- Object.defineProperty(exports, "createJsxComponent", {
53
- enumerable: true,
54
- get: function() {
55
- return createJsxComponent;
56
- }
57
- });
58
- Object.defineProperty(exports, "isAnyJsxComponent", {
59
- enumerable: true,
60
- get: function() {
61
- return isAnyJsxComponent;
62
- }
63
- });
64
- Object.defineProperty(exports, "isJsxComponent", {
65
- enumerable: true,
66
- get: function() {
67
- return isJsxComponent;
68
- }
69
- });
70
- Object.defineProperty(exports, "jsx_exports", {
71
- enumerable: true,
72
- get: function() {
73
- return jsx_exports;
74
- }
75
- });
package/dist/jsx.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { z } from '@bpinternal/zui';
2
- export type JsxComponent<TType extends string = string, TProps extends {} = {}, TChildren = any> = {
3
- __jsx: true;
4
- type: TType;
5
- props: TProps;
6
- children: Array<TChildren>;
7
- };
8
- export declare function isAnyJsxComponent(component: any): component is JsxComponent;
9
- export declare function isJsxComponent<T extends JsxComponent>(type: T['type'], component: any): component is T;
10
- export declare const createJsxComponent: (props: Omit<JsxComponent, '__jsx'>) => JsxComponent;
11
- export declare const Jsx: z.ZodType<JsxComponent<string, {}, any>, z.ZodTypeDef, JsxComponent<string, {}, any>>;
@@ -1,9 +0,0 @@
1
- export * from './types.js';
2
- export { StreamingMessageParser, tryParseJson, type StreamingParserOptions } from './parser.js';
3
- export { BaseResponse, NextResponse, RunResponse, SendResponse, parseStream, parseText, type MessageStreamResponse, } from './stream.js';
4
- export { ReplayableAsyncIterable, collectText } from './replayable.js';
5
- export { ComponentRegistry } from './registry.js';
6
- export { normalizeComponentDefinition, normalizeComponentName, normalizePropsSchema, type GenerativeComponentDefinition, } from './normalizer.js';
7
- export { validateComponent, validateProps, type ComponentValidationError, type ComponentValidationResult, } from './validator.js';
8
- export { generateInstructions, type InstructionGeneratorOptions, type InstructionVerbosity } from './instructions.js';
9
- export { sanitizeMessageText, type SanitizeOptions } from './sanitize.js';
@@ -1,30 +0,0 @@
1
- import { type NormalizedComponentDefinition, type NormalizedExitDefinition } from './types.js';
2
- export type InstructionVerbosity = 'compact' | 'standard' | 'verbose';
3
- export type InstructionGeneratorOptions = {
4
- /** Exits available to `■next`. */
5
- exits?: NormalizedExitDefinition[];
6
- /** Whether the `■run` directive is available. Default: true. */
7
- includeRun?: boolean;
8
- /** Whether the `■send` directive is available. Default: true when at least one component is registered. */
9
- includeSend?: boolean;
10
- verbosity?: InstructionVerbosity;
11
- /** Defaults to true, except in compact mode. */
12
- includeExamples?: boolean;
13
- maxExamples?: number;
14
- /** Sort components by priority then name. Default: true. */
15
- sortComponents?: boolean;
16
- };
17
- /**
18
- * Converts registered component and exit definitions into a deterministic,
19
- * model-facing protocol specification. Given the same definitions and options,
20
- * the output is byte-identical — safe for prompt caching and snapshots.
21
- */
22
- export declare function generateInstructions(components: NormalizedComponentDefinition[], options?: InstructionGeneratorOptions): string;
23
- /** Render catalogues with a partial example beside every component and exit. */
24
- export declare function generateInstructionSections(components: NormalizedComponentDefinition[], options?: InstructionGeneratorOptions): {
25
- syntax: string;
26
- components: string;
27
- exits: string;
28
- };
29
- export declare const componentExample: (definition: NormalizedComponentDefinition) => string;
30
- export declare const exitExample: (exit: NormalizedExitDefinition) => string;
@@ -1,21 +0,0 @@
1
- import { type ZodObject } from '@bpinternal/zui';
2
- import { type BodyFormat, type GenerativeComponentMetadata, type JsonSchema, type NormalizedComponentDefinition } from './types.js';
3
- /**
4
- * User-facing component definition. Props may be declared with a ZUI/Zod object
5
- * schema or a plain JSON schema. Everything downstream of the normalizer
6
- * (parser, validator, instruction generator) is independent of ZUI/Zod.
7
- */
8
- export type GenerativeComponentDefinition = {
9
- name: string;
10
- description?: string;
11
- props?: ZodObject<any> | JsonSchema;
12
- body?: {
13
- type: BodyFormat;
14
- description?: string;
15
- required?: boolean;
16
- };
17
- generation?: GenerativeComponentMetadata;
18
- };
19
- export declare const normalizeComponentName: (name: string) => string;
20
- export declare function normalizeComponentDefinition(definition: GenerativeComponentDefinition): NormalizedComponentDefinition;
21
- export declare function normalizePropsSchema(props: ZodObject<any> | JsonSchema | undefined, name: string): JsonSchema;
@@ -1,89 +0,0 @@
1
- import { type Diagnostic, type MessageStreamEvent, type ParsedItem } from './types.js';
2
- export type StreamingParserOptions = {
3
- /** Maximum number of characters buffered for a props object before the item is marked invalid. Default: 100 000. */
4
- maxPropsLength?: number;
5
- };
6
- /**
7
- * Lenient JSON parsing: JSON5 first (unquoted keys, single quotes, trailing
8
- * commas), then jsonrepair for anything else the model got slightly wrong.
9
- */
10
- export declare const tryParseJson: (text: string) => unknown;
11
- /**
12
- * Incremental, chunk-boundary-agnostic parser for the message-stream protocol.
13
- *
14
- * The parser is purely syntactic: it knows the reserved `■` symbol and the
15
- * directive grammar, but nothing about registered components, exits or their
16
- * schemas. Semantic validation is a separate step (see `validator.ts`).
17
- * Text outside protocol blocks is always discarded with a diagnostic; only
18
- * explicit `■send` blocks can produce messages.
19
- *
20
- * Pushing the same text split across arbitrary chunk boundaries always produces
21
- * the same items and the same concatenated body deltas. For a higher-level
22
- * `AsyncIterable` API, see `stream.ts`.
23
- */
24
- export declare class StreamingMessageParser {
25
- private _maxPropsLength;
26
- private _state;
27
- private _items;
28
- private _diagnostics;
29
- private _current;
30
- private _currentReady;
31
- private _counter;
32
- private _finished;
33
- private _ended;
34
- private _directiveBuffer;
35
- private _nameBuffer;
36
- private _propsBuffer;
37
- private _propsDepth;
38
- private _quoteChar;
39
- private _escaped;
40
- private _propsBroken;
41
- private _bodyDelta;
42
- private _pendingWhitespace;
43
- private _preambleHeader;
44
- private _closingFenceTicks;
45
- private _lineStart;
46
- private _exampleDelimiter;
47
- constructor(options?: StreamingParserOptions);
48
- /** All items parsed so far, in order of appearance. */
49
- get items(): ParsedItem[];
50
- /** All syntax diagnostics, including discarded text that has no protocol item. */
51
- get diagnostics(): Diagnostic[];
52
- push(chunk: string): MessageStreamEvent[];
53
- /**
54
- * Signals the end of the transport stream.
55
- * Pass `'interrupted'` when the stream was cut short (aborted request, network
56
- * error) so the active item is marked `interrupted` instead of `complete`.
57
- * All received content is preserved either way.
58
- */
59
- finish(reason?: 'end' | 'interrupted'): MessageStreamEvent[];
60
- reset(): void;
61
- private _processOutputChar;
62
- private _flushExampleDelimiter;
63
- private _discardExampleDelimiter;
64
- private _processChar;
65
- private _recoverPreambleHeader;
66
- /** Handles a character on the header line, after the directive and name have been parsed. */
67
- private _afterHeaderChar;
68
- private _processPropsChar;
69
- private _beginItem;
70
- /**
71
- * Finalizes the directive token. `terminator` tells us what ended it:
72
- * '=' (a name follows), whitespace/newline/'{' (no name), or undefined (■ or end of stream).
73
- */
74
- private _endDirective;
75
- private _endName;
76
- private _startProps;
77
- private _endProps;
78
- /** Attempts to salvage props that were cut off by the end of the stream. */
79
- private _endPartialProps;
80
- private _failProps;
81
- private _startBody;
82
- private _appendBody;
83
- private _emitBodyText;
84
- private _flushBodyDelta;
85
- private _ready;
86
- private _completeCurrent;
87
- private _skipUnexpectedText;
88
- private _diagnostic;
89
- }
@@ -1,14 +0,0 @@
1
- import { type NormalizedComponentDefinition } from './types.js';
2
- /**
3
- * Stores normalized component definitions. The registry (not the parser) is the
4
- * single source of truth for which components exist and how they are validated.
5
- */
6
- export declare class ComponentRegistry {
7
- private _definitions;
8
- constructor(definitions?: NormalizedComponentDefinition[]);
9
- register(definition: NormalizedComponentDefinition): void;
10
- unregister(name: string): void;
11
- has(name: string): boolean;
12
- get(name: string): NormalizedComponentDefinition | undefined;
13
- list(): NormalizedComponentDefinition[];
14
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Wraps an async iterable so it can be iterated multiple times: chunks pulled
3
- * from the source are cached, and every iteration replays the cache before
4
- * pulling new chunks. Concurrent iterations are safe — pulls on the underlying
5
- * source are serialized. If the source fails, the failure is cached too:
6
- * every iteration replays the chunks received before the failure, then
7
- * rethrows the source error.
8
- */
9
- export declare class ReplayableAsyncIterable<T> implements AsyncIterable<T> {
10
- private _source;
11
- private _chunks;
12
- private _done;
13
- private _failed;
14
- private _error;
15
- private _lock;
16
- constructor(source: AsyncIterable<T>);
17
- /** True once the underlying source has been fully consumed (or has failed). */
18
- get done(): boolean;
19
- /** The chunks pulled from the source so far. */
20
- get chunks(): T[];
21
- [Symbol.asyncIterator](): AsyncIterator<T>;
22
- /** Consumes the entire source and returns all chunks. */
23
- collect(): Promise<T[]>;
24
- private _pull;
25
- }
26
- /** Drains a string iterable into a single string. */
27
- export declare const collectText: (iterable: AsyncIterable<string>) => Promise<string>;
@@ -1,24 +0,0 @@
1
- import type { StopReason } from '@botpress/cognitive';
2
- import type { Diagnostic, MessageStreamEvent, ParsedItem } from './types.js';
3
- /** One wire format: a complete ■start … ■end envelope containing valid blocks. */
4
- export declare class ResponseParser {
5
- private _parser;
6
- private _mode;
7
- private _discardPrefixLine;
8
- private _prefixDiagnostics;
9
- private _prefix;
10
- private _boundary;
11
- private _closed;
12
- private _finished;
13
- private _failure;
14
- private _trailer;
15
- get framed(): boolean;
16
- get valid(): boolean;
17
- get items(): ParsedItem[];
18
- get diagnostics(): Diagnostic[];
19
- push(chunk: string): MessageStreamEvent[];
20
- finish(stopReason?: StopReason): MessageStreamEvent[];
21
- private _trailingDiagnostics;
22
- private _validateBlocks;
23
- private _fail;
24
- }
@@ -1,10 +0,0 @@
1
- export type SanitizeOptions = {
2
- /** Replacement for the reserved `■` marker. Defaults to a visually similar `▪`. */
3
- markerReplacement?: string;
4
- };
5
- /**
6
- * The protocol has no escaping mechanism by design. Any untrusted text that is
7
- * inserted into model context (user messages, tool results, documents) must be
8
- * sanitized so it cannot inject protocol blocks.
9
- */
10
- export declare const sanitizeMessageText: (value: string, options?: SanitizeOptions) => string;