llmz 0.8.0 → 1.0.1

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 (224) hide show
  1. package/DOCS.md +230 -1796
  2. package/ERRORS.md +98 -0
  3. package/README.md +96 -548
  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-BpMVZYOa.cjs +649 -0
  16. package/dist/component-C27qu6Zv.js +614 -0
  17. package/dist/context.d.ts +74 -385
  18. package/dist/custom-client-BDkgBR2w.js +1631 -0
  19. package/dist/custom-client-MytucGI-.cjs +1708 -0
  20. package/dist/custom-client.d.ts +12 -2
  21. package/dist/errors/catalog.d.ts +287 -0
  22. package/dist/errors/hooks.d.ts +2 -0
  23. package/dist/errors-H4JJFH3S.js +620 -0
  24. package/dist/errors-IhnTKUp7.cjs +871 -0
  25. package/dist/errors.d.ts +18 -36
  26. package/dist/execute-BYI_U5sR.js +1943 -0
  27. package/dist/execute-DLas4V2n.cjs +1944 -0
  28. package/dist/{exit-DUM96DN1.cjs → exit-BUgJ5qi5.cjs} +38 -28
  29. package/dist/{exit-CDdxDBRT.js → exit-CPNk3vbz.js} +37 -27
  30. package/dist/exit.d.ts +19 -16
  31. package/dist/index.cjs +181 -999
  32. package/dist/index.d.ts +25 -28
  33. package/dist/index.js +141 -974
  34. package/dist/index.workerd.js +7725 -9531
  35. package/dist/inspect.d.ts +19 -3
  36. package/dist/inspection.d.ts +38 -0
  37. package/dist/native-Bm6L9zOb.cjs +212 -0
  38. package/dist/native-DvTH9vFe.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 -98
  42. package/dist/quickjs-variant-DJwYDSsb.cjs +1073 -0
  43. package/dist/quickjs-variant-DlPi9-Sx.js +984 -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-activity.test.d.ts +1 -0
  48. package/dist/runtime/execution-diagnostics.d.ts +11 -0
  49. package/dist/runtime/execution-diagnostics.test.d.ts +1 -0
  50. package/dist/runtime/execution-report.d.ts +48 -0
  51. package/dist/runtime/execution-report.test.d.ts +1 -0
  52. package/dist/runtime/execution-safety.test.d.ts +1 -0
  53. package/dist/runtime/exit-control-flow.test.d.ts +1 -0
  54. package/dist/runtime/fixtures/chat.d.ts +8 -0
  55. package/dist/runtime/fixtures/long-search.d.ts +19 -0
  56. package/dist/runtime/fixtures/long-search.test.d.ts +1 -0
  57. package/dist/runtime/fixtures/native-client.d.ts +33 -0
  58. package/dist/runtime/fixtures/protocol-languages.d.ts +74 -0
  59. package/dist/runtime/generate.d.ts +23 -27
  60. package/dist/runtime/generate.test.d.ts +1 -0
  61. package/dist/runtime/hook-provenance.test.d.ts +1 -0
  62. package/dist/runtime/inspection-hook.test.d.ts +1 -0
  63. package/dist/runtime/inspection-values.d.ts +14 -0
  64. package/dist/runtime/inspection-values.test.d.ts +1 -0
  65. package/dist/runtime/interruption-control-flow.test.d.ts +1 -0
  66. package/dist/runtime/interruption-settings.test.d.ts +1 -0
  67. package/dist/runtime/javascript-api.d.ts +59 -0
  68. package/dist/runtime/javascript-api.test.d.ts +1 -0
  69. package/dist/runtime/native-review.test.d.ts +1 -0
  70. package/dist/runtime/native-tools.d.ts +18 -0
  71. package/dist/runtime/native-tools.test.d.ts +1 -0
  72. package/dist/runtime/object-memory.test.d.ts +1 -0
  73. package/dist/runtime/protocol-adherence.test.d.ts +1 -0
  74. package/dist/runtime/single-tool.test.d.ts +1 -0
  75. package/dist/runtime/token-budget.d.ts +22 -0
  76. package/dist/runtime/token-budget.test.d.ts +1 -0
  77. package/dist/runtime/tool-wrapper.d.ts +4 -5
  78. package/dist/runtime/traces.test.d.ts +1 -0
  79. package/dist/runtime/truncation.test.d.ts +1 -0
  80. package/dist/runtime/types.d.ts +41 -36
  81. package/dist/runtime/variable-recovery.test.d.ts +1 -0
  82. package/dist/runtime/vm-context.d.ts +6 -1
  83. package/dist/runtime/worker-completion.test.d.ts +1 -0
  84. package/dist/runtime-names.d.ts +4 -0
  85. package/dist/schema-Aer_W7Al.js +45 -0
  86. package/dist/schema-DBkjo0b7.cjs +68 -0
  87. package/dist/schema.d.ts +10 -0
  88. package/dist/schema.test.d.ts +1 -0
  89. package/dist/session/compactor.d.ts +51 -0
  90. package/dist/session/compactor.test.d.ts +1 -0
  91. package/dist/session/history.d.ts +36 -0
  92. package/dist/session/history.test.d.ts +1 -0
  93. package/dist/session/json.d.ts +3 -0
  94. package/dist/session/json.test.d.ts +1 -0
  95. package/dist/session/memory-codec.d.ts +9 -0
  96. package/dist/session/memory-codec.test.d.ts +1 -0
  97. package/dist/session/memory-render.d.ts +15 -0
  98. package/dist/session/memory-render.test.d.ts +1 -0
  99. package/dist/session/memory.d.ts +112 -0
  100. package/dist/session/memory.test.d.ts +1 -0
  101. package/dist/session/messages.d.ts +17 -0
  102. package/dist/session/messages.test.d.ts +1 -0
  103. package/dist/session/serialization.d.ts +34 -0
  104. package/dist/session/serialization.test.d.ts +1 -0
  105. package/dist/session/session-memory.test.d.ts +1 -0
  106. package/dist/session/session.d.ts +117 -0
  107. package/dist/session/session.test.d.ts +1 -0
  108. package/dist/{transcript.d.ts → session/transcript.d.ts} +4 -8
  109. package/dist/session/transcript.test.d.ts +1 -0
  110. package/dist/{tool-Bv8N4IPj.js → tool--gK91eez.js} +144 -92
  111. package/dist/{tool-Dy6AJpJH.cjs → tool-Da_F-N-5.cjs} +146 -94
  112. package/dist/tool.d.ts +25 -17
  113. package/dist/truncate-BSoH2-nY.js +79 -0
  114. package/dist/truncate-nV3Mxr6-.cjs +102 -0
  115. package/dist/truncate.d.ts +24 -0
  116. package/dist/truncate.test.d.ts +1 -0
  117. package/dist/types.d.ts +27 -9
  118. package/dist/{typings-3lsqCbkn.cjs → typings-C1ihexWE.cjs} +38 -193
  119. package/dist/{typings-CrBa7Tyy.js → typings-D9_aC8aq.js} +38 -175
  120. package/dist/typings-formatter.d.ts +1 -1
  121. package/dist/typings.d.ts +3 -0
  122. package/dist/{uniq-BYQ7GWwb.js → uniq-DfUeSNaX.js} +2 -2
  123. package/dist/{uniq-G872RWmE.cjs → uniq-DiXgysNV.cjs} +6 -18
  124. package/dist/{_baseIteratee-P_firB7b.js → utils-BOFzb8Ok.js} +1134 -16
  125. package/dist/{_baseIteratee-CF4qP2a8.cjs → utils-CTlsXvdj.cjs} +1281 -84
  126. package/dist/vm/drivers/node.d.ts +1 -1
  127. package/dist/vm/drivers/quickjs.d.ts +1 -1
  128. package/dist/vm/errors.d.ts +4 -4
  129. package/dist/vm/index.d.ts +3 -4
  130. package/dist/vm/instrument.d.ts +14 -6
  131. package/dist/vm/member-proxy.d.ts +4 -0
  132. package/dist/vm/member-proxy.test.d.ts +1 -0
  133. package/dist/vm/memory.test.d.ts +1 -0
  134. package/dist/vm/return-semantics.test.d.ts +1 -0
  135. package/dist/vm/types.d.ts +18 -3
  136. package/dist/{vm-BLsHw1da.js → vm-8jxt8PTK.js} +1162 -180
  137. package/dist/{vm-D6s1zF6M.cjs → vm-XuVPuW3Y.cjs} +1195 -207
  138. package/package.json +13 -6
  139. package/dist/_baseForOwn-BfWDTL8L.cjs +0 -53
  140. package/dist/_baseForOwn-CFhWe_W6.js +0 -48
  141. package/dist/_getPrototype-CG7Dxrrz.js +0 -6
  142. package/dist/_getPrototype-DQDlNVVM.cjs +0 -10
  143. package/dist/_overArg-C5Hy7oCi.cjs +0 -196
  144. package/dist/_overArg-CRYbj1NH.js +0 -155
  145. package/dist/chat.d.ts +0 -401
  146. package/dist/common-DdArNQhl.cjs +0 -643
  147. package/dist/common-pgJjFu2Y.js +0 -596
  148. package/dist/compiler/plugins/track-tool-calls.d.ts +0 -33
  149. package/dist/compiler-C-OI9sim.cjs +0 -547
  150. package/dist/compiler-CW1VjQsn.js +0 -473
  151. package/dist/component-BXS8vAwO.cjs +0 -73
  152. package/dist/component-Dq7ZLdvy.js +0 -44
  153. package/dist/component.d.ts +0 -88
  154. package/dist/component.default.d.ts +0 -268
  155. package/dist/custom-client-2V9lmzUf.js +0 -2655
  156. package/dist/custom-client-HkM1Sdzv.cjs +0 -2726
  157. package/dist/dual-modes-Cb7ThvoV.cjs +0 -3020
  158. package/dist/dual-modes-Cy0_W4O2.js +0 -2930
  159. package/dist/errors-C962uJdS.cjs +0 -220
  160. package/dist/errors-Cg1G0Awu.js +0 -161
  161. package/dist/example.d.ts +0 -45
  162. package/dist/execute-Aw4cbIx-.js +0 -1080
  163. package/dist/execute-COIHOIKR.cjs +0 -1081
  164. package/dist/exit-parser.d.ts +0 -39
  165. package/dist/handlers.d.ts +0 -10
  166. package/dist/hoist.d.ts +0 -2
  167. package/dist/isEmpty-BhJRCqIF.js +0 -52
  168. package/dist/isEmpty-LY533Wmh.cjs +0 -57
  169. package/dist/jsx-B0iYyvfr.js +0 -100
  170. package/dist/jsx-D5Y2cPo-.cjs +0 -129
  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 -22
  174. package/dist/message-stream/normalizer.d.ts +0 -21
  175. package/dist/message-stream/parser.d.ts +0 -83
  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/sanitize.d.ts +0 -10
  179. package/dist/message-stream/stream.d.ts +0 -54
  180. package/dist/message-stream/types.d.ts +0 -96
  181. package/dist/message-stream/validator.d.ts +0 -23
  182. package/dist/prompts/chat-mode/system.d.ts +0 -2
  183. package/dist/prompts/chat-mode/system.md.d.ts +0 -2
  184. package/dist/prompts/chat-mode/user.d.ts +0 -2
  185. package/dist/prompts/chat-mode/user.md.d.ts +0 -2
  186. package/dist/prompts/common.d.ts +0 -6
  187. package/dist/prompts/dual-modes.d.ts +0 -2
  188. package/dist/prompts/execution-history.d.ts +0 -6
  189. package/dist/prompts/execution-state.d.ts +0 -3
  190. package/dist/prompts/protocol.d.ts +0 -18
  191. package/dist/prompts/worker-mode/system.d.ts +0 -2
  192. package/dist/prompts/worker-mode/system.md.d.ts +0 -2
  193. package/dist/prompts/worker-mode/user.d.ts +0 -2
  194. package/dist/prompts/worker-mode/user.md.d.ts +0 -2
  195. package/dist/quickjs-variant-BYhMBpwU.js +0 -45
  196. package/dist/quickjs-variant-CsIwTVFC.cjs +0 -56
  197. package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
  198. package/dist/runtime/interpret-result.d.ts +0 -22
  199. package/dist/snapshots.d.ts +0 -249
  200. package/dist/stack-traces-BIE_5Xwf.js +0 -21
  201. package/dist/stack-traces-ntw_qhoy.cjs +0 -26
  202. package/dist/truncator-CLkouTCO.cjs +0 -276
  203. package/dist/truncator-DZqEqnpD.js +0 -253
  204. package/dist/truncator.d.ts +0 -118
  205. package/dist/utils-3ESwP3yg.cjs +0 -1075
  206. package/dist/utils-UBeAFeEI.js +0 -950
  207. /package/dist/{citations.d.ts → chat/citations.d.ts} +0 -0
  208. /package/dist/{citations.test.d.ts → chat/citations.test.d.ts} +0 -0
  209. /package/dist/{component.default.test.d.ts → chat/component.default.test.d.ts} +0 -0
  210. /package/dist/{compiler/plugins/track-tool-calls.test.d.ts → chat/component.test.d.ts} +0 -0
  211. /package/dist/{example.test.d.ts → chat/response.test.d.ts} +0 -0
  212. /package/dist/{exit-parser.test.d.ts → compiler/plugins/dynamic-code.test.d.ts} +0 -0
  213. /package/dist/{handlers.test.d.ts → compiler/plugins/tool-resolution.test.d.ts} +0 -0
  214. /package/dist/{hoist.test.d.ts → errors/catalog.test.d.ts} +0 -0
  215. /package/dist/{message-stream/instructions.test.d.ts → exit.test.d.ts} +0 -0
  216. /package/dist/{message-stream/normalizer.test.d.ts → inspection.test.d.ts} +0 -0
  217. /package/dist/{message-stream/parser.test.d.ts → prompts/native.test.d.ts} +0 -0
  218. /package/dist/{message-stream/stream.test.d.ts → result.test.d.ts} +0 -0
  219. /package/dist/{message-stream/validator.test.d.ts → runtime/chat-delivery.test.d.ts} +0 -0
  220. /package/dist/{prompts/common.test.d.ts → runtime/citations.test.d.ts} +0 -0
  221. /package/dist/{prompts/protocol.test.d.ts → runtime/compatibility-regressions.test.d.ts} +0 -0
  222. /package/dist/runtime/{interpret-result.test.d.ts → context-registration.test.d.ts} +0 -0
  223. /package/dist/{transcript.test.d.ts → runtime/error-recovery.test.d.ts} +0 -0
  224. /package/dist/{truncator.test.d.ts → runtime/errors.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,100 +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 getPrototype } from "./_getPrototype-CG7Dxrrz.js";
4
- import { z } from "@bpinternal/zui";
5
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isPlainObject.js
6
- /** `Object#toString` result references. */
7
- var objectTag = "[object Object]";
8
- /** Used for built-in method references. */
9
- var funcProto = Function.prototype;
10
- var objectProto = Object.prototype;
11
- /** Used to resolve the decompiled source of functions. */
12
- var funcToString = funcProto.toString;
13
- /** Used to check objects for own properties. */
14
- var hasOwnProperty = objectProto.hasOwnProperty;
15
- /** Used to infer the `Object` constructor. */
16
- var objectCtorString = funcToString.call(Object);
17
- /**
18
- * Checks if `value` is a plain object, that is, an object created by the
19
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
20
- *
21
- * @static
22
- * @memberOf _
23
- * @since 0.8.0
24
- * @category Lang
25
- * @param {*} value The value to check.
26
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
27
- * @example
28
- *
29
- * function Foo() {
30
- * this.a = 1;
31
- * }
32
- *
33
- * _.isPlainObject(new Foo);
34
- * // => false
35
- *
36
- * _.isPlainObject([1, 2, 3]);
37
- * // => false
38
- *
39
- * _.isPlainObject({ 'x': 0, 'y': 0 });
40
- * // => true
41
- *
42
- * _.isPlainObject(Object.create(null));
43
- * // => true
44
- */
45
- function isPlainObject(value) {
46
- if (!isObjectLike(value) || baseGetTag(value) != objectTag) return false;
47
- var proto = getPrototype(value);
48
- if (proto === null) return true;
49
- var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
50
- return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
51
- }
52
- //#endregion
53
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
54
- /** `Object#toString` result references. */
55
- var stringTag = "[object String]";
56
- /**
57
- * Checks if `value` is classified as a `String` primitive or object.
58
- *
59
- * @static
60
- * @since 0.1.0
61
- * @memberOf _
62
- * @category Lang
63
- * @param {*} value The value to check.
64
- * @returns {boolean} Returns `true` if `value` is a string, else `false`.
65
- * @example
66
- *
67
- * _.isString('abc');
68
- * // => true
69
- *
70
- * _.isString(1);
71
- * // => false
72
- */
73
- function isString(value) {
74
- return typeof value == "string" || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag;
75
- }
76
- //#endregion
77
- //#region src/jsx.ts
78
- var jsx_exports = /* @__PURE__ */ __exportAll({
79
- createJsxComponent: () => createJsxComponent,
80
- isAnyJsxComponent: () => isAnyJsxComponent,
81
- isJsxComponent: () => isJsxComponent
82
- });
83
- function isAnyJsxComponent(component) {
84
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string";
85
- }
86
- function isJsxComponent(type, component) {
87
- 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();
88
- }
89
- const createJsxComponent = (props) => ({
90
- __jsx: true,
91
- type: isString(props.type) ? props.type.toUpperCase() : "__unknown__",
92
- children: Array.isArray(props.children) ? props.children : props.children ? [props.children] : [],
93
- props: isPlainObject(props.props) ? props.props : {}
94
- });
95
- z.custom((value) => isAnyJsxComponent(value), (value) => ({
96
- params: { value },
97
- message: `Invalid JSX component: ${value}`
98
- }));
99
- //#endregion
100
- export { isPlainObject as a, jsx_exports as i, isAnyJsxComponent as n, isJsxComponent as r, createJsxComponent as t };
@@ -1,129 +0,0 @@
1
- const require_compiler = require("./compiler-C-OI9sim.cjs");
2
- const require__overArg = require("./_overArg-C5Hy7oCi.cjs");
3
- const require__getPrototype = require("./_getPrototype-DQDlNVVM.cjs");
4
- let _bpinternal_zui = require("@bpinternal/zui");
5
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isPlainObject.js
6
- /** `Object#toString` result references. */
7
- var objectTag = "[object Object]";
8
- /** Used for built-in method references. */
9
- var funcProto = Function.prototype;
10
- var objectProto = Object.prototype;
11
- /** Used to resolve the decompiled source of functions. */
12
- var funcToString = funcProto.toString;
13
- /** Used to check objects for own properties. */
14
- var hasOwnProperty = objectProto.hasOwnProperty;
15
- /** Used to infer the `Object` constructor. */
16
- var objectCtorString = funcToString.call(Object);
17
- /**
18
- * Checks if `value` is a plain object, that is, an object created by the
19
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
20
- *
21
- * @static
22
- * @memberOf _
23
- * @since 0.8.0
24
- * @category Lang
25
- * @param {*} value The value to check.
26
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
27
- * @example
28
- *
29
- * function Foo() {
30
- * this.a = 1;
31
- * }
32
- *
33
- * _.isPlainObject(new Foo);
34
- * // => false
35
- *
36
- * _.isPlainObject([1, 2, 3]);
37
- * // => false
38
- *
39
- * _.isPlainObject({ 'x': 0, 'y': 0 });
40
- * // => true
41
- *
42
- * _.isPlainObject(Object.create(null));
43
- * // => true
44
- */
45
- function isPlainObject(value) {
46
- if (!require__overArg.isObjectLike(value) || require__overArg.baseGetTag(value) != objectTag) return false;
47
- var proto = require__getPrototype.getPrototype(value);
48
- if (proto === null) return true;
49
- var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
50
- return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
51
- }
52
- //#endregion
53
- //#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
54
- /** `Object#toString` result references. */
55
- var stringTag = "[object String]";
56
- /**
57
- * Checks if `value` is classified as a `String` primitive or object.
58
- *
59
- * @static
60
- * @since 0.1.0
61
- * @memberOf _
62
- * @category Lang
63
- * @param {*} value The value to check.
64
- * @returns {boolean} Returns `true` if `value` is a string, else `false`.
65
- * @example
66
- *
67
- * _.isString('abc');
68
- * // => true
69
- *
70
- * _.isString(1);
71
- * // => false
72
- */
73
- function isString(value) {
74
- return typeof value == "string" || !require__overArg.isArray(value) && require__overArg.isObjectLike(value) && require__overArg.baseGetTag(value) == stringTag;
75
- }
76
- //#endregion
77
- //#region src/jsx.ts
78
- var jsx_exports = /* @__PURE__ */ require_compiler.__exportAll({
79
- createJsxComponent: () => createJsxComponent,
80
- isAnyJsxComponent: () => isAnyJsxComponent,
81
- isJsxComponent: () => isJsxComponent
82
- });
83
- function isAnyJsxComponent(component) {
84
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string";
85
- }
86
- function isJsxComponent(type, component) {
87
- 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();
88
- }
89
- const createJsxComponent = (props) => ({
90
- __jsx: true,
91
- type: isString(props.type) ? props.type.toUpperCase() : "__unknown__",
92
- children: Array.isArray(props.children) ? props.children : props.children ? [props.children] : [],
93
- props: isPlainObject(props.props) ? props.props : {}
94
- });
95
- _bpinternal_zui.z.custom((value) => isAnyJsxComponent(value), (value) => ({
96
- params: { value },
97
- message: `Invalid JSX component: ${value}`
98
- }));
99
- //#endregion
100
- Object.defineProperty(exports, "createJsxComponent", {
101
- enumerable: true,
102
- get: function() {
103
- return createJsxComponent;
104
- }
105
- });
106
- Object.defineProperty(exports, "isAnyJsxComponent", {
107
- enumerable: true,
108
- get: function() {
109
- return isAnyJsxComponent;
110
- }
111
- });
112
- Object.defineProperty(exports, "isJsxComponent", {
113
- enumerable: true,
114
- get: function() {
115
- return isJsxComponent;
116
- }
117
- });
118
- Object.defineProperty(exports, "isPlainObject", {
119
- enumerable: true,
120
- get: function() {
121
- return isPlainObject;
122
- }
123
- });
124
- Object.defineProperty(exports, "jsx_exports", {
125
- enumerable: true,
126
- get: function() {
127
- return jsx_exports;
128
- }
129
- });
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,22 +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;
@@ -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,83 +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 _directiveBuffer;
34
- private _nameBuffer;
35
- private _propsBuffer;
36
- private _propsDepth;
37
- private _quoteChar;
38
- private _escaped;
39
- private _propsBroken;
40
- private _bodyDelta;
41
- private _pendingWhitespace;
42
- private _preambleHeader;
43
- private _closingFenceTicks;
44
- constructor(options?: StreamingParserOptions);
45
- /** All items parsed so far, in order of appearance. */
46
- get items(): ParsedItem[];
47
- /** All syntax diagnostics, including discarded text that has no protocol item. */
48
- get diagnostics(): Diagnostic[];
49
- push(chunk: string): MessageStreamEvent[];
50
- /**
51
- * Signals the end of the transport stream.
52
- * Pass `'interrupted'` when the stream was cut short (aborted request, network
53
- * error) so the active item is marked `interrupted` instead of `complete`.
54
- * All received content is preserved either way.
55
- */
56
- finish(reason?: 'end' | 'interrupted'): MessageStreamEvent[];
57
- reset(): void;
58
- private _processChar;
59
- private _recoverPreambleHeader;
60
- /** Handles a character on the header line, after the directive and name have been parsed. */
61
- private _afterHeaderChar;
62
- private _processPropsChar;
63
- private _beginItem;
64
- /**
65
- * Finalizes the directive token. `terminator` tells us what ended it:
66
- * '=' (a name follows), whitespace/newline/'{' (no name), or undefined (■ or end of stream).
67
- */
68
- private _endDirective;
69
- private _endName;
70
- private _startProps;
71
- private _endProps;
72
- /** Attempts to salvage props that were cut off by the end of the stream. */
73
- private _endPartialProps;
74
- private _failProps;
75
- private _startBody;
76
- private _appendBody;
77
- private _emitBodyText;
78
- private _flushBodyDelta;
79
- private _ready;
80
- private _completeCurrent;
81
- private _skipUnexpectedText;
82
- private _diagnostic;
83
- }
@@ -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,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;
@@ -1,54 +0,0 @@
1
- import { type StreamingParserOptions } from './parser.js';
2
- import { ReplayableAsyncIterable } from './replayable.js';
3
- import { type Diagnostic, type ParsedItem } from './types.js';
4
- export declare abstract class BaseResponse {
5
- readonly action: 'send' | 'run' | 'next';
6
- /** The underlying parsed item. Live: status, body and diagnostics update as the stream advances. */
7
- readonly item: ParsedItem;
8
- protected constructor(action: 'send' | 'run' | 'next',
9
- /** The underlying parsed item. Live: status, body and diagnostics update as the stream advances. */
10
- item: ParsedItem);
11
- get diagnostics(): Diagnostic[];
12
- }
13
- /** `■send=<component> { props? }` followed by an optional streaming body. */
14
- export declare class SendResponse extends BaseResponse {
15
- /** The streaming body. Replayable: it can be consumed while streaming and read again later. */
16
- readonly content: ReplayableAsyncIterable<string>;
17
- constructor(item: ParsedItem,
18
- /** The streaming body. Replayable: it can be consumed while streaming and read again later. */
19
- content: ReplayableAsyncIterable<string>);
20
- get component(): string;
21
- get props(): Record<string, unknown>;
22
- static formatToText(component: string, props?: Record<string, unknown>, body?: string): string;
23
- }
24
- /** `■run` followed by streaming code. */
25
- export declare class RunResponse extends BaseResponse {
26
- /** The streaming code. Replayable: it can be consumed while streaming and read again later. */
27
- readonly code: ReplayableAsyncIterable<string>;
28
- constructor(item: ParsedItem,
29
- /** The streaming code. Replayable: it can be consumed while streaming and read again later. */
30
- code: ReplayableAsyncIterable<string>);
31
- static formatToText(code: string): string;
32
- }
33
- /** `■next=<name> { props? }` — hands control to an exit (e.g. listen) with optional props. */
34
- export declare class NextResponse extends BaseResponse {
35
- constructor(item: ParsedItem);
36
- get name(): string;
37
- get props(): Record<string, unknown>;
38
- static formatToText(name: string, props?: Record<string, unknown>): string;
39
- }
40
- export type MessageStreamResponse = SendResponse | RunResponse | NextResponse;
41
- /**
42
- * Parses a raw LLM text stream into typed responses.
43
- *
44
- * `send` and `run` responses are yielded as soon as their header is parsed —
45
- * while their body is still streaming — with the body exposed as a replayable
46
- * async iterable. `next` responses are yielded once complete.
47
- *
48
- * The body streams are pull-based: consuming them drives the underlying
49
- * transport. Requesting the next response first drains the previous body into
50
- * its replay cache, so it can always be read later.
51
- */
52
- export declare function parseStream(stream: AsyncIterable<string>, options?: StreamingParserOptions): AsyncIterable<MessageStreamResponse>;
53
- /** Parses a complete text (convenience wrapper over {@link parseStream}). */
54
- export declare function parseText(text: string, options?: StreamingParserOptions): AsyncIterable<MessageStreamResponse>;