llmz 0.0.25 → 0.0.27

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 (38) hide show
  1. package/dist/{chunk-XGJOEQMW.cjs → chunk-273DEMEU.cjs} +2 -2
  2. package/dist/{chunk-LUX4X7XO.js → chunk-7G5QAIUX.js} +2 -2
  3. package/dist/{chunk-A7QHWVD7.js → chunk-7POUFE5M.js} +1 -1
  4. package/dist/{chunk-2D2DE7CD.js → chunk-HCC76DDO.js} +2 -2
  5. package/dist/{chunk-EE6NVDID.js → chunk-IUE5BW56.js} +2 -2
  6. package/dist/chunk-KIN7Y247.cjs +32 -0
  7. package/dist/{chunk-DBRWIHIH.js → chunk-KQPGB6GB.js} +3 -3
  8. package/dist/{chunk-BNDY7RGX.cjs → chunk-M3LCKL55.cjs} +20 -20
  9. package/dist/{chunk-JKVVQN2P.js → chunk-MYLTD5WT.js} +15 -2
  10. package/dist/{chunk-FZJHYLM2.cjs → chunk-RLOPQZTQ.cjs} +3 -3
  11. package/dist/{chunk-JDABP4SD.cjs → chunk-T63Y6GTW.cjs} +17 -4
  12. package/dist/{chunk-UGXCQIHB.cjs → chunk-VADA6DMR.cjs} +11 -11
  13. package/dist/{chunk-PIDLNYIP.cjs → chunk-WP4F6KMW.cjs} +5 -5
  14. package/dist/chunk-YEAWWJSJ.js +32 -0
  15. package/dist/context.d.ts +8 -8
  16. package/dist/{dual-modes-7FI4T35O.js → dual-modes-DW3KRXT2.js} +2 -2
  17. package/dist/{dual-modes-OFHV2C3X.cjs → dual-modes-F4UV5VAZ.cjs} +3 -3
  18. package/dist/errors.d.ts +3 -0
  19. package/dist/index.cjs +19 -19
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +12 -12
  22. package/dist/{llmz-HRL52DC6.cjs → llmz-M7XYQZT7.cjs} +35 -34
  23. package/dist/{llmz-M5AWNDMV.js → llmz-WPO4HYQY.js} +11 -10
  24. package/dist/llmz.d.ts +3 -3
  25. package/dist/result.d.ts +3 -3
  26. package/dist/tool-GEBXW6AQ.js +11 -0
  27. package/dist/tool-GMYMVXUK.cjs +11 -0
  28. package/dist/typings-2RAAZ2YP.cjs +10 -0
  29. package/dist/{typings-WYHEFCYB.js → typings-3VYUEACY.js} +3 -3
  30. package/dist/{vm-CYC5RLKU.js → vm-I4G4IH7T.js} +3 -3
  31. package/dist/vm-YJX6M4NJ.cjs +12 -0
  32. package/package.json +7 -4
  33. package/dist/chunk-IKSIOIIP.cjs +0 -28
  34. package/dist/chunk-JQBT7UWN.js +0 -28
  35. package/dist/tool-O4SFRIE4.cjs +0 -11
  36. package/dist/tool-PCOYOCRH.js +0 -11
  37. package/dist/typings-Y45GMPZT.cjs +0 -10
  38. package/dist/vm-PRZ5GEM2.cjs +0 -12
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DualModePrompt
3
- } from "./chunk-2D2DE7CD.js";
4
- import "./chunk-JQBT7UWN.js";
3
+ } from "./chunk-HCC76DDO.js";
4
+ import "./chunk-YEAWWJSJ.js";
5
5
  import "./chunk-GGWM6X2K.js";
6
6
  import "./chunk-ORQP26SZ.js";
7
7
  import "./chunk-3JYCCI4S.js";
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPIDLNYIPcjs = require('./chunk-PIDLNYIP.cjs');
4
- require('./chunk-IKSIOIIP.cjs');
3
+ var _chunkWP4F6KMWcjs = require('./chunk-WP4F6KMW.cjs');
4
+ require('./chunk-KIN7Y247.cjs');
5
5
  require('./chunk-ZRCU35UV.cjs');
6
6
  require('./chunk-KMZDFWYZ.cjs');
7
7
  require('./chunk-GZPN7RGH.cjs');
@@ -9,4 +9,4 @@ require('./chunk-WHNOR4ZU.cjs');
9
9
  require('./chunk-UQOBUJIQ.cjs');
10
10
 
11
11
 
12
- exports.DualModePrompt = _chunkPIDLNYIPcjs.DualModePrompt;
12
+ exports.DualModePrompt = _chunkWP4F6KMWcjs.DualModePrompt;
package/dist/errors.d.ts CHANGED
@@ -62,3 +62,6 @@ export declare class CodeFormattingError extends Error {
62
62
  export declare class AssignmentError extends Error {
63
63
  constructor(message: string);
64
64
  }
65
+ export declare class CognitiveError extends Error {
66
+ constructor(message: string);
67
+ }
package/dist/index.cjs CHANGED
@@ -8,22 +8,22 @@
8
8
 
9
9
 
10
10
 
11
- var _chunkUGXCQIHBcjs = require('./chunk-UGXCQIHB.cjs');
12
- require('./chunk-PIDLNYIP.cjs');
11
+ var _chunkVADA6DMRcjs = require('./chunk-VADA6DMR.cjs');
12
+ require('./chunk-WP4F6KMW.cjs');
13
13
 
14
14
 
15
- var _chunkXGJOEQMWcjs = require('./chunk-XGJOEQMW.cjs');
15
+ var _chunk273DEMEUcjs = require('./chunk-273DEMEU.cjs');
16
16
 
17
17
 
18
18
 
19
- var _chunkFZJHYLM2cjs = require('./chunk-FZJHYLM2.cjs');
19
+ var _chunkRLOPQZTQcjs = require('./chunk-RLOPQZTQ.cjs');
20
20
 
21
21
 
22
22
 
23
23
 
24
24
 
25
- var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
26
- require('./chunk-IKSIOIIP.cjs');
25
+ var _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
26
+ require('./chunk-KIN7Y247.cjs');
27
27
 
28
28
 
29
29
  var _chunk3G3BS5IAcjs = require('./chunk-3G3BS5IA.cjs');
@@ -296,12 +296,12 @@ async function hoistTypings(code, formatOptions) {
296
296
  } catch (err) {
297
297
  console.error(err);
298
298
  if (formatOptions.throwOnError) {
299
- throw new (0, _chunkJDABP4SDcjs.CodeFormattingError)(err instanceof Error ? err.message : String(_nullishCoalesce(err, () => ( "Unknown Error"))), code);
299
+ throw new (0, _chunkT63Y6GTWcjs.CodeFormattingError)(err instanceof Error ? err.message : String(_nullishCoalesce(err, () => ( "Unknown Error"))), code);
300
300
  }
301
301
  break;
302
302
  }
303
303
  }
304
- return _chunkFZJHYLM2cjs.formatTypings.call(void 0, code, formatOptions);
304
+ return _chunkRLOPQZTQcjs.formatTypings.call(void 0, code, formatOptions);
305
305
  }
306
306
 
307
307
  // src/objects.ts
@@ -427,7 +427,7 @@ var ObjectInstance = class {
427
427
  this.description = props.description;
428
428
  this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
429
429
  this.properties = props.properties;
430
- this.tools = _chunkXGJOEQMWcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
430
+ this.tools = _chunk273DEMEUcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
431
431
  }
432
432
  /**
433
433
  * Generates TypeScript namespace declarations for this object.
@@ -508,7 +508,7 @@ function getObjectTypings(obj) {
508
508
  }
509
509
  let type = "unknown";
510
510
  if (prop.type) {
511
- type = await _chunkFZJHYLM2cjs.getTypings.call(void 0, prop.type, {});
511
+ type = await _chunkRLOPQZTQcjs.getTypings.call(void 0, prop.type, {});
512
512
  } else if (prop.value !== void 0) {
513
513
  type = typeof prop.value;
514
514
  }
@@ -528,7 +528,7 @@ function getObjectTypings(obj) {
528
528
  typings.push("");
529
529
  for (const tool of obj.tools) {
530
530
  const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
531
- let temp = await _chunkFZJHYLM2cjs.getTypings.call(void 0, fnType, {
531
+ let temp = await _chunkRLOPQZTQcjs.getTypings.call(void 0, fnType, {
532
532
  declaration: true
533
533
  });
534
534
  temp = temp.replace("declare function ", "function ");
@@ -551,7 +551,7 @@ function getObjectTypings(obj) {
551
551
  if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
552
552
  header = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, obj.description);
553
553
  }
554
- return _chunkFZJHYLM2cjs.formatTypings.call(void 0,
554
+ return _chunkRLOPQZTQcjs.formatTypings.call(void 0,
555
555
  `${header}
556
556
  export namespace ${obj.name} {
557
557
  ${body}
@@ -1103,20 +1103,20 @@ var utils = {
1103
1103
  truncateWrappedContent: _chunkGZPN7RGHcjs.truncateWrappedContent
1104
1104
  };
1105
1105
  var execute = async (props) => {
1106
- const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-HRL52DC6.cjs")));
1106
+ const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-M7XYQZT7.cjs")));
1107
1107
  return executeContext(props);
1108
1108
  };
1109
1109
  var init = async () => {
1110
- await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-HRL52DC6.cjs")));
1110
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-M7XYQZT7.cjs")));
1111
1111
  await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
1112
- await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-O4SFRIE4.cjs")));
1112
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-GMYMVXUK.cjs")));
1113
1113
  await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-XAYKJ6TR.cjs")));
1114
1114
  await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
1115
- await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-PRZ5GEM2.cjs")));
1115
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-YJX6M4NJ.cjs")));
1116
1116
  await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-L5QAQXV2.cjs")));
1117
1117
  await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-W3NXBLYJ.cjs")));
1118
- await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-Y45GMPZT.cjs")));
1119
- await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-OFHV2C3X.cjs")));
1118
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-2RAAZ2YP.cjs")));
1119
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-F4UV5VAZ.cjs")));
1120
1120
  };
1121
1121
 
1122
1122
 
@@ -1145,4 +1145,4 @@ var init = async () => {
1145
1145
 
1146
1146
 
1147
1147
 
1148
- exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkUGXCQIHBcjs.DefaultExit; exports.ErrorExecutionResult = _chunkUGXCQIHBcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkUGXCQIHBcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkUGXCQIHBcjs.ListenExit; exports.LoopExceededError = _chunkJDABP4SDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkUGXCQIHBcjs.PartialExecutionResult; exports.Snapshot = _chunkUGXCQIHBcjs.Snapshot; exports.SnapshotSignal = _chunkJDABP4SDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkUGXCQIHBcjs.SuccessExecutionResult; exports.ThinkExit = _chunkUGXCQIHBcjs.ThinkExit; exports.ThinkSignal = _chunkJDABP4SDcjs.ThinkSignal; exports.Tool = _chunkXGJOEQMWcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkUGXCQIHBcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx; exports.utils = utils;
1148
+ exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkVADA6DMRcjs.DefaultExit; exports.ErrorExecutionResult = _chunkVADA6DMRcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkVADA6DMRcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkVADA6DMRcjs.ListenExit; exports.LoopExceededError = _chunkT63Y6GTWcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkVADA6DMRcjs.PartialExecutionResult; exports.Snapshot = _chunkVADA6DMRcjs.Snapshot; exports.SnapshotSignal = _chunkT63Y6GTWcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkVADA6DMRcjs.SuccessExecutionResult; exports.ThinkExit = _chunkVADA6DMRcjs.ThinkExit; exports.ThinkSignal = _chunkT63Y6GTWcjs.ThinkSignal; exports.Tool = _chunk273DEMEUcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkVADA6DMRcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx; exports.utils = utils;
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare const utils: {
39
39
  * @param props.exits - Array of Exit definitions for structured completion (static or dynamic)
40
40
  * @param props.snapshot - Optional Snapshot to resume paused execution
41
41
  * @param props.signal - Optional AbortSignal to cancel execution
42
- * @param props.model - Optional model name (static or dynamic function)
42
+ * @param props.model - Optional model name (or array or models to use as fallback) (static or dynamic function)
43
43
  * @param props.temperature - Optional temperature value (static or dynamic function)
44
44
  * @param props.options - Optional execution options (loop limit, timeout)
45
45
  * @param props.onTrace - Optional non-blocking hook for monitoring traces during execution
package/dist/index.js CHANGED
@@ -8,22 +8,22 @@ import {
8
8
  SuccessExecutionResult,
9
9
  ThinkExit,
10
10
  getValue
11
- } from "./chunk-DBRWIHIH.js";
12
- import "./chunk-2D2DE7CD.js";
11
+ } from "./chunk-KQPGB6GB.js";
12
+ import "./chunk-HCC76DDO.js";
13
13
  import {
14
14
  Tool
15
- } from "./chunk-A7QHWVD7.js";
15
+ } from "./chunk-7POUFE5M.js";
16
16
  import {
17
17
  formatTypings,
18
18
  getTypings
19
- } from "./chunk-EE6NVDID.js";
19
+ } from "./chunk-IUE5BW56.js";
20
20
  import {
21
21
  CodeFormattingError,
22
22
  LoopExceededError,
23
23
  SnapshotSignal,
24
24
  ThinkSignal
25
- } from "./chunk-JKVVQN2P.js";
26
- import "./chunk-JQBT7UWN.js";
25
+ } from "./chunk-MYLTD5WT.js";
26
+ import "./chunk-YEAWWJSJ.js";
27
27
  import {
28
28
  Exit
29
29
  } from "./chunk-VPTFUOIK.js";
@@ -1103,20 +1103,20 @@ var utils = {
1103
1103
  truncateWrappedContent
1104
1104
  };
1105
1105
  var execute = async (props) => {
1106
- const { executeContext } = await import("./llmz-M5AWNDMV.js");
1106
+ const { executeContext } = await import("./llmz-WPO4HYQY.js");
1107
1107
  return executeContext(props);
1108
1108
  };
1109
1109
  var init = async () => {
1110
- await import("./llmz-M5AWNDMV.js");
1110
+ await import("./llmz-WPO4HYQY.js");
1111
1111
  await import("./component-WFVDVSDK.js");
1112
- await import("./tool-PCOYOCRH.js");
1112
+ await import("./tool-GEBXW6AQ.js");
1113
1113
  await import("./exit-YLO7BY7Z.js");
1114
1114
  await import("./jsx-AEHVFB3L.js");
1115
- await import("./vm-CYC5RLKU.js");
1115
+ await import("./vm-I4G4IH7T.js");
1116
1116
  await import("./utils-RQHQ2KOG.js");
1117
1117
  await import("./truncator-BSP6PQPC.js");
1118
- await import("./typings-WYHEFCYB.js");
1119
- await import("./dual-modes-7FI4T35O.js");
1118
+ await import("./typings-3VYUEACY.js");
1119
+ await import("./dual-modes-DW3KRXT2.js");
1120
1120
  };
1121
1121
  export {
1122
1122
  Chat,
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkBNDY7RGXcjs = require('./chunk-BNDY7RGX.cjs');
3
+ var _chunkM3LCKL55cjs = require('./chunk-M3LCKL55.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkUGXCQIHBcjs = require('./chunk-UGXCQIHB.cjs');
11
- require('./chunk-PIDLNYIP.cjs');
12
- require('./chunk-XGJOEQMW.cjs');
13
- require('./chunk-FZJHYLM2.cjs');
10
+ var _chunkVADA6DMRcjs = require('./chunk-VADA6DMR.cjs');
11
+ require('./chunk-WP4F6KMW.cjs');
12
+ require('./chunk-273DEMEU.cjs');
13
+ require('./chunk-RLOPQZTQ.cjs');
14
14
 
15
15
 
16
16
 
@@ -20,10 +20,11 @@ require('./chunk-FZJHYLM2.cjs');
20
20
 
21
21
 
22
22
 
23
- var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
24
23
 
24
+ var _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
25
25
 
26
- var _chunkIKSIOIIPcjs = require('./chunk-IKSIOIIP.cjs');
26
+
27
+ var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
27
28
  require('./chunk-3G3BS5IA.cjs');
28
29
  require('./chunk-ZRCU35UV.cjs');
29
30
  require('./chunk-KMZDFWYZ.cjs');
@@ -105,7 +106,7 @@ var _executeContext = async (props) => {
105
106
  const { onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
106
107
  const cognitive = _cognitive.Cognitive.isCognitiveClient(props.client) ? props.client : new (0, _cognitive.Cognitive)({ client: props.client });
107
108
  const cleanups = [];
108
- const ctx = new (0, _chunkUGXCQIHBcjs.Context)({
109
+ const ctx = new (0, _chunkVADA6DMRcjs.Context)({
109
110
  chat: props.chat,
110
111
  instructions: props.instructions,
111
112
  objects: props.objects,
@@ -120,7 +121,7 @@ var _executeContext = async (props) => {
120
121
  try {
121
122
  while (true) {
122
123
  if (ctx.iterations.length >= ctx.loop) {
123
- return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, new (0, _chunkJDABP4SDcjs.LoopExceededError)());
124
+ return new (0, _chunkVADA6DMRcjs.ErrorExecutionResult)(ctx, new (0, _chunkT63Y6GTWcjs.LoopExceededError)());
124
125
  }
125
126
  const iteration = await ctx.nextIteration();
126
127
  if (controller.signal.aborted) {
@@ -130,7 +131,7 @@ var _executeContext = async (props) => {
130
131
  reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
131
132
  }
132
133
  });
133
- return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
134
+ return new (0, _chunkVADA6DMRcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
134
135
  }
135
136
  cleanups.push(
136
137
  iteration.traces.onPush((traces) => {
@@ -155,7 +156,7 @@ var _executeContext = async (props) => {
155
156
  type: "execution_error",
156
157
  execution_error: {
157
158
  message: "An unexpected error occurred: " + getErrorMessage(err),
158
- stack: _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, _nullishCoalesce(err.stack, () => ( "No stack trace available")))
159
+ stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(err.stack, () => ( "No stack trace available")))
159
160
  }
160
161
  });
161
162
  }
@@ -166,25 +167,25 @@ var _executeContext = async (props) => {
166
167
  }
167
168
  if (iteration.status.type === "exit_success") {
168
169
  const exitName = iteration.status.exit_success.exit_name;
169
- return new (0, _chunkUGXCQIHBcjs.SuccessExecutionResult)(ctx, {
170
+ return new (0, _chunkVADA6DMRcjs.SuccessExecutionResult)(ctx, {
170
171
  exit: iteration.exits.find((x) => x.name === exitName),
171
172
  result: iteration.status.exit_success.return_value
172
173
  });
173
174
  }
174
175
  if (iteration.status.type === "callback_requested") {
175
- return new (0, _chunkUGXCQIHBcjs.PartialExecutionResult)(
176
+ return new (0, _chunkVADA6DMRcjs.PartialExecutionResult)(
176
177
  ctx,
177
178
  iteration.status.callback_requested.signal,
178
- _chunkUGXCQIHBcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
179
+ _chunkVADA6DMRcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
179
180
  );
180
181
  }
181
182
  if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
182
183
  continue;
183
184
  }
184
- return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
185
+ return new (0, _chunkVADA6DMRcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
185
186
  }
186
187
  } catch (error) {
187
- return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
188
+ return new (0, _chunkVADA6DMRcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
188
189
  } finally {
189
190
  for (const cleanup of cleanups) {
190
191
  try {
@@ -207,8 +208,8 @@ var executeIteration = async ({
207
208
  var _a, _b, _c, _d, _e;
208
209
  let startedAt = Date.now();
209
210
  const traces = iteration.traces;
210
- const model = await cognitive.getModelDetails(_nullishCoalesce(iteration.model, () => ( "best")));
211
- const modelLimit = model.input.maxTokens;
211
+ const model = await cognitive.getModelDetails(Array.isArray(iteration.model) ? iteration.model[0] : iteration.model);
212
+ const modelLimit = Math.max(model.input.maxTokens, 8e3);
212
213
  const responseLengthBuffer = getModelOutputLimit(modelLimit);
213
214
  const messages = _chunkGZPN7RGHcjs.truncateWrappedContent.call(void 0, {
214
215
  messages: iteration.messages,
@@ -238,7 +239,7 @@ var executeIteration = async ({
238
239
  });
239
240
  const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
240
241
  if (!out) {
241
- throw new Error("No output from LLM");
242
+ throw new (0, _chunkT63Y6GTWcjs.CognitiveError)("LLM did not return any text output");
242
243
  }
243
244
  const assistantResponse = ctx.version.parseAssistantResponse(out);
244
245
  iteration.code = assistantResponse.code.trim();
@@ -249,7 +250,7 @@ var executeIteration = async ({
249
250
  iteration.code = hookRes.code.trim();
250
251
  }
251
252
  } catch (err) {
252
- if (err instanceof _chunkJDABP4SDcjs.ThinkSignal) {
253
+ if (err instanceof _chunkT63Y6GTWcjs.ThinkSignal) {
253
254
  return iteration.end({
254
255
  type: "thinking_requested",
255
256
  thinking_requested: {
@@ -262,7 +263,7 @@ var executeIteration = async ({
262
263
  type: "execution_error",
263
264
  execution_error: {
264
265
  message: `Error in onBeforeExecution hook: ${getErrorMessage(err)}`,
265
- stack: _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, _nullishCoalesce(err.stack, () => ( "No stack trace available")))
266
+ stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(err.stack, () => ( "No stack trace available")))
266
267
  }
267
268
  });
268
269
  }
@@ -303,14 +304,14 @@ var executeIteration = async ({
303
304
  return;
304
305
  }
305
306
  if (!writable) {
306
- throw new (0, _chunkJDABP4SDcjs.AssignmentError)(`Property ${obj.name}.${name} is read-only and cannot be modified`);
307
+ throw new (0, _chunkT63Y6GTWcjs.AssignmentError)(`Property ${obj.name}.${name} is read-only and cannot be modified`);
307
308
  }
308
309
  if (value2 === internalValues[name]) {
309
310
  return;
310
311
  }
311
312
  const parsed = schema.safeParse(value2);
312
313
  if (!parsed.success) {
313
- throw new (0, _chunkJDABP4SDcjs.AssignmentError)(
314
+ throw new (0, _chunkT63Y6GTWcjs.AssignmentError)(
314
315
  `Invalid value for Object property ${obj.name}.${name}: ${getErrorMessage(parsed.error)}`
315
316
  );
316
317
  }
@@ -361,7 +362,7 @@ var executeIteration = async ({
361
362
  });
362
363
  }
363
364
  startedAt = Date.now();
364
- const result = await _chunkBNDY7RGXcjs.runAsyncFunction.call(void 0,
365
+ const result = await _chunkM3LCKL55cjs.runAsyncFunction.call(void 0,
365
366
  vmContext,
366
367
  iteration.code,
367
368
  traces,
@@ -376,7 +377,7 @@ var executeIteration = async ({
376
377
  variables: {}
377
378
  };
378
379
  });
379
- if (result.error && result.error instanceof _chunkJDABP4SDcjs.InvalidCodeError) {
380
+ if (result.error && result.error instanceof _chunkT63Y6GTWcjs.InvalidCodeError) {
380
381
  return iteration.end({
381
382
  type: "invalid_code_error",
382
383
  invalid_code_error: {
@@ -390,12 +391,12 @@ var executeIteration = async ({
390
391
  started_at: startedAt,
391
392
  ended_at: Date.now()
392
393
  });
393
- if (result.error && result.error instanceof _chunkJDABP4SDcjs.CodeExecutionError) {
394
+ if (result.error && result.error instanceof _chunkT63Y6GTWcjs.CodeExecutionError) {
394
395
  return iteration.end({
395
396
  type: "execution_error",
396
397
  execution_error: {
397
398
  message: result.error.message,
398
- stack: _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, _nullishCoalesce(_nullishCoalesce(result.error.stacktrace, () => ( result.error.stack)), () => ( "No stack trace available")))
399
+ stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(_nullishCoalesce(result.error.stacktrace, () => ( result.error.stack)), () => ( "No stack trace available")))
399
400
  }
400
401
  });
401
402
  }
@@ -412,11 +413,11 @@ var executeIteration = async ({
412
413
  type: "execution_error",
413
414
  execution_error: {
414
415
  message: _nullishCoalesce(((_e = result == null ? void 0 : result.error) == null ? void 0 : _e.message), () => ( "Unknown error occurred")),
415
- stack: _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, _nullishCoalesce(result.error.stack, () => ( "No stack trace available")))
416
+ stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(result.error.stack, () => ( "No stack trace available")))
416
417
  }
417
418
  });
418
419
  }
419
- if (result.signal instanceof _chunkJDABP4SDcjs.ThinkSignal) {
420
+ if (result.signal instanceof _chunkT63Y6GTWcjs.ThinkSignal) {
420
421
  return iteration.end({
421
422
  type: "thinking_requested",
422
423
  thinking_requested: {
@@ -425,7 +426,7 @@ var executeIteration = async ({
425
426
  }
426
427
  });
427
428
  }
428
- if (result.signal instanceof _chunkJDABP4SDcjs.SnapshotSignal) {
429
+ if (result.signal instanceof _chunkT63Y6GTWcjs.SnapshotSignal) {
429
430
  return iteration.end({
430
431
  type: "callback_requested",
431
432
  callback_requested: {
@@ -538,16 +539,16 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
538
539
  if (output === error2) {
539
540
  return true;
540
541
  }
541
- if (error2 instanceof _chunkJDABP4SDcjs.SnapshotSignal) {
542
+ if (error2 instanceof _chunkT63Y6GTWcjs.SnapshotSignal) {
542
543
  error2.toolCall = {
543
544
  name: tool.name,
544
545
  inputSchema: tool.input,
545
546
  outputSchema: tool.output,
546
547
  input
547
548
  };
548
- error2.message = _chunkJDABP4SDcjs.Signals.serializeError(error2);
549
+ error2.message = _chunkT63Y6GTWcjs.Signals.serializeError(error2);
549
550
  }
550
- if (error2 instanceof _chunkJDABP4SDcjs.ThinkSignal) {
551
+ if (error2 instanceof _chunkT63Y6GTWcjs.ThinkSignal) {
551
552
  traces.push({
552
553
  type: "think_signal",
553
554
  started_at: Date.now(),
@@ -638,7 +639,7 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
638
639
  if (!success) {
639
640
  throw error;
640
641
  }
641
- if (output instanceof _chunkJDABP4SDcjs.VMSignal) {
642
+ if (output instanceof _chunkT63Y6GTWcjs.VMSignal) {
642
643
  throw output;
643
644
  }
644
645
  return output;
@@ -1,29 +1,30 @@
1
1
  import {
2
2
  runAsyncFunction
3
- } from "./chunk-LUX4X7XO.js";
3
+ } from "./chunk-7G5QAIUX.js";
4
4
  import {
5
5
  Context,
6
6
  ErrorExecutionResult,
7
7
  PartialExecutionResult,
8
8
  Snapshot,
9
9
  SuccessExecutionResult
10
- } from "./chunk-DBRWIHIH.js";
11
- import "./chunk-2D2DE7CD.js";
12
- import "./chunk-A7QHWVD7.js";
13
- import "./chunk-EE6NVDID.js";
10
+ } from "./chunk-KQPGB6GB.js";
11
+ import "./chunk-HCC76DDO.js";
12
+ import "./chunk-7POUFE5M.js";
13
+ import "./chunk-IUE5BW56.js";
14
14
  import {
15
15
  AssignmentError,
16
16
  CodeExecutionError,
17
+ CognitiveError,
17
18
  InvalidCodeError,
18
19
  LoopExceededError,
19
20
  Signals,
20
21
  SnapshotSignal,
21
22
  ThinkSignal,
22
23
  VMSignal
23
- } from "./chunk-JKVVQN2P.js";
24
+ } from "./chunk-MYLTD5WT.js";
24
25
  import {
25
26
  cleanStackTrace
26
- } from "./chunk-JQBT7UWN.js";
27
+ } from "./chunk-YEAWWJSJ.js";
27
28
  import "./chunk-VPTFUOIK.js";
28
29
  import "./chunk-GGWM6X2K.js";
29
30
  import "./chunk-ORQP26SZ.js";
@@ -207,8 +208,8 @@ var executeIteration = async ({
207
208
  var _a, _b, _c, _d, _e;
208
209
  let startedAt = Date.now();
209
210
  const traces = iteration.traces;
210
- const model = await cognitive.getModelDetails(iteration.model ?? "best");
211
- const modelLimit = model.input.maxTokens;
211
+ const model = await cognitive.getModelDetails(Array.isArray(iteration.model) ? iteration.model[0] : iteration.model);
212
+ const modelLimit = Math.max(model.input.maxTokens, 8e3);
212
213
  const responseLengthBuffer = getModelOutputLimit(modelLimit);
213
214
  const messages = truncateWrappedContent({
214
215
  messages: iteration.messages,
@@ -238,7 +239,7 @@ var executeIteration = async ({
238
239
  });
239
240
  const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
240
241
  if (!out) {
241
- throw new Error("No output from LLM");
242
+ throw new CognitiveError("LLM did not return any text output");
242
243
  }
243
244
  const assistantResponse = ctx.version.parseAssistantResponse(out);
244
245
  iteration.code = assistantResponse.code.trim();
package/dist/llmz.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Cognitive, type BotpressClientLike } from '@botpress/cognitive';
1
+ import { Cognitive, Models, type BotpressClientLike } from '@botpress/cognitive';
2
2
  import { Chat } from './chat.js';
3
- import { Context, Iteration, Model } from './context.js';
3
+ import { Context, Iteration } from './context.js';
4
4
  import { Exit, ExitResult } from './exit.js';
5
5
  import { ValueOrGetter } from './getter.js';
6
6
  import { type ObjectInstance } from './objects.js';
@@ -175,7 +175,7 @@ export type ExecutionProps = {
175
175
  * The model to use for the LLM.
176
176
  * This can be a static model name or a function that returns a model name based on the current context.
177
177
  */
178
- model?: ValueOrGetter<Model, Context>;
178
+ model?: ValueOrGetter<Models | Models[], Context>;
179
179
  /**
180
180
  * The temperature to use for the LLM.
181
181
  * This can be a static temperature or a function that returns a temperature based on the current context.
package/dist/result.d.ts CHANGED
@@ -388,7 +388,7 @@ export declare class SuccessExecutionResult<TOutput = unknown> extends Execution
388
388
  id: string;
389
389
  messages: import("./index.js").LLMzPrompts.Message[];
390
390
  code: string | undefined;
391
- model: import("./context.js").Model;
391
+ model: import("@botpress/cognitive").Models | import("@botpress/cognitive").Models[];
392
392
  temperature: number;
393
393
  traces: import("./types.js").Traces.Trace[];
394
394
  variables: Record<string, any>;
@@ -543,7 +543,7 @@ export declare class ErrorExecutionResult extends ExecutionResult implements Ser
543
543
  id: string;
544
544
  messages: import("./index.js").LLMzPrompts.Message[];
545
545
  code: string | undefined;
546
- model: import("./context.js").Model;
546
+ model: import("@botpress/cognitive").Models | import("@botpress/cognitive").Models[];
547
547
  temperature: number;
548
548
  traces: import("./types.js").Traces.Trace[];
549
549
  variables: Record<string, any>;
@@ -718,7 +718,7 @@ export declare class PartialExecutionResult extends ExecutionResult implements S
718
718
  id: string;
719
719
  messages: import("./index.js").LLMzPrompts.Message[];
720
720
  code: string | undefined;
721
- model: import("./context.js").Model;
721
+ model: import("@botpress/cognitive").Models | import("@botpress/cognitive").Models[];
722
722
  temperature: number;
723
723
  traces: import("./types.js").Traces.Trace[];
724
724
  variables: Record<string, any>;
@@ -0,0 +1,11 @@
1
+ import {
2
+ Tool
3
+ } from "./chunk-7POUFE5M.js";
4
+ import "./chunk-IUE5BW56.js";
5
+ import "./chunk-MYLTD5WT.js";
6
+ import "./chunk-YEAWWJSJ.js";
7
+ import "./chunk-ZORRILUV.js";
8
+ import "./chunk-7WRN4E42.js";
9
+ export {
10
+ Tool
11
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk273DEMEUcjs = require('./chunk-273DEMEU.cjs');
4
+ require('./chunk-RLOPQZTQ.cjs');
5
+ require('./chunk-T63Y6GTW.cjs');
6
+ require('./chunk-KIN7Y247.cjs');
7
+ require('./chunk-WHNOR4ZU.cjs');
8
+ require('./chunk-UQOBUJIQ.cjs');
9
+
10
+
11
+ exports.Tool = _chunk273DEMEUcjs.Tool;
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkRLOPQZTQcjs = require('./chunk-RLOPQZTQ.cjs');
4
+ require('./chunk-T63Y6GTW.cjs');
5
+ require('./chunk-KIN7Y247.cjs');
6
+ require('./chunk-WHNOR4ZU.cjs');
7
+ require('./chunk-UQOBUJIQ.cjs');
8
+
9
+
10
+ exports.getTypings = _chunkRLOPQZTQcjs.getTypings;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getTypings
3
- } from "./chunk-EE6NVDID.js";
4
- import "./chunk-JKVVQN2P.js";
5
- import "./chunk-JQBT7UWN.js";
3
+ } from "./chunk-IUE5BW56.js";
4
+ import "./chunk-MYLTD5WT.js";
5
+ import "./chunk-YEAWWJSJ.js";
6
6
  import "./chunk-ZORRILUV.js";
7
7
  import "./chunk-7WRN4E42.js";
8
8
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  CAN_USE_ISOLATED_VM,
3
3
  runAsyncFunction
4
- } from "./chunk-LUX4X7XO.js";
5
- import "./chunk-JKVVQN2P.js";
6
- import "./chunk-JQBT7UWN.js";
4
+ } from "./chunk-7G5QAIUX.js";
5
+ import "./chunk-MYLTD5WT.js";
6
+ import "./chunk-YEAWWJSJ.js";
7
7
  import "./chunk-ORQP26SZ.js";
8
8
  import "./chunk-7WRN4E42.js";
9
9
  export {
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkM3LCKL55cjs = require('./chunk-M3LCKL55.cjs');
5
+ require('./chunk-T63Y6GTW.cjs');
6
+ require('./chunk-KIN7Y247.cjs');
7
+ require('./chunk-KMZDFWYZ.cjs');
8
+ require('./chunk-UQOBUJIQ.cjs');
9
+
10
+
11
+
12
+ exports.CAN_USE_ISOLATED_VM = _chunkM3LCKL55cjs.CAN_USE_ISOLATED_VM; exports.runAsyncFunction = _chunkM3LCKL55cjs.runAsyncFunction;