llmz 0.2.2 → 0.2.3

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 (50) hide show
  1. package/CLAUDE.md +0 -1
  2. package/dist/{chunk-2EZSVF5X.cjs → chunk-3UZKLXAD.cjs} +29 -23
  3. package/dist/{chunk-HM5H556L.js → chunk-72ZWBNZV.js} +1 -1
  4. package/dist/{chunk-D6PU5YAS.cjs → chunk-DDSJTR6Q.cjs} +8 -7
  5. package/dist/{chunk-GDWRFHM5.js → chunk-GDJTKI7J.js} +1 -1
  6. package/dist/{chunk-YX27XM67.js → chunk-GLXADNTR.js} +13 -1
  7. package/dist/{chunk-FPLSJF4S.cjs → chunk-GOWPACSK.cjs} +15 -3
  8. package/dist/{chunk-XVVYNOTX.js → chunk-HB2G32AK.js} +3 -2
  9. package/dist/{chunk-YQT5G77W.cjs → chunk-HEAQAEFZ.cjs} +2 -2
  10. package/dist/{chunk-MHVORH33.cjs → chunk-HMMM32RG.cjs} +14 -14
  11. package/dist/{chunk-5XPEVOOW.cjs → chunk-KG5E3UZZ.cjs} +20 -20
  12. package/dist/{chunk-C2KND2PS.cjs → chunk-OVRDJMZJ.cjs} +26 -34
  13. package/dist/{chunk-5ISVDYBA.js → chunk-OXEKAOVI.js} +3 -11
  14. package/dist/{chunk-S46T73HR.cjs → chunk-PZE6PIPG.cjs} +12 -11
  15. package/dist/chunk-RGUG3UMF.cjs +26 -0
  16. package/dist/{chunk-3OSQ4XL4.js → chunk-TDALRNGL.js} +4 -3
  17. package/dist/chunk-UGHFNCPD.js +26 -0
  18. package/dist/{chunk-2MSLOTFO.js → chunk-XMFQVARN.js} +5 -5
  19. package/dist/{chunk-EJIDFDQP.js → chunk-YRS7KRKP.js} +28 -22
  20. package/dist/{dual-modes-J4RWHJ2O.js → dual-modes-BYABHBDI.js} +3 -3
  21. package/dist/dual-modes-HO6RRIZ5.cjs +10 -0
  22. package/dist/emscripten-module.wasm +0 -0
  23. package/dist/{execute-6AYBMTRM.js → execute-DSGJ2UNL.js} +9 -8
  24. package/dist/{execute-4IL4QPAR.cjs → execute-MRZZ4AYY.cjs} +41 -40
  25. package/dist/exit-MX56VN2C.cjs +8 -0
  26. package/dist/{exit-VJATJTQI.js → exit-UQ3EUX5D.js} +2 -2
  27. package/dist/exit.d.ts +1 -1
  28. package/dist/index.cjs +67 -61
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.js +23 -17
  31. package/dist/index.workerd.js +17328 -0
  32. package/dist/quickjs-variant.d.ts +22 -0
  33. package/dist/quickjs-variant.workerd.d.ts +22 -0
  34. package/dist/{tool-I3MAWDN2.js → tool-KD7FL45V.js} +3 -3
  35. package/dist/{tool-56I7OSKU.cjs → tool-VE2YHIY2.cjs} +4 -4
  36. package/dist/{truncator-OZOBNYON.js → truncator-73RCL52Y.js} +2 -2
  37. package/dist/truncator-FZNLYSDL.cjs +12 -0
  38. package/dist/{typings-SR3EE6LR.js → typings-E2RROCLT.js} +2 -2
  39. package/dist/{typings-LVI4VGE2.cjs → typings-LQOBZXSO.cjs} +3 -3
  40. package/dist/{utils-ZEZ66X6Q.js → utils-IATCUNKF.js} +5 -1
  41. package/dist/utils-ITB4NEL7.cjs +43 -0
  42. package/dist/utils.d.ts +18 -0
  43. package/dist/vm-6D3IIIU7.cjs +12 -0
  44. package/dist/{vm-ZLWGAYYJ.js → vm-QO5FSGPN.js} +2 -1
  45. package/package.json +5 -3
  46. package/dist/dual-modes-IZQJTXR7.cjs +0 -10
  47. package/dist/exit-LUJY7JIG.cjs +0 -8
  48. package/dist/truncator-7PGEGCHV.cjs +0 -12
  49. package/dist/utils-GLZVMRWO.cjs +0 -39
  50. package/dist/vm-ZVONLAZV.cjs +0 -11
@@ -6,3 +6,25 @@ export type QuickJSSyncVariantEx = QuickJSSyncVariant & {
6
6
  _wasmLoadError?: any;
7
7
  };
8
8
  export declare const BundledReleaseSyncVariant: QuickJSSyncVariantEx;
9
+ /**
10
+ * Overrides the QuickJS variant used by the sandbox.
11
+ *
12
+ * The default variant inlines the WASM as base64 and compiles it at runtime
13
+ * (`new WebAssembly.Module(bytes)`), which is disallowed on some platforms
14
+ * (e.g. Cloudflare Workers / workerd). On those platforms, inject a variant
15
+ * built from a statically imported precompiled `WebAssembly.Module` — e.g.
16
+ * quickjs-emscripten's documented Cloudflare recipe:
17
+ *
18
+ * ```ts
19
+ * import { newVariant } from 'quickjs-emscripten-core'
20
+ * import wasmfileVariant from '@jitl/quickjs-wasmfile-release-sync'
21
+ * import wasmModule from '@jitl/quickjs-wasmfile-release-sync/wasm'
22
+ *
23
+ * configureQuickJS(newVariant(wasmfileVariant, { wasmModule }))
24
+ * ```
25
+ *
26
+ * Call this before the first `execute()` (or `warmupVM()`); the WASM module is
27
+ * loaded once per variant and cached.
28
+ */
29
+ export declare const configureQuickJS: (variant: QuickJSSyncVariant) => void;
30
+ export declare const getQuickJSVariant: () => QuickJSSyncVariant;
@@ -0,0 +1,22 @@
1
+ import { type QuickJSSyncVariant } from 'quickjs-emscripten-core';
2
+ /**
3
+ * Workerd (Cloudflare Workers) drop-in replacement for `./quickjs-variant.ts` —
4
+ * the workerd tsup build aliases that module to this one. Same export surface,
5
+ * but the default variant follows quickjs-emscripten's documented Cloudflare
6
+ * recipe (wasmfile variant + statically imported precompiled module) instead of
7
+ * the singlefile variant that compiles inlined base64 WASM at runtime.
8
+ */
9
+ export type QuickJSSyncVariantEx = QuickJSSyncVariant & {
10
+ _wasmSource?: any;
11
+ _wasmLoadedSuccessfully?: any;
12
+ _wasmSize?: any;
13
+ _wasmLoadError?: any;
14
+ };
15
+ export declare const BundledReleaseSyncVariant: QuickJSSyncVariantEx;
16
+ /**
17
+ * Overrides the QuickJS variant used by the sandbox. On workerd the default
18
+ * variant is already Workers-compatible; this stays available for consumers
19
+ * who want a different QuickJS build (e.g. debug, asyncify).
20
+ */
21
+ export declare const configureQuickJS: (variant: QuickJSSyncVariant) => void;
22
+ export declare const getQuickJSVariant: () => QuickJSSyncVariant;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Tool
3
- } from "./chunk-3OSQ4XL4.js";
4
- import "./chunk-GDWRFHM5.js";
3
+ } from "./chunk-TDALRNGL.js";
4
+ import "./chunk-GDJTKI7J.js";
5
5
  import "./chunk-WSVDMGMR.js";
6
6
  import "./chunk-YEAWWJSJ.js";
7
- import "./chunk-YX27XM67.js";
7
+ import "./chunk-GLXADNTR.js";
8
8
  import "./chunk-34GJUS6U.js";
9
9
  export {
10
10
  Tool
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkS46T73HRcjs = require('./chunk-S46T73HR.cjs');
4
- require('./chunk-MHVORH33.cjs');
3
+ var _chunkPZE6PIPGcjs = require('./chunk-PZE6PIPG.cjs');
4
+ require('./chunk-HMMM32RG.cjs');
5
5
  require('./chunk-PK72FAKD.cjs');
6
6
  require('./chunk-KIN7Y247.cjs');
7
- require('./chunk-FPLSJF4S.cjs');
7
+ require('./chunk-GOWPACSK.cjs');
8
8
  require('./chunk-HC2QZTVT.cjs');
9
9
 
10
10
 
11
- exports.Tool = _chunkS46T73HRcjs.Tool;
11
+ exports.Tool = _chunkPZE6PIPGcjs.Tool;
@@ -2,8 +2,8 @@ import {
2
2
  stripTruncationTags,
3
3
  truncateWrappedContent,
4
4
  wrapContent
5
- } from "./chunk-HM5H556L.js";
6
- import "./chunk-YX27XM67.js";
5
+ } from "./chunk-72ZWBNZV.js";
6
+ import "./chunk-GLXADNTR.js";
7
7
  import "./chunk-34GJUS6U.js";
8
8
  export {
9
9
  stripTruncationTags,
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkHEAQAEFZcjs = require('./chunk-HEAQAEFZ.cjs');
6
+ require('./chunk-GOWPACSK.cjs');
7
+ require('./chunk-HC2QZTVT.cjs');
8
+
9
+
10
+
11
+
12
+ exports.stripTruncationTags = _chunkHEAQAEFZcjs.stripTruncationTags; exports.truncateWrappedContent = _chunkHEAQAEFZcjs.truncateWrappedContent; exports.wrapContent = _chunkHEAQAEFZcjs.wrapContent;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getTypings
3
- } from "./chunk-GDWRFHM5.js";
3
+ } from "./chunk-GDJTKI7J.js";
4
4
  import "./chunk-WSVDMGMR.js";
5
5
  import "./chunk-YEAWWJSJ.js";
6
- import "./chunk-YX27XM67.js";
6
+ import "./chunk-GLXADNTR.js";
7
7
  import "./chunk-34GJUS6U.js";
8
8
  export {
9
9
  getTypings
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkMHVORH33cjs = require('./chunk-MHVORH33.cjs');
3
+ var _chunkHMMM32RGcjs = require('./chunk-HMMM32RG.cjs');
4
4
  require('./chunk-PK72FAKD.cjs');
5
5
  require('./chunk-KIN7Y247.cjs');
6
- require('./chunk-FPLSJF4S.cjs');
6
+ require('./chunk-GOWPACSK.cjs');
7
7
  require('./chunk-HC2QZTVT.cjs');
8
8
 
9
9
 
10
- exports.getTypings = _chunkMHVORH33cjs.getTypings;
10
+ exports.getTypings = _chunkHMMM32RGcjs.getTypings;
@@ -2,7 +2,9 @@ import {
2
2
  Identifier,
3
3
  Tokens,
4
4
  awaitObject,
5
+ configureTokenizer,
5
6
  escapeString,
7
+ fromJSONSchemaCompat,
6
8
  getErrorMessage,
7
9
  getMultilineComment,
8
10
  getTokenizer,
@@ -16,13 +18,15 @@ import {
16
18
  toPropertyKey,
17
19
  toValidFunctionName,
18
20
  toValidObjectName
19
- } from "./chunk-YX27XM67.js";
21
+ } from "./chunk-GLXADNTR.js";
20
22
  import "./chunk-34GJUS6U.js";
21
23
  export {
22
24
  Identifier,
23
25
  Tokens,
24
26
  awaitObject,
27
+ configureTokenizer,
25
28
  escapeString,
29
+ fromJSONSchemaCompat,
26
30
  getErrorMessage,
27
31
  getMultilineComment,
28
32
  getTokenizer,
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
22
+ require('./chunk-HC2QZTVT.cjs');
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ exports.Identifier = _chunkGOWPACSKcjs.Identifier; exports.Tokens = _chunkGOWPACSKcjs.Tokens; exports.awaitObject = _chunkGOWPACSKcjs.awaitObject; exports.configureTokenizer = _chunkGOWPACSKcjs.configureTokenizer; exports.escapeString = _chunkGOWPACSKcjs.escapeString; exports.fromJSONSchemaCompat = _chunkGOWPACSKcjs.fromJSONSchemaCompat; exports.getErrorMessage = _chunkGOWPACSKcjs.getErrorMessage; exports.getMultilineComment = _chunkGOWPACSKcjs.getMultilineComment; exports.getTokenizer = _chunkGOWPACSKcjs.getTokenizer; exports.init = _chunkGOWPACSKcjs.init; exports.isJsonSchema = _chunkGOWPACSKcjs.isJsonSchema; exports.isValidIdentifier = _chunkGOWPACSKcjs.isValidIdentifier; exports.isValidMessageName = _chunkGOWPACSKcjs.isValidMessageName; exports.isValidSchema = _chunkGOWPACSKcjs.isValidSchema; exports.isZuiSchema = _chunkGOWPACSKcjs.isZuiSchema; exports.stripInvalidIdentifiers = _chunkGOWPACSKcjs.stripInvalidIdentifiers; exports.toPropertyKey = _chunkGOWPACSKcjs.toPropertyKey; exports.toValidFunctionName = _chunkGOWPACSKcjs.toValidFunctionName; exports.toValidObjectName = _chunkGOWPACSKcjs.toValidObjectName;
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,16 @@
1
1
  import { TextTokenizer } from '@bpinternal/thicktoken';
2
2
  import { z } from '@bpinternal/zui';
3
3
  import { JSONSchema7 } from 'json-schema';
4
+ /**
5
+ * Injects the tokenizer used for prompt budgeting instead of the default
6
+ * `@bpinternal/thicktoken` WASM tokenizer.
7
+ *
8
+ * The default tokenizer compiles its WASM at runtime (`new WebAssembly.Module(bytes)`),
9
+ * which is disallowed on some platforms (e.g. Cloudflare Workers / workerd). On those
10
+ * platforms, build a tokenizer from a statically imported precompiled `WebAssembly.Module`
11
+ * and inject it here before calling `execute()`.
12
+ */
13
+ export declare const configureTokenizer: (customTokenizer: TextTokenizer) => void;
4
14
  export declare const init: () => Promise<void>;
5
15
  export declare const getTokenizer: () => TextTokenizer;
6
16
  export declare const Tokens: (min: number, max: number) => z.ZodEffects<z.ZodString, string, string>;
@@ -12,6 +22,14 @@ export declare const toValidFunctionName: (str: string) => string;
12
22
  export declare const awaitObject: <T extends {}>(obj: T) => Promise<T>;
13
23
  export declare const toValidObjectName: (str: string) => string;
14
24
  export declare const stripInvalidIdentifiers: (object: unknown) => any;
25
+ /**
26
+ * JSON Schema → Zui via the legacy transform, falling back to the eval-free one.
27
+ * The legacy transform builds the schema by evaluating generated code, which is
28
+ * banned on some platforms (e.g. Cloudflare Workers / workerd) — there it throws
29
+ * and the eval-free transform takes over. Kept legacy-first because the two
30
+ * transforms differ on some shapes (e.g. discriminated unions).
31
+ */
32
+ export declare const fromJSONSchemaCompat: (schema: JSONSchema7) => z.ZodType;
15
33
  export declare const isValidSchema: (schema: JSONSchema7) => boolean;
16
34
  export declare function isZuiSchema(schema: unknown): schema is z.ZodSchema;
17
35
  export declare function isJsonSchema(schema: unknown): schema is JSONSchema7;
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunk3UZKLXADcjs = require('./chunk-3UZKLXAD.cjs');
5
+ require('./chunk-RGUG3UMF.cjs');
6
+ require('./chunk-PK72FAKD.cjs');
7
+ require('./chunk-KIN7Y247.cjs');
8
+ require('./chunk-HC2QZTVT.cjs');
9
+
10
+
11
+
12
+ exports.runAsyncFunction = _chunk3UZKLXADcjs.runAsyncFunction; exports.warmupVM = _chunk3UZKLXADcjs.warmupVM;
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  runAsyncFunction,
3
3
  warmupVM
4
- } from "./chunk-EJIDFDQP.js";
4
+ } from "./chunk-YRS7KRKP.js";
5
+ import "./chunk-UGHFNCPD.js";
5
6
  import "./chunk-WSVDMGMR.js";
6
7
  import "./chunk-YEAWWJSJ.js";
7
8
  import "./chunk-34GJUS6U.js";
package/package.json CHANGED
@@ -2,12 +2,14 @@
2
2
  "name": "llmz",
3
3
  "type": "module",
4
4
  "description": "LLMz - An LLM-native Typescript VM built on top of Zui",
5
- "version": "0.2.2",
5
+ "version": "0.2.3",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "workerd": "./dist/index.workerd.js",
11
13
  "import": "./dist/index.js",
12
14
  "require": "./dist/index.cjs"
13
15
  }
@@ -34,7 +36,6 @@
34
36
  "acorn": "^8.17.0",
35
37
  "bytes": "^3.1.2",
36
38
  "exponential-backoff": "^3.1.1",
37
- "handlebars": "^4.7.8",
38
39
  "json5": "^2.2.3",
39
40
  "jsonrepair": "^3.10.0",
40
41
  "lodash-es": "^4.17.21",
@@ -45,6 +46,7 @@
45
46
  },
46
47
  "devDependencies": {
47
48
  "@botpress/cli": "workspace:*",
49
+ "@jitl/quickjs-wasmfile-release-sync": "^0.31.0",
48
50
  "@microsoft/api-extractor": "^7.49.0",
49
51
  "@types/bytes": "^3.1.5",
50
52
  "@types/json-schema": "^7.0.12",
@@ -64,7 +66,7 @@
64
66
  "peerDependencies": {
65
67
  "@botpress/client": "1.49.0",
66
68
  "@botpress/cognitive": "0.6.2",
67
- "@bpinternal/thicktoken": "^3.0.0",
69
+ "@bpinternal/thicktoken": "^3.1.0",
68
70
  "@bpinternal/zui": "^2.4.0"
69
71
  },
70
72
  "dependenciesMeta": {
@@ -1,10 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkC2KND2PScjs = require('./chunk-C2KND2PS.cjs');
4
- require('./chunk-KIN7Y247.cjs');
5
- require('./chunk-YQT5G77W.cjs');
6
- require('./chunk-FPLSJF4S.cjs');
7
- require('./chunk-HC2QZTVT.cjs');
8
-
9
-
10
- exports.DualModePrompt = _chunkC2KND2PScjs.DualModePrompt;
@@ -1,8 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkD6PU5YAScjs = require('./chunk-D6PU5YAS.cjs');
4
- require('./chunk-FPLSJF4S.cjs');
5
- require('./chunk-HC2QZTVT.cjs');
6
-
7
-
8
- exports.Exit = _chunkD6PU5YAScjs.Exit;
@@ -1,12 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
- var _chunkYQT5G77Wcjs = require('./chunk-YQT5G77W.cjs');
6
- require('./chunk-FPLSJF4S.cjs');
7
- require('./chunk-HC2QZTVT.cjs');
8
-
9
-
10
-
11
-
12
- exports.stripTruncationTags = _chunkYQT5G77Wcjs.stripTruncationTags; exports.truncateWrappedContent = _chunkYQT5G77Wcjs.truncateWrappedContent; exports.wrapContent = _chunkYQT5G77Wcjs.wrapContent;
@@ -1,39 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
- var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
20
- require('./chunk-HC2QZTVT.cjs');
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
- exports.Identifier = _chunkFPLSJF4Scjs.Identifier; exports.Tokens = _chunkFPLSJF4Scjs.Tokens; exports.awaitObject = _chunkFPLSJF4Scjs.awaitObject; exports.escapeString = _chunkFPLSJF4Scjs.escapeString; exports.getErrorMessage = _chunkFPLSJF4Scjs.getErrorMessage; exports.getMultilineComment = _chunkFPLSJF4Scjs.getMultilineComment; exports.getTokenizer = _chunkFPLSJF4Scjs.getTokenizer; exports.init = _chunkFPLSJF4Scjs.init; exports.isJsonSchema = _chunkFPLSJF4Scjs.isJsonSchema; exports.isValidIdentifier = _chunkFPLSJF4Scjs.isValidIdentifier; exports.isValidMessageName = _chunkFPLSJF4Scjs.isValidMessageName; exports.isValidSchema = _chunkFPLSJF4Scjs.isValidSchema; exports.isZuiSchema = _chunkFPLSJF4Scjs.isZuiSchema; exports.stripInvalidIdentifiers = _chunkFPLSJF4Scjs.stripInvalidIdentifiers; exports.toPropertyKey = _chunkFPLSJF4Scjs.toPropertyKey; exports.toValidFunctionName = _chunkFPLSJF4Scjs.toValidFunctionName; exports.toValidObjectName = _chunkFPLSJF4Scjs.toValidObjectName;
@@ -1,11 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunk2EZSVF5Xcjs = require('./chunk-2EZSVF5X.cjs');
5
- require('./chunk-PK72FAKD.cjs');
6
- require('./chunk-KIN7Y247.cjs');
7
- require('./chunk-HC2QZTVT.cjs');
8
-
9
-
10
-
11
- exports.runAsyncFunction = _chunk2EZSVF5Xcjs.runAsyncFunction; exports.warmupVM = _chunk2EZSVF5Xcjs.warmupVM;