llmz 0.0.83 → 0.0.84

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 (36) hide show
  1. package/dist/{chunk-I2CZYEMH.js → chunk-2O3UTPVH.js} +2 -2
  2. package/dist/{chunk-73XYX76S.cjs → chunk-7LMIOS6H.cjs} +14 -14
  3. package/dist/{chunk-NQBIU5VM.cjs → chunk-BBX2LDZE.cjs} +25 -25
  4. package/dist/{chunk-RLUTWFAA.cjs → chunk-D6PU5YAS.cjs} +6 -6
  5. package/dist/{chunk-NWTG73QR.cjs → chunk-FPLSJF4S.cjs} +1 -43
  6. package/dist/{chunk-5Z2SJOGS.js → chunk-IRCB4FRM.js} +65 -19
  7. package/dist/{chunk-MM2FLD3J.js → chunk-L74UZONX.js} +1 -1
  8. package/dist/{chunk-VDTORFBP.js → chunk-NK2NCYSY.js} +4 -4
  9. package/dist/{chunk-YCLKXXSF.cjs → chunk-PQGZQQA6.cjs} +18 -18
  10. package/dist/{chunk-NPVV3PHY.js → chunk-TOGYDN6U.js} +1 -1
  11. package/dist/{chunk-52QTFQOB.cjs → chunk-WODK7Y4J.cjs} +60 -14
  12. package/dist/{chunk-VLJA22PB.js → chunk-XVVYNOTX.js} +1 -1
  13. package/dist/{chunk-5MAFEI2A.js → chunk-YX27XM67.js} +0 -42
  14. package/dist/{chunk-6KR6VRA6.cjs → chunk-ZPHRTTQX.cjs} +2 -2
  15. package/dist/convert.d.ts +11 -0
  16. package/dist/{dual-modes-VDFZH4YM.js → dual-modes-HEXPFVUE.js} +3 -3
  17. package/dist/{dual-modes-E5HGE35E.cjs → dual-modes-LLIWZCHC.cjs} +4 -4
  18. package/dist/{execute-R6R3A42S.cjs → execute-2BVFYTJT.cjs} +30 -30
  19. package/dist/{execute-CJVHUFYI.js → execute-EZXXBWB6.js} +7 -7
  20. package/dist/exit-LUJY7JIG.cjs +8 -0
  21. package/dist/{exit-GKF4EEMZ.js → exit-VJATJTQI.js} +2 -2
  22. package/dist/index.cjs +33 -33
  23. package/dist/index.js +16 -16
  24. package/dist/{tool-JZP3UN2F.js → tool-DNHVW3KC.js} +3 -3
  25. package/dist/{tool-4VK7TZV2.cjs → tool-GJ6ZXWS2.cjs} +4 -4
  26. package/dist/{truncator-IIRX3MB2.js → truncator-3U2QUUJJ.js} +2 -2
  27. package/dist/truncator-3ZN7W6NB.cjs +10 -0
  28. package/dist/{typings-SKZSSL2M.js → typings-3YV3RDMP.js} +2 -2
  29. package/dist/{typings-SHVPZ5AR.cjs → typings-ZTFPPA5W.cjs} +3 -3
  30. package/dist/utils-GLZVMRWO.cjs +39 -0
  31. package/dist/{utils-SYJGSVFW.js → utils-ZEZ66X6Q.js} +1 -3
  32. package/dist/utils.d.ts +0 -4
  33. package/package.json +1 -1
  34. package/dist/exit-VZASQELZ.cjs +0 -8
  35. package/dist/truncator-NWENJXMR.cjs +0 -10
  36. package/dist/utils-6MFSS4AT.cjs +0 -41
@@ -2,22 +2,22 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkNQBIU5VMcjs = require('./chunk-NQBIU5VM.cjs');
5
+ var _chunkBBX2LDZEcjs = require('./chunk-BBX2LDZE.cjs');
6
6
 
7
7
 
8
- var _chunk52QTFQOBcjs = require('./chunk-52QTFQOB.cjs');
8
+ var _chunkWODK7Y4Jcjs = require('./chunk-WODK7Y4J.cjs');
9
9
 
10
10
 
11
11
  var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
12
12
 
13
13
 
14
- var _chunkRLUTWFAAcjs = require('./chunk-RLUTWFAA.cjs');
14
+ var _chunkD6PU5YAScjs = require('./chunk-D6PU5YAS.cjs');
15
15
 
16
16
 
17
17
  var _chunkCQ3UJW76cjs = require('./chunk-CQ3UJW76.cjs');
18
18
 
19
19
 
20
- var _chunk6KR6VRA6cjs = require('./chunk-6KR6VRA6.cjs');
20
+ var _chunkZPHRTTQXcjs = require('./chunk-ZPHRTTQX.cjs');
21
21
 
22
22
 
23
23
 
@@ -493,10 +493,10 @@ var Snapshot = class _Snapshot {
493
493
  };
494
494
  function parseVariables(variableMap) {
495
495
  return Object.entries(variableMap).map(([name, value]) => {
496
- const type = _chunkNQBIU5VMcjs.extractType.call(void 0, value);
496
+ const type = _chunkBBX2LDZEcjs.extractType.call(void 0, value);
497
497
  const bytes = JSON.stringify(value || "").length;
498
498
  const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
499
- return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkNQBIU5VMcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
499
+ return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkBBX2LDZEcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
500
500
  });
501
501
  }
502
502
 
@@ -507,9 +507,9 @@ function getMessagePreview(message) {
507
507
  return message.content;
508
508
  }
509
509
  if (message.role === "event") {
510
- return _chunkNQBIU5VMcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
510
+ return _chunkBBX2LDZEcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
511
511
  }
512
- return _chunkNQBIU5VMcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
512
+ return _chunkBBX2LDZEcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
513
513
  }
514
514
  function getMessageType(message) {
515
515
  if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
@@ -933,15 +933,15 @@ var HookedArray = class extends Array {
933
933
  };
934
934
 
935
935
  // src/context.ts
936
- var ThinkExit = new (0, _chunkRLUTWFAAcjs.Exit)({
936
+ var ThinkExit = new (0, _chunkD6PU5YAScjs.Exit)({
937
937
  name: "think",
938
938
  description: "Think about the current situation and provide a response"
939
939
  });
940
- var ListenExit = new (0, _chunkRLUTWFAAcjs.Exit)({
940
+ var ListenExit = new (0, _chunkD6PU5YAScjs.Exit)({
941
941
  name: "listen",
942
942
  description: "Listen to the user and provide a response"
943
943
  });
944
- var DefaultExit = new (0, _chunkRLUTWFAAcjs.Exit)({
944
+ var DefaultExit = new (0, _chunkD6PU5YAScjs.Exit)({
945
945
  name: "done",
946
946
  description: "When the execution is sucessfully completed or when error recovery is not possible",
947
947
  schema: _zui.z.discriminatedUnion("success", [
@@ -1103,7 +1103,7 @@ var Context = (_class2 = class {
1103
1103
 
1104
1104
 
1105
1105
 
1106
- __init3() {this.version = _chunkNQBIU5VMcjs.DualModePrompt}
1106
+ __init3() {this.version = _chunkBBX2LDZEcjs.DualModePrompt}
1107
1107
  __init4() {this.timeout = 6e4}
1108
1108
  // Default timeout of 60 seconds
1109
1109
 
@@ -1224,7 +1224,7 @@ var Context = (_class2 = class {
1224
1224
  ...lastIterationMessages,
1225
1225
  {
1226
1226
  role: "assistant",
1227
- content: _chunk6KR6VRA6cjs.wrapContent.call(void 0, _nullishCoalesce(((_c = lastIteration.llm) == null ? void 0 : _c.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1227
+ content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_c = lastIteration.llm) == null ? void 0 : _c.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1228
1228
  },
1229
1229
  await this.version.getThinkingMessage({
1230
1230
  reason: lastIteration.status.thinking_requested.reason,
@@ -1237,7 +1237,7 @@ var Context = (_class2 = class {
1237
1237
  ...lastIterationMessages,
1238
1238
  {
1239
1239
  role: "assistant",
1240
- content: _chunk6KR6VRA6cjs.wrapContent.call(void 0, _nullishCoalesce(((_d = lastIteration.llm) == null ? void 0 : _d.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1240
+ content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_d = lastIteration.llm) == null ? void 0 : _d.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1241
1241
  },
1242
1242
  await this.version.getInvalidCodeMessage({
1243
1243
  code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
@@ -1250,7 +1250,7 @@ var Context = (_class2 = class {
1250
1250
  ...lastIterationMessages,
1251
1251
  {
1252
1252
  role: "assistant",
1253
- content: _chunk6KR6VRA6cjs.wrapContent.call(void 0, _nullishCoalesce(((_e = lastIteration.llm) == null ? void 0 : _e.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1253
+ content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_e = lastIteration.llm) == null ? void 0 : _e.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1254
1254
  },
1255
1255
  await this.version.getInvalidCodeMessage({
1256
1256
  code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
@@ -1263,7 +1263,7 @@ var Context = (_class2 = class {
1263
1263
  ...lastIterationMessages,
1264
1264
  {
1265
1265
  role: "assistant",
1266
- content: _chunk6KR6VRA6cjs.wrapContent.call(void 0, _nullishCoalesce(((_f = lastIteration.llm) == null ? void 0 : _f.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1266
+ content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_f = lastIteration.llm) == null ? void 0 : _f.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
1267
1267
  },
1268
1268
  await this.version.getCodeExecutionErrorMessage({
1269
1269
  message: lastIteration.status.execution_error.message,
@@ -1279,7 +1279,7 @@ var Context = (_class2 = class {
1279
1279
  var _a, _b;
1280
1280
  const instructions = await getValue(this.instructions, this);
1281
1281
  const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
1282
- const tools = _chunk52QTFQOBcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1282
+ const tools = _chunkWODK7Y4Jcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1283
1283
  const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
1284
1284
  const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
1285
1285
  const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
@@ -1312,7 +1312,7 @@ var Context = (_class2 = class {
1312
1312
  "boolean",
1313
1313
  "array"
1314
1314
  ];
1315
- const MessageTool = this.chat && components.length ? new (0, _chunk52QTFQOBcjs.Tool)({
1315
+ const MessageTool = this.chat && components.length ? new (0, _chunkWODK7Y4Jcjs.Tool)({
1316
1316
  name: "Message",
1317
1317
  description: "Send a message to the user",
1318
1318
  aliases: Array.from(
@@ -5,7 +5,7 @@ import {
5
5
  escapeString,
6
6
  getMultilineComment,
7
7
  toPropertyKey
8
- } from "./chunk-5MAFEI2A.js";
8
+ } from "./chunk-YX27XM67.js";
9
9
 
10
10
  // src/typings.ts
11
11
  import { z } from "@bpinternal/zui";
@@ -1,12 +1,11 @@
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 _chunk73XYX76Scjs = require('./chunk-73XYX76S.cjs');
3
+ var _chunk7LMIOS6Hcjs = require('./chunk-7LMIOS6H.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
-
9
- var _chunkNWTG73QRcjs = require('./chunk-NWTG73QR.cjs');
8
+ var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
10
9
 
11
10
 
12
11
 
@@ -14,6 +13,49 @@ var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
14
13
 
15
14
  // src/tool.ts
16
15
  var _zui = require('@bpinternal/zui');
16
+
17
+ // src/convert.ts
18
+
19
+ function convertObjectToZuiLiterals(obj, nested = false) {
20
+ if (typeof obj === "string") {
21
+ return _zui.z.literal(obj).catch(() => obj);
22
+ }
23
+ if (typeof obj === "number") {
24
+ return _zui.z.literal(obj).catch(() => obj);
25
+ }
26
+ if (typeof obj === "boolean") {
27
+ return _zui.z.literal(obj).catch(() => obj);
28
+ }
29
+ if (Array.isArray(obj)) {
30
+ if (obj.length === 0) {
31
+ return _zui.z.tuple([]).catch(() => obj);
32
+ }
33
+ const items = obj.map((child) => convertObjectToZuiLiterals(child, true));
34
+ return _zui.z.tuple(items).catch(() => obj);
35
+ }
36
+ if (obj !== null && typeof obj === "object") {
37
+ const shape = {};
38
+ for (const [key, value] of Object.entries(obj)) {
39
+ shape[key] = convertObjectToZuiLiterals(value, true);
40
+ }
41
+ if (nested) {
42
+ return _zui.z.object(shape).catch(() => obj);
43
+ }
44
+ if (Object.keys(shape).length === 0) {
45
+ return _zui.z.object({}).catch(() => obj);
46
+ }
47
+ return shape;
48
+ }
49
+ if (obj === void 0) {
50
+ return _zui.z.undefined().catch(() => void 0);
51
+ }
52
+ if (obj === null) {
53
+ return _zui.z.null().catch(() => null);
54
+ }
55
+ throw new Error(`Unsupported object type ${typeof obj}, ${obj})`);
56
+ }
57
+
58
+ // src/tool.ts
17
59
  var Tool = (_class = class _Tool {
18
60
 
19
61
 
@@ -105,12 +147,16 @@ var Tool = (_class = class _Tool {
105
147
  input = _zui.z.any();
106
148
  }
107
149
  if (!_chunkHC2QZTVTcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
108
- const inputExtensions = _chunkNWTG73QRcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
109
150
  if (_zui.z.is.zuiObject(input)) {
151
+ const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
110
152
  input = input.extend(inputExtensions);
111
153
  } else if (_zui.z.is.zuiArray(input)) {
154
+ const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
112
155
  input = _zui.z.array(input.element.extend(inputExtensions));
113
156
  } else {
157
+ const inputExtensions = convertObjectToZuiLiterals(
158
+ this._staticInputValues
159
+ );
114
160
  input = inputExtensions;
115
161
  }
116
162
  }
@@ -149,7 +195,7 @@ var Tool = (_class = class _Tool {
149
195
  */
150
196
  rename(name) {
151
197
  const before = this.name;
152
- if (!_chunkNWTG73QRcjs.isValidIdentifier.call(void 0, name)) {
198
+ if (!_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, name)) {
153
199
  throw new Error(
154
200
  `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.`
155
201
  );
@@ -325,7 +371,7 @@ var Tool = (_class = class _Tool {
325
371
  * ```
326
372
  */
327
373
  constructor(props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
328
- if (!_chunkNWTG73QRcjs.isValidIdentifier.call(void 0, props.name)) {
374
+ if (!_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, props.name)) {
329
375
  throw new Error(
330
376
  `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.`
331
377
  );
@@ -350,17 +396,17 @@ var Tool = (_class = class _Tool {
350
396
  `Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
351
397
  );
352
398
  }
353
- if (props.aliases && props.aliases.some((alias) => !_chunkNWTG73QRcjs.isValidIdentifier.call(void 0, alias))) {
399
+ if (props.aliases && props.aliases.some((alias) => !_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, alias))) {
354
400
  throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
355
401
  }
356
402
  if (typeof props.input !== "undefined") {
357
- if (_chunkNWTG73QRcjs.isZuiSchema.call(void 0, props.input)) {
403
+ if (_chunkFPLSJF4Scjs.isZuiSchema.call(void 0, props.input)) {
358
404
  try {
359
405
  this.input = _zui.transforms.toJSONSchema(props.input);
360
406
  } catch (e6) {
361
407
  this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
362
408
  }
363
- } else if (_chunkNWTG73QRcjs.isJsonSchema.call(void 0, props.input)) {
409
+ } else if (_chunkFPLSJF4Scjs.isJsonSchema.call(void 0, props.input)) {
364
410
  this.input = props.input;
365
411
  } else {
366
412
  throw new Error(
@@ -369,13 +415,13 @@ var Tool = (_class = class _Tool {
369
415
  }
370
416
  }
371
417
  if (typeof props.output !== "undefined") {
372
- if (_chunkNWTG73QRcjs.isZuiSchema.call(void 0, props.output)) {
418
+ if (_chunkFPLSJF4Scjs.isZuiSchema.call(void 0, props.output)) {
373
419
  try {
374
420
  this.output = _zui.transforms.toJSONSchema(props.output);
375
421
  } catch (e7) {
376
422
  this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
377
423
  }
378
- } else if (_chunkNWTG73QRcjs.isJsonSchema.call(void 0, props.output)) {
424
+ } else if (_chunkFPLSJF4Scjs.isJsonSchema.call(void 0, props.output)) {
379
425
  this.output = props.output;
380
426
  } else {
381
427
  throw new Error(
@@ -496,13 +542,13 @@ var Tool = (_class = class _Tool {
496
542
  }
497
543
  }
498
544
  if (input && _zui.z.is.zuiObject(input.naked()) && typeof this._staticInputValues === "object" && !_chunkHC2QZTVTcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
499
- const inputExtensions = _chunkNWTG73QRcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
545
+ const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
500
546
  input = input.extend(inputExtensions);
501
547
  } else if (this._staticInputValues !== void 0) {
502
- input = _chunkNWTG73QRcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
548
+ input = convertObjectToZuiLiterals(this._staticInputValues);
503
549
  }
504
550
  const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
505
- return _chunk73XYX76Scjs.getTypings.call(void 0, fnType, {
551
+ return _chunk7LMIOS6Hcjs.getTypings.call(void 0, fnType, {
506
552
  declaration: true
507
553
  });
508
554
  }
@@ -2,7 +2,7 @@ import {
2
2
  isJsonSchema,
3
3
  isValidIdentifier,
4
4
  isZuiSchema
5
- } from "./chunk-5MAFEI2A.js";
5
+ } from "./chunk-YX27XM67.js";
6
6
  import {
7
7
  uniq_default
8
8
  } from "./chunk-34GJUS6U.js";
@@ -138,47 +138,6 @@ var stripInvalidIdentifiers = (object) => {
138
138
  }
139
139
  return pickBy_default(object, (__, key) => Identifier.safeParse(key).success);
140
140
  };
141
- var convertObjectToZuiLiterals = (obj, nested = false) => {
142
- if (typeof obj === "string") {
143
- return z.literal(obj).catch(() => obj);
144
- }
145
- if (typeof obj === "number") {
146
- return z.literal(obj).catch(() => obj);
147
- }
148
- if (typeof obj === "boolean") {
149
- return z.literal(obj).catch(() => obj);
150
- }
151
- if (Array.isArray(obj)) {
152
- if (obj.length === 0) {
153
- return z.tuple([]).catch(() => obj);
154
- }
155
- return z.tuple([
156
- // the tuple needs to have at least one element
157
- convertObjectToZuiLiterals(obj[0]),
158
- ...obj.slice(1).map((child) => convertObjectToZuiLiterals(child))
159
- ]).catch(() => obj);
160
- }
161
- if (obj !== null && typeof obj === "object") {
162
- const shape = {};
163
- for (const key in obj) {
164
- shape[key] = convertObjectToZuiLiterals(obj[key], true);
165
- }
166
- if (nested) {
167
- return z.object(shape).catch(() => shape);
168
- }
169
- if (Object.keys(shape).length === 0) {
170
- return z.object({}).catch(() => shape);
171
- }
172
- return shape;
173
- }
174
- if (obj === void 0) {
175
- return z.undefined().catch(() => void 0);
176
- }
177
- if (obj === null) {
178
- return z.null().catch(() => null);
179
- }
180
- throw new Error(`Unsupported object type ${typeof obj}, ${obj})`);
181
- };
182
141
  var isValidSchema = (schema) => {
183
142
  try {
184
143
  transforms.fromJSONSchemaLegacy(schema);
@@ -219,7 +178,6 @@ export {
219
178
  awaitObject,
220
179
  toValidObjectName,
221
180
  stripInvalidIdentifiers,
222
- convertObjectToZuiLiterals,
223
181
  isValidSchema,
224
182
  isZuiSchema,
225
183
  isJsonSchema,
@@ -1,6 +1,6 @@
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 _chunkNWTG73QRcjs = require('./chunk-NWTG73QR.cjs');
3
+ var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
4
4
 
5
5
  // src/truncator.ts
6
6
  var DEFAULT_REMOVE_CHUNK = 250;
@@ -25,7 +25,7 @@ function truncateWrappedContent({
25
25
  throwOnFailure = true
26
26
  }) {
27
27
  var _a, _b, _c;
28
- const tokenizer = _chunkNWTG73QRcjs.getTokenizer.call(void 0, );
28
+ const tokenizer = _chunkFPLSJF4Scjs.getTokenizer.call(void 0, );
29
29
  const parts = [];
30
30
  for (const msg of messages) {
31
31
  const current = [];
@@ -0,0 +1,11 @@
1
+ import { z } from '@bpinternal/zui';
2
+ export type StaticValue = string | number | boolean | null | undefined | readonly StaticValue[] | StaticObject;
3
+ export type StaticObject = {
4
+ readonly [key: string]: StaticValue;
5
+ };
6
+ /**
7
+ * Transforms static input values to Zui schemas that narrow manually provided values to literals.
8
+ */
9
+ export declare function convertObjectToZuiLiterals<T extends StaticObject>(obj: T, nested?: false): keyof T extends never ? z.ZodTypeAny : z.ZodRawShape;
10
+ export declare function convertObjectToZuiLiterals<T extends StaticValue>(obj: T, nested: true): z.ZodTypeAny;
11
+ export declare function convertObjectToZuiLiterals<T extends Exclude<StaticValue, StaticObject>>(obj: T, nested?: false): z.ZodTypeAny;
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  DualModePrompt
3
- } from "./chunk-I2CZYEMH.js";
3
+ } from "./chunk-2O3UTPVH.js";
4
4
  import "./chunk-YEAWWJSJ.js";
5
5
  import "./chunk-3T5IU7OU.js";
6
6
  import "./chunk-XTEHT2TK.js";
7
- import "./chunk-MM2FLD3J.js";
8
- import "./chunk-5MAFEI2A.js";
7
+ import "./chunk-L74UZONX.js";
8
+ import "./chunk-YX27XM67.js";
9
9
  import "./chunk-34GJUS6U.js";
10
10
  export {
11
11
  DualModePrompt
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkNQBIU5VMcjs = require('./chunk-NQBIU5VM.cjs');
3
+ var _chunkBBX2LDZEcjs = require('./chunk-BBX2LDZE.cjs');
4
4
  require('./chunk-KIN7Y247.cjs');
5
5
  require('./chunk-CQ3UJW76.cjs');
6
6
  require('./chunk-5ZF6NTYI.cjs');
7
- require('./chunk-6KR6VRA6.cjs');
8
- require('./chunk-NWTG73QR.cjs');
7
+ require('./chunk-ZPHRTTQX.cjs');
8
+ require('./chunk-FPLSJF4S.cjs');
9
9
  require('./chunk-HC2QZTVT.cjs');
10
10
 
11
11
 
12
- exports.DualModePrompt = _chunkNQBIU5VMcjs.DualModePrompt;
12
+ exports.DualModePrompt = _chunkBBX2LDZEcjs.DualModePrompt;
@@ -8,10 +8,10 @@ var _chunkJXD2KJVBcjs = require('./chunk-JXD2KJVB.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunkYCLKXXSFcjs = require('./chunk-YCLKXXSF.cjs');
12
- require('./chunk-NQBIU5VM.cjs');
13
- require('./chunk-52QTFQOB.cjs');
14
- require('./chunk-73XYX76S.cjs');
11
+ var _chunkPQGZQQA6cjs = require('./chunk-PQGZQQA6.cjs');
12
+ require('./chunk-BBX2LDZE.cjs');
13
+ require('./chunk-WODK7Y4J.cjs');
14
+ require('./chunk-7LMIOS6H.cjs');
15
15
 
16
16
 
17
17
 
@@ -25,17 +25,17 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
25
25
 
26
26
 
27
27
  var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
28
- require('./chunk-RLUTWFAA.cjs');
28
+ require('./chunk-D6PU5YAS.cjs');
29
29
  require('./chunk-CQ3UJW76.cjs');
30
30
  require('./chunk-5ZF6NTYI.cjs');
31
31
 
32
32
 
33
- var _chunk6KR6VRA6cjs = require('./chunk-6KR6VRA6.cjs');
33
+ var _chunkZPHRTTQXcjs = require('./chunk-ZPHRTTQX.cjs');
34
34
 
35
35
 
36
36
 
37
37
 
38
- var _chunkNWTG73QRcjs = require('./chunk-NWTG73QR.cjs');
38
+ var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
39
39
 
40
40
 
41
41
 
@@ -93,11 +93,11 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
93
93
  const traces = iteration.traces;
94
94
  const modelRef = Array.isArray(iteration.model) ? iteration.model[0] : iteration.model;
95
95
  const model = await cognitive.getModelDetails(modelRef).catch((thrown) => {
96
- throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`Failed to fetch model details for model "${modelRef}": ${_chunkNWTG73QRcjs.getErrorMessage.call(void 0, thrown)}`);
96
+ throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`Failed to fetch model details for model "${modelRef}": ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, thrown)}`);
97
97
  });
98
98
  const modelLimit = Math.max(model.input.maxTokens, 8e3);
99
99
  const responseLengthBuffer = getModelOutputLimit(modelLimit);
100
- const messages = _chunk6KR6VRA6cjs.truncateWrappedContent.call(void 0, {
100
+ const messages = _chunkZPHRTTQXcjs.truncateWrappedContent.call(void 0, {
101
101
  messages: iteration.messages,
102
102
  tokenLimit: modelLimit - responseLengthBuffer,
103
103
  throwOnFailure: true
@@ -119,7 +119,7 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
119
119
  messages: messages.filter((x) => x.role !== "system"),
120
120
  stopSequences: ctx.version.getStopTokens()
121
121
  }).catch((thrown) => {
122
- throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`LLM generation failed: ${_chunkNWTG73QRcjs.getErrorMessage.call(void 0, thrown)}`);
122
+ throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`LLM generation failed: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, thrown)}`);
123
123
  });
124
124
  const out = typeof ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.content) === "string" ? output.output.choices[0].content : null;
125
125
  if (!out) {
@@ -243,7 +243,7 @@ var interpretVMResult = async ({
243
243
  });
244
244
  return;
245
245
  }
246
- const parsedExit = _chunkYCLKXXSFcjs.parseExit.call(void 0, returnValue, iteration.exits);
246
+ const parsedExit = _chunkPQGZQQA6cjs.parseExit.call(void 0, returnValue, iteration.exits);
247
247
  if (!parsedExit.success) {
248
248
  iteration.end({
249
249
  type: "exit_error",
@@ -267,7 +267,7 @@ var interpretVMResult = async ({
267
267
  type: "exit_error",
268
268
  exit_error: {
269
269
  exit: returnExit.name,
270
- message: `Error executing exit ${returnExit.name}: ${_chunkNWTG73QRcjs.getErrorMessage.call(void 0, err)}`,
270
+ message: `Error executing exit ${returnExit.name}: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, err)}`,
271
271
  return_value: returnValue
272
272
  }
273
273
  });
@@ -449,7 +449,7 @@ var buildVMContext = ({
449
449
  onAfterTool
450
450
  }) => {
451
451
  const traces = iteration.traces;
452
- const vmContext = { ..._chunkNWTG73QRcjs.stripInvalidIdentifiers.call(void 0, iteration.variables) };
452
+ const vmContext = { ..._chunkFPLSJF4Scjs.stripInvalidIdentifiers.call(void 0, iteration.variables) };
453
453
  for (const obj of iteration.objects) {
454
454
  const internalValues = {};
455
455
  const instance = {};
@@ -473,7 +473,7 @@ var buildVMContext = ({
473
473
  const parsed = schema.safeParse(value2);
474
474
  if (!parsed.success) {
475
475
  throw new (0, _chunkPK72FAKDcjs.AssignmentError)(
476
- `Invalid value for Object property ${obj.name}.${name}: ${_chunkNWTG73QRcjs.getErrorMessage.call(void 0, parsed.error)}`
476
+ `Invalid value for Object property ${obj.name}.${name}: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, parsed.error)}`
477
477
  );
478
478
  }
479
479
  internalValues[name] = parsed.data;
@@ -524,7 +524,7 @@ var buildVMContext = ({
524
524
  // src/runtime/execute.ts
525
525
  var executeContext = async (props) => {
526
526
  var _a, _b;
527
- await _chunkNWTG73QRcjs.init.call(void 0, );
527
+ await _chunkFPLSJF4Scjs.init.call(void 0, );
528
528
  const result = await executeContextInternal(props);
529
529
  try {
530
530
  (_b = (_a = result.context.chat) == null ? void 0 : _a.onExecutionDone) == null ? void 0 : _b.call(_a, result);
@@ -538,7 +538,7 @@ var executeContextInternal = async (props) => {
538
538
  const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
539
539
  const client = _nullishCoalesce(props.client, () => ( new (0, _client.Client)()));
540
540
  const cognitive = _cognitive.Cognitive.isCognitiveClient(client) ? client : _cognitive.CognitiveBeta.isBetaClient(client) ? _cognitive.cognitiveFromBeta.call(void 0, client) : new (0, _cognitive.Cognitive)({ client, __experimental_beta: true });
541
- const ctx = new (0, _chunkYCLKXXSFcjs.Context)({
541
+ const ctx = new (0, _chunkPQGZQQA6cjs.Context)({
542
542
  chat: props.chat,
543
543
  instructions: props.instructions,
544
544
  objects: props.objects,
@@ -554,7 +554,7 @@ var executeContextInternal = async (props) => {
554
554
  try {
555
555
  while (true) {
556
556
  if (ctx.iterations.length >= ctx.loop) {
557
- return new (0, _chunkYCLKXXSFcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
557
+ return new (0, _chunkPQGZQQA6cjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
558
558
  }
559
559
  const iteration = await ctx.nextIteration();
560
560
  const unsubscribeTrace = iteration.traces.onPush((traces) => {
@@ -585,7 +585,7 @@ var executeContextInternal = async (props) => {
585
585
  }
586
586
  }
587
587
  });
588
- return new (0, _chunkYCLKXXSFcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
588
+ return new (0, _chunkPQGZQQA6cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
589
589
  }
590
590
  const iterationResult = await executeIterationWithErrorHandling({
591
591
  iteration,
@@ -614,7 +614,7 @@ var executeContextInternal = async (props) => {
614
614
  }
615
615
  }
616
616
  } catch (error) {
617
- return new (0, _chunkYCLKXXSFcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
617
+ return new (0, _chunkPQGZQQA6cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
618
618
  }
619
619
  };
620
620
  var executeIterationStartHook = async ({
@@ -644,7 +644,7 @@ var executeIterationStartHook = async ({
644
644
  } : {
645
645
  type: "execution_error",
646
646
  execution_error: {
647
- message: `Error in onIterationStart hook: ${_chunkNWTG73QRcjs.getErrorMessage.call(void 0, err)}`,
647
+ message: `Error in onIterationStart hook: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, err)}`,
648
648
  stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0,
649
649
  err instanceof Error ? _nullishCoalesce(err.stack, () => ( "No stack trace available")) : "No stack trace available"
650
650
  )
@@ -687,7 +687,7 @@ var executeIterationWithErrorHandling = async ({
687
687
  status: iteration.status.type === "pending" ? {
688
688
  type: "execution_error",
689
689
  execution_error: {
690
- message: "An unexpected error occurred: " + _chunkNWTG73QRcjs.getErrorMessage.call(void 0, err),
690
+ message: "An unexpected error occurred: " + _chunkFPLSJF4Scjs.getErrorMessage.call(void 0, err),
691
691
  stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0,
692
692
  err instanceof Error ? _nullishCoalesce(err.stack, () => ( "No stack trace available")) : "No stack trace available"
693
693
  )
@@ -699,7 +699,7 @@ var executeIterationWithErrorHandling = async ({
699
699
  if (!controller.signal.aborted) {
700
700
  return {
701
701
  type: "return",
702
- result: new (0, _chunkYCLKXXSFcjs.ErrorExecutionResult)(ctx, err)
702
+ result: new (0, _chunkPQGZQQA6cjs.ErrorExecutionResult)(ctx, err)
703
703
  };
704
704
  }
705
705
  await finalizeIteration({
@@ -715,7 +715,7 @@ var executeIterationWithErrorHandling = async ({
715
715
  });
716
716
  return {
717
717
  type: "return",
718
- result: new (0, _chunkYCLKXXSFcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")))
718
+ result: new (0, _chunkPQGZQQA6cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")))
719
719
  };
720
720
  }
721
721
  };
@@ -727,7 +727,7 @@ var transformIterationResult = ({
727
727
  const exitName = iteration.status.exit_success.exit_name;
728
728
  return {
729
729
  type: "return",
730
- result: new (0, _chunkYCLKXXSFcjs.SuccessExecutionResult)(ctx, {
730
+ result: new (0, _chunkPQGZQQA6cjs.SuccessExecutionResult)(ctx, {
731
731
  exit: iteration.exits.find((x) => x.name === exitName),
732
732
  result: iteration.status.exit_success.return_value
733
733
  })
@@ -736,17 +736,17 @@ var transformIterationResult = ({
736
736
  if (iteration.status.type === "callback_requested") {
737
737
  return {
738
738
  type: "return",
739
- result: new (0, _chunkYCLKXXSFcjs.PartialExecutionResult)(
739
+ result: new (0, _chunkPQGZQQA6cjs.PartialExecutionResult)(
740
740
  ctx,
741
741
  iteration.status.callback_requested.signal,
742
- _chunkYCLKXXSFcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
742
+ _chunkPQGZQQA6cjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
743
743
  )
744
744
  };
745
745
  }
746
746
  if (iteration.status.type === "aborted") {
747
747
  return {
748
748
  type: "return",
749
- result: new (0, _chunkYCLKXXSFcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( "The operation was aborted")))
749
+ result: new (0, _chunkPQGZQQA6cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( "The operation was aborted")))
750
750
  };
751
751
  }
752
752
  if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
@@ -754,7 +754,7 @@ var transformIterationResult = ({
754
754
  }
755
755
  return {
756
756
  type: "return",
757
- result: new (0, _chunkYCLKXXSFcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)))
757
+ result: new (0, _chunkPQGZQQA6cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)))
758
758
  };
759
759
  };
760
760
  var executeIteration = async ({
@@ -788,7 +788,7 @@ var executeIteration = async ({
788
788
  iteration.end({
789
789
  type: "execution_error",
790
790
  execution_error: {
791
- message: `Error in onBeforeExecution hook: ${_chunkNWTG73QRcjs.getErrorMessage.call(void 0, err)}`,
791
+ message: `Error in onBeforeExecution hook: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, err)}`,
792
792
  stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0,
793
793
  err instanceof Error ? _nullishCoalesce(err.stack, () => ( "No stack trace available")) : "No stack trace available"
794
794
  )
@@ -823,7 +823,7 @@ var executeIteration = async ({
823
823
  ).catch((err) => {
824
824
  return {
825
825
  success: false,
826
- error: err instanceof Error ? err : new Error(_chunkNWTG73QRcjs.getErrorMessage.call(void 0, err)),
826
+ error: err instanceof Error ? err : new Error(_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, err)),
827
827
  lines_executed: [],
828
828
  traces: [],
829
829
  variables: {}