llmz 0.0.76 → 0.0.77

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.
@@ -1368,8 +1368,15 @@ var Context = (_class2 = class {
1368
1368
  if (typeof temperature !== "number" || isNaN(temperature) || temperature < 0 || temperature > 2) {
1369
1369
  throw new Error("Invalid temperature. Expected a number between 0 and 2.");
1370
1370
  }
1371
- if (typeof model !== "string" || model.length === 0) {
1372
- throw new Error("Invalid model. Expected a non-empty string.");
1371
+ const isValidModel = (m) => typeof m === "string" && (m === "best" || m === "fast" || m === "auto" || m.includes(":"));
1372
+ if (Array.isArray(model)) {
1373
+ if (model.length === 0 || !model.every(isValidModel)) {
1374
+ throw new Error(
1375
+ "Invalid model. Expected a non-empty array of model strings ('best'/'fast'/'auto' or 'provider:model')."
1376
+ );
1377
+ }
1378
+ } else if (!isValidModel(model)) {
1379
+ throw new Error("Invalid model. Expected 'best'/'fast'/'auto' or 'provider:model'.");
1373
1380
  }
1374
1381
  return {
1375
1382
  transcript,
@@ -1368,8 +1368,15 @@ var Context = class {
1368
1368
  if (typeof temperature !== "number" || isNaN(temperature) || temperature < 0 || temperature > 2) {
1369
1369
  throw new Error("Invalid temperature. Expected a number between 0 and 2.");
1370
1370
  }
1371
- if (typeof model !== "string" || model.length === 0) {
1372
- throw new Error("Invalid model. Expected a non-empty string.");
1371
+ const isValidModel = (m) => typeof m === "string" && (m === "best" || m === "fast" || m === "auto" || m.includes(":"));
1372
+ if (Array.isArray(model)) {
1373
+ if (model.length === 0 || !model.every(isValidModel)) {
1374
+ throw new Error(
1375
+ "Invalid model. Expected a non-empty array of model strings ('best'/'fast'/'auto' or 'provider:model')."
1376
+ );
1377
+ }
1378
+ } else if (!isValidModel(model)) {
1379
+ throw new Error("Invalid model. Expected 'best'/'fast'/'auto' or 'provider:model'.");
1373
1380
  }
1374
1381
  return {
1375
1382
  transcript,
package/dist/index.cjs CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkC4CL2QZIcjs = require('./chunk-C4CL2QZI.cjs');
12
+ var _chunkBFZJ4UV2cjs = require('./chunk-BFZJ4UV2.cjs');
13
13
  require('./chunk-3SZK4YSR.cjs');
14
14
 
15
15
 
@@ -53,7 +53,7 @@ var _chunk4VYDQ3VFcjs = require('./chunk-4VYDQ3VF.cjs');
53
53
  var _chunkRKKRSBX3cjs = require('./chunk-RKKRSBX3.cjs');
54
54
 
55
55
  // package.json
56
- var version = "0.0.76";
56
+ var version = "0.0.77";
57
57
 
58
58
  // src/objects.ts
59
59
  var _zui = require('@bpinternal/zui');
@@ -1115,11 +1115,11 @@ var utils = {
1115
1115
  truncateWrappedContent: _chunkUCXQ4U7Pcjs.truncateWrappedContent
1116
1116
  };
1117
1117
  var execute = async (props) => {
1118
- const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-6L7C5M25.cjs")));
1118
+ const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-YPI4WWBW.cjs")));
1119
1119
  return executeContext(props);
1120
1120
  };
1121
1121
  var init = async () => {
1122
- await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-6L7C5M25.cjs")));
1122
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-YPI4WWBW.cjs")));
1123
1123
  await Promise.resolve().then(() => _interopRequireWildcard(require("./component-36KG7B5H.cjs")));
1124
1124
  await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-NCCTC74P.cjs")));
1125
1125
  await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-OOGJ3TAS.cjs")));
@@ -1159,4 +1159,4 @@ var init = async () => {
1159
1159
 
1160
1160
 
1161
1161
 
1162
- exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkK2B5YEGJcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkC4CL2QZIcjs.DefaultExit; exports.ErrorExecutionResult = _chunkC4CL2QZIcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkC4CL2QZIcjs.ExecutionResult; exports.Exit = _chunkF4OZHUMScjs.Exit; exports.ListenExit = _chunkC4CL2QZIcjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkC4CL2QZIcjs.PartialExecutionResult; exports.Snapshot = _chunkC4CL2QZIcjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkC4CL2QZIcjs.SuccessExecutionResult; exports.ThinkExit = _chunkC4CL2QZIcjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunk2JTZOTO5cjs.Tool; exports.assertValidComponent = _chunkK2B5YEGJcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkC4CL2QZIcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkK2B5YEGJcjs.isAnyComponent; exports.isComponent = _chunkK2B5YEGJcjs.isComponent; exports.parseExit = _chunkC4CL2QZIcjs.parseExit; exports.renderToTsx = _chunkK2B5YEGJcjs.renderToTsx; exports.utils = utils; exports.version = version;
1162
+ exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkK2B5YEGJcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkBFZJ4UV2cjs.DefaultExit; exports.ErrorExecutionResult = _chunkBFZJ4UV2cjs.ErrorExecutionResult; exports.ExecutionResult = _chunkBFZJ4UV2cjs.ExecutionResult; exports.Exit = _chunkF4OZHUMScjs.Exit; exports.ListenExit = _chunkBFZJ4UV2cjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkBFZJ4UV2cjs.PartialExecutionResult; exports.Snapshot = _chunkBFZJ4UV2cjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkBFZJ4UV2cjs.SuccessExecutionResult; exports.ThinkExit = _chunkBFZJ4UV2cjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunk2JTZOTO5cjs.Tool; exports.assertValidComponent = _chunkK2B5YEGJcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkBFZJ4UV2cjs.getValue; exports.init = init; exports.isAnyComponent = _chunkK2B5YEGJcjs.isAnyComponent; exports.isComponent = _chunkK2B5YEGJcjs.isComponent; exports.parseExit = _chunkBFZJ4UV2cjs.parseExit; exports.renderToTsx = _chunkK2B5YEGJcjs.renderToTsx; exports.utils = utils; exports.version = version;
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  ThinkExit,
10
10
  getValue,
11
11
  parseExit
12
- } from "./chunk-E6WEQRZF.js";
12
+ } from "./chunk-EXSETPV7.js";
13
13
  import "./chunk-6EAURSDP.js";
14
14
  import {
15
15
  Tool
@@ -53,7 +53,7 @@ import {
53
53
  } from "./chunk-5XC6ZMS5.js";
54
54
 
55
55
  // package.json
56
- var version = "0.0.76";
56
+ var version = "0.0.77";
57
57
 
58
58
  // src/objects.ts
59
59
  import { z } from "@bpinternal/zui";
@@ -1115,11 +1115,11 @@ var utils = {
1115
1115
  truncateWrappedContent
1116
1116
  };
1117
1117
  var execute = async (props) => {
1118
- const { executeContext } = await import("./llmz-7OZC2RFA.js");
1118
+ const { executeContext } = await import("./llmz-D4MQK65F.js");
1119
1119
  return executeContext(props);
1120
1120
  };
1121
1121
  var init = async () => {
1122
- await import("./llmz-7OZC2RFA.js");
1122
+ await import("./llmz-D4MQK65F.js");
1123
1123
  await import("./component-EZAROCAF.js");
1124
1124
  await import("./tool-ZP6BC3P2.js");
1125
1125
  await import("./exit-56DISPLS.js");
@@ -8,7 +8,7 @@ import {
8
8
  Snapshot,
9
9
  SuccessExecutionResult,
10
10
  parseExit
11
- } from "./chunk-E6WEQRZF.js";
11
+ } from "./chunk-EXSETPV7.js";
12
12
  import "./chunk-6EAURSDP.js";
13
13
  import "./chunk-G5INQ5LJ.js";
14
14
  import "./chunk-LR6KTFHO.js";
@@ -255,7 +255,9 @@ var executeIteration = async ({
255
255
  const output = await cognitive.generateContent({
256
256
  signal: controller.signal,
257
257
  systemPrompt: (_a = messages.find((x) => x.role === "system")) == null ? void 0 : _a.content,
258
- model: model.ref,
258
+ // Validated upstream in Context (see context.ts isValidModel). Cast narrows
259
+ // Models' `({} & string)` escape hatch down to cognitive's stricter InputModel.
260
+ model: iteration.model,
259
261
  temperature: iteration.temperature,
260
262
  responseFormat: "text",
261
263
  reasoningEffort: iteration.reasoningEffort,
@@ -8,7 +8,7 @@ var _chunk5CXOW4DCcjs = require('./chunk-5CXOW4DC.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunkC4CL2QZIcjs = require('./chunk-C4CL2QZI.cjs');
11
+ var _chunkBFZJ4UV2cjs = require('./chunk-BFZJ4UV2.cjs');
12
12
  require('./chunk-3SZK4YSR.cjs');
13
13
  require('./chunk-2JTZOTO5.cjs');
14
14
  require('./chunk-BLB44ZDU.cjs');
@@ -109,7 +109,7 @@ var _executeContext = async (props) => {
109
109
  const client = _nullishCoalesce(props.client, () => ( new (0, _client.Client)()));
110
110
  const cognitive = _cognitive.Cognitive.isCognitiveClient(client) ? client : new (0, _cognitive.Cognitive)({ client, __experimental_beta: true });
111
111
  const cleanups = [];
112
- const ctx = new (0, _chunkC4CL2QZIcjs.Context)({
112
+ const ctx = new (0, _chunkBFZJ4UV2cjs.Context)({
113
113
  chat: props.chat,
114
114
  instructions: props.instructions,
115
115
  objects: props.objects,
@@ -125,7 +125,7 @@ var _executeContext = async (props) => {
125
125
  try {
126
126
  while (true) {
127
127
  if (ctx.iterations.length >= ctx.loop) {
128
- return new (0, _chunkC4CL2QZIcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
128
+ return new (0, _chunkBFZJ4UV2cjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
129
129
  }
130
130
  const iteration = await ctx.nextIteration();
131
131
  try {
@@ -148,7 +148,7 @@ var _executeContext = async (props) => {
148
148
  reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
149
149
  }
150
150
  });
151
- return new (0, _chunkC4CL2QZIcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
151
+ return new (0, _chunkBFZJ4UV2cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
152
152
  }
153
153
  cleanups.push(
154
154
  iteration.traces.onPush((traces) => {
@@ -170,7 +170,7 @@ var _executeContext = async (props) => {
170
170
  });
171
171
  } catch (err) {
172
172
  if (err instanceof _chunkPK72FAKDcjs.CognitiveError) {
173
- return new (0, _chunkC4CL2QZIcjs.ErrorExecutionResult)(ctx, err);
173
+ return new (0, _chunkBFZJ4UV2cjs.ErrorExecutionResult)(ctx, err);
174
174
  }
175
175
  iteration.end({
176
176
  type: "execution_error",
@@ -187,25 +187,25 @@ var _executeContext = async (props) => {
187
187
  }
188
188
  if (iteration.status.type === "exit_success") {
189
189
  const exitName = iteration.status.exit_success.exit_name;
190
- return new (0, _chunkC4CL2QZIcjs.SuccessExecutionResult)(ctx, {
190
+ return new (0, _chunkBFZJ4UV2cjs.SuccessExecutionResult)(ctx, {
191
191
  exit: iteration.exits.find((x) => x.name === exitName),
192
192
  result: iteration.status.exit_success.return_value
193
193
  });
194
194
  }
195
195
  if (iteration.status.type === "callback_requested") {
196
- return new (0, _chunkC4CL2QZIcjs.PartialExecutionResult)(
196
+ return new (0, _chunkBFZJ4UV2cjs.PartialExecutionResult)(
197
197
  ctx,
198
198
  iteration.status.callback_requested.signal,
199
- _chunkC4CL2QZIcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
199
+ _chunkBFZJ4UV2cjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
200
200
  );
201
201
  }
202
202
  if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
203
203
  continue;
204
204
  }
205
- return new (0, _chunkC4CL2QZIcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
205
+ return new (0, _chunkBFZJ4UV2cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
206
206
  }
207
207
  } catch (error) {
208
- return new (0, _chunkC4CL2QZIcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
208
+ return new (0, _chunkBFZJ4UV2cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
209
209
  } finally {
210
210
  for (const cleanup of cleanups) {
211
211
  try {
@@ -255,7 +255,9 @@ var executeIteration = async ({
255
255
  const output = await cognitive.generateContent({
256
256
  signal: controller.signal,
257
257
  systemPrompt: (_a = messages.find((x) => x.role === "system")) == null ? void 0 : _a.content,
258
- model: model.ref,
258
+ // Validated upstream in Context (see context.ts isValidModel). Cast narrows
259
+ // Models' `({} & string)` escape hatch down to cognitive's stricter InputModel.
260
+ model: iteration.model,
259
261
  temperature: iteration.temperature,
260
262
  responseFormat: "text",
261
263
  reasoningEffort: iteration.reasoningEffort,
@@ -484,7 +486,7 @@ var executeIteration = async ({
484
486
  }
485
487
  });
486
488
  }
487
- const parsedExit = _chunkC4CL2QZIcjs.parseExit.call(void 0, returnValue, iteration.exits);
489
+ const parsedExit = _chunkBFZJ4UV2cjs.parseExit.call(void 0, returnValue, iteration.exits);
488
490
  if (!parsedExit.success) {
489
491
  return iteration.end({
490
492
  type: "exit_error",
package/package.json CHANGED
@@ -2,7 +2,7 @@
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.0.76",
5
+ "version": "0.0.77",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@botpress/client": "1.45.0",
75
- "@botpress/cognitive": "0.5.3",
75
+ "@botpress/cognitive": "0.5.4",
76
76
  "@bpinternal/thicktoken": "^2.0.0",
77
77
  "@bpinternal/zui": "^2.1.1"
78
78
  },