llmz 0.2.2 → 0.3.0

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 (55) 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/context.d.ts +2 -2
  21. package/dist/custom-client.d.ts +4 -3
  22. package/dist/{dual-modes-J4RWHJ2O.js → dual-modes-BYABHBDI.js} +3 -3
  23. package/dist/dual-modes-HO6RRIZ5.cjs +10 -0
  24. package/dist/emscripten-module.wasm +0 -0
  25. package/dist/{execute-4IL4QPAR.cjs → execute-2H4F7GFE.cjs} +81 -69
  26. package/dist/{execute-6AYBMTRM.js → execute-DPCZ6PKH.js} +51 -39
  27. package/dist/exit-MX56VN2C.cjs +8 -0
  28. package/dist/{exit-VJATJTQI.js → exit-UQ3EUX5D.js} +2 -2
  29. package/dist/exit.d.ts +1 -1
  30. package/dist/index.cjs +67 -61
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +23 -17
  33. package/dist/index.workerd.js +17339 -0
  34. package/dist/prompts/prompt.d.ts +3 -6
  35. package/dist/quickjs-variant.d.ts +22 -0
  36. package/dist/quickjs-variant.workerd.d.ts +22 -0
  37. package/dist/result.d.ts +3 -3
  38. package/dist/runtime/types.d.ts +7 -9
  39. package/dist/{tool-I3MAWDN2.js → tool-KD7FL45V.js} +3 -3
  40. package/dist/{tool-56I7OSKU.cjs → tool-VE2YHIY2.cjs} +4 -4
  41. package/dist/{truncator-OZOBNYON.js → truncator-73RCL52Y.js} +2 -2
  42. package/dist/truncator-FZNLYSDL.cjs +12 -0
  43. package/dist/{typings-SR3EE6LR.js → typings-E2RROCLT.js} +2 -2
  44. package/dist/{typings-LVI4VGE2.cjs → typings-LQOBZXSO.cjs} +3 -3
  45. package/dist/{utils-ZEZ66X6Q.js → utils-IATCUNKF.js} +5 -1
  46. package/dist/utils-ITB4NEL7.cjs +43 -0
  47. package/dist/utils.d.ts +18 -0
  48. package/dist/vm-6D3IIIU7.cjs +12 -0
  49. package/dist/{vm-ZLWGAYYJ.js → vm-QO5FSGPN.js} +2 -1
  50. package/package.json +6 -4
  51. package/dist/dual-modes-IZQJTXR7.cjs +0 -10
  52. package/dist/exit-LUJY7JIG.cjs +0 -8
  53. package/dist/truncator-7PGEGCHV.cjs +0 -12
  54. package/dist/utils-GLZVMRWO.cjs +0 -39
  55. package/dist/vm-ZVONLAZV.cjs +0 -11
@@ -3,11 +3,11 @@
3
3
  var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
4
4
 
5
5
 
6
- var _chunkYQT5G77Wcjs = require('./chunk-YQT5G77W.cjs');
6
+ var _chunkHEAQAEFZcjs = require('./chunk-HEAQAEFZ.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
10
+ var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
11
11
 
12
12
 
13
13
 
@@ -54,7 +54,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
54
54
  }
55
55
  if (typeof currentObj !== "object" || currentObj === null) {
56
56
  const value = JSON.stringify(currentObj);
57
- currentLength += _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(value);
57
+ currentLength += _chunkGOWPACSKcjs.getTokenizer.call(void 0, ).count(value);
58
58
  return value;
59
59
  }
60
60
  const indentation = " ".repeat(currentIndent);
@@ -67,7 +67,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
67
67
  result += indentation + " ".repeat(indent) + recurse(currentObj[i], depth + 1, currentIndent + indent);
68
68
  }
69
69
  result += "\n" + indentation + "]";
70
- currentLength += _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(result);
70
+ currentLength += _chunkGOWPACSKcjs.getTokenizer.call(void 0, ).count(result);
71
71
  return result;
72
72
  } else {
73
73
  let result = "{\n";
@@ -86,11 +86,11 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
86
86
  result += ",\n" + indentation + `... (${numKeys - maxKeys} more keys)`;
87
87
  }
88
88
  result += "\n" + indentation + "}";
89
- currentLength += _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(result);
89
+ currentLength += _chunkGOWPACSKcjs.getTokenizer.call(void 0, ).count(result);
90
90
  return result;
91
91
  }
92
92
  }
93
- const output = _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
93
+ const output = _chunkGOWPACSKcjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
94
94
  return { output, truncated: wasTruncated };
95
95
  }
96
96
  function extractType(value, generic = true) {
@@ -155,9 +155,9 @@ function previewValue(value, length = LONG_TEXT_LENGTH) {
155
155
  }
156
156
  const previewStr = (str) => {
157
157
  if (str.length > length) {
158
- return _chunkFPLSJF4Scjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
158
+ return _chunkGOWPACSKcjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
159
159
  }
160
- return _chunkFPLSJF4Scjs.escapeString.call(void 0, str);
160
+ return _chunkGOWPACSKcjs.escapeString.call(void 0, str);
161
161
  };
162
162
  const previewObj = (obj) => {
163
163
  const mapped = _chunkHC2QZTVTcjs.mapKeys_default.call(void 0, obj, (_value, key) => previewStr(key));
@@ -350,7 +350,7 @@ var inspect = (value, name, options = DEFAULT_OPTIONS) => {
350
350
  } else if (genericType === "boolean") {
351
351
  return header + previewValue(value);
352
352
  } else if (typeof value === "string") {
353
- if (_chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
353
+ if (_chunkGOWPACSKcjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
354
354
  return header + previewValue(value);
355
355
  } else {
356
356
  return header + previewLongText(value);
@@ -368,9 +368,6 @@ var system_md_default = "# Important Instructions\n\nYou are a helpful assistant
368
368
  // src/prompts/chat-mode/user.md.ts
369
369
  var user_md_default = "\u25A0\u25A0\u25A0recap\u25A0\u25A0\u25A0\n\nConsidering the **Instructions, Tools and Guidelines (Part 3)**, what should you do or reply next?\nRemember to reply using only \u25A0 blocks (\u25A0send=<component>, \u25A0run, \u25A0next=<exit>) and to write full, final message content (no placeholders).\n";
370
370
 
371
- // src/prompts/common.ts
372
- var _handlebars = require('handlebars'); var _handlebars2 = _interopRequireDefault(_handlebars);
373
-
374
371
  // src/message-stream/parser.ts
375
372
  var _json5 = require('json5'); var _json52 = _interopRequireDefault(_json5);
376
373
  var _jsonrepair = require('jsonrepair');
@@ -924,12 +921,7 @@ var parseAssistantResponse = (response) => {
924
921
  var replacePlaceholders = (prompt, values) => {
925
922
  const regex = new RegExp("\u25A0\u25A0\u25A0([A-Z0-9_\\.-]+)\u25A0\u25A0\u25A0", "gi");
926
923
  const obj = Object.assign({}, values);
927
- const compile = _handlebars2.default.compile(prompt);
928
- const compiled = compile({
929
- is_message_enabled: false,
930
- ...values
931
- });
932
- const replaced = compiled.replace(regex, (_match, name) => {
924
+ const replaced = prompt.replace(regex, (_match, name) => {
933
925
  if (name in values) {
934
926
  delete obj[name];
935
927
  return typeof values[name] === "string" ? values[name] : JSON.stringify(values[name]);
@@ -1340,15 +1332,15 @@ ${variables_example}
1340
1332
  role: "system",
1341
1333
  content: replacePlaceholders(canTalk ? system_md_default : system_md_default2, {
1342
1334
  is_message_enabled: canTalk,
1343
- "tools.d.ts": _chunkYQT5G77Wcjs.wrapContent.call(void 0, dts, {
1335
+ "tools.d.ts": _chunkHEAQAEFZcjs.wrapContent.call(void 0, dts, {
1344
1336
  preserve: "both",
1345
1337
  minTokens: 500
1346
1338
  }),
1347
- identity: _chunkYQT5G77Wcjs.wrapContent.call(void 0, identity, {
1339
+ identity: _chunkHEAQAEFZcjs.wrapContent.call(void 0, identity, {
1348
1340
  preserve: "both",
1349
1341
  minTokens: 1e3
1350
1342
  }),
1351
- transcript: _chunkYQT5G77Wcjs.wrapContent.call(void 0, transcript, {
1343
+ transcript: _chunkHEAQAEFZcjs.wrapContent.call(void 0, transcript, {
1352
1344
  preserve: "bottom",
1353
1345
  minTokens: 500
1354
1346
  }),
@@ -1356,7 +1348,7 @@ ${variables_example}
1356
1348
  readonly_vars: readonly_vars.join(", "),
1357
1349
  writeable_vars: writeable_vars.join(", "),
1358
1350
  variables_example,
1359
- protocol: _chunkYQT5G77Wcjs.wrapContent.call(void 0, protocol, {
1351
+ protocol: _chunkHEAQAEFZcjs.wrapContent.call(void 0, protocol, {
1360
1352
  preserve: "both",
1361
1353
  minTokens: 500
1362
1354
  })
@@ -1437,12 +1429,12 @@ The response you provided is invalid. Here's the error:
1437
1429
  Code:
1438
1430
 
1439
1431
  \`\`\`ts
1440
- ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, props.code)}
1432
+ ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, props.code)}
1441
1433
  \`\`\`
1442
1434
 
1443
1435
  Error:
1444
1436
  \`\`\`
1445
- ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, props.message, { flex: 4 })}
1437
+ ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, props.message, { flex: 4 })}
1446
1438
  \`\`\`
1447
1439
 
1448
1440
  Please fix the error and try again.
@@ -1466,11 +1458,11 @@ var getCodeExecutionErrorMessage = async (props) => {
1466
1458
 
1467
1459
  An error occurred while executing the code.
1468
1460
 
1469
- ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, props.message, { preserve: "top", flex: 4 })}
1461
+ ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, props.message, { preserve: "top", flex: 4 })}
1470
1462
 
1471
1463
  Stack Trace:
1472
1464
  \`\`\`
1473
- ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
1465
+ ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
1474
1466
  \`\`\`
1475
1467
 
1476
1468
  Let the user know that an error occurred, and if possible, try something else. Do not repeat yourself in the message.
@@ -1487,7 +1479,7 @@ var getThinkingMessage = async (props) => {
1487
1479
  if (inspected) {
1488
1480
  acc.push(inspected);
1489
1481
  } else {
1490
- acc.push(`Value of ${key} is ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`);
1482
+ acc.push(`Value of ${key} is ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`);
1491
1483
  }
1492
1484
  return acc;
1493
1485
  }, []);
@@ -1498,7 +1490,7 @@ var getThinkingMessage = async (props) => {
1498
1490
  if (inspected) {
1499
1491
  return inspected;
1500
1492
  } else {
1501
- return `Value at index ${index} is ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`;
1493
+ return `Value at index ${index} is ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`;
1502
1494
  }
1503
1495
  });
1504
1496
  context = mapped.join("\n\n");
@@ -1516,7 +1508,7 @@ The code execution completed. Here's the context:
1516
1508
  -------------------
1517
1509
  Reason: ${props.reason || "Code execution returned a value"}
1518
1510
  Context:
1519
- ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, context, { preserve: "top" })}
1511
+ ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, context, { preserve: "top" })}
1520
1512
  -------------------
1521
1513
 
1522
1514
  Continue with a new response using \u25A0 blocks. Do not re-run the code above; use its result.
@@ -1536,19 +1528,19 @@ var getSnapshotResolvedMessage = (props) => {
1536
1528
  injectedVariables[variable.name] = variable.value;
1537
1529
  variablesMessage += `
1538
1530
  // Variable "${variable.name}" restored with its full value:
1539
- // ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, _nullishCoalesce(((_a = inspect(variable.value)) == null ? void 0 : _a.split("\n").join("\n// ")), () => ( "")))}
1531
+ // ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, _nullishCoalesce(((_a = inspect(variable.value)) == null ? void 0 : _a.split("\n").join("\n// ")), () => ( "")))}
1540
1532
  declare const ${variable.name}: ${variable.type}
1541
1533
  `;
1542
1534
  } else {
1543
1535
  variablesMessage += `
1544
1536
  // The variable "${variable.name}" was too large to be restored with its full value, here's a preview of its last known value:
1545
- // ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, variable.preview.split("\n").join("\n// "))}
1537
+ // ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, variable.preview.split("\n").join("\n// "))}
1546
1538
  // Important: To restore the full value, please re-run the code that generated this variable in the first place.
1547
1539
  let ${variable.name}: undefined | ${variable.type} = undefined;
1548
1540
  `;
1549
1541
  }
1550
1542
  }
1551
- const output = _chunkYQT5G77Wcjs.wrapContent.call(void 0, _nullishCoalesce(((_b = inspect(props.snapshot.status.value)) == null ? void 0 : _b.split("\n").join("\n * ")), () => ( "")), {
1543
+ const output = _chunkHEAQAEFZcjs.wrapContent.call(void 0, _nullishCoalesce(((_b = inspect(props.snapshot.status.value)) == null ? void 0 : _b.split("\n").join("\n * ")), () => ( "")), {
1552
1544
  preserve: "top",
1553
1545
  flex: 4
1554
1546
  });
@@ -1570,7 +1562,7 @@ ${_chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.snapshot.stack).split("\n
1570
1562
  Continue the conversation from here, without repeating the above code, as it has already been executed. Here's the variables you can rely on:
1571
1563
 
1572
1564
  \`\`\`tsx
1573
- ${_chunkYQT5G77Wcjs.wrapContent.call(void 0, variablesMessage)}
1565
+ ${_chunkHEAQAEFZcjs.wrapContent.call(void 0, variablesMessage)}
1574
1566
  \`\`\`
1575
1567
 
1576
1568
  You can now assume that the code you about to generate can rely on the variables "${Object.keys(injectedVariables).join('", "')}" being available.
@@ -1587,7 +1579,7 @@ var getSnapshotRejectedMessage = (props) => {
1587
1579
  throw new Error("Snapshot is not resolved");
1588
1580
  }
1589
1581
  const errorMessage = _nullishCoalesce(inspect(props.snapshot.status.error), () => ( "Unknown Error"));
1590
- const output = _chunkYQT5G77Wcjs.wrapContent.call(void 0, _nullishCoalesce(errorMessage.split("\n").join("\n * "), () => ( "Unknown Error")), {
1582
+ const output = _chunkHEAQAEFZcjs.wrapContent.call(void 0, _nullishCoalesce(errorMessage.split("\n").join("\n * "), () => ( "Unknown Error")), {
1591
1583
  preserve: "both",
1592
1584
  minTokens: 100
1593
1585
  });
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-YEAWWJSJ.js";
4
4
  import {
5
5
  wrapContent
6
- } from "./chunk-HM5H556L.js";
6
+ } from "./chunk-72ZWBNZV.js";
7
7
  import {
8
8
  escapeString,
9
9
  getTokenizer
10
- } from "./chunk-YX27XM67.js";
10
+ } from "./chunk-GLXADNTR.js";
11
11
  import {
12
12
  countBy_default,
13
13
  filter_default,
@@ -368,9 +368,6 @@ var system_md_default = "# Important Instructions\n\nYou are a helpful assistant
368
368
  // src/prompts/chat-mode/user.md.ts
369
369
  var user_md_default = "\u25A0\u25A0\u25A0recap\u25A0\u25A0\u25A0\n\nConsidering the **Instructions, Tools and Guidelines (Part 3)**, what should you do or reply next?\nRemember to reply using only \u25A0 blocks (\u25A0send=<component>, \u25A0run, \u25A0next=<exit>) and to write full, final message content (no placeholders).\n";
370
370
 
371
- // src/prompts/common.ts
372
- import Handlebars from "handlebars";
373
-
374
371
  // src/message-stream/parser.ts
375
372
  import JSON5 from "json5";
376
373
  import { jsonrepair } from "jsonrepair";
@@ -924,12 +921,7 @@ var parseAssistantResponse = (response) => {
924
921
  var replacePlaceholders = (prompt, values) => {
925
922
  const regex = new RegExp("\u25A0\u25A0\u25A0([A-Z0-9_\\.-]+)\u25A0\u25A0\u25A0", "gi");
926
923
  const obj = Object.assign({}, values);
927
- const compile = Handlebars.compile(prompt);
928
- const compiled = compile({
929
- is_message_enabled: false,
930
- ...values
931
- });
932
- const replaced = compiled.replace(regex, (_match, name) => {
924
+ const replaced = prompt.replace(regex, (_match, name) => {
933
925
  if (name in values) {
934
926
  delete obj[name];
935
927
  return typeof values[name] === "string" ? values[name] : JSON.stringify(values[name]);
@@ -1,11 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
2
 
3
- var _chunkMHVORH33cjs = require('./chunk-MHVORH33.cjs');
3
+ var _chunkHMMM32RGcjs = require('./chunk-HMMM32RG.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
8
+
9
+ var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
9
10
 
10
11
 
11
12
 
@@ -112,7 +113,7 @@ var Tool = (_class = class _Tool {
112
113
  this._staticInputValues = void 0;
113
114
  return this;
114
115
  }
115
- const input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
116
+ const input = this.input ? _chunkGOWPACSKcjs.fromJSONSchemaCompat.call(void 0, this.input) : _zui.z.any();
116
117
  if (_zui.z.is.zuiObject(input) && typeof values !== "object") {
117
118
  throw new Error(
118
119
  `Invalid static input values for tool ${this.name}. Expected an object, but got type "${typeof values}"`
@@ -195,7 +196,7 @@ var Tool = (_class = class _Tool {
195
196
  */
196
197
  rename(name) {
197
198
  const before = this.name;
198
- if (!_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, name)) {
199
+ if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, name)) {
199
200
  throw new Error(
200
201
  `Invalid name for tool ${name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
201
202
  );
@@ -371,7 +372,7 @@ var Tool = (_class = class _Tool {
371
372
  * ```
372
373
  */
373
374
  constructor(props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
374
- if (!_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, props.name)) {
375
+ if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, props.name)) {
375
376
  throw new Error(
376
377
  `Invalid name for tool ${props.name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
377
378
  );
@@ -396,17 +397,17 @@ var Tool = (_class = class _Tool {
396
397
  `Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
397
398
  );
398
399
  }
399
- if (props.aliases && props.aliases.some((alias) => !_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, alias))) {
400
+ if (props.aliases && props.aliases.some((alias) => !_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, alias))) {
400
401
  throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
401
402
  }
402
403
  if (typeof props.input !== "undefined") {
403
- if (_chunkFPLSJF4Scjs.isZuiSchema.call(void 0, props.input)) {
404
+ if (_chunkGOWPACSKcjs.isZuiSchema.call(void 0, props.input)) {
404
405
  try {
405
406
  this.input = _zui.transforms.toJSONSchema(props.input);
406
407
  } catch (e6) {
407
408
  this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
408
409
  }
409
- } else if (_chunkFPLSJF4Scjs.isJsonSchema.call(void 0, props.input)) {
410
+ } else if (_chunkGOWPACSKcjs.isJsonSchema.call(void 0, props.input)) {
410
411
  this.input = props.input;
411
412
  } else {
412
413
  throw new Error(
@@ -415,13 +416,13 @@ var Tool = (_class = class _Tool {
415
416
  }
416
417
  }
417
418
  if (typeof props.output !== "undefined") {
418
- if (_chunkFPLSJF4Scjs.isZuiSchema.call(void 0, props.output)) {
419
+ if (_chunkGOWPACSKcjs.isZuiSchema.call(void 0, props.output)) {
419
420
  try {
420
421
  this.output = _zui.transforms.toJSONSchema(props.output);
421
422
  } catch (e7) {
422
423
  this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
423
424
  }
424
- } else if (_chunkFPLSJF4Scjs.isJsonSchema.call(void 0, props.output)) {
425
+ } else if (_chunkGOWPACSKcjs.isJsonSchema.call(void 0, props.output)) {
425
426
  this.output = props.output;
426
427
  } else {
427
428
  throw new Error(
@@ -548,7 +549,7 @@ var Tool = (_class = class _Tool {
548
549
  input = convertObjectToZuiLiterals(this._staticInputValues);
549
550
  }
550
551
  const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
551
- return _chunkMHVORH33cjs.getTypings.call(void 0, fnType, {
552
+ return _chunkHMMM32RGcjs.getTypings.call(void 0, fnType, {
552
553
  declaration: true
553
554
  });
554
555
  }
@@ -0,0 +1,26 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// src/quickjs-variant.ts
2
+ var getVariant = async () => {
3
+ const module = await Promise.resolve().then(() => _interopRequireWildcard(require("@jitl/quickjs-singlefile-browser-release-sync")));
4
+ return module.default;
5
+ };
6
+ var BundledReleaseSyncVariant = {
7
+ type: "sync",
8
+ importFFI: async () => {
9
+ const variant = await getVariant();
10
+ return variant.importFFI();
11
+ },
12
+ importModuleLoader: async () => {
13
+ const variant = await getVariant();
14
+ return variant.importModuleLoader();
15
+ }
16
+ };
17
+ var _activeVariant = BundledReleaseSyncVariant;
18
+ var configureQuickJS = (variant) => {
19
+ _activeVariant = variant;
20
+ };
21
+ var getQuickJSVariant = () => _activeVariant;
22
+
23
+
24
+
25
+
26
+ exports.configureQuickJS = configureQuickJS; exports.getQuickJSVariant = getQuickJSVariant;
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  getTypings
3
- } from "./chunk-GDWRFHM5.js";
3
+ } from "./chunk-GDJTKI7J.js";
4
4
  import {
5
+ fromJSONSchemaCompat,
5
6
  isJsonSchema,
6
7
  isValidIdentifier,
7
8
  isZuiSchema
8
- } from "./chunk-YX27XM67.js";
9
+ } from "./chunk-GLXADNTR.js";
9
10
  import {
10
11
  isEmpty_default,
11
12
  uniq_default
@@ -112,7 +113,7 @@ var Tool = class _Tool {
112
113
  this._staticInputValues = void 0;
113
114
  return this;
114
115
  }
115
- const input = this.input ? transforms.fromJSONSchemaLegacy(this.input) : z2.any();
116
+ const input = this.input ? fromJSONSchemaCompat(this.input) : z2.any();
116
117
  if (z2.is.zuiObject(input) && typeof values !== "object") {
117
118
  throw new Error(
118
119
  `Invalid static input values for tool ${this.name}. Expected an object, but got type "${typeof values}"`
@@ -0,0 +1,26 @@
1
+ // src/quickjs-variant.ts
2
+ var getVariant = async () => {
3
+ const module = await import("@jitl/quickjs-singlefile-browser-release-sync");
4
+ return module.default;
5
+ };
6
+ var BundledReleaseSyncVariant = {
7
+ type: "sync",
8
+ importFFI: async () => {
9
+ const variant = await getVariant();
10
+ return variant.importFFI();
11
+ },
12
+ importModuleLoader: async () => {
13
+ const variant = await getVariant();
14
+ return variant.importModuleLoader();
15
+ }
16
+ };
17
+ var _activeVariant = BundledReleaseSyncVariant;
18
+ var configureQuickJS = (variant) => {
19
+ _activeVariant = variant;
20
+ };
21
+ var getQuickJSVariant = () => _activeVariant;
22
+
23
+ export {
24
+ configureQuickJS,
25
+ getQuickJSVariant
26
+ };
@@ -2,26 +2,26 @@ import {
2
2
  DualModePrompt,
3
3
  extractType,
4
4
  inspect
5
- } from "./chunk-5ISVDYBA.js";
5
+ } from "./chunk-OXEKAOVI.js";
6
6
  import {
7
7
  Tool
8
- } from "./chunk-3OSQ4XL4.js";
8
+ } from "./chunk-TDALRNGL.js";
9
9
  import {
10
10
  LoopExceededError
11
11
  } from "./chunk-WSVDMGMR.js";
12
12
  import {
13
13
  Exit
14
- } from "./chunk-XVVYNOTX.js";
14
+ } from "./chunk-HB2G32AK.js";
15
15
  import {
16
16
  assertValidComponent
17
17
  } from "./chunk-KWQTYXAT.js";
18
18
  import {
19
19
  stripTruncationTags,
20
20
  wrapContent
21
- } from "./chunk-HM5H556L.js";
21
+ } from "./chunk-72ZWBNZV.js";
22
22
  import {
23
23
  getTokenizer
24
- } from "./chunk-YX27XM67.js";
24
+ } from "./chunk-GLXADNTR.js";
25
25
  import {
26
26
  cloneDeep_default,
27
27
  isPlainObject_default,
@@ -1,3 +1,6 @@
1
+ import {
2
+ getQuickJSVariant
3
+ } from "./chunk-UGHFNCPD.js";
1
4
  import {
2
5
  CodeExecutionError,
3
6
  InvalidCodeError,
@@ -2376,23 +2379,6 @@ function compile(code) {
2376
2379
  };
2377
2380
  }
2378
2381
 
2379
- // src/quickjs-variant.ts
2380
- var getVariant = async () => {
2381
- const module = await import("@jitl/quickjs-singlefile-browser-release-sync");
2382
- return module.default;
2383
- };
2384
- var BundledReleaseSyncVariant = {
2385
- type: "sync",
2386
- importFFI: async () => {
2387
- const variant = await getVariant();
2388
- return variant.importFFI();
2389
- },
2390
- importModuleLoader: async () => {
2391
- const variant = await getVariant();
2392
- return variant.importModuleLoader();
2393
- }
2394
- };
2395
-
2396
2382
  // src/vm/errors.ts
2397
2383
  var handleErrorQuickJS = (err, code, _consumer, traces, variables, lines_executed, userCodeStartLine, currentToolCall) => {
2398
2384
  err = Signals.maybeDeserializeError(err);
@@ -2655,7 +2641,15 @@ import {
2655
2641
  shouldInterruptAfterDeadline
2656
2642
  } from "quickjs-emscripten-core";
2657
2643
  var _quickJSModule;
2658
- var loadQuickJSModule = () => _quickJSModule ??= newQuickJSWASMModuleFromVariant(BundledReleaseSyncVariant);
2644
+ var _loadedVariant;
2645
+ var loadQuickJSModule = () => {
2646
+ const variant = getQuickJSVariant();
2647
+ if (!_quickJSModule || _loadedVariant !== variant) {
2648
+ _loadedVariant = variant;
2649
+ _quickJSModule = newQuickJSWASMModuleFromVariant(variant);
2650
+ }
2651
+ return _quickJSModule;
2652
+ };
2659
2653
  var QuickJSDriver = class {
2660
2654
  async execute(ctx) {
2661
2655
  const { transformed, consumer, context, traces, signal, timeout, code, lines_executed, variables } = ctx;
@@ -3155,6 +3149,7 @@ var useQuickJS = () => {
3155
3149
  var _a;
3156
3150
  return typeof process === "undefined" || ((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.USE_QUICKJS) !== "false";
3157
3151
  };
3152
+ var isWorkerd = () => typeof navigator !== "undefined" && (navigator == null ? void 0 : navigator.userAgent) === "Cloudflare-Workers";
3158
3153
  var warmupVM = () => {
3159
3154
  if (useQuickJS()) {
3160
3155
  loadQuickJSModule().catch(() => {
@@ -3206,16 +3201,27 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
3206
3201
  currentToolCall: void 0
3207
3202
  });
3208
3203
  } catch (quickjsError) {
3204
+ const variant = getQuickJSVariant();
3209
3205
  const debugInfo = {
3210
3206
  error: (quickjsError == null ? void 0 : quickjsError.message) || String(quickjsError),
3211
3207
  errorStack: quickjsError == null ? void 0 : quickjsError.stack,
3212
- wasmSource: BundledReleaseSyncVariant._wasmSource,
3213
- wasmLoadedSuccessfully: BundledReleaseSyncVariant._wasmLoadedSuccessfully,
3214
- wasmSize: BundledReleaseSyncVariant._wasmSize,
3215
- wasmLoadError: BundledReleaseSyncVariant._wasmLoadError,
3208
+ wasmSource: variant._wasmSource,
3209
+ wasmLoadedSuccessfully: variant._wasmLoadedSuccessfully,
3210
+ wasmSize: variant._wasmSize,
3211
+ wasmLoadError: variant._wasmLoadError,
3216
3212
  nodeVersion: typeof process !== "undefined" && process.version ? process.version : "undefined",
3217
3213
  platform: typeof process !== "undefined" && process.platform ? process.platform : "undefined"
3218
3214
  };
3215
+ if (isWorkerd()) {
3216
+ console.error("QuickJS failed to load and the node driver is unavailable on Cloudflare Workers.");
3217
+ console.error("Debug info:", JSON.stringify(debugInfo, null, 2));
3218
+ if (quickjsError instanceof Error) {
3219
+ ;
3220
+ quickjsError.debugInfo = debugInfo;
3221
+ throw quickjsError;
3222
+ }
3223
+ throw new Error(`QuickJS failed to load on Cloudflare Workers: ${debugInfo.error}`);
3224
+ }
3219
3225
  console.warn("QuickJS failed to load, falling back to node driver.");
3220
3226
  console.warn("Error:", (quickjsError == null ? void 0 : quickjsError.message) || quickjsError);
3221
3227
  console.warn("Debug info:", JSON.stringify(debugInfo, null, 2));
package/dist/context.d.ts CHANGED
@@ -456,7 +456,7 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
456
456
  end(status: IterationStatus): void;
457
457
  toJSON(): {
458
458
  id: string;
459
- messages: LLMzPrompts.Message[];
459
+ messages: import("@botpress/cognitive").CognitiveMessage[];
460
460
  code: string | undefined;
461
461
  model: Models | Models[];
462
462
  temperature: number;
@@ -600,7 +600,7 @@ export declare class Context implements Serializable<Context.JSON> {
600
600
  id: string;
601
601
  iterations: {
602
602
  id: string;
603
- messages: LLMzPrompts.Message[];
603
+ messages: import("@botpress/cognitive").CognitiveMessage[];
604
604
  code: string | undefined;
605
605
  model: Models | Models[];
606
606
  temperature: number;
@@ -1,7 +1,8 @@
1
1
  import { Model } from '@botpress/cognitive';
2
2
  import { RuntimeCognitive } from './runtime/types.js';
3
- export type RuntimeGenerateContentInput = Parameters<RuntimeCognitive['generateContent']>[0];
4
- export type RuntimeGenerateContentOutput = Awaited<ReturnType<RuntimeCognitive['generateContent']>>;
3
+ export type RuntimeGenerateContentInput = Parameters<RuntimeCognitive['generateText']>[0];
4
+ export type RuntimeGenerateContentOptions = Parameters<RuntimeCognitive['generateText']>[1];
5
+ export type RuntimeGenerateContentOutput = Awaited<ReturnType<RuntimeCognitive['generateText']>>;
5
6
  /**
6
7
  * Internal escape hatch for supplying a custom model client that bypasses Cognitive.
7
8
  *
@@ -14,5 +15,5 @@ export declare abstract class _CustomModelClient implements RuntimeCognitive {
14
15
  private readonly ['$$COGNITIVE'];
15
16
  static isCustomClient(obj: any): obj is _CustomModelClient;
16
17
  abstract getModelDetails(model: string): Promise<Model>;
17
- abstract generateContent(input: RuntimeGenerateContentInput): Promise<RuntimeGenerateContentOutput>;
18
+ abstract generateText(input: RuntimeGenerateContentInput, options?: RuntimeGenerateContentOptions): Promise<RuntimeGenerateContentOutput>;
18
19
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  DualModePrompt
3
- } from "./chunk-5ISVDYBA.js";
3
+ } from "./chunk-OXEKAOVI.js";
4
4
  import "./chunk-YEAWWJSJ.js";
5
- import "./chunk-HM5H556L.js";
6
- import "./chunk-YX27XM67.js";
5
+ import "./chunk-72ZWBNZV.js";
6
+ import "./chunk-GLXADNTR.js";
7
7
  import "./chunk-34GJUS6U.js";
8
8
  export {
9
9
  DualModePrompt
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkOVRDJMZJcjs = require('./chunk-OVRDJMZJ.cjs');
4
+ require('./chunk-KIN7Y247.cjs');
5
+ require('./chunk-HEAQAEFZ.cjs');
6
+ require('./chunk-GOWPACSK.cjs');
7
+ require('./chunk-HC2QZTVT.cjs');
8
+
9
+
10
+ exports.DualModePrompt = _chunkOVRDJMZJcjs.DualModePrompt;
Binary file