llm-exe 2.1.8 → 2.2.1

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.
package/dist/index.mjs CHANGED
@@ -3,13 +3,6 @@ var __typeError = (msg) => {
3
3
  throw TypeError(msg);
4
4
  };
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
6
  var __export = (target, all) => {
14
7
  for (var name in all)
15
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -28,38 +21,30 @@ function pick(object, keys) {
28
21
  return obj;
29
22
  }, {});
30
23
  }
31
- __name(pick, "pick");
32
24
 
33
25
  // src/utils/modules/ensureInputIsObject.ts
34
26
  function ensureInputIsObject(input) {
35
27
  if (input === null || typeof input === "undefined") {
36
- return {
37
- input
38
- };
28
+ return { input };
39
29
  }
40
30
  switch (typeof input) {
41
31
  case "object": {
42
32
  if (Array.isArray(input)) {
43
- return {
44
- input
45
- };
33
+ return { input };
46
34
  }
47
35
  return input;
48
36
  }
49
37
  default:
50
- return {
51
- input
52
- };
38
+ return { input };
53
39
  }
54
40
  }
55
- __name(ensureInputIsObject, "ensureInputIsObject");
56
41
 
57
42
  // src/utils/modules/uuid.ts
58
43
  import { v4 as uuidv4 } from "uuid";
59
44
 
60
45
  // src/executor/_metadata.ts
61
46
  var _state;
62
- var _ExecutorExecutionMetadataState = class _ExecutorExecutionMetadataState {
47
+ var ExecutorExecutionMetadataState = class {
63
48
  constructor(items) {
64
49
  __privateAdd(this, _state, {
65
50
  start: null,
@@ -102,12 +87,9 @@ var _ExecutorExecutionMetadataState = class _ExecutorExecutionMetadataState {
102
87
  }
103
88
  };
104
89
  _state = new WeakMap();
105
- __name(_ExecutorExecutionMetadataState, "ExecutorExecutionMetadataState");
106
- var ExecutorExecutionMetadataState = _ExecutorExecutionMetadataState;
107
90
  function createMetadataState(items) {
108
91
  return new ExecutorExecutionMetadataState(items);
109
92
  }
110
- __name(createMetadataState, "createMetadataState");
111
93
 
112
94
  // src/utils/const.ts
113
95
  var hookOnComplete = `onComplete`;
@@ -115,38 +97,34 @@ var hookOnError = `onError`;
115
97
  var hookOnSuccess = `onSuccess`;
116
98
 
117
99
  // src/executor/_base.ts
118
- var _BaseExecutor = class _BaseExecutor {
100
+ var BaseExecutor = class {
119
101
  constructor(name, type, options) {
120
102
  /**
121
- * @property id - internal id of the executor
122
- */
103
+ * @property id - internal id of the executor
104
+ */
123
105
  __publicField(this, "id");
124
106
  /**
125
- * @property type - type of executor
126
- */
107
+ * @property type - type of executor
108
+ */
127
109
  __publicField(this, "type");
128
110
  /**
129
- * @property created - timestamp date created
130
- */
111
+ * @property created - timestamp date created
112
+ */
131
113
  __publicField(this, "created");
132
114
  /**
133
- * @property name - name of executor
134
- */
115
+ * @property name - name of executor
116
+ */
135
117
  __publicField(this, "name");
136
118
  /**
137
- * @property executions -
138
- */
119
+ * @property executions -
120
+ */
139
121
  __publicField(this, "executions");
140
122
  __publicField(this, "traceId", null);
141
123
  /**
142
- * @property hooks - hooks to be ran during execution
143
- */
124
+ * @property hooks - hooks to be ran during execution
125
+ */
144
126
  __publicField(this, "hooks");
145
- __publicField(this, "allowedHooks", [
146
- hookOnComplete,
147
- hookOnError,
148
- hookOnSuccess
149
- ]);
127
+ __publicField(this, "allowedHooks", [hookOnComplete, hookOnError, hookOnSuccess]);
150
128
  this.id = uuidv4();
151
129
  this.type = type;
152
130
  this.name = name;
@@ -162,29 +140,29 @@ var _BaseExecutor = class _BaseExecutor {
162
140
  }
163
141
  }
164
142
  /**
165
- *
166
- * Used to filter the input of the handler
167
- * @param _input
168
- * @returns original input formatted for handler
169
- */
143
+ *
144
+ * Used to filter the input of the handler
145
+ * @param _input
146
+ * @returns original input formatted for handler
147
+ */
170
148
  async getHandlerInput(_input, _metadata, _options) {
171
149
  return ensureInputIsObject(_input);
172
150
  }
173
151
  /**
174
- *
175
- * Used to filter the output of the handler
176
- * @param _input
177
- * @returns output O
178
- */
152
+ *
153
+ * Used to filter the output of the handler
154
+ * @param _input
155
+ * @returns output O
156
+ */
179
157
  getHandlerOutput(out, _metadata, _options) {
180
158
  return out;
181
159
  }
182
160
  /**
183
- *
184
- * execute - Runs the executor
185
- * @param _input
186
- * @returns handler output
187
- */
161
+ *
162
+ * execute - Runs the executor
163
+ * @param _input
164
+ * @returns handler output
165
+ */
188
166
  async execute(_input, _options) {
189
167
  this.executions++;
190
168
  const _metadata = createMetadataState({
@@ -192,31 +170,28 @@ var _BaseExecutor = class _BaseExecutor {
192
170
  input: _input
193
171
  });
194
172
  try {
195
- const input = await this.getHandlerInput(_input, _metadata.asPlainObject(), _options);
196
- _metadata.setItem({
197
- handlerInput: input
198
- });
173
+ const input = await this.getHandlerInput(
174
+ _input,
175
+ _metadata.asPlainObject(),
176
+ _options
177
+ );
178
+ _metadata.setItem({ handlerInput: input });
199
179
  let result = await this.handler(input, _options);
200
- _metadata.setItem({
201
- handlerOutput: result
202
- });
203
- const output = this.getHandlerOutput(result, _metadata.asPlainObject(), _options);
204
- _metadata.setItem({
205
- output
206
- });
180
+ _metadata.setItem({ handlerOutput: result });
181
+ const output = this.getHandlerOutput(
182
+ result,
183
+ _metadata.asPlainObject(),
184
+ _options
185
+ );
186
+ _metadata.setItem({ output });
207
187
  this.runHook("onSuccess", _metadata.asPlainObject());
208
188
  return output;
209
189
  } catch (error) {
210
- _metadata.setItem({
211
- error,
212
- errorMessage: error.message
213
- });
190
+ _metadata.setItem({ error, errorMessage: error.message });
214
191
  this.runHook("onError", _metadata.asPlainObject());
215
192
  throw error;
216
193
  } finally {
217
- _metadata.setItem({
218
- end: (/* @__PURE__ */ new Date()).getTime()
219
- });
194
+ _metadata.setItem({ end: (/* @__PURE__ */ new Date()).getTime() });
220
195
  this.runHook("onComplete", _metadata.asPlainObject());
221
196
  }
222
197
  }
@@ -236,9 +211,7 @@ var _BaseExecutor = class _BaseExecutor {
236
211
  }
237
212
  runHook(hook, _metadata) {
238
213
  const { [hook]: hooks = [] } = pick(this.hooks, this.allowedHooks);
239
- for (const hookFn of [
240
- ...hooks
241
- ]) {
214
+ for (const hookFn of [...hooks]) {
242
215
  if (typeof hookFn === "function") {
243
216
  try {
244
217
  hookFn(_metadata, this.getMetadata());
@@ -249,12 +222,12 @@ var _BaseExecutor = class _BaseExecutor {
249
222
  }
250
223
  setHooks(hooks = {}) {
251
224
  const hookKeys = Object.keys(hooks);
252
- for (const hookKey of hookKeys.filter((k) => this.allowedHooks.includes(k))) {
225
+ for (const hookKey of hookKeys.filter(
226
+ (k) => this.allowedHooks.includes(k)
227
+ )) {
253
228
  const hookInput = hooks[hookKey];
254
229
  if (hookInput) {
255
- const _hooks = Array.isArray(hookInput) ? hookInput : [
256
- hookInput
257
- ];
230
+ const _hooks = Array.isArray(hookInput) ? hookInput : [hookInput];
258
231
  for (const hook of _hooks) {
259
232
  if (hook && typeof hook === "function" && !this.hooks[hookKey].find((h) => h === hook)) {
260
233
  this.hooks[hookKey].push(hook);
@@ -277,19 +250,17 @@ var _BaseExecutor = class _BaseExecutor {
277
250
  return this;
278
251
  }
279
252
  on(eventName, fn) {
280
- return this.setHooks({
281
- [eventName]: fn
282
- });
253
+ return this.setHooks({ [eventName]: fn });
283
254
  }
284
255
  off(eventName, fn) {
285
256
  return this.removeHook(eventName, fn);
286
257
  }
287
258
  once(eventName, fn) {
288
259
  if (typeof fn !== "function") return this;
289
- const onceWrapper = /* @__PURE__ */ __name((...args) => {
260
+ const onceWrapper = (...args) => {
290
261
  fn(...args);
291
262
  this.off(eventName, onceWrapper);
292
- }, "onceWrapper");
263
+ };
293
264
  this.hooks[eventName].push(onceWrapper);
294
265
  return this;
295
266
  }
@@ -301,26 +272,20 @@ var _BaseExecutor = class _BaseExecutor {
301
272
  return this.traceId;
302
273
  }
303
274
  };
304
- __name(_BaseExecutor, "BaseExecutor");
305
- var BaseExecutor = _BaseExecutor;
306
275
 
307
276
  // src/utils/modules/inferFunctionName.ts
308
277
  function inferFunctionName(func, defaultName) {
309
- const name = func?.name;
310
- if (name && typeof name === "string") {
311
- if (name.substring(0, 6) === "bound ") {
312
- return name.replace("bound ", "");
313
- } else {
314
- return name;
315
- }
278
+ if (typeof func !== "function") return defaultName;
279
+ const name = func.name;
280
+ if (typeof name === "string" && name.length > 0) {
281
+ return name.startsWith("bound ") ? name.slice(6) : name;
316
282
  }
317
- var result = /^function\s+([\w\$]+)\s*\(/.exec(func.toString());
318
- return result ? result[1] : defaultName;
283
+ const match = /^function\s+([\w$]+)\s*\(/.exec(func.toString());
284
+ return match?.[1] ?? defaultName;
319
285
  }
320
- __name(inferFunctionName, "inferFunctionName");
321
286
 
322
287
  // src/executor/core.ts
323
- var _CoreExecutor = class _CoreExecutor extends BaseExecutor {
288
+ var CoreExecutor = class extends BaseExecutor {
324
289
  constructor(fn, options) {
325
290
  const name = fn?.name ? fn.name : inferFunctionName(fn.handler, "anonymous-core-executor");
326
291
  super(name, "function-executor", options);
@@ -331,16 +296,14 @@ var _CoreExecutor = class _CoreExecutor extends BaseExecutor {
331
296
  return this._handler.call(null, _input);
332
297
  }
333
298
  };
334
- __name(_CoreExecutor, "CoreExecutor");
335
- var CoreExecutor = _CoreExecutor;
336
299
 
337
300
  // src/parser/_base.ts
338
- var _BaseParser = class _BaseParser {
301
+ var BaseParser = class {
339
302
  /**
340
- * Create a new BaseParser.
341
- * @param name - The name of the parser.
342
- * @param options - options
343
- */
303
+ * Create a new BaseParser.
304
+ * @param name - The name of the parser.
305
+ * @param options - options
306
+ */
344
307
  constructor(name, options = {}, target = "text") {
345
308
  __publicField(this, "name");
346
309
  __publicField(this, "options");
@@ -352,14 +315,12 @@ var _BaseParser = class _BaseParser {
352
315
  }
353
316
  }
354
317
  };
355
- __name(_BaseParser, "BaseParser");
356
- var BaseParser = _BaseParser;
357
- var _BaseParserWithJson = class _BaseParserWithJson extends BaseParser {
318
+ var BaseParserWithJson = class extends BaseParser {
358
319
  /**
359
- * Create a new BaseParser.
360
- * @param name - The name of the parser.
361
- * @param options - options
362
- */
320
+ * Create a new BaseParser.
321
+ * @param name - The name of the parser.
322
+ * @param options - options
323
+ */
363
324
  constructor(name, options) {
364
325
  super(name);
365
326
  __publicField(this, "schema");
@@ -371,8 +332,79 @@ var _BaseParserWithJson = class _BaseParserWithJson extends BaseParser {
371
332
  }
372
333
  }
373
334
  };
374
- __name(_BaseParserWithJson, "BaseParserWithJson");
375
- var BaseParserWithJson = _BaseParserWithJson;
335
+
336
+ // src/utils/modules/assert.ts
337
+ function assert(condition, message) {
338
+ if (condition === void 0 || condition === null || condition === false) {
339
+ if (typeof message === "string") {
340
+ throw new Error(message);
341
+ } else if (message instanceof Error) {
342
+ throw message;
343
+ } else {
344
+ throw new Error(`Assertion error`);
345
+ }
346
+ }
347
+ }
348
+
349
+ // src/parser/parsers/StringParser.ts
350
+ var StringParser = class extends BaseParser {
351
+ constructor(options) {
352
+ super("string", options);
353
+ }
354
+ parse(text, _options) {
355
+ assert(
356
+ typeof text === "string",
357
+ `Invalid input. Expected string. Received ${typeof text}.`
358
+ );
359
+ const parsed = text.toString();
360
+ return parsed;
361
+ }
362
+ };
363
+
364
+ // src/parser/parsers/BooleanParser.ts
365
+ var BooleanParser = class extends BaseParser {
366
+ constructor(options) {
367
+ super("boolean", options);
368
+ }
369
+ parse(text) {
370
+ assert(
371
+ typeof text === "string",
372
+ `Invalid input. Expected string. Received ${typeof text}.`
373
+ );
374
+ const clean = text.toLowerCase().trim();
375
+ if (clean === "true") {
376
+ return true;
377
+ }
378
+ return false;
379
+ }
380
+ };
381
+
382
+ // src/utils/modules/isFinite.ts
383
+ function isFinite(value) {
384
+ return typeof value === "number" && Number.isFinite(value);
385
+ }
386
+
387
+ // src/utils/modules/toNumber.ts
388
+ function toNumber(value) {
389
+ if (typeof value === "number") {
390
+ return value;
391
+ }
392
+ if (typeof value === "string" && value.trim() !== "") {
393
+ return Number(value);
394
+ }
395
+ return NaN;
396
+ }
397
+
398
+ // src/parser/parsers/NumberParser.ts
399
+ var NumberParser = class extends BaseParser {
400
+ constructor(options) {
401
+ super("number", options);
402
+ }
403
+ parse(text) {
404
+ const match = text.match(/\d/g);
405
+ return match && isFinite(toNumber(match[0])) ? toNumber(match[0]) : -1;
406
+ }
407
+ };
376
408
 
377
409
  // src/utils/index.ts
378
410
  var utils_exports = {};
@@ -393,33 +425,20 @@ __export(utils_exports, {
393
425
  replaceTemplateStringAsync: () => replaceTemplateStringAsync
394
426
  });
395
427
 
396
- // src/utils/modules/assert.ts
397
- function assert(condition, message) {
398
- if (condition === void 0 || condition === null || condition === false) {
399
- if (typeof message === "string") {
400
- throw new Error(message);
401
- } else if (message instanceof Error) {
402
- throw message;
403
- } else {
404
- throw new Error(`Assertion error`);
405
- }
406
- }
407
- }
408
- __name(assert, "assert");
409
-
410
428
  // src/utils/modules/defineSchema.ts
411
429
  import { asConst } from "json-schema-to-ts";
412
430
  function defineSchema(obj) {
413
431
  obj.additionalProperties = false;
414
432
  return asConst(obj);
415
433
  }
416
- __name(defineSchema, "defineSchema");
417
434
 
418
435
  // src/utils/modules/handlebars/utils/importPartials.ts
419
436
  function importPartials(_partials) {
420
437
  let partials2 = [];
421
438
  if (_partials) {
422
- const externalPartialKeys = Object.keys(_partials);
439
+ const externalPartialKeys = Object.keys(
440
+ _partials
441
+ );
423
442
  for (const externalPartialKey of externalPartialKeys) {
424
443
  if (typeof externalPartialKey === "string") {
425
444
  partials2.push({
@@ -431,13 +450,14 @@ function importPartials(_partials) {
431
450
  }
432
451
  return partials2;
433
452
  }
434
- __name(importPartials, "importPartials");
435
453
 
436
454
  // src/utils/modules/handlebars/utils/importHelpers.ts
437
455
  function importHelpers(_helpers) {
438
456
  let helpers = [];
439
457
  if (_helpers) {
440
- const externalHelperKeys = Object.keys(_helpers);
458
+ const externalHelperKeys = Object.keys(
459
+ _helpers
460
+ );
441
461
  for (const externalHelperKey of externalHelperKeys) {
442
462
  if (typeof externalHelperKey === "string") {
443
463
  helpers.push({
@@ -449,19 +469,6 @@ function importHelpers(_helpers) {
449
469
  }
450
470
  return helpers;
451
471
  }
452
- __name(importHelpers, "importHelpers");
453
-
454
- // src/utils/modules/toNumber.ts
455
- function toNumber(value) {
456
- if (typeof value === "number") {
457
- return value;
458
- }
459
- if (typeof value === "string" && value.trim() !== "") {
460
- return Number(value);
461
- }
462
- return NaN;
463
- }
464
- __name(toNumber, "toNumber");
465
472
 
466
473
  // src/utils/modules/get.ts
467
474
  function get(obj, path, defaultValue) {
@@ -469,17 +476,18 @@ function get(obj, path, defaultValue) {
469
476
  return defaultValue;
470
477
  }
471
478
  const pathString = Array.isArray(path) ? path.join(".") : path;
472
- const travel = /* @__PURE__ */ __name((regexp) => pathString.split(regexp).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj), "travel");
479
+ const travel = (regexp) => pathString.split(regexp).filter(Boolean).reduce(
480
+ (res, key) => res !== null && res !== void 0 ? res[key] : res,
481
+ obj
482
+ );
473
483
  const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
474
484
  return result === void 0 || result === obj ? defaultValue : result === null ? defaultValue : result;
475
485
  }
476
- __name(get, "get");
477
486
 
478
487
  // src/utils/modules/filterObjectOnSchema.ts
479
488
  function isObject(obj) {
480
489
  return obj === Object(obj);
481
490
  }
482
- __name(isObject, "isObject");
483
491
  function getType(schemaType) {
484
492
  if (!Array.isArray(schemaType)) {
485
493
  return schemaType;
@@ -492,7 +500,6 @@ function getType(schemaType) {
492
500
  }
493
501
  }
494
502
  }
495
- __name(getType, "getType");
496
503
  function filterObjectOnSchema(schema, doc, detach, property) {
497
504
  let result;
498
505
  if (doc === null || doc === void 0) {
@@ -537,25 +544,10 @@ function filterObjectOnSchema(schema, doc, detach, property) {
537
544
  }
538
545
  return result;
539
546
  }
540
- __name(filterObjectOnSchema, "filterObjectOnSchema");
541
547
 
542
548
  // src/utils/modules/handlebars/hbs.ts
543
549
  import Handlebars from "handlebars";
544
550
 
545
- // src/utils/modules/handlebars/utils/registerPartials.ts
546
- function _registerPartials(partials2, instance) {
547
- if (partials2 && Array.isArray(partials2)) {
548
- for (const partial of partials2) {
549
- if (partial.name && typeof partial.name === "string" && typeof partial.template === "string") {
550
- if (instance) {
551
- instance.registerPartial(partial.name, partial.template);
552
- }
553
- }
554
- }
555
- }
556
- }
557
- __name(_registerPartials, "_registerPartials");
558
-
559
551
  // src/utils/modules/handlebars/utils/registerHelpers.ts
560
552
  function _registerHelpers(helpers, instance) {
561
553
  if (helpers && Array.isArray(helpers)) {
@@ -568,17 +560,6 @@ function _registerHelpers(helpers, instance) {
568
560
  }
569
561
  }
570
562
  }
571
- __name(_registerHelpers, "_registerHelpers");
572
-
573
- // src/utils/modules/getEnvironmentVariable.ts
574
- function getEnvironmentVariable(name) {
575
- if (typeof process === "object" && process?.env) {
576
- return process.env[name];
577
- } else {
578
- return void 0;
579
- }
580
- }
581
- __name(getEnvironmentVariable, "getEnvironmentVariable");
582
563
 
583
564
  // src/utils/modules/handlebars/templates/index.ts
584
565
  var MarkdownCode = `{{#if code}}\`\`\`{{#if language}}{{language}}{{/if}}
@@ -652,7 +633,7 @@ __export(helpers_exports, {
652
633
  });
653
634
 
654
635
  // src/utils/modules/json.ts
655
- var maybeStringifyJSON = /* @__PURE__ */ __name((objOrMaybeString) => {
636
+ var maybeStringifyJSON = (objOrMaybeString) => {
656
637
  if (!objOrMaybeString || typeof objOrMaybeString !== "object") {
657
638
  return objOrMaybeString;
658
639
  }
@@ -662,8 +643,8 @@ var maybeStringifyJSON = /* @__PURE__ */ __name((objOrMaybeString) => {
662
643
  } catch (error) {
663
644
  }
664
645
  return "";
665
- }, "maybeStringifyJSON");
666
- var maybeParseJSON = /* @__PURE__ */ __name((objOrMaybeJSON) => {
646
+ };
647
+ var maybeParseJSON = (objOrMaybeJSON) => {
667
648
  if (!objOrMaybeJSON) return {};
668
649
  if (typeof objOrMaybeJSON === "string") {
669
650
  try {
@@ -679,24 +660,19 @@ var maybeParseJSON = /* @__PURE__ */ __name((objOrMaybeJSON) => {
679
660
  return objOrMaybeJSON;
680
661
  }
681
662
  return {};
682
- }, "maybeParseJSON");
663
+ };
683
664
  function isObjectStringified(maybeObject) {
684
665
  if (typeof maybeObject !== "string") return false;
685
- const isMaybeObject = maybeObject.substring(0, 1) === "{" && maybeObject.substring(maybeObject.length - 1, maybeObject.length) === "}";
686
- const isMaybeArray = maybeObject.substring(0, 1) === "[" && maybeObject.substring(maybeObject.length - 1, maybeObject.length) === "]";
687
- if (!isMaybeObject && !isMaybeArray) {
688
- return false;
689
- }
690
- let canDecode = false;
666
+ const trimmed = maybeObject.trim();
667
+ const isWrapped = trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]");
668
+ if (!isWrapped) return false;
691
669
  try {
692
- JSON.parse(maybeObject);
693
- canDecode = true;
694
- } catch (error) {
695
- canDecode = false;
670
+ const parsed = JSON.parse(trimmed);
671
+ return typeof parsed === "object" && parsed !== null;
672
+ } catch {
673
+ return false;
696
674
  }
697
- return canDecode;
698
675
  }
699
- __name(isObjectStringified, "isObjectStringified");
700
676
  function helpJsonMarkup(str) {
701
677
  if (typeof str !== "string") {
702
678
  return str;
@@ -704,12 +680,17 @@ function helpJsonMarkup(str) {
704
680
  const input = str.trim();
705
681
  const markdownJsonStartsWith = "```json";
706
682
  const markdownJsonEndsWith = "```";
707
- if (input.substring(0, markdownJsonStartsWith.length) === markdownJsonStartsWith && input.substring(input.length - markdownJsonEndsWith.length, input.length) === markdownJsonEndsWith) {
708
- return str.substring(markdownJsonStartsWith.length, input.length - markdownJsonEndsWith.length)?.trim();
683
+ if (input.substring(0, markdownJsonStartsWith.length) === markdownJsonStartsWith && input.substring(
684
+ input.length - markdownJsonEndsWith.length,
685
+ input.length
686
+ ) === markdownJsonEndsWith) {
687
+ return str.substring(
688
+ markdownJsonStartsWith.length,
689
+ input.length - markdownJsonEndsWith.length
690
+ )?.trim();
709
691
  }
710
692
  return str;
711
693
  }
712
- __name(helpJsonMarkup, "helpJsonMarkup");
713
694
 
714
695
  // src/utils/modules/replaceTemplateStringSimple.ts
715
696
  function replaceTemplateStringSimple(template, context) {
@@ -726,31 +707,28 @@ function replaceTemplateStringSimple(template, context) {
726
707
  return typeof value === "string" ? value : String(value);
727
708
  });
728
709
  }
729
- __name(replaceTemplateStringSimple, "replaceTemplateStringSimple");
730
710
 
731
711
  // src/utils/modules/handlebars/helpers/indentJson.ts
732
712
  function indentJson(arg1, collapse = "false") {
733
713
  if (typeof arg1 !== "object") {
734
714
  return replaceTemplateStringSimple(arg1 || "", this);
735
715
  }
736
- const replaced = maybeParseJSON(replaceTemplateStringSimple(maybeStringifyJSON(arg1), this));
716
+ const replaced = maybeParseJSON(
717
+ replaceTemplateStringSimple(maybeStringifyJSON(arg1), this)
718
+ );
737
719
  if (collapse == "true") {
738
720
  return JSON.stringify(replaced);
739
721
  }
740
722
  return JSON.stringify(replaced, null, 2);
741
723
  }
742
- __name(indentJson, "indentJson");
743
724
 
744
725
  // src/utils/modules/schemaExampleWith.ts
745
726
  function schemaExampleWith(schema, property) {
746
727
  if (schema.type === "array") {
747
- return filterObjectOnSchema(schema, [
748
- {}
749
- ], void 0, property);
728
+ return filterObjectOnSchema(schema, [{}], void 0, property);
750
729
  }
751
730
  return filterObjectOnSchema(schema, {}, void 0, property);
752
731
  }
753
- __name(schemaExampleWith, "schemaExampleWith");
754
732
 
755
733
  // src/utils/modules/handlebars/helpers/jsonSchemaExample.ts
756
734
  function jsonSchemaExample(key, prop, collapse) {
@@ -760,7 +738,9 @@ function jsonSchemaExample(key, prop, collapse) {
760
738
  if (typeof result !== "object") {
761
739
  return "";
762
740
  }
763
- const replaced = maybeParseJSON(replaceTemplateStringSimple(maybeStringifyJSON(result), this));
741
+ const replaced = maybeParseJSON(
742
+ replaceTemplateStringSimple(maybeStringifyJSON(result), this)
743
+ );
764
744
  if (collapse == "true") {
765
745
  return JSON.stringify(replaced);
766
746
  }
@@ -768,41 +748,35 @@ function jsonSchemaExample(key, prop, collapse) {
768
748
  }
769
749
  return "";
770
750
  }
771
- __name(jsonSchemaExample, "jsonSchemaExample");
772
751
 
773
752
  // src/utils/modules/handlebars/helpers/getKeyOr.ts
774
753
  function getKeyOr(key, arg2) {
775
754
  const res = get(this, key);
776
755
  return typeof res !== "undefined" && res !== "" ? res : arg2;
777
756
  }
778
- __name(getKeyOr, "getKeyOr");
779
757
 
780
758
  // src/utils/modules/handlebars/helpers/getOr.ts
781
759
  function getOr(arg1, arg2) {
782
760
  return typeof arg1 !== "undefined" && arg1 !== "" ? arg1 : arg2;
783
761
  }
784
- __name(getOr, "getOr");
785
762
 
786
763
  // src/utils/modules/handlebars/helpers/pluralize.ts
787
764
  function pluralize(arg1, arg2) {
788
765
  const [singular, plural] = arg1.split("|");
789
766
  return arg2 > 1 ? plural : singular;
790
767
  }
791
- __name(pluralize, "pluralize");
792
768
 
793
769
  // src/utils/modules/handlebars/helpers/eq.ts
794
770
  function eq(arg1 = "", arg2 = "", options) {
795
771
  const isArr = arg2.toString().split(",").map((a) => a.trim());
796
772
  return isArr.includes(arg1) ? options.fn(this) : options.inverse(this);
797
773
  }
798
- __name(eq, "eq");
799
774
 
800
775
  // src/utils/modules/handlebars/helpers/neq.ts
801
776
  function neq(arg1 = "", arg2 = "", options) {
802
777
  const isArr = arg2.toString().split(",").map((a) => a.trim());
803
778
  return !isArr.includes(arg1) ? options.fn(this) : options.inverse(this);
804
779
  }
805
- __name(neq, "neq");
806
780
 
807
781
  // src/utils/modules/handlebars/helpers/ifCond.ts
808
782
  function ifCond(v1, operator, v2, options) {
@@ -831,13 +805,11 @@ function ifCond(v1, operator, v2, options) {
831
805
  return options.inverse(this);
832
806
  }
833
807
  }
834
- __name(ifCond, "ifCond");
835
808
 
836
809
  // src/utils/modules/handlebars/helpers/objectToList.ts
837
810
  function objectToList(arg = {}) {
838
811
  return Object.keys(arg).map((key) => `- ${key}: ${arg[key]}`).join("\n");
839
812
  }
840
- __name(objectToList, "objectToList");
841
813
 
842
814
  // src/utils/modules/handlebars/helpers/join.ts
843
815
  function join(array) {
@@ -845,13 +817,11 @@ function join(array) {
845
817
  if (!Array.isArray(array)) return "";
846
818
  return array.join(", ");
847
819
  }
848
- __name(join, "join");
849
820
 
850
821
  // src/utils/modules/handlebars/helpers/cut.ts
851
822
  function cutFn(str, arg) {
852
823
  return str.toString().replace(new RegExp(arg, "g"), "");
853
824
  }
854
- __name(cutFn, "cutFn");
855
825
 
856
826
  // src/utils/modules/handlebars/helpers/substring.ts
857
827
  function substringFn(str, start, end) {
@@ -864,47 +834,42 @@ function substringFn(str, start, end) {
864
834
  return str;
865
835
  }
866
836
  }
867
- __name(substringFn, "substringFn");
868
837
 
869
838
  // src/utils/modules/handlebars/helpers/with.ts
870
839
  function withFn(options, context) {
871
840
  return options.fn(context);
872
841
  }
873
- __name(withFn, "withFn");
874
842
 
875
843
  // src/utils/modules/handlebars/utils/makeHandlebarsInstance.ts
876
844
  function makeHandlebarsInstance(hbs2) {
877
845
  const handlebars = hbs2.create();
878
846
  const helperKeys = Object.keys(helpers_exports);
879
- _registerHelpers(helperKeys.map((a) => ({
880
- handler: helpers_exports[a],
881
- name: a
882
- })), handlebars);
883
- handlebars.registerHelper("hbsInTemplate", function(str, substitutions) {
884
- const template = handlebars.compile(str);
885
- return template(substitutions, {
886
- allowedProtoMethods: {
887
- substring: true
888
- }
889
- });
890
- });
891
- const helperPath = getEnvironmentVariable("CUSTOM_PROMPT_TEMPLATE_HELPERS_PATH");
892
- if (helperPath) {
893
- const externalHelpers = __require(helperPath);
894
- _registerHelpers(importHelpers(externalHelpers), handlebars);
895
- }
896
- const contextPartialKeys = Object.keys(partials);
847
+ _registerHelpers(
848
+ helperKeys.map((a) => ({ handler: helpers_exports[a], name: a })),
849
+ handlebars
850
+ );
851
+ handlebars.registerHelper(
852
+ "hbsInTemplate",
853
+ function(str, substitutions) {
854
+ const template = handlebars.compile(str);
855
+ return template(substitutions, {
856
+ allowedProtoMethods: {
857
+ substring: true
858
+ }
859
+ });
860
+ }
861
+ );
862
+ const contextPartialKeys = Object.keys(
863
+ partials
864
+ );
897
865
  for (const contextPartialKey of contextPartialKeys) {
898
- handlebars.registerPartial(contextPartialKey, partials[contextPartialKey]);
899
- }
900
- const partialsPath = getEnvironmentVariable("CUSTOM_PROMPT_TEMPLATE_PARTIALS_PATH");
901
- if (typeof process === "object" && partialsPath) {
902
- const externalPartials = __require(partialsPath);
903
- _registerPartials(importPartials(externalPartials), handlebars);
866
+ handlebars.registerPartial(
867
+ contextPartialKey,
868
+ partials[contextPartialKey]
869
+ );
904
870
  }
905
871
  return handlebars;
906
872
  }
907
- __name(makeHandlebarsInstance, "makeHandlebarsInstance");
908
873
 
909
874
  // src/utils/modules/isPromise.ts
910
875
  function isPromise(value) {
@@ -913,24 +878,16 @@ function isPromise(value) {
913
878
  }
914
879
  return Object.prototype.toString.call(value) === "[object AsyncFunction]";
915
880
  }
916
- __name(isPromise, "isPromise");
917
881
 
918
882
  // src/utils/modules/handlebars/utils/appendContextPath.ts
919
883
  function appendContextPath(contextPath, id) {
920
884
  return (contextPath ? `${contextPath}.` : "") + id;
921
885
  }
922
- __name(appendContextPath, "appendContextPath");
923
886
 
924
887
  // src/utils/modules/handlebars/utils/blockParams.ts
925
888
  function blockParams(params, ids) {
926
- return {
927
- ...params,
928
- ...{
929
- path: ids
930
- }
931
- };
889
+ return { ...params, ...{ path: ids } };
932
890
  }
933
- __name(blockParams, "blockParams");
934
891
 
935
892
  // src/utils/modules/extend.ts
936
893
  function extend(obj, _source) {
@@ -943,7 +900,6 @@ function extend(obj, _source) {
943
900
  }
944
901
  return obj;
945
902
  }
946
- __name(extend, "extend");
947
903
 
948
904
  // src/utils/modules/handlebars/utils/createFrame.ts
949
905
  function createFrame(object) {
@@ -951,7 +907,6 @@ function createFrame(object) {
951
907
  frame._parent = object;
952
908
  return frame;
953
909
  }
954
- __name(createFrame, "createFrame");
955
910
 
956
911
  // src/utils/modules/isEmpty.ts
957
912
  function isEmpty(value) {
@@ -963,7 +918,6 @@ function isEmpty(value) {
963
918
  }
964
919
  return false;
965
920
  }
966
- __name(isEmpty, "isEmpty");
967
921
 
968
922
  // src/utils/modules/handlebars/helpers/async/with.ts
969
923
  async function withFnAsync(context, options) {
@@ -980,20 +934,18 @@ async function withFnAsync(context, options) {
980
934
  let { data } = options;
981
935
  if (options.data && options.ids) {
982
936
  data = createFrame(options.data);
983
- data.contextPath = appendContextPath(options.data.contextPath, options.ids[0]);
937
+ data.contextPath = appendContextPath(
938
+ options.data.contextPath,
939
+ options.ids[0]
940
+ );
984
941
  }
985
942
  return fn(context, {
986
943
  data,
987
- blockParams: blockParams([
988
- context
989
- ], [
990
- data && data.contextPath
991
- ])
944
+ blockParams: blockParams([context], [data && data.contextPath])
992
945
  });
993
946
  }
994
947
  return options.inverse(this);
995
948
  }
996
- __name(withFnAsync, "withFnAsync");
997
949
 
998
950
  // src/utils/modules/handlebars/helpers/async/if.ts
999
951
  async function ifFnAsync(conditional, options) {
@@ -1011,13 +963,11 @@ async function ifFnAsync(conditional, options) {
1011
963
  return options.fn(this);
1012
964
  }
1013
965
  }
1014
- __name(ifFnAsync, "ifFnAsync");
1015
966
 
1016
967
  // src/utils/modules/isReadableStream.ts
1017
968
  function isReadableStream(obj) {
1018
969
  return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj._read === "function";
1019
970
  }
1020
- __name(isReadableStream, "isReadableStream");
1021
971
 
1022
972
  // src/utils/modules/handlebars/helpers/async/each.ts
1023
973
  async function eachFnAsync(arg1, options) {
@@ -1031,7 +981,10 @@ async function eachFnAsync(arg1, options) {
1031
981
  let ret = [];
1032
982
  let contextPath = "";
1033
983
  if (options.data && options.ids) {
1034
- contextPath = `${appendContextPath(options.data.contextPath, options.ids[0])}.`;
984
+ contextPath = `${appendContextPath(
985
+ options.data.contextPath,
986
+ options.ids[0]
987
+ )}.`;
1035
988
  }
1036
989
  if (typeof arg1 === "function") {
1037
990
  arg1 = arg1.call(this);
@@ -1049,18 +1002,16 @@ async function eachFnAsync(arg1, options) {
1049
1002
  data.contextPath = contextPath + field;
1050
1003
  }
1051
1004
  }
1052
- ret.push(await fn(arg1[field], {
1053
- data,
1054
- blockParams: blockParams([
1055
- arg1[field],
1056
- field
1057
- ], [
1058
- contextPath + field,
1059
- null
1060
- ])
1061
- }));
1005
+ ret.push(
1006
+ await fn(arg1[field], {
1007
+ data,
1008
+ blockParams: blockParams(
1009
+ [arg1[field], field],
1010
+ [contextPath + field, null]
1011
+ )
1012
+ })
1013
+ );
1062
1014
  }
1063
- __name(execIteration, "execIteration");
1064
1015
  if (isPromise(arg1)) {
1065
1016
  arg1 = await arg1;
1066
1017
  }
@@ -1109,13 +1060,10 @@ async function eachFnAsync(arg1, options) {
1109
1060
  }
1110
1061
  if (i === 0) {
1111
1062
  ret = inverse(this);
1112
- ret = [
1113
- inverse(this)
1114
- ];
1063
+ ret = [inverse(this)];
1115
1064
  }
1116
1065
  return ret.join("");
1117
1066
  }
1118
- __name(eachFnAsync, "eachFnAsync");
1119
1067
 
1120
1068
  // src/utils/modules/handlebars/helpers/async/unless.ts
1121
1069
  async function unlessFnAsync(conditional, options) {
@@ -1128,7 +1076,6 @@ async function unlessFnAsync(conditional, options) {
1128
1076
  hash: options.hash
1129
1077
  });
1130
1078
  }
1131
- __name(unlessFnAsync, "unlessFnAsync");
1132
1079
 
1133
1080
  // src/utils/modules/handlebars/helpers/async/async-helpers.ts
1134
1081
  var asyncCoreOverrideHelpers = {
@@ -1140,9 +1087,8 @@ var asyncCoreOverrideHelpers = {
1140
1087
 
1141
1088
  // src/utils/modules/handlebars/utils/makeHandlebarsInstanceAsync.ts
1142
1089
  function makeHandlebarsInstanceAsync(hbs2) {
1143
- var _a;
1144
1090
  const handlebars = hbs2.create();
1145
- const asyncCompiler = (_a = class extends hbs2.JavaScriptCompiler {
1091
+ const asyncCompiler = class extends hbs2.JavaScriptCompiler {
1146
1092
  constructor() {
1147
1093
  super();
1148
1094
  this.compiler = asyncCompiler;
@@ -1155,30 +1101,20 @@ function makeHandlebarsInstanceAsync(hbs2) {
1155
1101
  }
1156
1102
  appendToBuffer(source, location, explicit) {
1157
1103
  if (!Array.isArray(source)) {
1158
- source = [
1159
- source
1160
- ];
1104
+ source = [source];
1161
1105
  }
1162
1106
  source = this.source.wrap(source, location);
1163
1107
  if (this.environment.isSimple) {
1164
- return [
1165
- "return await ",
1166
- source,
1167
- ";"
1168
- ];
1108
+ return ["return await ", source, ";"];
1169
1109
  }
1170
1110
  if (explicit) {
1171
- return [
1172
- "buffer += await ",
1173
- source,
1174
- ";"
1175
- ];
1111
+ return ["buffer += await ", source, ";"];
1176
1112
  }
1177
1113
  source.appendToBuffer = true;
1178
1114
  source.prepend("await ");
1179
1115
  return source;
1180
1116
  }
1181
- }, __name(_a, "asyncCompiler"), _a);
1117
+ };
1182
1118
  handlebars.JavaScriptCompiler = asyncCompiler;
1183
1119
  const _compile = handlebars.compile;
1184
1120
  const _template = handlebars.VM.template;
@@ -1189,90 +1125,110 @@ function makeHandlebarsInstanceAsync(hbs2) {
1189
1125
  }
1190
1126
  return _escapeExpression(value);
1191
1127
  }
1192
- __name(escapeExpression, "escapeExpression");
1193
1128
  function lookupProperty(containerLookupProperty) {
1194
1129
  return function(parent, propertyName) {
1195
1130
  if (isPromise(parent)) {
1196
1131
  if (typeof parent?.then === "function") {
1197
- return parent.then((p) => containerLookupProperty(p, propertyName));
1132
+ return parent.then(
1133
+ (p) => containerLookupProperty(p, propertyName)
1134
+ );
1198
1135
  }
1199
- return parent().then((p) => containerLookupProperty(p, propertyName));
1136
+ return parent().then(
1137
+ (p) => containerLookupProperty(p, propertyName)
1138
+ );
1200
1139
  }
1201
1140
  return containerLookupProperty(parent, propertyName);
1202
1141
  };
1203
1142
  }
1204
- __name(lookupProperty, "lookupProperty");
1205
1143
  handlebars.template = function(spec) {
1206
1144
  spec.main_d = (_prog, _props, container, _depth, data, blockParams2, depths) => async (context) => {
1207
1145
  container.escapeExpression = escapeExpression;
1208
1146
  container.lookupProperty = lookupProperty(container.lookupProperty);
1209
1147
  if (depths.length == 0) {
1210
- depths = [
1211
- data.root
1212
- ];
1148
+ depths = [data.root];
1213
1149
  }
1214
- const v = spec.main(container, context, container.helpers, container.partials, data, blockParams2, depths);
1150
+ const v = spec.main(
1151
+ container,
1152
+ context,
1153
+ container.helpers,
1154
+ container.partials,
1155
+ data,
1156
+ blockParams2,
1157
+ depths
1158
+ );
1215
1159
  return v;
1216
1160
  };
1217
1161
  return _template(spec, handlebars);
1218
1162
  };
1219
1163
  handlebars.compile = function(template, options) {
1220
- const compiled = _compile.apply(handlebars, [
1221
- template,
1222
- {
1223
- ...options
1224
- }
1225
- ]);
1164
+ const compiled = _compile.apply(handlebars, [template, { ...options }]);
1226
1165
  return function(context, execOptions) {
1227
1166
  context = context || {};
1228
1167
  return compiled.call(handlebars, context, execOptions);
1229
1168
  };
1230
1169
  };
1231
1170
  const helperKeys = Object.keys(helpers_exports);
1232
- _registerHelpers(helperKeys.map((a) => ({
1233
- handler: helpers_exports[a],
1234
- name: a
1235
- })), handlebars);
1236
- const asyncHelperKeys = Object.keys(asyncCoreOverrideHelpers);
1237
- _registerHelpers(asyncHelperKeys.map((a) => ({
1238
- handler: asyncCoreOverrideHelpers[a],
1239
- name: a
1240
- })), handlebars);
1241
- const contextPartialKeys = Object.keys(partials);
1171
+ _registerHelpers(
1172
+ helperKeys.map((a) => ({ handler: helpers_exports[a], name: a })),
1173
+ handlebars
1174
+ );
1175
+ const asyncHelperKeys = Object.keys(
1176
+ asyncCoreOverrideHelpers
1177
+ );
1178
+ _registerHelpers(
1179
+ asyncHelperKeys.map((a) => ({
1180
+ handler: asyncCoreOverrideHelpers[a],
1181
+ name: a
1182
+ })),
1183
+ handlebars
1184
+ );
1185
+ const contextPartialKeys = Object.keys(
1186
+ partials
1187
+ );
1242
1188
  for (const contextPartialKey of contextPartialKeys) {
1243
- handlebars.registerPartial(contextPartialKey, partials[contextPartialKey]);
1244
- }
1245
- const partialsPath = getEnvironmentVariable("CUSTOM_PROMPT_TEMPLATE_PARTIALS_PATH");
1246
- if (typeof process === "object" && partialsPath) {
1247
- const externalPartials = __require(partialsPath);
1248
- _registerPartials(importPartials(externalPartials), handlebars);
1189
+ handlebars.registerPartial(
1190
+ contextPartialKey,
1191
+ partials[contextPartialKey]
1192
+ );
1249
1193
  }
1250
1194
  return handlebars;
1251
1195
  }
1252
- __name(makeHandlebarsInstanceAsync, "makeHandlebarsInstanceAsync");
1253
1196
 
1254
1197
  // src/utils/modules/handlebars/hbs.ts
1255
1198
  var _hbsAsync = makeHandlebarsInstanceAsync(Handlebars);
1256
1199
  var _hbs = makeHandlebarsInstance(Handlebars);
1257
1200
 
1201
+ // src/utils/modules/handlebars/utils/registerPartials.ts
1202
+ function _registerPartials(partials2, instance) {
1203
+ if (partials2 && Array.isArray(partials2)) {
1204
+ for (const partial of partials2) {
1205
+ if (partial.name && typeof partial.name === "string" && typeof partial.template === "string") {
1206
+ if (instance) {
1207
+ instance.registerPartial(partial.name, partial.template);
1208
+ }
1209
+ }
1210
+ }
1211
+ }
1212
+ }
1213
+
1258
1214
  // src/utils/modules/handlebars/index.ts
1259
1215
  var hbs = {
1260
1216
  handlebars: _hbs,
1261
- registerHelpers: /* @__PURE__ */ __name((helpers) => {
1217
+ registerHelpers: (helpers) => {
1262
1218
  _registerHelpers(helpers, _hbs);
1263
- }, "registerHelpers"),
1264
- registerPartials: /* @__PURE__ */ __name((partials2) => {
1219
+ },
1220
+ registerPartials: (partials2) => {
1265
1221
  _registerPartials(partials2, _hbs);
1266
- }, "registerPartials")
1222
+ }
1267
1223
  };
1268
1224
  var hbsAsync = {
1269
1225
  handlebars: _hbsAsync,
1270
- registerHelpers: /* @__PURE__ */ __name((helpers) => {
1226
+ registerHelpers: (helpers) => {
1271
1227
  _registerHelpers(helpers, _hbsAsync);
1272
- }, "registerHelpers"),
1273
- registerPartials: /* @__PURE__ */ __name((partials2) => {
1228
+ },
1229
+ registerPartials: (partials2) => {
1274
1230
  _registerPartials(partials2, _hbsAsync);
1275
- }, "registerPartials")
1231
+ }
1276
1232
  };
1277
1233
 
1278
1234
  // src/utils/modules/replaceTemplateString.ts
@@ -1305,7 +1261,6 @@ function replaceTemplateString(templateString, substitutions = {}, configuration
1305
1261
  });
1306
1262
  return res;
1307
1263
  }
1308
- __name(replaceTemplateString, "replaceTemplateString");
1309
1264
 
1310
1265
  // src/utils/modules/replaceTemplateStringAsync.ts
1311
1266
  async function replaceTemplateStringAsync(templateString, substitutions = {}, configuration = {
@@ -1337,24 +1292,22 @@ async function replaceTemplateStringAsync(templateString, substitutions = {}, co
1337
1292
  });
1338
1293
  return res;
1339
1294
  }
1340
- __name(replaceTemplateStringAsync, "replaceTemplateStringAsync");
1341
1295
 
1342
1296
  // src/utils/modules/asyncCallWithTimeout.ts
1343
- var asyncCallWithTimeout = /* @__PURE__ */ __name(async (asyncPromise, timeLimit = 1e4) => {
1297
+ var asyncCallWithTimeout = async (asyncPromise, timeLimit = 1e4) => {
1344
1298
  let timeoutHandle;
1345
1299
  const timeoutPromise = new Promise((_resolve, reject) => {
1346
1300
  timeoutHandle = setTimeout(() => {
1347
- return reject(new Error("Unable to perform action. Try again, or use another action."));
1301
+ return reject(
1302
+ new Error("Unable to perform action. Try again, or use another action.")
1303
+ );
1348
1304
  }, timeLimit);
1349
1305
  });
1350
- return Promise.race([
1351
- asyncPromise,
1352
- timeoutPromise
1353
- ]).then((result) => {
1306
+ return Promise.race([asyncPromise, timeoutPromise]).then((result) => {
1354
1307
  clearTimeout(timeoutHandle);
1355
1308
  return result;
1356
1309
  });
1357
- }, "asyncCallWithTimeout");
1310
+ };
1358
1311
 
1359
1312
  // src/utils/modules/guessProviderFromModel.ts
1360
1313
  function isModelKnownOpenAi(payload) {
@@ -1370,7 +1323,6 @@ function isModelKnownOpenAi(payload) {
1370
1323
  }
1371
1324
  return false;
1372
1325
  }
1373
- __name(isModelKnownOpenAi, "isModelKnownOpenAi");
1374
1326
  function isModelKnownAnthropic(payload) {
1375
1327
  const model = payload.model.toLowerCase();
1376
1328
  if (model.startsWith("claude-")) {
@@ -1378,7 +1330,6 @@ function isModelKnownAnthropic(payload) {
1378
1330
  }
1379
1331
  return false;
1380
1332
  }
1381
- __name(isModelKnownAnthropic, "isModelKnownAnthropic");
1382
1333
  function isModelKnownXai(payload) {
1383
1334
  const model = payload.model.toLowerCase();
1384
1335
  if (model.startsWith("grok-")) {
@@ -1386,7 +1337,6 @@ function isModelKnownXai(payload) {
1386
1337
  }
1387
1338
  return false;
1388
1339
  }
1389
- __name(isModelKnownXai, "isModelKnownXai");
1390
1340
  function isModelKnownBedrockAnthropic(payload) {
1391
1341
  const model = payload.model.toLowerCase();
1392
1342
  if (model.startsWith("anthropic.claude-")) {
@@ -1394,7 +1344,6 @@ function isModelKnownBedrockAnthropic(payload) {
1394
1344
  }
1395
1345
  return false;
1396
1346
  }
1397
- __name(isModelKnownBedrockAnthropic, "isModelKnownBedrockAnthropic");
1398
1347
  function guessProviderFromModel(payload) {
1399
1348
  switch (true) {
1400
1349
  case isModelKnownOpenAi(payload):
@@ -1409,99 +1358,16 @@ function guessProviderFromModel(payload) {
1409
1358
  throw new Error("Unsupported model");
1410
1359
  }
1411
1360
  }
1412
- __name(guessProviderFromModel, "guessProviderFromModel");
1413
1361
 
1414
1362
  // src/utils/modules/index.ts
1415
1363
  function registerHelpers(helpers) {
1416
1364
  hbs.registerHelpers(helpers);
1417
1365
  hbsAsync.registerHelpers(helpers);
1418
1366
  }
1419
- __name(registerHelpers, "registerHelpers");
1420
1367
  function registerPartials(partials2) {
1421
1368
  hbs.registerPartials(partials2);
1422
1369
  hbsAsync.registerPartials(partials2);
1423
1370
  }
1424
- __name(registerPartials, "registerPartials");
1425
-
1426
- // src/llm/output/_utils/getResultText.ts
1427
- function getResultText(content) {
1428
- if (content.length === 1 && content.every((a) => a.type === "text")) {
1429
- return content[0]?.text || "";
1430
- }
1431
- return "";
1432
- }
1433
- __name(getResultText, "getResultText");
1434
-
1435
- // src/parser/parsers/OpenAiFunctionParser.ts
1436
- var _OpenAiFunctionParser = class _OpenAiFunctionParser extends BaseParser {
1437
- constructor(options) {
1438
- super("openAiFunction", options, "function_call");
1439
- __publicField(this, "parser");
1440
- this.parser = options.parser;
1441
- }
1442
- parse(text, _options) {
1443
- const functionUse = text?.find((a) => a.type === "function_use");
1444
- if (functionUse && "name" in functionUse && "input" in functionUse) {
1445
- return {
1446
- name: functionUse.name,
1447
- arguments: maybeParseJSON(functionUse.input)
1448
- };
1449
- }
1450
- return this.parser.parse(getResultText(text));
1451
- }
1452
- };
1453
- __name(_OpenAiFunctionParser, "OpenAiFunctionParser");
1454
- var OpenAiFunctionParser = _OpenAiFunctionParser;
1455
-
1456
- // src/parser/parsers/StringParser.ts
1457
- var _StringParser = class _StringParser extends BaseParser {
1458
- constructor(options) {
1459
- super("string", options);
1460
- }
1461
- parse(text, _options) {
1462
- assert(typeof text === "string", `Invalid input. Expected string. Received ${typeof text}.`);
1463
- const parsed = text.toString();
1464
- return parsed;
1465
- }
1466
- };
1467
- __name(_StringParser, "StringParser");
1468
- var StringParser = _StringParser;
1469
-
1470
- // src/parser/parsers/BooleanParser.ts
1471
- var _BooleanParser = class _BooleanParser extends BaseParser {
1472
- constructor(options) {
1473
- super("boolean", options);
1474
- }
1475
- parse(text) {
1476
- assert(typeof text === "string", `Invalid input. Expected string. Received ${typeof text}.`);
1477
- const clean = text.toLowerCase().trim();
1478
- if (clean === "true") {
1479
- return true;
1480
- }
1481
- return false;
1482
- }
1483
- };
1484
- __name(_BooleanParser, "BooleanParser");
1485
- var BooleanParser = _BooleanParser;
1486
-
1487
- // src/utils/modules/isFinite.ts
1488
- function isFinite(value) {
1489
- return typeof value === "number" && Number.isFinite(value);
1490
- }
1491
- __name(isFinite, "isFinite");
1492
-
1493
- // src/parser/parsers/NumberParser.ts
1494
- var _NumberParser = class _NumberParser extends BaseParser {
1495
- constructor(options) {
1496
- super("number", options);
1497
- }
1498
- parse(text) {
1499
- const match = text.match(/\d/g);
1500
- return match && isFinite(toNumber(match[0])) ? toNumber(match[0]) : -1;
1501
- }
1502
- };
1503
- __name(_NumberParser, "NumberParser");
1504
- var NumberParser = _NumberParser;
1505
1371
 
1506
1372
  // src/parser/_utils.ts
1507
1373
  import { validate as validateSchema } from "jsonschema";
@@ -1511,7 +1377,6 @@ function enforceParserSchema(schema, parsed) {
1511
1377
  }
1512
1378
  return filterObjectOnSchema(schema, parsed);
1513
1379
  }
1514
- __name(enforceParserSchema, "enforceParserSchema");
1515
1380
  function validateParserSchema(schema, parsed) {
1516
1381
  if (!schema || !parsed || typeof parsed !== "object") {
1517
1382
  return null;
@@ -1522,10 +1387,9 @@ function validateParserSchema(schema, parsed) {
1522
1387
  }
1523
1388
  return null;
1524
1389
  }
1525
- __name(validateParserSchema, "validateParserSchema");
1526
1390
 
1527
1391
  // src/utils/modules/errors.ts
1528
- var _LlmExeError = class _LlmExeError extends Error {
1392
+ var LlmExeError = class extends Error {
1529
1393
  constructor(message, code, context) {
1530
1394
  super(message ?? "");
1531
1395
  __publicField(this, "code");
@@ -1538,11 +1402,9 @@ var _LlmExeError = class _LlmExeError extends Error {
1538
1402
  }
1539
1403
  }
1540
1404
  };
1541
- __name(_LlmExeError, "LlmExeError");
1542
- var LlmExeError = _LlmExeError;
1543
1405
 
1544
1406
  // src/parser/parsers/JsonParser.ts
1545
- var _JsonParser = class _JsonParser extends BaseParserWithJson {
1407
+ var JsonParser = class extends BaseParserWithJson {
1546
1408
  constructor(options = {}) {
1547
1409
  super("json", options);
1548
1410
  }
@@ -1565,8 +1427,6 @@ var _JsonParser = class _JsonParser extends BaseParserWithJson {
1565
1427
  return parsed;
1566
1428
  }
1567
1429
  };
1568
- __name(_JsonParser, "JsonParser");
1569
- var JsonParser = _JsonParser;
1570
1430
 
1571
1431
  // src/utils/modules/camelCase.ts
1572
1432
  function camelCase(input) {
@@ -1581,10 +1441,9 @@ function camelCase(input) {
1581
1441
  }
1582
1442
  }).join("");
1583
1443
  }
1584
- __name(camelCase, "camelCase");
1585
1444
 
1586
1445
  // src/parser/parsers/ListToJsonParser.ts
1587
- var _ListToJsonParser = class _ListToJsonParser extends BaseParserWithJson {
1446
+ var ListToJsonParser = class extends BaseParserWithJson {
1588
1447
  constructor(options = {}) {
1589
1448
  super("listToJson", options);
1590
1449
  }
@@ -1614,76 +1473,65 @@ var _ListToJsonParser = class _ListToJsonParser extends BaseParserWithJson {
1614
1473
  return output;
1615
1474
  }
1616
1475
  };
1617
- __name(_ListToJsonParser, "ListToJsonParser");
1618
- var ListToJsonParser = _ListToJsonParser;
1619
1476
 
1620
1477
  // src/parser/parsers/ListToKeyValueParser.ts
1621
- var _ListToKeyValueParser = class _ListToKeyValueParser extends BaseParser {
1478
+ var ListToKeyValueParser = class extends BaseParser {
1622
1479
  constructor(options) {
1623
1480
  super("listToKeyValue", options);
1624
1481
  }
1625
1482
  parse(text) {
1626
- const lines = text.split("\n").map((s) => s.replace("- ", "").replace(/\'/g, "'"));
1483
+ const lines = text.split("\n").map((s) => s.replace("- ", "").replace(/'/g, "'"));
1627
1484
  let res = [];
1628
1485
  for (const line of lines) {
1629
1486
  const [key, value] = line.split(":");
1630
1487
  if (key && value) {
1631
- res.push({
1632
- key: key?.trim(),
1633
- value: value?.trim()
1634
- });
1488
+ res.push({ key: key?.trim(), value: value?.trim() });
1635
1489
  }
1636
1490
  }
1637
1491
  return res;
1638
1492
  }
1639
1493
  };
1640
- __name(_ListToKeyValueParser, "ListToKeyValueParser");
1641
- var ListToKeyValueParser = _ListToKeyValueParser;
1642
1494
 
1643
1495
  // src/parser/parsers/CustomParser.ts
1644
- var _CustomParser = class _CustomParser extends BaseParser {
1496
+ var CustomParser = class extends BaseParser {
1645
1497
  /**
1646
- * Creates a new CustomParser instance.
1647
- * @param {string} name The name of the parser.
1648
- * @param {any} parserFn The custom parsing function.
1649
- */
1498
+ * Creates a new CustomParser instance.
1499
+ * @param {string} name The name of the parser.
1500
+ * @param {any} parserFn The custom parsing function.
1501
+ */
1650
1502
  constructor(name, parserFn) {
1651
1503
  super(name);
1652
1504
  /**
1653
- * Custom parsing function.
1654
- * @type {any}
1655
- */
1505
+ * Custom parsing function.
1506
+ * @type {any}
1507
+ */
1656
1508
  __publicField(this, "parserFn");
1657
1509
  this.parserFn = parserFn;
1658
1510
  }
1659
1511
  /**
1660
- * Parses the text using the custom parsing function.
1661
- * @param {string} text The text to be parsed.
1662
- * @param {any} inputValues Additional input values for the parser function.
1663
- * @returns {O} The parsed value.
1664
- */
1512
+ * Parses the text using the custom parsing function.
1513
+ * @param {string} text The text to be parsed.
1514
+ * @param {any} inputValues Additional input values for the parser function.
1515
+ * @returns {O} The parsed value.
1516
+ */
1665
1517
  parse(text, inputValues) {
1666
1518
  return this.parserFn.call(this, text, inputValues);
1667
1519
  }
1668
1520
  };
1669
- __name(_CustomParser, "CustomParser");
1670
- var CustomParser = _CustomParser;
1671
1521
 
1672
1522
  // src/parser/parsers/ListToArrayParser.ts
1673
- var _ListToArrayParser = class _ListToArrayParser extends BaseParser {
1523
+ var ListToArrayParser = class extends BaseParser {
1674
1524
  constructor() {
1675
1525
  super("listToArray");
1676
1526
  }
1677
1527
  parse(text) {
1678
- const lines = text.split("\n").map((s) => s.replace(/^- /, "").replace(/\'/g, "'").trim());
1528
+ const lines = text.split("\n").map((s) => s.replace(/^- /, "").replace(/'/g, "'").trim());
1679
1529
  return lines;
1680
1530
  }
1681
1531
  };
1682
- __name(_ListToArrayParser, "ListToArrayParser");
1683
- var ListToArrayParser = _ListToArrayParser;
1684
1532
 
1685
1533
  // src/parser/parsers/ReplaceStringTemplateParser.ts
1686
- var _ReplaceStringTemplateParser = class _ReplaceStringTemplateParser extends BaseParser {
1534
+ var ReplaceStringTemplateParser = class extends BaseParser {
1687
1535
  constructor(options) {
1688
1536
  super("replaceStringTemplate", options);
1689
1537
  }
@@ -1691,17 +1539,38 @@ var _ReplaceStringTemplateParser = class _ReplaceStringTemplateParser extends Ba
1691
1539
  return replaceTemplateString(text, attributes);
1692
1540
  }
1693
1541
  };
1694
- __name(_ReplaceStringTemplateParser, "ReplaceStringTemplateParser");
1695
- var ReplaceStringTemplateParser = _ReplaceStringTemplateParser;
1542
+
1543
+ // src/parser/singleKeyObjectToString.ts
1544
+ function singleKeyObjectToString(input) {
1545
+ try {
1546
+ const parsed = JSON.parse(input);
1547
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
1548
+ const keys = Object.keys(parsed);
1549
+ if (keys.length === 1) {
1550
+ const value = parsed[keys[0]];
1551
+ if (typeof value === "string") {
1552
+ return value;
1553
+ } else {
1554
+ return input;
1555
+ }
1556
+ }
1557
+ }
1558
+ } catch {
1559
+ }
1560
+ return input;
1561
+ }
1696
1562
 
1697
1563
  // src/parser/parsers/MarkdownCodeBlocks.ts
1698
- var _MarkdownCodeBlocksParser = class _MarkdownCodeBlocksParser extends BaseParser {
1564
+ var MarkdownCodeBlocksParser = class extends BaseParser {
1699
1565
  constructor(options) {
1700
1566
  super("markdownCodeBlocks", options);
1701
1567
  }
1702
1568
  parse(input) {
1703
1569
  const out = [];
1704
- const regex = input.matchAll(new RegExp(/`{3}([\w]*)\n([\S\s]+?)\n`{3}/, "g"));
1570
+ if (isObjectStringified(input)) {
1571
+ input = singleKeyObjectToString(input);
1572
+ }
1573
+ const regex = input.matchAll(new RegExp(/```(\w*)\n([\s\S]*?)```/, "g"));
1705
1574
  for (const iterator of regex) {
1706
1575
  if (iterator) {
1707
1576
  const [_input, language, code] = iterator;
@@ -1714,24 +1583,26 @@ var _MarkdownCodeBlocksParser = class _MarkdownCodeBlocksParser extends BasePars
1714
1583
  return out;
1715
1584
  }
1716
1585
  };
1717
- __name(_MarkdownCodeBlocksParser, "MarkdownCodeBlocksParser");
1718
- var MarkdownCodeBlocksParser = _MarkdownCodeBlocksParser;
1719
1586
 
1720
1587
  // src/parser/parsers/MarkdownCodeBlock.ts
1721
- var _MarkdownCodeBlockParser = class _MarkdownCodeBlockParser extends BaseParser {
1588
+ var MarkdownCodeBlockParser = class extends BaseParser {
1722
1589
  constructor(options) {
1723
1590
  super("markdownCodeBlock", options);
1724
1591
  }
1725
1592
  parse(input) {
1726
1593
  const [block] = new MarkdownCodeBlocksParser().parse(input);
1594
+ if (!block) {
1595
+ return {
1596
+ code: "",
1597
+ language: ""
1598
+ };
1599
+ }
1727
1600
  return block;
1728
1601
  }
1729
1602
  };
1730
- __name(_MarkdownCodeBlockParser, "MarkdownCodeBlockParser");
1731
- var MarkdownCodeBlockParser = _MarkdownCodeBlockParser;
1732
1603
 
1733
1604
  // src/parser/parsers/StringExtractParser.ts
1734
- var _StringExtractParser = class _StringExtractParser extends BaseParser {
1605
+ var StringExtractParser = class extends BaseParser {
1735
1606
  constructor(options) {
1736
1607
  super("stringExtract", options);
1737
1608
  __publicField(this, "enum", []);
@@ -1744,7 +1615,10 @@ var _StringExtractParser = class _StringExtractParser extends BaseParser {
1744
1615
  }
1745
1616
  }
1746
1617
  parse(text) {
1747
- assert(typeof text === "string", `Invalid input. Expected string. Received ${typeof text}.`);
1618
+ assert(
1619
+ typeof text === "string",
1620
+ `Invalid input. Expected string. Received ${typeof text}.`
1621
+ );
1748
1622
  for (const option of this.enum) {
1749
1623
  const regex = this.ignoreCase ? new RegExp(option.toLowerCase(), "i") : new RegExp(option);
1750
1624
  if (regex.test(text)) {
@@ -1754,8 +1628,6 @@ var _StringExtractParser = class _StringExtractParser extends BaseParser {
1754
1628
  return "";
1755
1629
  }
1756
1630
  };
1757
- __name(_StringExtractParser, "StringExtractParser");
1758
- var StringExtractParser = _StringExtractParser;
1759
1631
 
1760
1632
  // src/parser/_functions.ts
1761
1633
  function createParser(type, options = {}) {
@@ -1785,16 +1657,46 @@ function createParser(type, options = {}) {
1785
1657
  return new StringParser();
1786
1658
  }
1787
1659
  }
1788
- __name(createParser, "createParser");
1789
1660
  function createCustomParser(name, parserFn) {
1790
1661
  return new CustomParser(name, parserFn);
1791
1662
  }
1792
- __name(createCustomParser, "createCustomParser");
1663
+
1664
+ // src/llm/output/_utils/getResultText.ts
1665
+ function getResultText(content) {
1666
+ if (content.length === 1 && content.every((a) => a.type === "text")) {
1667
+ return content[0]?.text || "";
1668
+ }
1669
+ return "";
1670
+ }
1671
+
1672
+ // src/parser/parsers/LlmNativeFunctionParser.ts
1673
+ var LlmNativeFunctionParser = class extends BaseParser {
1674
+ constructor(options) {
1675
+ super("openAiFunction", options, "function_call");
1676
+ __publicField(this, "parser");
1677
+ this.parser = options.parser;
1678
+ }
1679
+ parse(text, _options) {
1680
+ const functionUse = text?.find((a) => a.type === "function_use");
1681
+ if (functionUse && "name" in functionUse && "input" in functionUse) {
1682
+ return {
1683
+ name: functionUse.name,
1684
+ arguments: maybeParseJSON(functionUse.input)
1685
+ };
1686
+ }
1687
+ return this.parser.parse(getResultText(text));
1688
+ }
1689
+ };
1690
+ var OpenAiFunctionParser = LlmNativeFunctionParser;
1793
1691
 
1794
1692
  // src/executor/llm.ts
1795
- var _LlmExecutor = class _LlmExecutor extends BaseExecutor {
1693
+ var LlmExecutor = class extends BaseExecutor {
1796
1694
  constructor(llmConfiguration, options) {
1797
- super(llmConfiguration.name || "anonymous-llm-executor", "llm-executor", options);
1695
+ super(
1696
+ llmConfiguration.name || "anonymous-llm-executor",
1697
+ "llm-executor",
1698
+ options
1699
+ );
1798
1700
  __publicField(this, "llm");
1799
1701
  __publicField(this, "prompt");
1800
1702
  __publicField(this, "promptFn");
@@ -1810,12 +1712,13 @@ var _LlmExecutor = class _LlmExecutor extends BaseExecutor {
1810
1712
  }
1811
1713
  }
1812
1714
  async execute(_input, _options) {
1715
+ const input = _input ?? {};
1813
1716
  if (this?.parser instanceof JsonParser && this.parser.schema) {
1814
1717
  _options = Object.assign(_options || {}, {
1815
1718
  jsonSchema: this.parser.schema
1816
1719
  });
1817
1720
  }
1818
- return super.execute(_input, _options);
1721
+ return super.execute(input, _options);
1819
1722
  }
1820
1723
  async handler(_input, ..._args) {
1821
1724
  const call = await this.llm.call(_input, ..._args);
@@ -1860,57 +1763,53 @@ var _LlmExecutor = class _LlmExecutor extends BaseExecutor {
1860
1763
  return this.llm.getTraceId();
1861
1764
  }
1862
1765
  };
1863
- __name(_LlmExecutor, "LlmExecutor");
1864
- var LlmExecutor = _LlmExecutor;
1865
-
1866
- // src/executor/_functions.ts
1867
- function createCoreExecutor(handler, options) {
1868
- return new CoreExecutor({
1869
- handler
1870
- }, options);
1871
- }
1872
- __name(createCoreExecutor, "createCoreExecutor");
1873
- function createLlmExecutor(llmConfiguration, options) {
1874
- return new LlmExecutor(llmConfiguration, options);
1875
- }
1876
- __name(createLlmExecutor, "createLlmExecutor");
1877
1766
 
1878
1767
  // src/executor/llm-openai-function.ts
1879
- var _LlmExecutorOpenAiFunctions = class _LlmExecutorOpenAiFunctions extends LlmExecutor {
1768
+ var LlmExecutorWithFunctions = class extends LlmExecutor {
1880
1769
  constructor(llmConfiguration, options) {
1881
- super(Object.assign({}, llmConfiguration, {
1882
- parser: new OpenAiFunctionParser({
1883
- parser: llmConfiguration.parser || new StringParser()
1884
- })
1885
- }), options);
1770
+ super(
1771
+ Object.assign({}, llmConfiguration, {
1772
+ parser: new LlmNativeFunctionParser({
1773
+ parser: llmConfiguration.parser || new StringParser()
1774
+ })
1775
+ }),
1776
+ options
1777
+ );
1886
1778
  }
1887
1779
  async execute(_input, _options) {
1888
1780
  return super.execute(_input, _options);
1889
1781
  }
1890
1782
  };
1891
- __name(_LlmExecutorOpenAiFunctions, "LlmExecutorOpenAiFunctions");
1892
- var LlmExecutorOpenAiFunctions = _LlmExecutorOpenAiFunctions;
1783
+ var LlmExecutorOpenAiFunctions = class extends LlmExecutorWithFunctions {
1784
+ };
1785
+
1786
+ // src/executor/_functions.ts
1787
+ function createCoreExecutor(handler, options) {
1788
+ return new CoreExecutor({ handler }, options);
1789
+ }
1790
+ function createLlmExecutor(llmConfiguration, options) {
1791
+ return new LlmExecutor(llmConfiguration, options);
1792
+ }
1793
+ function createLlmFunctionExecutor(llmConfiguration, options) {
1794
+ return new LlmExecutorWithFunctions(
1795
+ llmConfiguration,
1796
+ options
1797
+ );
1798
+ }
1893
1799
 
1894
1800
  // src/utils/modules/enforceResultAttributes.ts
1895
1801
  function enforceResultAttributes(input) {
1896
1802
  if (!input) {
1897
- return {
1898
- result: input,
1899
- attributes: {}
1900
- };
1803
+ return { result: input, attributes: {} };
1901
1804
  }
1902
1805
  if (typeof input === "object" && (Object.keys(input).length === 2 && "result" in input && "attributes" in input || Object.keys(input).length === 1 && ("result" in input || "attributes" in input))) {
1903
1806
  return input;
1904
1807
  }
1905
- return {
1906
- result: input,
1907
- attributes: {}
1908
- };
1808
+ return { result: input, attributes: {} };
1909
1809
  }
1910
- __name(enforceResultAttributes, "enforceResultAttributes");
1911
1810
 
1912
1811
  // src/plugins/callable/callable.ts
1913
- var _CallableExecutor = class _CallableExecutor {
1812
+ var CallableExecutor = class {
1914
1813
  constructor(options) {
1915
1814
  __publicField(this, "name");
1916
1815
  __publicField(this, "key");
@@ -1945,32 +1844,29 @@ var _CallableExecutor = class _CallableExecutor {
1945
1844
  async validateInput(input) {
1946
1845
  try {
1947
1846
  if (typeof this._validateInput === "function") {
1948
- const response = await this._validateInput(ensureInputIsObject(input), this._handler.getMetadata());
1847
+ const response = await this._validateInput(
1848
+ ensureInputIsObject(input),
1849
+ this._handler.getMetadata()
1850
+ );
1949
1851
  return enforceResultAttributes(response);
1950
1852
  }
1951
- return {
1952
- result: true,
1953
- attributes: {}
1954
- };
1853
+ return { result: true, attributes: {} };
1955
1854
  } catch (error) {
1956
- return {
1957
- result: false,
1958
- attributes: {
1959
- error: error.message
1960
- }
1961
- };
1855
+ return { result: false, attributes: { error: error.message } };
1962
1856
  }
1963
1857
  }
1964
1858
  visibilityHandler(input, attributes) {
1965
1859
  if (typeof this._visibilityHandler === "function") {
1966
- return this._visibilityHandler(input, this._handler.getMetadata(), attributes);
1860
+ return this._visibilityHandler(
1861
+ input,
1862
+ this._handler.getMetadata(),
1863
+ attributes
1864
+ );
1967
1865
  }
1968
1866
  return true;
1969
1867
  }
1970
1868
  };
1971
- __name(_CallableExecutor, "CallableExecutor");
1972
- var CallableExecutor = _CallableExecutor;
1973
- var _UseExecutorsBase = class _UseExecutorsBase {
1869
+ var UseExecutorsBase = class {
1974
1870
  constructor(handlers) {
1975
1871
  __publicField(this, "handlers", []);
1976
1872
  this.handlers = handlers;
@@ -1982,18 +1878,21 @@ var _UseExecutorsBase = class _UseExecutorsBase {
1982
1878
  return this.handlers.find((a) => a.name === name);
1983
1879
  }
1984
1880
  getFunctions() {
1985
- return [
1986
- ...this.handlers
1987
- ];
1881
+ return [...this.handlers];
1988
1882
  }
1989
1883
  getVisibleFunctions(_input, _attributes = {}) {
1990
1884
  const handlers = this.getFunctions();
1991
- return handlers.filter((a) => typeof a.visibilityHandler === "undefined" || typeof a.visibilityHandler === "function" && a.visibilityHandler(_input, _attributes));
1885
+ return handlers.filter(
1886
+ (a) => typeof a.visibilityHandler === "undefined" || typeof a.visibilityHandler === "function" && a.visibilityHandler(_input, _attributes)
1887
+ );
1992
1888
  }
1993
1889
  async callFunction(name, input) {
1994
1890
  try {
1995
1891
  const handler = this.getFunction(name);
1996
- assert(handler, `[invalid handler] The handler (${name}) does not exist.`);
1892
+ assert(
1893
+ handler,
1894
+ `[invalid handler] The handler (${name}) does not exist.`
1895
+ );
1997
1896
  const result = await handler.execute(ensureInputIsObject(input));
1998
1897
  return result;
1999
1898
  } catch (error) {
@@ -2003,41 +1902,37 @@ var _UseExecutorsBase = class _UseExecutorsBase {
2003
1902
  async validateFunctionInput(name, input) {
2004
1903
  try {
2005
1904
  const handler = this.getFunction(name);
2006
- assert(handler, `[invalid handler] The handler (${name}) does not exist.`);
2007
- const result = await handler.validateInput(ensureInputIsObject(input));
1905
+ assert(
1906
+ handler,
1907
+ `[invalid handler] The handler (${name}) does not exist.`
1908
+ );
1909
+ const result = await handler.validateInput(
1910
+ ensureInputIsObject(input)
1911
+ );
2008
1912
  return result;
2009
1913
  } catch (error) {
2010
- return {
2011
- result: false,
2012
- attributes: {
2013
- error: error.message
2014
- }
2015
- };
1914
+ return { result: false, attributes: { error: error.message } };
2016
1915
  }
2017
1916
  }
2018
1917
  };
2019
- __name(_UseExecutorsBase, "UseExecutorsBase");
2020
- var UseExecutorsBase = _UseExecutorsBase;
2021
1918
 
2022
1919
  // src/plugins/callable/index.ts
2023
1920
  function createCallableExecutor(options) {
2024
1921
  return new CallableExecutor(options);
2025
1922
  }
2026
- __name(createCallableExecutor, "createCallableExecutor");
2027
- var _UseExecutors = class _UseExecutors extends UseExecutorsBase {
1923
+ var UseExecutors = class extends UseExecutorsBase {
2028
1924
  constructor(handlers) {
2029
1925
  super(handlers);
2030
1926
  }
2031
1927
  };
2032
- __name(_UseExecutors, "UseExecutors");
2033
- var UseExecutors = _UseExecutors;
2034
1928
  function useExecutors(executors) {
2035
- return new UseExecutors(executors.map((e) => {
2036
- if (e instanceof CallableExecutor) return e;
2037
- return createCallableExecutor(e);
2038
- }));
1929
+ return new UseExecutors(
1930
+ executors.map((e) => {
1931
+ if (e instanceof CallableExecutor) return e;
1932
+ return createCallableExecutor(e);
1933
+ })
1934
+ );
2039
1935
  }
2040
- __name(useExecutors, "useExecutors");
2041
1936
 
2042
1937
  // src/utils/modules/deepClone.ts
2043
1938
  function deepClone(obj) {
@@ -2059,7 +1954,6 @@ function deepClone(obj) {
2059
1954
  }
2060
1955
  return obj;
2061
1956
  }
2062
- __name(deepClone, "deepClone");
2063
1957
 
2064
1958
  // src/llm/_utils.withDefaultModel.ts
2065
1959
  function withDefaultModel(obj1, model) {
@@ -2081,7 +1975,15 @@ function withDefaultModel(obj1, model) {
2081
1975
  }
2082
1976
  return copy;
2083
1977
  }
2084
- __name(withDefaultModel, "withDefaultModel");
1978
+
1979
+ // src/utils/modules/getEnvironmentVariable.ts
1980
+ function getEnvironmentVariable(name) {
1981
+ if (typeof process === "object" && process?.env) {
1982
+ return process.env[name];
1983
+ } else {
1984
+ return void 0;
1985
+ }
1986
+ }
2085
1987
 
2086
1988
  // src/llm/config/openai/index.ts
2087
1989
  var openAiChatV1 = {
@@ -2101,17 +2003,12 @@ var openAiChatV1 = {
2101
2003
  mapBody: {
2102
2004
  prompt: {
2103
2005
  key: "messages",
2104
- sanitize: /* @__PURE__ */ __name((v) => {
2006
+ sanitize: (v) => {
2105
2007
  if (typeof v === "string") {
2106
- return [
2107
- {
2108
- role: "user",
2109
- content: v
2110
- }
2111
- ];
2008
+ return [{ role: "user", content: v }];
2112
2009
  }
2113
2010
  return v;
2114
- }, "sanitize")
2011
+ }
2115
2012
  },
2116
2013
  model: {
2117
2014
  key: "model"
@@ -2121,7 +2018,7 @@ var openAiChatV1 = {
2121
2018
  },
2122
2019
  useJson: {
2123
2020
  key: "response_format.type",
2124
- sanitize: /* @__PURE__ */ __name((v) => v ? "json_object" : "text", "sanitize")
2021
+ sanitize: (v) => v ? "json_object" : "text"
2125
2022
  }
2126
2023
  }
2127
2024
  };
@@ -2151,7 +2048,7 @@ var openAiChatMockV1 = {
2151
2048
  },
2152
2049
  useJson: {
2153
2050
  key: "response_format.type",
2154
- sanitize: /* @__PURE__ */ __name((v) => v ? "json_object" : "text", "sanitize")
2051
+ sanitize: (v) => v ? "json_object" : "text"
2155
2052
  }
2156
2053
  }
2157
2054
  };
@@ -2165,35 +2062,17 @@ var openai = {
2165
2062
  // src/llm/config/anthropic/promptSanitize.ts
2166
2063
  function anthropicPromptSanitize(_messages, _inputBodyObj, _outputObj) {
2167
2064
  if (typeof _messages === "string") {
2168
- return [
2169
- {
2170
- role: "user",
2171
- content: _messages
2172
- }
2173
- ];
2065
+ return [{ role: "user", content: _messages }];
2174
2066
  }
2175
- const [first, ...messages] = [
2176
- ..._messages.map((a) => ({
2177
- ...a
2178
- }))
2179
- ];
2067
+ const [first, ...messages] = [..._messages.map((a) => ({ ...a }))];
2180
2068
  if (first.role === "system" && messages.length === 0) {
2181
- return [
2182
- {
2183
- role: "user",
2184
- content: first.content
2185
- },
2186
- ...messages
2187
- ];
2069
+ return [{ role: "user", content: first.content }, ...messages];
2188
2070
  }
2189
2071
  if (first.role === "system" && messages.length > 0) {
2190
2072
  _outputObj.system = first.content;
2191
2073
  return messages.map((m) => {
2192
2074
  if (m.role === "system") {
2193
- return {
2194
- ...m,
2195
- role: "user"
2196
- };
2075
+ return { ...m, role: "user" };
2197
2076
  }
2198
2077
  return m;
2199
2078
  });
@@ -2202,16 +2081,12 @@ function anthropicPromptSanitize(_messages, _inputBodyObj, _outputObj) {
2202
2081
  first,
2203
2082
  ...messages.map((m) => {
2204
2083
  if (m.role === "system") {
2205
- return {
2206
- ...m,
2207
- role: "user"
2208
- };
2084
+ return { ...m, role: "user" };
2209
2085
  }
2210
2086
  return m;
2211
2087
  })
2212
2088
  ];
2213
2089
  }
2214
- __name(anthropicPromptSanitize, "anthropicPromptSanitize");
2215
2090
 
2216
2091
  // src/llm/config/bedrock/index.ts
2217
2092
  var ANTORPIC_BEDROCK_VERSION = "bedrock-2023-05-31";
@@ -2227,10 +2102,7 @@ var amazonAnthropicChatV1 = {
2227
2102
  maxTokens: {},
2228
2103
  awsRegion: {
2229
2104
  default: getEnvironmentVariable("AWS_REGION"),
2230
- required: [
2231
- true,
2232
- "aws region is required"
2233
- ]
2105
+ required: [true, "aws region is required"]
2234
2106
  },
2235
2107
  awsSecretKey: {},
2236
2108
  awsAccessKey: {}
@@ -2273,7 +2145,7 @@ var amazonMetaChatV1 = {
2273
2145
  mapBody: {
2274
2146
  prompt: {
2275
2147
  key: "prompt",
2276
- sanitize: /* @__PURE__ */ __name((messages) => {
2148
+ sanitize: (messages) => {
2277
2149
  if (typeof messages === "string") {
2278
2150
  return messages;
2279
2151
  } else {
@@ -2281,7 +2153,7 @@ var amazonMetaChatV1 = {
2281
2153
  messages
2282
2154
  });
2283
2155
  }
2284
- }, "sanitize")
2156
+ }
2285
2157
  },
2286
2158
  topP: {
2287
2159
  key: "top_p"
@@ -2298,6 +2170,7 @@ var amazonMetaChatV1 = {
2298
2170
  var bedrock = {
2299
2171
  "amazon:anthropic.chat.v1": amazonAnthropicChatV1,
2300
2172
  "amazon:meta.chat.v1": amazonMetaChatV1
2173
+ // "amazon:nova.chat.v1": amazonAmazonNovaChatV1,
2301
2174
  };
2302
2175
 
2303
2176
  // src/llm/config/anthropic/index.ts
@@ -2312,10 +2185,7 @@ var anthropicChatV1 = {
2312
2185
  prompt: {},
2313
2186
  system: {},
2314
2187
  maxTokens: {
2315
- required: [
2316
- true,
2317
- "maxTokens required"
2318
- ],
2188
+ required: [true, "maxTokens required"],
2319
2189
  default: 4096
2320
2190
  },
2321
2191
  anthropicApiKey: {
@@ -2340,10 +2210,22 @@ var anthropicChatV1 = {
2340
2210
  };
2341
2211
  var anthropic = {
2342
2212
  "anthropic.chat.v1": anthropicChatV1,
2343
- "anthropic.claude-3-7-sonnet": withDefaultModel(anthropicChatV1, "claude-3-7-sonnet-latest"),
2344
- "anthropic.claude-3-5-sonnet": withDefaultModel(anthropicChatV1, "claude-3-5-sonnet-latest"),
2345
- "anthropic.claude-3-5-haiku": withDefaultModel(anthropicChatV1, "claude-3-5-haiku-latest"),
2346
- "anthropic.claude-3-opus": withDefaultModel(anthropicChatV1, "claude-3-opus-latest")
2213
+ "anthropic.claude-3-7-sonnet": withDefaultModel(
2214
+ anthropicChatV1,
2215
+ "claude-3-7-sonnet-latest"
2216
+ ),
2217
+ "anthropic.claude-3-5-sonnet": withDefaultModel(
2218
+ anthropicChatV1,
2219
+ "claude-3-5-sonnet-latest"
2220
+ ),
2221
+ "anthropic.claude-3-5-haiku": withDefaultModel(
2222
+ anthropicChatV1,
2223
+ "claude-3-5-haiku-latest"
2224
+ ),
2225
+ "anthropic.claude-3-opus": withDefaultModel(
2226
+ anthropicChatV1,
2227
+ "claude-3-opus-latest"
2228
+ )
2347
2229
  };
2348
2230
 
2349
2231
  // src/llm/config/x/index.ts
@@ -2364,17 +2246,12 @@ var xaiChatV1 = {
2364
2246
  mapBody: {
2365
2247
  prompt: {
2366
2248
  key: "messages",
2367
- sanitize: /* @__PURE__ */ __name((v) => {
2249
+ sanitize: (v) => {
2368
2250
  if (typeof v === "string") {
2369
- return [
2370
- {
2371
- role: "user",
2372
- content: v
2373
- }
2374
- ];
2251
+ return [{ role: "user", content: v }];
2375
2252
  }
2376
2253
  return v;
2377
- }, "sanitize")
2254
+ }
2378
2255
  },
2379
2256
  model: {
2380
2257
  key: "model"
@@ -2384,7 +2261,7 @@ var xaiChatV1 = {
2384
2261
  },
2385
2262
  useJson: {
2386
2263
  key: "response_format.type",
2387
- sanitize: /* @__PURE__ */ __name((v) => v ? "json_object" : "text", "sanitize")
2264
+ sanitize: (v) => v ? "json_object" : "text"
2388
2265
  }
2389
2266
  }
2390
2267
  };
@@ -2406,17 +2283,12 @@ var ollamaChatV1 = {
2406
2283
  mapBody: {
2407
2284
  prompt: {
2408
2285
  key: "messages",
2409
- sanitize: /* @__PURE__ */ __name((v) => {
2286
+ sanitize: (v) => {
2410
2287
  if (typeof v === "string") {
2411
- return [
2412
- {
2413
- role: "user",
2414
- content: v
2415
- }
2416
- ];
2288
+ return [{ role: "user", content: v }];
2417
2289
  }
2418
2290
  return v;
2419
- }, "sanitize")
2291
+ }
2420
2292
  },
2421
2293
  model: {
2422
2294
  key: "model"
@@ -2434,90 +2306,58 @@ var ollama = {
2434
2306
 
2435
2307
  // src/utils/modules/modifyPromptRoleChange.ts
2436
2308
  function modifyPromptRoleChange(messages, roleChanges) {
2437
- const roleChangeMap = new Map(roleChanges.map(({ from, to }) => [
2438
- from,
2439
- to
2440
- ]));
2309
+ const roleChangeMap = new Map(roleChanges.map(({ from, to }) => [from, to]));
2441
2310
  if (Array.isArray(messages)) {
2442
2311
  return messages.map((message) => {
2443
2312
  const newRole2 = roleChangeMap.get(message.role);
2444
- return newRole2 ? {
2445
- ...message,
2446
- role: newRole2
2447
- } : message;
2313
+ return newRole2 ? { ...message, role: newRole2 } : message;
2448
2314
  });
2449
2315
  }
2450
2316
  const newRole = roleChangeMap.get(messages.role);
2451
- return newRole ? {
2452
- ...messages,
2453
- role: newRole
2454
- } : messages;
2317
+ return newRole ? { ...messages, role: newRole } : messages;
2455
2318
  }
2456
- __name(modifyPromptRoleChange, "modifyPromptRoleChange");
2457
2319
 
2458
2320
  // src/llm/config/google/promptSanitizeMessageCallback.ts
2459
2321
  function googleGeminiPromptMessageCallback(_message) {
2460
- let message = {
2461
- ..._message
2462
- };
2322
+ let message = { ..._message };
2463
2323
  message = modifyPromptRoleChange(_message, [
2464
- {
2465
- from: "assistant",
2466
- to: "model"
2467
- }
2324
+ { from: "assistant", to: "model" }
2468
2325
  ]);
2469
2326
  const { role, ...payload } = message;
2470
2327
  const parts = [];
2471
2328
  if (typeof payload.content === "string") {
2472
- parts.push({
2473
- text: message.content
2474
- });
2329
+ parts.push({ text: message.content });
2475
2330
  }
2476
2331
  return {
2477
2332
  role,
2478
2333
  parts
2479
2334
  };
2480
2335
  }
2481
- __name(googleGeminiPromptMessageCallback, "googleGeminiPromptMessageCallback");
2482
2336
 
2483
2337
  // src/llm/config/google/promptSanitize.ts
2484
2338
  function googleGeminiPromptSanitize(_messages, _inputBodyObj, _outputObj) {
2485
2339
  if (typeof _messages === "string") {
2486
- return [
2487
- {
2488
- role: "user",
2489
- parts: [
2490
- {
2491
- text: _messages
2492
- }
2493
- ]
2494
- }
2495
- ];
2340
+ return [{ role: "user", parts: [{ text: _messages }] }];
2496
2341
  }
2497
2342
  if (Array.isArray(_messages)) {
2498
2343
  if (_messages.length === 0) {
2499
2344
  throw new Error("Empty messages array");
2500
2345
  }
2501
2346
  if (_messages.length === 1 && _messages[0].role === "system") {
2502
- return [
2503
- {
2504
- role: "user",
2505
- parts: [
2506
- {
2507
- text: _messages[0].content
2508
- }
2509
- ]
2510
- }
2511
- ];
2347
+ return [{ role: "user", parts: [{ text: _messages[0].content }] }];
2512
2348
  }
2513
- const hasSystemInstruction = _messages.some((message) => message.role === "system");
2349
+ const hasSystemInstruction = _messages.some(
2350
+ (message) => message.role === "system"
2351
+ );
2514
2352
  if (hasSystemInstruction) {
2515
- const theSystemInstructions = _messages.filter((message) => message.role === "system");
2516
- const withoutSystemInstructions = _messages.filter((message) => message.role !== "system");
2353
+ const theSystemInstructions = _messages.filter(
2354
+ (message) => message.role === "system"
2355
+ );
2356
+ const withoutSystemInstructions = _messages.filter(
2357
+ (message) => message.role !== "system"
2358
+ );
2517
2359
  _outputObj.system_instruction = {
2518
- parts: theSystemInstructions.map((message) => ({
2519
- text: message.content
2520
- }))
2360
+ parts: theSystemInstructions.map((message) => ({ text: message.content }))
2521
2361
  };
2522
2362
  return withoutSystemInstructions.map(googleGeminiPromptMessageCallback);
2523
2363
  }
@@ -2525,7 +2365,6 @@ function googleGeminiPromptSanitize(_messages, _inputBodyObj, _outputObj) {
2525
2365
  }
2526
2366
  throw new Error("Invalid messages format");
2527
2367
  }
2528
- __name(googleGeminiPromptSanitize, "googleGeminiPromptSanitize");
2529
2368
 
2530
2369
  // src/llm/config/google/index.ts
2531
2370
  var googleGeminiChatV1 = {
@@ -2546,13 +2385,25 @@ var googleGeminiChatV1 = {
2546
2385
  key: "contents",
2547
2386
  sanitize: googleGeminiPromptSanitize
2548
2387
  }
2388
+ // topP: {
2389
+ // key: "top_p",
2390
+ // }
2549
2391
  }
2550
2392
  };
2551
2393
  var google = {
2552
2394
  "google.chat.v1": googleGeminiChatV1,
2553
- "google.gemini-2.0-flash": withDefaultModel(googleGeminiChatV1, "gemini-2.0-flash"),
2554
- "google.gemini-2.0-flash-lite": withDefaultModel(googleGeminiChatV1, "gemini-2.0-flash-lite"),
2555
- "google.gemini-1.5-pro": withDefaultModel(googleGeminiChatV1, "gemini-1.5-pro")
2395
+ "google.gemini-2.0-flash": withDefaultModel(
2396
+ googleGeminiChatV1,
2397
+ "gemini-2.0-flash"
2398
+ ),
2399
+ "google.gemini-2.0-flash-lite": withDefaultModel(
2400
+ googleGeminiChatV1,
2401
+ "gemini-2.0-flash-lite"
2402
+ ),
2403
+ "google.gemini-1.5-pro": withDefaultModel(
2404
+ googleGeminiChatV1,
2405
+ "gemini-1.5-pro"
2406
+ )
2556
2407
  };
2557
2408
 
2558
2409
  // src/llm/config/deepseek/index.ts
@@ -2573,17 +2424,12 @@ var deepseekChatV1 = {
2573
2424
  mapBody: {
2574
2425
  prompt: {
2575
2426
  key: "messages",
2576
- sanitize: /* @__PURE__ */ __name((v) => {
2427
+ sanitize: (v) => {
2577
2428
  if (typeof v === "string") {
2578
- return [
2579
- {
2580
- role: "user",
2581
- content: v
2582
- }
2583
- ];
2429
+ return [{ role: "user", content: v }];
2584
2430
  }
2585
2431
  return v;
2586
- }, "sanitize")
2432
+ }
2587
2433
  },
2588
2434
  model: {
2589
2435
  key: "model"
@@ -2593,7 +2439,7 @@ var deepseekChatV1 = {
2593
2439
  },
2594
2440
  useJson: {
2595
2441
  key: "response_format.type",
2596
- sanitize: /* @__PURE__ */ __name((v) => v ? "json_object" : "text", "sanitize")
2442
+ sanitize: (v) => v ? "json_object" : "text"
2597
2443
  }
2598
2444
  }
2599
2445
  };
@@ -2629,7 +2475,6 @@ function getLlmConfig(provider) {
2629
2475
  resolution: "Provide a valid provider"
2630
2476
  });
2631
2477
  }
2632
- __name(getLlmConfig, "getLlmConfig");
2633
2478
 
2634
2479
  // src/llm/output/_utils/getResultContent.ts
2635
2480
  function getResultContent(result, index) {
@@ -2638,11 +2483,8 @@ function getResultContent(result, index) {
2638
2483
  const val = arr[index];
2639
2484
  return val ? val : [];
2640
2485
  }
2641
- return [
2642
- ...result.content
2643
- ];
2486
+ return [...result.content];
2644
2487
  }
2645
- __name(getResultContent, "getResultContent");
2646
2488
 
2647
2489
  // src/llm/output/base.ts
2648
2490
  function BaseLlmOutput2(result) {
@@ -2651,12 +2493,8 @@ function BaseLlmOutput2(result) {
2651
2493
  name: result.name,
2652
2494
  usage: result.usage,
2653
2495
  stopReason: result.stopReason,
2654
- options: [
2655
- ...result?.options || []
2656
- ],
2657
- content: [
2658
- ...result.content
2659
- ],
2496
+ options: [...result?.options || []],
2497
+ content: [...result.content],
2660
2498
  created: result?.created || (/* @__PURE__ */ new Date()).getTime()
2661
2499
  });
2662
2500
  function getResult() {
@@ -2670,14 +2508,12 @@ function BaseLlmOutput2(result) {
2670
2508
  stopReason: __result.stopReason
2671
2509
  };
2672
2510
  }
2673
- __name(getResult, "getResult");
2674
2511
  return {
2675
- getResultContent: /* @__PURE__ */ __name((index) => getResultContent(__result, index), "getResultContent"),
2676
- getResultText: /* @__PURE__ */ __name(() => getResultText(__result.content), "getResultText"),
2512
+ getResultContent: (index) => getResultContent(__result, index),
2513
+ getResultText: () => getResultText(__result.content),
2677
2514
  getResult
2678
2515
  };
2679
2516
  }
2680
- __name(BaseLlmOutput2, "BaseLlmOutput2");
2681
2517
 
2682
2518
  // src/llm/output/_util.ts
2683
2519
  function normalizeFunctionCall(input, provider) {
@@ -2688,20 +2524,16 @@ function normalizeFunctionCall(input, provider) {
2688
2524
  }
2689
2525
  return input;
2690
2526
  }
2691
- __name(normalizeFunctionCall, "normalizeFunctionCall");
2692
2527
  function formatOptions(response, handler) {
2693
2528
  const out = [];
2694
2529
  for (const item of response) {
2695
2530
  const result = handler(item);
2696
2531
  if (result) {
2697
- out.push([
2698
- result
2699
- ]);
2532
+ out.push([result]);
2700
2533
  }
2701
2534
  }
2702
2535
  return out;
2703
2536
  }
2704
- __name(formatOptions, "formatOptions");
2705
2537
  function formatContent(response, handler) {
2706
2538
  const out = [];
2707
2539
  const result = handler(response);
@@ -2710,7 +2542,6 @@ function formatContent(response, handler) {
2710
2542
  }
2711
2543
  return out;
2712
2544
  }
2713
- __name(formatContent, "formatContent");
2714
2545
 
2715
2546
  // src/llm/output/openai.ts
2716
2547
  function formatResult(result) {
@@ -2734,7 +2565,6 @@ function formatResult(result) {
2734
2565
  text: ""
2735
2566
  };
2736
2567
  }
2737
- __name(formatResult, "formatResult");
2738
2568
  function OutputOpenAIChat(result, _config) {
2739
2569
  const id = result.id;
2740
2570
  const name = result.model || _config?.model || "openai.unknown";
@@ -2758,7 +2588,6 @@ function OutputOpenAIChat(result, _config) {
2758
2588
  options
2759
2589
  });
2760
2590
  }
2761
- __name(OutputOpenAIChat, "OutputOpenAIChat");
2762
2591
 
2763
2592
  // src/llm/output/claude.ts
2764
2593
  function formatResult2(response) {
@@ -2781,7 +2610,6 @@ function formatResult2(response) {
2781
2610
  }
2782
2611
  return out;
2783
2612
  }
2784
- __name(formatResult2, "formatResult");
2785
2613
  function OutputAnthropicClaude3Chat(result, _config) {
2786
2614
  const id = result.id;
2787
2615
  const name = result.model || _config?.model || "anthropic.unknown";
@@ -2800,17 +2628,13 @@ function OutputAnthropicClaude3Chat(result, _config) {
2800
2628
  content
2801
2629
  });
2802
2630
  }
2803
- __name(OutputAnthropicClaude3Chat, "OutputAnthropicClaude3Chat");
2804
2631
 
2805
2632
  // src/llm/output/llama.ts
2806
2633
  function OutputMetaLlama3Chat(result, _config) {
2807
2634
  const name = _config?.model || "meta";
2808
2635
  const stopReason = result.stop_reason;
2809
2636
  const content = [
2810
- {
2811
- type: "text",
2812
- text: result.generation
2813
- }
2637
+ { type: "text", text: result.generation }
2814
2638
  ];
2815
2639
  const usage = {
2816
2640
  output_tokens: result?.generation_token_count,
@@ -2824,7 +2648,6 @@ function OutputMetaLlama3Chat(result, _config) {
2824
2648
  content
2825
2649
  });
2826
2650
  }
2827
- __name(OutputMetaLlama3Chat, "OutputMetaLlama3Chat");
2828
2651
 
2829
2652
  // src/llm/output/default.ts
2830
2653
  function OutputDefault(result, _config) {
@@ -2832,10 +2655,7 @@ function OutputDefault(result, _config) {
2832
2655
  const stopReason = result?.stopReason || "stop";
2833
2656
  const content = [];
2834
2657
  if (result?.text) {
2835
- content.push({
2836
- type: "text",
2837
- text: result.text
2838
- });
2658
+ content.push({ type: "text", text: result.text });
2839
2659
  }
2840
2660
  const usage = {
2841
2661
  output_tokens: result?.output_tokens || 0,
@@ -2849,7 +2669,6 @@ function OutputDefault(result, _config) {
2849
2669
  content
2850
2670
  });
2851
2671
  }
2852
- __name(OutputDefault, "OutputDefault");
2853
2672
 
2854
2673
  // src/llm/output/xai.ts
2855
2674
  function formatResult3(result) {
@@ -2873,7 +2692,6 @@ function formatResult3(result) {
2873
2692
  text: ""
2874
2693
  };
2875
2694
  }
2876
- __name(formatResult3, "formatResult");
2877
2695
  function OutputXAIChat(result, _config) {
2878
2696
  const id = result.id;
2879
2697
  const name = result?.model;
@@ -2897,7 +2715,6 @@ function OutputXAIChat(result, _config) {
2897
2715
  options
2898
2716
  });
2899
2717
  }
2900
- __name(OutputXAIChat, "OutputXAIChat");
2901
2718
 
2902
2719
  // src/llm/output/_utils/combineJsonl.ts
2903
2720
  function combineJsonl(jsonl) {
@@ -2911,7 +2728,9 @@ function combineJsonl(jsonl) {
2911
2728
  if (lines.length === 0) {
2912
2729
  throw new Error("No JSON lines provided.");
2913
2730
  }
2914
- lines.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime());
2731
+ lines.sort(
2732
+ (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
2733
+ );
2915
2734
  let combinedContent = lines.map((line) => line?.message?.content ?? "").join("");
2916
2735
  combinedContent = combinedContent.replace(/\\u003c/g, "<").replace(/\\u003e/g, ">");
2917
2736
  const finalLine = lines.find((line) => line.done === true);
@@ -2944,7 +2763,6 @@ function combineJsonl(jsonl) {
2944
2763
  content
2945
2764
  };
2946
2765
  }
2947
- __name(combineJsonl, "combineJsonl");
2948
2766
 
2949
2767
  // src/llm/output/ollama.ts
2950
2768
  function OutputOllamaChat(result, _config) {
@@ -2953,9 +2771,7 @@ function OutputOllamaChat(result, _config) {
2953
2771
  const name = combined.result.model || _config?.model || "ollama.unknown";
2954
2772
  const created = (/* @__PURE__ */ new Date(`${combined.result.created_at}`)).getTime();
2955
2773
  const stopReason = `${combined?.result?.done_reason || "stop"}`;
2956
- const content = [
2957
- combined.content
2958
- ];
2774
+ const content = [combined.content];
2959
2775
  const usage = {
2960
2776
  output_tokens: 0,
2961
2777
  input_tokens: 0,
@@ -2971,7 +2787,6 @@ function OutputOllamaChat(result, _config) {
2971
2787
  options: []
2972
2788
  });
2973
2789
  }
2974
- __name(OutputOllamaChat, "OutputOllamaChat");
2975
2790
 
2976
2791
  // src/llm/output/google.gemini/formatResult.ts
2977
2792
  function formatResult4(result) {
@@ -2996,7 +2811,6 @@ function formatResult4(result) {
2996
2811
  text: ""
2997
2812
  };
2998
2813
  }
2999
- __name(formatResult4, "formatResult");
3000
2814
 
3001
2815
  // src/llm/output/google.gemini/index.ts
3002
2816
  function OutputGoogleGeminiChat(result, _config) {
@@ -3022,7 +2836,6 @@ function OutputGoogleGeminiChat(result, _config) {
3022
2836
  options
3023
2837
  });
3024
2838
  }
3025
- __name(OutputGoogleGeminiChat, "OutputGoogleGeminiChat");
3026
2839
 
3027
2840
  // src/llm/output/index.ts
3028
2841
  function getOutputParser(config, response) {
@@ -3054,7 +2867,6 @@ function getOutputParser(config, response) {
3054
2867
  }
3055
2868
  }
3056
2869
  }
3057
- __name(getOutputParser, "getOutputParser");
3058
2870
 
3059
2871
  // src/utils/modules/debug.ts
3060
2872
  function debug(...args) {
@@ -3066,7 +2878,11 @@ function debug(...args) {
3066
2878
  } else if (arg instanceof Array) {
3067
2879
  logs.push(arg.map((item) => JSON.stringify(item, null, 2)));
3068
2880
  } else if (arg instanceof Map) {
3069
- logs.push(Array.from(arg.entries()).map(([key, value]) => `${key}: ${JSON.stringify(value, null, 2)}`));
2881
+ logs.push(
2882
+ Array.from(arg.entries()).map(
2883
+ ([key, value]) => `${key}: ${JSON.stringify(value, null, 2)}`
2884
+ )
2885
+ );
3070
2886
  } else if (arg instanceof Set) {
3071
2887
  logs.push(Array.from(arg).map((item) => JSON.stringify(item, null, 2)));
3072
2888
  } else if (arg instanceof Date) {
@@ -3090,7 +2906,6 @@ function debug(...args) {
3090
2906
  console.debug(...logs);
3091
2907
  }
3092
2908
  }
3093
- __name(debug, "debug");
3094
2909
 
3095
2910
  // src/utils/modules/isValidUrl.ts
3096
2911
  function isValidUrl(input) {
@@ -3101,7 +2916,6 @@ function isValidUrl(input) {
3101
2916
  return false;
3102
2917
  }
3103
2918
  }
3104
- __name(isValidUrl, "isValidUrl");
3105
2919
 
3106
2920
  // src/utils/modules/request.ts
3107
2921
  async function apiRequest(url, options) {
@@ -3137,7 +2951,6 @@ async function apiRequest(url, options) {
3137
2951
  throw new Error(`Request to ${url} failed: ${message}`);
3138
2952
  }
3139
2953
  }
3140
- __name(apiRequest, "apiRequest");
3141
2954
 
3142
2955
  // src/utils/modules/convertDotNotation.ts
3143
2956
  function convertDotNotation(obj) {
@@ -3162,7 +2975,6 @@ function convertDotNotation(obj) {
3162
2975
  }
3163
2976
  return result;
3164
2977
  }
3165
- __name(convertDotNotation, "convertDotNotation");
3166
2978
 
3167
2979
  // src/llm/_utils.mapBody.ts
3168
2980
  function mapBody(template, body) {
@@ -3175,9 +2987,11 @@ function mapBody(template, body) {
3175
2987
  if (providerSpecificKey) {
3176
2988
  let valueForThisKey = body[genericInputKey];
3177
2989
  if (providerSpecificSettings.sanitize && typeof providerSpecificSettings.sanitize === "function") {
3178
- valueForThisKey = providerSpecificSettings.sanitize(valueForThisKey, Object.freeze({
3179
- ...body
3180
- }), output);
2990
+ valueForThisKey = providerSpecificSettings.sanitize(
2991
+ valueForThisKey,
2992
+ Object.freeze({ ...body }),
2993
+ output
2994
+ );
3181
2995
  }
3182
2996
  if (typeof valueForThisKey !== "undefined") {
3183
2997
  output[providerSpecificKey] = valueForThisKey;
@@ -3188,127 +3002,16 @@ function mapBody(template, body) {
3188
3002
  }
3189
3003
  return convertDotNotation(output);
3190
3004
  }
3191
- __name(mapBody, "mapBody");
3192
3005
 
3193
3006
  // src/utils/modules/getAwsAuthorizationHeaders.ts
3194
3007
  import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
3195
3008
  import { SignatureV4 } from "@smithy/signature-v4";
3196
-
3197
- // node_modules/@smithy/types/dist-es/auth/auth.js
3198
- var HttpAuthLocation;
3199
- (function(HttpAuthLocation2) {
3200
- HttpAuthLocation2["HEADER"] = "header";
3201
- HttpAuthLocation2["QUERY"] = "query";
3202
- })(HttpAuthLocation || (HttpAuthLocation = {}));
3203
-
3204
- // node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js
3205
- var HttpApiKeyAuthLocation;
3206
- (function(HttpApiKeyAuthLocation2) {
3207
- HttpApiKeyAuthLocation2["HEADER"] = "header";
3208
- HttpApiKeyAuthLocation2["QUERY"] = "query";
3209
- })(HttpApiKeyAuthLocation || (HttpApiKeyAuthLocation = {}));
3210
-
3211
- // node_modules/@smithy/types/dist-es/endpoint.js
3212
- var EndpointURLScheme;
3213
- (function(EndpointURLScheme2) {
3214
- EndpointURLScheme2["HTTP"] = "http";
3215
- EndpointURLScheme2["HTTPS"] = "https";
3216
- })(EndpointURLScheme || (EndpointURLScheme = {}));
3217
-
3218
- // node_modules/@smithy/types/dist-es/extensions/checksum.js
3219
- var AlgorithmId;
3220
- (function(AlgorithmId2) {
3221
- AlgorithmId2["MD5"] = "md5";
3222
- AlgorithmId2["CRC32"] = "crc32";
3223
- AlgorithmId2["CRC32C"] = "crc32c";
3224
- AlgorithmId2["SHA1"] = "sha1";
3225
- AlgorithmId2["SHA256"] = "sha256";
3226
- })(AlgorithmId || (AlgorithmId = {}));
3227
-
3228
- // node_modules/@smithy/types/dist-es/http.js
3229
- var FieldPosition;
3230
- (function(FieldPosition2) {
3231
- FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
3232
- FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
3233
- })(FieldPosition || (FieldPosition = {}));
3234
-
3235
- // node_modules/@smithy/types/dist-es/profile.js
3236
- var IniSectionType;
3237
- (function(IniSectionType2) {
3238
- IniSectionType2["PROFILE"] = "profile";
3239
- IniSectionType2["SSO_SESSION"] = "sso-session";
3240
- IniSectionType2["SERVICES"] = "services";
3241
- })(IniSectionType || (IniSectionType = {}));
3242
-
3243
- // node_modules/@smithy/types/dist-es/transfer.js
3244
- var RequestHandlerProtocol;
3245
- (function(RequestHandlerProtocol2) {
3246
- RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
3247
- RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
3248
- RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
3249
- })(RequestHandlerProtocol || (RequestHandlerProtocol = {}));
3250
-
3251
- // node_modules/@smithy/protocol-http/dist-es/httpRequest.js
3252
- var _HttpRequest = class _HttpRequest {
3253
- constructor(options) {
3254
- this.method = options.method || "GET";
3255
- this.hostname = options.hostname || "localhost";
3256
- this.port = options.port;
3257
- this.query = options.query || {};
3258
- this.headers = options.headers || {};
3259
- this.body = options.body;
3260
- this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? `${options.protocol}:` : options.protocol : "https:";
3261
- this.path = options.path ? options.path.charAt(0) !== "/" ? `/${options.path}` : options.path : "/";
3262
- this.username = options.username;
3263
- this.password = options.password;
3264
- this.fragment = options.fragment;
3265
- }
3266
- static clone(request) {
3267
- const cloned = new _HttpRequest({
3268
- ...request,
3269
- headers: {
3270
- ...request.headers
3271
- }
3272
- });
3273
- if (cloned.query) {
3274
- cloned.query = cloneQuery(cloned.query);
3275
- }
3276
- return cloned;
3277
- }
3278
- static isInstance(request) {
3279
- if (!request) {
3280
- return false;
3281
- }
3282
- const req = request;
3283
- return "method" in req && "protocol" in req && "hostname" in req && "path" in req && typeof req["query"] === "object" && typeof req["headers"] === "object";
3284
- }
3285
- clone() {
3286
- return _HttpRequest.clone(this);
3287
- }
3288
- };
3289
- __name(_HttpRequest, "HttpRequest");
3290
- var HttpRequest = _HttpRequest;
3291
- function cloneQuery(query) {
3292
- return Object.keys(query).reduce((carry, paramName) => {
3293
- const param = query[paramName];
3294
- return {
3295
- ...carry,
3296
- [paramName]: Array.isArray(param) ? [
3297
- ...param
3298
- ] : param
3299
- };
3300
- }, {});
3301
- }
3302
- __name(cloneQuery, "cloneQuery");
3303
-
3304
- // src/utils/modules/getAwsAuthorizationHeaders.ts
3009
+ import { HttpRequest } from "@smithy/protocol-http";
3305
3010
  import { Sha256 } from "@aws-crypto/sha256-js";
3306
3011
 
3307
3012
  // src/utils/modules/runWithTemporaryEnv.ts
3308
3013
  async function runWithTemporaryEnv(env, handler) {
3309
- const previousEnv = {
3310
- ...process.env
3311
- };
3014
+ const previousEnv = { ...process.env };
3312
3015
  try {
3313
3016
  env();
3314
3017
  const value = await handler();
@@ -3317,22 +3020,24 @@ async function runWithTemporaryEnv(env, handler) {
3317
3020
  process.env = previousEnv;
3318
3021
  }
3319
3022
  }
3320
- __name(runWithTemporaryEnv, "runWithTemporaryEnv");
3321
3023
 
3322
3024
  // src/utils/modules/getAwsAuthorizationHeaders.ts
3323
3025
  async function getAwsAuthorizationHeaders(req, props) {
3324
3026
  const providerChain = fromNodeProviderChain();
3325
- const credentials = await runWithTemporaryEnv(() => {
3326
- if (props.awsAccessKey) {
3327
- process.env["AWS_ACCESS_KEY_ID"] = props.awsAccessKey;
3328
- }
3329
- if (props.awsSecretKey) {
3330
- process.env["AWS_SECRET_ACCESS_KEY"] = props.awsSecretKey;
3331
- }
3332
- if (props.awsSessionToken) {
3333
- process.env["AWS_SESSION_TOKEN"] = props.awsSessionToken;
3334
- }
3335
- }, () => providerChain());
3027
+ const credentials = await runWithTemporaryEnv(
3028
+ () => {
3029
+ if (props.awsAccessKey) {
3030
+ process.env["AWS_ACCESS_KEY_ID"] = props.awsAccessKey;
3031
+ }
3032
+ if (props.awsSecretKey) {
3033
+ process.env["AWS_SECRET_ACCESS_KEY"] = props.awsSecretKey;
3034
+ }
3035
+ if (props.awsSessionToken) {
3036
+ process.env["AWS_SESSION_TOKEN"] = props.awsSessionToken;
3037
+ }
3038
+ },
3039
+ () => providerChain()
3040
+ );
3336
3041
  const signer = new SignatureV4({
3337
3042
  service: "bedrock",
3338
3043
  region: props.regionName,
@@ -3340,11 +3045,7 @@ async function getAwsAuthorizationHeaders(req, props) {
3340
3045
  sha256: Sha256
3341
3046
  });
3342
3047
  const url = new URL(props.url);
3343
- const headers = !req.headers ? {} : Symbol.iterator in req.headers ? Object.fromEntries(Array.from(req.headers).map((header) => [
3344
- ...header
3345
- ])) : {
3346
- ...req.headers
3347
- };
3048
+ const headers = !req.headers ? {} : Symbol.iterator in req.headers ? Object.fromEntries(Array.from(req.headers).map((header) => [...header])) : { ...req.headers };
3348
3049
  delete headers["connection"];
3349
3050
  headers["host"] = url.hostname;
3350
3051
  const request = new HttpRequest({
@@ -3357,7 +3058,6 @@ async function getAwsAuthorizationHeaders(req, props) {
3357
3058
  const signed = await signer.sign(request);
3358
3059
  return signed.headers;
3359
3060
  }
3360
- __name(getAwsAuthorizationHeaders, "getAwsAuthorizationHeaders");
3361
3061
 
3362
3062
  // src/llm/_utils.parseHeaders.ts
3363
3063
  async function parseHeaders(config, replacements, payload) {
@@ -3366,30 +3066,40 @@ async function parseHeaders(config, replacements, payload) {
3366
3066
  const headers = Object.assign({}, payload.headers, parse);
3367
3067
  if (config.provider.startsWith("amazon:") || config.provider.startsWith("amazon.")) {
3368
3068
  const url = payload.url;
3369
- return getAwsAuthorizationHeaders({
3370
- method: config.method,
3371
- headers,
3372
- body: payload.body
3373
- }, {
3374
- url,
3375
- regionName: replacements?.awsRegion || getEnvironmentVariable("AWS_REGION"),
3376
- awsSecretKey: replacements.awsSecretKey,
3377
- awsAccessKey: replacements.awsAccessKey
3378
- });
3069
+ return getAwsAuthorizationHeaders(
3070
+ {
3071
+ method: config.method,
3072
+ headers,
3073
+ body: payload.body
3074
+ },
3075
+ {
3076
+ url,
3077
+ regionName: replacements?.awsRegion || getEnvironmentVariable("AWS_REGION"),
3078
+ awsSecretKey: replacements.awsSecretKey,
3079
+ awsAccessKey: replacements.awsAccessKey
3080
+ }
3081
+ );
3379
3082
  } else {
3380
3083
  return headers;
3381
3084
  }
3382
3085
  }
3383
- __name(parseHeaders, "parseHeaders");
3384
3086
 
3385
3087
  // src/llm/output/_utils/cleanJsonSchemaFor.ts
3386
3088
  var providerFieldExclusions = {
3387
- "openai.chat": [
3388
- "default"
3389
- ]
3089
+ "openai.chat": ["default"],
3090
+ // fields to exclude for openai.chat
3091
+ "anthropic.chat": []
3092
+ // fields to exclude for openai.chat
3390
3093
  };
3391
3094
  function cleanJsonSchemaFor(schema = {}, provider) {
3392
3095
  const clone = deepClone(schema);
3096
+ if (Object.keys(clone).length === 0) {
3097
+ return {
3098
+ type: "object",
3099
+ properties: {},
3100
+ required: []
3101
+ };
3102
+ }
3393
3103
  const exclusions = providerFieldExclusions[provider] || [];
3394
3104
  function removeDisallowedFields(obj) {
3395
3105
  if (Array.isArray(obj)) {
@@ -3404,20 +3114,21 @@ function cleanJsonSchemaFor(schema = {}, provider) {
3404
3114
  }
3405
3115
  return obj;
3406
3116
  }
3407
- __name(removeDisallowedFields, "removeDisallowedFields");
3408
3117
  return removeDisallowedFields(clone);
3409
3118
  }
3410
- __name(cleanJsonSchemaFor, "cleanJsonSchemaFor");
3411
3119
 
3412
3120
  // src/llm/llm.call.ts
3413
3121
  async function useLlm_call(state, messages, _options) {
3414
3122
  const config = getLlmConfig(state.key);
3415
3123
  const { functionCallStrictInput = false } = _options || {};
3416
- const input = mapBody(config.mapBody, Object.assign({}, state, {
3417
- prompt: messages
3418
- }));
3124
+ const input = mapBody(
3125
+ config.mapBody,
3126
+ Object.assign({}, state, {
3127
+ prompt: messages
3128
+ })
3129
+ );
3419
3130
  if (_options && _options?.jsonSchema) {
3420
- if (state.provider === "openai.chat") {
3131
+ if (state.provider.startsWith("openai")) {
3421
3132
  const curr = input["response_format"] || {};
3422
3133
  input["response_format"] = Object.assign(curr, {
3423
3134
  type: "json_schema",
@@ -3430,28 +3141,29 @@ async function useLlm_call(state, messages, _options) {
3430
3141
  }
3431
3142
  }
3432
3143
  if (_options && _options?.functionCall) {
3433
- if (state.provider === "anthropic.chat") {
3144
+ if (state.provider.startsWith("anthropic")) {
3434
3145
  if (_options?.functionCall === "none") {
3435
3146
  _options.functions = [];
3436
3147
  } else if (_options?.functionCall === "auto" || _options?.functionCall === "any") {
3437
- input["tool_choice"] = {
3438
- type: _options?.functionCall
3439
- };
3148
+ input["tool_choice"] = { type: _options?.functionCall };
3440
3149
  } else {
3441
3150
  input["tool_choice"] = _options?.functionCall;
3442
3151
  }
3443
- } else if (state.provider === "openai.chat") {
3444
- input["tool_choice"] = normalizeFunctionCall(_options?.functionCall, "openai");
3152
+ } else if (state.provider.startsWith("openai")) {
3153
+ input["tool_choice"] = normalizeFunctionCall(
3154
+ _options?.functionCall,
3155
+ "openai"
3156
+ );
3445
3157
  }
3446
3158
  }
3447
3159
  if (_options && _options?.functions?.length) {
3448
- if (state.provider === "anthropic.chat") {
3160
+ if (state.provider.startsWith("anthropic")) {
3449
3161
  input["tools"] = _options.functions.map((f) => ({
3450
3162
  name: f.name,
3451
3163
  description: f.description,
3452
- input_schema: f.parameters
3164
+ input_schema: cleanJsonSchemaFor(f.parameters, "anthropic.chat")
3453
3165
  }));
3454
- } else if (state.provider === "openai.chat") {
3166
+ } else if (state.provider.startsWith("openai")) {
3455
3167
  input["tools"] = _options.functions.map((f) => {
3456
3168
  const props = {
3457
3169
  name: f?.name,
@@ -3460,11 +3172,13 @@ async function useLlm_call(state, messages, _options) {
3460
3172
  };
3461
3173
  return {
3462
3174
  type: "function",
3463
- function: Object.assign(props, {
3464
- parameters: cleanJsonSchemaFor(props.parameters, "openai.chat")
3465
- }, {
3466
- strict: functionCallStrictInput
3467
- })
3175
+ function: Object.assign(
3176
+ props,
3177
+ {
3178
+ parameters: cleanJsonSchemaFor(props.parameters, "openai.chat")
3179
+ },
3180
+ { strict: functionCallStrictInput }
3181
+ )
3468
3182
  };
3469
3183
  });
3470
3184
  }
@@ -3480,16 +3194,14 @@ async function useLlm_call(state, messages, _options) {
3480
3194
  id: "0123-45-6789",
3481
3195
  model: "model",
3482
3196
  created: (/* @__PURE__ */ new Date()).getTime(),
3483
- usage: {
3484
- completion_tokens: 0,
3485
- prompt_tokens: 0,
3486
- total_tokens: 0
3487
- },
3197
+ usage: { completion_tokens: 0, prompt_tokens: 0, total_tokens: 0 },
3488
3198
  choices: [
3489
3199
  {
3490
3200
  message: {
3491
3201
  role: "assistant",
3492
- content: `Hello world from LLM! The input was ${JSON.stringify(messages)}`
3202
+ content: `Hello world from LLM! The input was ${JSON.stringify(
3203
+ messages
3204
+ )}`
3493
3205
  }
3494
3206
  }
3495
3207
  ]
@@ -3500,7 +3212,6 @@ async function useLlm_call(state, messages, _options) {
3500
3212
  });
3501
3213
  return getOutputParser(state, response);
3502
3214
  }
3503
- __name(useLlm_call, "useLlm_call");
3504
3215
 
3505
3216
  // src/llm/_utils.stateFromOptions.ts
3506
3217
  function stateFromOptions(options, config) {
@@ -3519,16 +3230,16 @@ function stateFromOptions(options, config) {
3519
3230
  state[key] = thisConfig.default;
3520
3231
  }
3521
3232
  }
3522
- if (thisConfig?.required && typeof get(state, key) === "undefined") {
3523
- const [required, message = `Error: [${key}] is required`] = thisConfig?.required;
3524
- if (required) {
3233
+ const value = get(state, key);
3234
+ if (Array.isArray(thisConfig?.required)) {
3235
+ const [required, message = `Error: [${key}] is required`] = thisConfig.required;
3236
+ if (required && typeof value === "undefined") {
3525
3237
  throw new Error(message);
3526
3238
  }
3527
3239
  }
3528
3240
  }
3529
3241
  return state;
3530
3242
  }
3531
- __name(stateFromOptions, "stateFromOptions");
3532
3243
 
3533
3244
  // src/utils/modules/deepFreeze.ts
3534
3245
  function deepFreeze(obj) {
@@ -3545,13 +3256,14 @@ function deepFreeze(obj) {
3545
3256
  }
3546
3257
  if (typeof obj === "object" && obj !== null) {
3547
3258
  for (const key of Object.keys(obj)) {
3548
- obj[key] = deepFreeze(obj[key]);
3259
+ obj[key] = deepFreeze(
3260
+ obj[key]
3261
+ );
3549
3262
  }
3550
3263
  return Object.freeze(obj);
3551
3264
  }
3552
3265
  return obj;
3553
3266
  }
3554
- __name(deepFreeze, "deepFreeze");
3555
3267
 
3556
3268
  // src/utils/modules/requestWrapper.ts
3557
3269
  import { backOff } from "exponential-backoff";
@@ -3572,19 +3284,29 @@ function apiRequestWrapper(config, options, handler, doNotRetryErrorMessages = [
3572
3284
  async function call(messages, options2) {
3573
3285
  try {
3574
3286
  metrics.total_calls++;
3575
- const result = await backOff(() => asyncCallWithTimeout(handler(deepFreeze(state), deepFreeze(messages), deepFreeze(options2)), timeout), {
3576
- startingDelay: 0,
3577
- maxDelay,
3578
- numOfAttempts,
3579
- jitter,
3580
- retry: /* @__PURE__ */ __name((_error, _stepNumber) => {
3581
- if (doNotRetryErrorMessages.includes(_error.message)) {
3582
- return false;
3287
+ const result = await backOff(
3288
+ () => asyncCallWithTimeout(
3289
+ handler(
3290
+ deepFreeze(state),
3291
+ deepFreeze(messages),
3292
+ deepFreeze(options2)
3293
+ ),
3294
+ timeout
3295
+ ),
3296
+ {
3297
+ startingDelay: 0,
3298
+ maxDelay,
3299
+ numOfAttempts,
3300
+ jitter,
3301
+ retry: (_error, _stepNumber) => {
3302
+ if (doNotRetryErrorMessages.includes(_error.message)) {
3303
+ return false;
3304
+ }
3305
+ metrics.total_call_retry++;
3306
+ return true;
3583
3307
  }
3584
- metrics.total_call_retry++;
3585
- return true;
3586
- }, "retry")
3587
- });
3308
+ }
3309
+ );
3588
3310
  metrics.total_call_success++;
3589
3311
  return result;
3590
3312
  } catch (error) {
@@ -3592,29 +3314,32 @@ function apiRequestWrapper(config, options, handler, doNotRetryErrorMessages = [
3592
3314
  throw error;
3593
3315
  }
3594
3316
  }
3595
- __name(call, "call");
3596
3317
  function getMetadata() {
3597
- const { awsSecretKey, awsAccessKey, openAiApiKey, anthropicApiKey, ...rest } = options;
3598
- return Object.assign({
3599
- traceId: getTraceId(),
3600
- timeout,
3601
- jitter,
3602
- maxDelay,
3603
- numOfAttempts,
3604
- metrics: {
3605
- ...metrics
3606
- }
3607
- }, rest);
3318
+ const {
3319
+ awsSecretKey,
3320
+ awsAccessKey,
3321
+ openAiApiKey,
3322
+ anthropicApiKey,
3323
+ ...rest
3324
+ } = options;
3325
+ return Object.assign(
3326
+ {
3327
+ traceId: getTraceId(),
3328
+ timeout,
3329
+ jitter,
3330
+ maxDelay,
3331
+ numOfAttempts,
3332
+ metrics: { ...metrics }
3333
+ },
3334
+ rest
3335
+ );
3608
3336
  }
3609
- __name(getMetadata, "getMetadata");
3610
3337
  function getTraceId() {
3611
3338
  return traceId;
3612
3339
  }
3613
- __name(getTraceId, "getTraceId");
3614
3340
  function withTraceId(id) {
3615
3341
  traceId = id;
3616
3342
  }
3617
- __name(withTraceId, "withTraceId");
3618
3343
  return {
3619
3344
  call,
3620
3345
  getTraceId,
@@ -3622,14 +3347,12 @@ function apiRequestWrapper(config, options, handler, doNotRetryErrorMessages = [
3622
3347
  getMetadata
3623
3348
  };
3624
3349
  }
3625
- __name(apiRequestWrapper, "apiRequestWrapper");
3626
3350
 
3627
3351
  // src/llm/llm.ts
3628
3352
  function useLlm(provider, options = {}) {
3629
3353
  const config = getLlmConfig(provider);
3630
3354
  return apiRequestWrapper(config, options, useLlm_call);
3631
3355
  }
3632
- __name(useLlm, "useLlm");
3633
3356
 
3634
3357
  // src/embedding/config.ts
3635
3358
  var embeddingConfigs = {
@@ -3677,10 +3400,7 @@ var embeddingConfigs = {
3677
3400
  },
3678
3401
  awsRegion: {
3679
3402
  default: getEnvironmentVariable("AWS_REGION"),
3680
- required: [
3681
- true,
3682
- "aws region is required"
3683
- ]
3403
+ required: [true, "aws region is required"]
3684
3404
  },
3685
3405
  awsSecretKey: {},
3686
3406
  awsAccessKey: {}
@@ -3705,7 +3425,6 @@ function getEmbeddingConfig(provider) {
3705
3425
  }
3706
3426
  throw new Error(`Invalid provider: ${provider}`);
3707
3427
  }
3708
- __name(getEmbeddingConfig, "getEmbeddingConfig");
3709
3428
 
3710
3429
  // src/embedding/output/BaseEmbeddingOutput.ts
3711
3430
  function BaseEmbeddingOutput(result) {
@@ -3713,9 +3432,7 @@ function BaseEmbeddingOutput(result) {
3713
3432
  id: result.id || uuidv4(),
3714
3433
  model: result.model,
3715
3434
  usage: result.usage,
3716
- embedding: [
3717
- ...result?.embedding || []
3718
- ],
3435
+ embedding: [...result?.embedding || []],
3719
3436
  created: result?.created || (/* @__PURE__ */ new Date()).getTime()
3720
3437
  });
3721
3438
  function getResult() {
@@ -3727,7 +3444,6 @@ function BaseEmbeddingOutput(result) {
3727
3444
  embedding: __result.embedding
3728
3445
  };
3729
3446
  }
3730
- __name(getResult, "getResult");
3731
3447
  function getEmbedding(index) {
3732
3448
  if (index && index > 0) {
3733
3449
  const arr = __result?.embedding;
@@ -3736,22 +3452,18 @@ function BaseEmbeddingOutput(result) {
3736
3452
  }
3737
3453
  return __result.embedding[0];
3738
3454
  }
3739
- __name(getEmbedding, "getEmbedding");
3740
3455
  return {
3741
3456
  getEmbedding,
3742
3457
  getResult
3743
3458
  };
3744
3459
  }
3745
- __name(BaseEmbeddingOutput, "BaseEmbeddingOutput");
3746
3460
 
3747
3461
  // src/embedding/output/AmazonTitan.ts
3748
3462
  function AmazonTitanEmbedding(result, config) {
3749
3463
  const __result = deepClone(result);
3750
3464
  const model = config.model || "amazon.unknown";
3751
3465
  const created = (/* @__PURE__ */ new Date()).getTime();
3752
- const embedding = [
3753
- __result.embedding
3754
- ];
3466
+ const embedding = [__result.embedding];
3755
3467
  const usage = {
3756
3468
  output_tokens: 0,
3757
3469
  input_tokens: __result.inputTextTokenCount,
@@ -3764,7 +3476,6 @@ function AmazonTitanEmbedding(result, config) {
3764
3476
  embedding
3765
3477
  });
3766
3478
  }
3767
- __name(AmazonTitanEmbedding, "AmazonTitanEmbedding");
3768
3479
 
3769
3480
  // src/embedding/output/OpenAiEmbedding.ts
3770
3481
  function OpenAiEmbedding(result, config) {
@@ -3785,7 +3496,6 @@ function OpenAiEmbedding(result, config) {
3785
3496
  embedding
3786
3497
  });
3787
3498
  }
3788
- __name(OpenAiEmbedding, "OpenAiEmbedding");
3789
3499
 
3790
3500
  // src/embedding/output/getEmbeddingOutputParser.ts
3791
3501
  function getEmbeddingOutputParser(config, response) {
@@ -3798,14 +3508,16 @@ function getEmbeddingOutputParser(config, response) {
3798
3508
  throw new Error("Unsupported provider");
3799
3509
  }
3800
3510
  }
3801
- __name(getEmbeddingOutputParser, "getEmbeddingOutputParser");
3802
3511
 
3803
3512
  // src/embedding/embedding.call.ts
3804
3513
  async function createEmbedding_call(state, _input, _options) {
3805
3514
  const config = getEmbeddingConfig(state.key);
3806
- const input = mapBody(config.mapBody, Object.assign({}, state, {
3807
- input: _input
3808
- }));
3515
+ const input = mapBody(
3516
+ config.mapBody,
3517
+ Object.assign({}, state, {
3518
+ input: _input
3519
+ })
3520
+ );
3809
3521
  const body = JSON.stringify(input);
3810
3522
  const url = replaceTemplateStringSimple(config.endpoint, state);
3811
3523
  const headers = await parseHeaders(config, state, {
@@ -3820,21 +3532,19 @@ async function createEmbedding_call(state, _input, _options) {
3820
3532
  });
3821
3533
  return getEmbeddingOutputParser(state, request);
3822
3534
  }
3823
- __name(createEmbedding_call, "createEmbedding_call");
3824
3535
 
3825
3536
  // src/embedding/embedding.ts
3826
3537
  function createEmbedding(provider, options) {
3827
3538
  const config = getEmbeddingConfig(provider);
3828
3539
  return apiRequestWrapper(config, options, createEmbedding_call);
3829
3540
  }
3830
- __name(createEmbedding, "createEmbedding");
3831
3541
 
3832
3542
  // src/prompt/_base.ts
3833
- var _BasePrompt = class _BasePrompt {
3543
+ var BasePrompt = class {
3834
3544
  /**
3835
- * constructor description
3836
- * @param initialPromptMessage An initial message to add to the prompt.
3837
- */
3545
+ * constructor description
3546
+ * @param initialPromptMessage An initial message to add to the prompt.
3547
+ */
3838
3548
  constructor(initialPromptMessage, options) {
3839
3549
  __publicField(this, "type", "text");
3840
3550
  __publicField(this, "messages", []);
@@ -3868,11 +3578,11 @@ var _BasePrompt = class _BasePrompt {
3868
3578
  }
3869
3579
  }
3870
3580
  /**
3871
- * addToPrompt description
3872
- * @param content The message content
3873
- * @param role The role of the user. Defaults to system for base text prompt.
3874
- * @return instance of BasePrompt.
3875
- */
3581
+ * addToPrompt description
3582
+ * @param content The message content
3583
+ * @param role The role of the user. Defaults to system for base text prompt.
3584
+ * @return instance of BasePrompt.
3585
+ */
3876
3586
  addToPrompt(content, role = "system") {
3877
3587
  if (content) {
3878
3588
  switch (role) {
@@ -3885,10 +3595,10 @@ var _BasePrompt = class _BasePrompt {
3885
3595
  return this;
3886
3596
  }
3887
3597
  /**
3888
- * addSystemMessage description
3889
- * @param content The message content
3890
- * @return returns BasePrompt so it can be chained.
3891
- */
3598
+ * addSystemMessage description
3599
+ * @param content The message content
3600
+ * @return returns BasePrompt so it can be chained.
3601
+ */
3892
3602
  addSystemMessage(content) {
3893
3603
  this.messages.push({
3894
3604
  role: "system",
@@ -3897,58 +3607,62 @@ var _BasePrompt = class _BasePrompt {
3897
3607
  return this;
3898
3608
  }
3899
3609
  /**
3900
- * registerPartial description
3901
- * @param partialOrPartials Additional partials that can be made available to the template parser.
3902
- * @return BasePrompt so it can be chained.
3903
- */
3610
+ * registerPartial description
3611
+ * @param partialOrPartials Additional partials that can be made available to the template parser.
3612
+ * @return BasePrompt so it can be chained.
3613
+ */
3904
3614
  registerPartial(partialOrPartials) {
3905
- const partials2 = Array.isArray(partialOrPartials) ? partialOrPartials : [
3906
- partialOrPartials
3907
- ];
3615
+ const partials2 = Array.isArray(partialOrPartials) ? partialOrPartials : [partialOrPartials];
3908
3616
  this.partials.push(...partials2);
3909
3617
  return this;
3910
3618
  }
3911
3619
  /**
3912
- * registerHelpers description
3913
- * @param helperOrHelpers Additional helper functions that can be made available to the template parser.
3914
- * @return BasePrompt so it can be chained.
3915
- */
3620
+ * registerHelpers description
3621
+ * @param helperOrHelpers Additional helper functions that can be made available to the template parser.
3622
+ * @return BasePrompt so it can be chained.
3623
+ */
3916
3624
  registerHelpers(helperOrHelpers) {
3917
- const helpers = Array.isArray(helperOrHelpers) ? helperOrHelpers : [
3918
- helperOrHelpers
3919
- ];
3625
+ const helpers = Array.isArray(helperOrHelpers) ? helperOrHelpers : [helperOrHelpers];
3920
3626
  this.helpers.push(...helpers);
3921
3627
  return this;
3922
3628
  }
3923
3629
  /**
3924
- * format description
3925
- * @param values The message content
3926
- * @param separator The separator between messages. defaults to "\n\n"
3927
- * @return returns messages formatted with template replacement
3928
- */
3630
+ * format description
3631
+ * @param values The message content
3632
+ * @param separator The separator between messages. defaults to "\n\n"
3633
+ * @return returns messages formatted with template replacement
3634
+ */
3929
3635
  format(values, separator = "\n\n") {
3930
3636
  const replacements = this.getReplacements(values);
3931
3637
  const messages = this.messages.map((message) => {
3932
- return message.content && !Array.isArray(message.content) ? this.replaceTemplateString(this.runPromptFilter(message.content, this.filters.pre, values), replacements, {
3933
- partials: this.partials,
3934
- helpers: this.helpers
3935
- }) : "";
3638
+ return message.content && !Array.isArray(message.content) ? this.replaceTemplateString(
3639
+ this.runPromptFilter(message.content, this.filters.pre, values),
3640
+ replacements,
3641
+ {
3642
+ partials: this.partials,
3643
+ helpers: this.helpers
3644
+ }
3645
+ ) : "";
3936
3646
  }).join(separator);
3937
3647
  return this.runPromptFilter(messages, this.filters.post, values);
3938
3648
  }
3939
3649
  /**
3940
- * format description
3941
- * @param values The message content
3942
- * @param separator The separator between messages. defaults to "\n\n"
3943
- * @return returns messages formatted with template replacement
3944
- */
3650
+ * format description
3651
+ * @param values The message content
3652
+ * @param separator The separator between messages. defaults to "\n\n"
3653
+ * @return returns messages formatted with template replacement
3654
+ */
3945
3655
  async formatAsync(values, separator = "\n\n") {
3946
3656
  const replacements = this.getReplacements(values);
3947
3657
  const _messages = await Promise.all(this.messages.map((message) => {
3948
- return message.content && !Array.isArray(message.content) ? this.replaceTemplateStringAsync(this.runPromptFilter(message.content, this.filters.pre, values), replacements, {
3949
- partials: this.partials,
3950
- helpers: this.helpers
3951
- }) : "";
3658
+ return message.content && !Array.isArray(message.content) ? this.replaceTemplateStringAsync(
3659
+ this.runPromptFilter(message.content, this.filters.pre, values),
3660
+ replacements,
3661
+ {
3662
+ partials: this.partials,
3663
+ helpers: this.helpers
3664
+ }
3665
+ ) : "";
3952
3666
  }));
3953
3667
  const messages = _messages.join(separator);
3954
3668
  return this.runPromptFilter(messages, this.filters.post, values);
@@ -3962,33 +3676,31 @@ var _BasePrompt = class _BasePrompt {
3962
3676
  }
3963
3677
  getReplacements(values) {
3964
3678
  const { input = "", ...restOfValues } = values;
3965
- const replacements = Object.assign({}, {
3966
- ...restOfValues
3967
- }, {
3968
- input,
3969
- _input: input
3970
- });
3679
+ const replacements = Object.assign(
3680
+ {},
3681
+ { ...restOfValues },
3682
+ {
3683
+ input,
3684
+ _input: input
3685
+ }
3686
+ );
3971
3687
  return replacements;
3972
3688
  }
3973
3689
  /**
3974
- * validate description
3975
- * @return {boolean} Returns false if the template is not valid.
3976
- */
3690
+ * validate description
3691
+ * @return {boolean} Returns false if the template is not valid.
3692
+ */
3977
3693
  validate() {
3978
3694
  return true;
3979
3695
  }
3980
3696
  };
3981
- __name(_BasePrompt, "BasePrompt");
3982
- var BasePrompt = _BasePrompt;
3983
3697
 
3984
3698
  // src/prompt/text.ts
3985
- var _TextPrompt = class _TextPrompt extends BasePrompt {
3699
+ var TextPrompt = class extends BasePrompt {
3986
3700
  constructor(base, options) {
3987
3701
  super(base, options);
3988
3702
  }
3989
3703
  };
3990
- __name(_TextPrompt, "TextPrompt");
3991
- var TextPrompt = _TextPrompt;
3992
3704
 
3993
3705
  // src/utils/modules/unescape.ts
3994
3706
  function unescape(str) {
@@ -4002,13 +3714,10 @@ function unescape(str) {
4002
3714
  const entityRegex = /&amp;|&lt;|&gt;|&quot;|&#39;/g;
4003
3715
  return str.replace(entityRegex, (m) => map[m]);
4004
3716
  }
4005
- __name(unescape, "unescape");
4006
3717
 
4007
3718
  // src/utils/modules/extractPromptPlaceholderToken.ts
4008
3719
  function extractPromptPlaceholderToken(tok) {
4009
- if (!tok) return {
4010
- token: ""
4011
- };
3720
+ if (!tok) return { token: "" };
4012
3721
  const token = tok.replace(/ /g, "");
4013
3722
  if (token.substring(2, 18) === ">DialogueHistory") {
4014
3723
  const matchKey = tok.match(/key=(['"`])((?:(?!\1).)*)\1/);
@@ -4035,11 +3744,8 @@ function extractPromptPlaceholderToken(tok) {
4035
3744
  };
4036
3745
  }
4037
3746
  }
4038
- return {
4039
- token: ""
4040
- };
3747
+ return { token: "" };
4041
3748
  }
4042
- __name(extractPromptPlaceholderToken, "extractPromptPlaceholderToken");
4043
3749
 
4044
3750
  // src/utils/modules/escape.ts
4045
3751
  function escape(str) {
@@ -4052,29 +3758,28 @@ function escape(str) {
4052
3758
  };
4053
3759
  return str.replace(/[&<>"']/g, (m) => map[m]);
4054
3760
  }
4055
- __name(escape, "escape");
4056
3761
 
4057
3762
  // src/prompt/chat.ts
4058
- var _ChatPrompt = class _ChatPrompt extends BasePrompt {
3763
+ var ChatPrompt = class extends BasePrompt {
4059
3764
  /**
4060
- * new `ChatPrompt`
4061
- * @param initialSystemPromptMessage (optional) An initial system message to add to the new prompt.
4062
- * @param options (optional) Options to pass in when creating the prompt.
4063
- */
3765
+ * new `ChatPrompt`
3766
+ * @param initialSystemPromptMessage (optional) An initial system message to add to the new prompt.
3767
+ * @param options (optional) Options to pass in when creating the prompt.
3768
+ */
4064
3769
  constructor(initialSystemPromptMessage, options) {
4065
3770
  super(initialSystemPromptMessage, options);
4066
3771
  /**
4067
- * @property type - Prompt type (chat)
4068
- */
3772
+ * @property type - Prompt type (chat)
3773
+ */
4069
3774
  __publicField(this, "type", "chat");
4070
3775
  /**
4071
- * @property parseUserTemplates - Whether or not to allow parsing
4072
- * user messages with the template engine. This could be a risk,
4073
- * so we only parse user messages if explicitly set.
4074
- */
4075
- __publicField(this, "parseUserTemplates", false);
4076
- if (options?.allowUnsafeUserTemplate) {
4077
- this.parseUserTemplates = true;
3776
+ * @property parseUserTemplates - Whether or not to allow parsing
3777
+ * user messages with the template engine. This could be a risk,
3778
+ * so we only parse user messages if explicitly set.
3779
+ */
3780
+ __publicField(this, "parseUserTemplates", true);
3781
+ if (typeof options?.allowUnsafeUserTemplate === "boolean") {
3782
+ this.parseUserTemplates = options?.allowUnsafeUserTemplate;
4078
3783
  }
4079
3784
  }
4080
3785
  addToPrompt(content, role, name) {
@@ -4095,21 +3800,18 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4095
3800
  break;
4096
3801
  case "function_call":
4097
3802
  assert(name, "Function message requires name");
4098
- this.addFunctionCallMessage({
4099
- name,
4100
- arguments: content
4101
- });
3803
+ this.addFunctionCallMessage({ name, arguments: content });
4102
3804
  break;
4103
3805
  }
4104
3806
  }
4105
3807
  return this;
4106
3808
  }
4107
3809
  /**
4108
- * addUserMessage Helper to add a user message to the prompt.
4109
- * @param content The message content.
4110
- * @param name (optional) The name of the user.
4111
- * @return instance of ChatPrompt.
4112
- */
3810
+ * addUserMessage Helper to add a user message to the prompt.
3811
+ * @param content The message content.
3812
+ * @param name (optional) The name of the user.
3813
+ * @return instance of ChatPrompt.
3814
+ */
4113
3815
  addUserMessage(content, name) {
4114
3816
  const message = {
4115
3817
  role: "user",
@@ -4122,10 +3824,10 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4122
3824
  return this;
4123
3825
  }
4124
3826
  /**
4125
- * addAssistantMessage Helper to add an assistant message to the prompt.
4126
- * @param content The message content.
4127
- * @return ChatPrompt so it can be chained.
4128
- */
3827
+ * addAssistantMessage Helper to add an assistant message to the prompt.
3828
+ * @param content The message content.
3829
+ * @return ChatPrompt so it can be chained.
3830
+ */
4129
3831
  addAssistantMessage(content) {
4130
3832
  this.messages.push({
4131
3833
  role: "assistant",
@@ -4134,10 +3836,10 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4134
3836
  return this;
4135
3837
  }
4136
3838
  /**
4137
- * addFunctionMessage Helper to add an assistant message to the prompt.
4138
- * @param content The message content.
4139
- * @return ChatPrompt so it can be chained.
4140
- */
3839
+ * addFunctionMessage Helper to add an assistant message to the prompt.
3840
+ * @param content The message content.
3841
+ * @return ChatPrompt so it can be chained.
3842
+ */
4141
3843
  addFunctionMessage(content, name) {
4142
3844
  this.messages.push({
4143
3845
  role: "function",
@@ -4147,10 +3849,10 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4147
3849
  return this;
4148
3850
  }
4149
3851
  /**
4150
- * addFunctionCallMessage Helper to add an assistant message to the prompt.
4151
- * @param content The message content.
4152
- * @return ChatPrompt so it can be chained.
4153
- */
3852
+ * addFunctionCallMessage Helper to add an assistant message to the prompt.
3853
+ * @param content The message content.
3854
+ * @return ChatPrompt so it can be chained.
3855
+ */
4154
3856
  addFunctionCallMessage(function_call) {
4155
3857
  if (function_call) {
4156
3858
  this.messages.push({
@@ -4165,10 +3867,10 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4165
3867
  return this;
4166
3868
  }
4167
3869
  /**
4168
- * addFromHistory Adds multiple messages at one time.
4169
- * @param history History of chat messages.
4170
- * @return ChatPrompt so it can be chained.
4171
- */
3870
+ * addFromHistory Adds multiple messages at one time.
3871
+ * @param history History of chat messages.
3872
+ * @return ChatPrompt so it can be chained.
3873
+ */
4172
3874
  addFromHistory(history) {
4173
3875
  if (history && Array.isArray(history)) {
4174
3876
  for (const message of history) {
@@ -4195,15 +3897,13 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4195
3897
  return this;
4196
3898
  }
4197
3899
  /**
4198
- * addPlaceholder description
4199
- * @param content The message content
4200
- * @return returns ChatPrompt so it can be chained.
4201
- */
3900
+ * addPlaceholder description
3901
+ * @param content The message content
3902
+ * @return returns ChatPrompt so it can be chained.
3903
+ */
4202
3904
  addChatHistoryPlaceholder(key, options) {
4203
3905
  const start = `{{> DialogueHistory `;
4204
- const params = [
4205
- `key='${String(key)}'`
4206
- ];
3906
+ const params = [`key='${String(key)}'`];
4207
3907
  const end = `}}`;
4208
3908
  if (options?.assistant) {
4209
3909
  params.push(`assistant='${options.assistant}'`);
@@ -4218,17 +3918,14 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4218
3918
  return this;
4219
3919
  }
4220
3920
  /**
4221
- * addTokenPlaceholder description
4222
- * @param content The message content
4223
- * @return returns ChatPrompt so it can be chained.
4224
- */
3921
+ * addTokenPlaceholder description
3922
+ * @param content The message content
3923
+ * @return returns ChatPrompt so it can be chained.
3924
+ */
4225
3925
  addMessagePlaceholder(content, role = "user", name) {
4226
3926
  if (content) {
4227
3927
  const start = `{{> SingleChatMessage `;
4228
- const params = [
4229
- `role='${role}'`,
4230
- `content='${escape(content)}'`
4231
- ];
3928
+ const params = [`role='${role}'`, `content='${escape(content)}'`];
4232
3929
  const end = `}}`;
4233
3930
  if (name) {
4234
3931
  params.push(`name='${name}'`);
@@ -4248,11 +3945,7 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4248
3945
  for (const message of history) {
4249
3946
  switch (message.role) {
4250
3947
  case "user": {
4251
- const m = pick(message, [
4252
- "role",
4253
- "content",
4254
- "name"
4255
- ]);
3948
+ const m = pick(message, ["role", "content", "name"]);
4256
3949
  if (user) {
4257
3950
  m["name"] = user;
4258
3951
  }
@@ -4293,19 +3986,16 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4293
3986
  return messagesOut;
4294
3987
  }
4295
3988
  /**
4296
- * format formats the stored prompt based on input values.
4297
- * Uses template engine.
4298
- * Output is intended for LLM.
4299
- * @param values input values.
4300
- * @return formatted prompt.
4301
- */
3989
+ * format formats the stored prompt based on input values.
3990
+ * Uses template engine.
3991
+ * Output is intended for LLM.
3992
+ * @param values input values.
3993
+ * @return formatted prompt.
3994
+ */
4302
3995
  format(values) {
4303
3996
  const messagesOut = [];
4304
3997
  const replacements = this.getReplacements(values);
4305
- const safeToParseTemplate = [
4306
- "assistant",
4307
- "system"
4308
- ];
3998
+ const safeToParseTemplate = ["assistant", "system"];
4309
3999
  if (this.parseUserTemplates) {
4310
4000
  safeToParseTemplate.push("user");
4311
4001
  }
@@ -4314,7 +4004,12 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4314
4004
  const tokenData = extractPromptPlaceholderToken(message.content);
4315
4005
  switch (tokenData.token) {
4316
4006
  case ">DialogueHistory": {
4317
- messagesOut.push(...this._format_placeholderDialogueHistory(tokenData, replacements));
4007
+ messagesOut.push(
4008
+ ...this._format_placeholderDialogueHistory(
4009
+ tokenData,
4010
+ replacements
4011
+ )
4012
+ );
4318
4013
  break;
4319
4014
  }
4320
4015
  case ">SingleChatMessage": {
@@ -4337,70 +4032,103 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4337
4032
  }
4338
4033
  }
4339
4034
  } else if (message.role === "function") {
4340
- messagesOut.push(Object.assign({}, message, {
4341
- content: this.replaceTemplateString(message.content, replacements, {
4342
- partials: this.partials,
4343
- helpers: this.helpers
4035
+ messagesOut.push(
4036
+ Object.assign({}, message, {
4037
+ content: this.replaceTemplateString(message.content, replacements, {
4038
+ partials: this.partials,
4039
+ helpers: this.helpers
4040
+ })
4344
4041
  })
4345
- }));
4042
+ );
4346
4043
  } else {
4347
4044
  if (safeToParseTemplate.includes(message.role)) {
4348
4045
  if (Array.isArray(message.content)) {
4349
- const content = message.content.map((m) => m.text ? {
4350
- type: "text",
4351
- text: this.runPromptFilter(this.replaceTemplateString(this.runPromptFilter(m.text, this.filters.pre, values), replacements, {
4352
- partials: this.partials,
4353
- helpers: this.helpers
4354
- }), this.filters.post, values)
4355
- } : m);
4356
- messagesOut.push(Object.assign({}, message, {
4357
- content
4358
- }));
4046
+ const content = message.content.map(
4047
+ (m) => m.text ? {
4048
+ type: "text",
4049
+ text: this.runPromptFilter(
4050
+ this.replaceTemplateString(
4051
+ this.runPromptFilter(m.text, this.filters.pre, values),
4052
+ replacements,
4053
+ {
4054
+ partials: this.partials,
4055
+ helpers: this.helpers
4056
+ }
4057
+ ),
4058
+ this.filters.post,
4059
+ values
4060
+ )
4061
+ } : m
4062
+ );
4063
+ messagesOut.push(Object.assign({}, message, { content }));
4359
4064
  } else if (message.content) {
4360
- const content = this.runPromptFilter(this.replaceTemplateString(this.runPromptFilter(message.content, this.filters.pre, values), replacements, {
4361
- partials: this.partials,
4362
- helpers: this.helpers
4363
- }), this.filters.post, values);
4364
- messagesOut.push(Object.assign({}, message, {
4365
- content
4366
- }));
4065
+ const content = this.runPromptFilter(
4066
+ this.replaceTemplateString(
4067
+ this.runPromptFilter(message.content, this.filters.pre, values),
4068
+ replacements,
4069
+ {
4070
+ partials: this.partials,
4071
+ helpers: this.helpers
4072
+ }
4073
+ ),
4074
+ this.filters.post,
4075
+ values
4076
+ );
4077
+ messagesOut.push(Object.assign({}, message, { content }));
4367
4078
  } else {
4368
- messagesOut.push(Object.assign({}, message, {
4369
- content: null
4370
- }));
4079
+ messagesOut.push(Object.assign({}, message, { content: null }));
4371
4080
  }
4372
4081
  } else {
4373
- messagesOut.push(Object.assign({}, message, {
4374
- content: Array.isArray(message.content) ? message.content.map((m) => m.text ? {
4375
- type: "text",
4376
- text: this.runPromptFilter(this.runPromptFilter(m.text, this.filters.pre, values), this.filters.post, values)
4377
- } : m) : message.content && !Array.isArray(message.content) ? this.runPromptFilter(this.runPromptFilter(message.content, this.filters.pre, values), this.filters.post, values) : null
4378
- }));
4082
+ messagesOut.push(
4083
+ Object.assign({}, message, {
4084
+ content: Array.isArray(message.content) ? message.content.map(
4085
+ (m) => m.text ? {
4086
+ type: "text",
4087
+ text: this.runPromptFilter(
4088
+ this.runPromptFilter(
4089
+ m.text,
4090
+ this.filters.pre,
4091
+ values
4092
+ ),
4093
+ this.filters.post,
4094
+ values
4095
+ )
4096
+ } : m
4097
+ ) : message.content && !Array.isArray(message.content) ? this.runPromptFilter(
4098
+ this.runPromptFilter(
4099
+ message.content,
4100
+ this.filters.pre,
4101
+ values
4102
+ ),
4103
+ this.filters.post,
4104
+ values
4105
+ ) : null
4106
+ })
4107
+ );
4379
4108
  }
4380
4109
  }
4381
4110
  }
4382
4111
  return messagesOut;
4383
4112
  }
4384
4113
  /**
4385
- * format formats the stored prompt based on input values.
4386
- * Uses template engine.
4387
- * Output is intended for LLM.
4388
- * @param values input values.
4389
- * @return formatted prompt.
4390
- */
4114
+ * format formats the stored prompt based on input values.
4115
+ * Uses template engine.
4116
+ * Output is intended for LLM.
4117
+ * @param values input values.
4118
+ * @return formatted prompt.
4119
+ */
4391
4120
  async formatAsync(values) {
4392
4121
  const messagesOut = [];
4393
4122
  const replacements = this.getReplacements(values);
4394
- const safeToParseTemplate = [
4395
- "assistant",
4396
- "system"
4397
- ];
4123
+ const safeToParseTemplate = ["assistant", "system"];
4398
4124
  if (this.parseUserTemplates) {
4399
4125
  safeToParseTemplate.push("user");
4400
4126
  }
4401
4127
  for (const message of this.messages) {
4402
4128
  if (message.role === "placeholder") {
4403
- const { token, ...data } = extractPromptPlaceholderToken(message.content);
4129
+ const { token, ...data } = extractPromptPlaceholderToken(
4130
+ message.content
4131
+ );
4404
4132
  switch (token) {
4405
4133
  case ">DialogueHistory": {
4406
4134
  const { key = "", user } = data;
@@ -4409,11 +4137,7 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4409
4137
  for (const message2 of history) {
4410
4138
  switch (message2.role) {
4411
4139
  case "user": {
4412
- const m = pick(message2, [
4413
- "role",
4414
- "content",
4415
- "name"
4416
- ]);
4140
+ const m = pick(message2, ["role", "content", "name"]);
4417
4141
  if (user) {
4418
4142
  m["name"] = user;
4419
4143
  }
@@ -4459,10 +4183,14 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4459
4183
  const message2 = {
4460
4184
  role,
4461
4185
  name,
4462
- content: await this.replaceTemplateStringAsync(content, replacements, {
4463
- partials: this.partials,
4464
- helpers: this.helpers
4465
- })
4186
+ content: await this.replaceTemplateStringAsync(
4187
+ content,
4188
+ replacements,
4189
+ {
4190
+ partials: this.partials,
4191
+ helpers: this.helpers
4192
+ }
4193
+ )
4466
4194
  };
4467
4195
  if (!name || role !== "user") {
4468
4196
  delete message2.name;
@@ -4473,12 +4201,18 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4473
4201
  }
4474
4202
  }
4475
4203
  } else if (message.role === "function") {
4476
- messagesOut.push(Object.assign({}, message, {
4477
- content: await this.replaceTemplateStringAsync(message.content, replacements, {
4478
- partials: this.partials,
4479
- helpers: this.helpers
4204
+ messagesOut.push(
4205
+ Object.assign({}, message, {
4206
+ content: await this.replaceTemplateStringAsync(
4207
+ message.content,
4208
+ replacements,
4209
+ {
4210
+ partials: this.partials,
4211
+ helpers: this.helpers
4212
+ }
4213
+ )
4480
4214
  })
4481
- }));
4215
+ );
4482
4216
  } else {
4483
4217
  if (safeToParseTemplate.includes(message.role)) {
4484
4218
  if (Array.isArray(message.content)) {
@@ -4489,10 +4223,14 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4489
4223
  type: "text",
4490
4224
  text: this.runPromptFilter(
4491
4225
  // HERE
4492
- await this.replaceTemplateStringAsync(this.runPromptFilter(m.text, this.filters.pre, values), replacements, {
4493
- partials: this.partials,
4494
- helpers: this.helpers
4495
- }),
4226
+ await this.replaceTemplateStringAsync(
4227
+ this.runPromptFilter(m.text, this.filters.pre, values),
4228
+ replacements,
4229
+ {
4230
+ partials: this.partials,
4231
+ helpers: this.helpers
4232
+ }
4233
+ ),
4496
4234
  this.filters.post,
4497
4235
  values
4498
4236
  )
@@ -4501,45 +4239,65 @@ var _ChatPrompt = class _ChatPrompt extends BasePrompt {
4501
4239
  content.push(m);
4502
4240
  }
4503
4241
  }
4504
- messagesOut.push(Object.assign({}, message, {
4505
- content
4506
- }));
4242
+ messagesOut.push(Object.assign({}, message, { content }));
4507
4243
  } else if (message.content) {
4508
- const content = this.runPromptFilter(await this.replaceTemplateStringAsync(this.runPromptFilter(message.content, this.filters.pre, values), replacements, {
4509
- partials: this.partials,
4510
- helpers: this.helpers
4511
- }), this.filters.post, values);
4512
- messagesOut.push(Object.assign({}, message, {
4513
- content
4514
- }));
4244
+ const content = this.runPromptFilter(
4245
+ await this.replaceTemplateStringAsync(
4246
+ this.runPromptFilter(message.content, this.filters.pre, values),
4247
+ replacements,
4248
+ {
4249
+ partials: this.partials,
4250
+ helpers: this.helpers
4251
+ }
4252
+ ),
4253
+ this.filters.post,
4254
+ values
4255
+ );
4256
+ messagesOut.push(Object.assign({}, message, { content }));
4515
4257
  } else {
4516
- messagesOut.push(Object.assign({}, message, {
4517
- content: null
4518
- }));
4258
+ messagesOut.push(Object.assign({}, message, { content: null }));
4519
4259
  }
4520
4260
  } else {
4521
- messagesOut.push(Object.assign({}, message, {
4522
- content: Array.isArray(message.content) ? message.content.map((m) => m.text ? {
4523
- type: "text",
4524
- text: this.runPromptFilter(this.runPromptFilter(m.text, this.filters.pre, values), this.filters.post, values)
4525
- } : m) : message.content && !Array.isArray(message.content) ? this.runPromptFilter(this.runPromptFilter(message.content, this.filters.pre, values), this.filters.post, values) : null
4526
- }));
4261
+ messagesOut.push(
4262
+ Object.assign({}, message, {
4263
+ content: Array.isArray(message.content) ? message.content.map(
4264
+ (m) => m.text ? {
4265
+ type: "text",
4266
+ text: this.runPromptFilter(
4267
+ this.runPromptFilter(
4268
+ m.text,
4269
+ this.filters.pre,
4270
+ values
4271
+ ),
4272
+ this.filters.post,
4273
+ values
4274
+ )
4275
+ } : m
4276
+ ) : message.content && !Array.isArray(message.content) ? this.runPromptFilter(
4277
+ this.runPromptFilter(
4278
+ message.content,
4279
+ this.filters.pre,
4280
+ values
4281
+ ),
4282
+ this.filters.post,
4283
+ values
4284
+ ) : null
4285
+ })
4286
+ );
4527
4287
  }
4528
4288
  }
4529
4289
  }
4530
4290
  return messagesOut;
4531
4291
  }
4532
4292
  /**
4533
- * validate Ensures there are not unresolved tokens in prompt.
4534
- * @TODO Make this work!
4535
- * @return Returns false if the template is not valid.
4536
- */
4293
+ * validate Ensures there are not unresolved tokens in prompt.
4294
+ * @TODO Make this work!
4295
+ * @return Returns false if the template is not valid.
4296
+ */
4537
4297
  validate() {
4538
4298
  return true;
4539
4299
  }
4540
4300
  };
4541
- __name(_ChatPrompt, "ChatPrompt");
4542
- var ChatPrompt = _ChatPrompt;
4543
4301
 
4544
4302
  // src/prompt/_functions.ts
4545
4303
  function createPrompt(type, initialPromptMessage, options) {
@@ -4550,14 +4308,12 @@ function createPrompt(type, initialPromptMessage, options) {
4550
4308
  return new TextPrompt(initialPromptMessage);
4551
4309
  }
4552
4310
  }
4553
- __name(createPrompt, "createPrompt");
4554
4311
  function createChatPrompt(initialSystemPromptMessage, options) {
4555
4312
  return new ChatPrompt(initialSystemPromptMessage, options);
4556
4313
  }
4557
- __name(createChatPrompt, "createChatPrompt");
4558
4314
 
4559
4315
  // src/state/item.ts
4560
- var _BaseStateItem = class _BaseStateItem {
4316
+ var BaseStateItem = class {
4561
4317
  constructor(key, initialValue) {
4562
4318
  __publicField(this, "key");
4563
4319
  __publicField(this, "value");
@@ -4567,7 +4323,10 @@ var _BaseStateItem = class _BaseStateItem {
4567
4323
  this.initialValue = initialValue;
4568
4324
  }
4569
4325
  setValue(value) {
4570
- assert(typeof value === typeof this.value, `Invalid value type. Expected ${typeof this.value}, received ${typeof value}`);
4326
+ assert(
4327
+ typeof value === typeof this.value,
4328
+ `Invalid value type. Expected ${typeof this.value}, received ${typeof value}`
4329
+ );
4571
4330
  this.value = value;
4572
4331
  }
4573
4332
  getKey() {
@@ -4591,19 +4350,18 @@ var _BaseStateItem = class _BaseStateItem {
4591
4350
  value: this.serializeValue()
4592
4351
  };
4593
4352
  }
4353
+ // deserialize() {}
4594
4354
  };
4595
- __name(_BaseStateItem, "BaseStateItem");
4596
- var BaseStateItem = _BaseStateItem;
4597
- var _DefaultStateItem = class _DefaultStateItem extends BaseStateItem {
4355
+ var DefaultStateItem = class extends BaseStateItem {
4598
4356
  constructor(name, defaultValue) {
4599
4357
  super(name, defaultValue);
4600
4358
  }
4359
+ // serialize() { return {}; }
4360
+ // deserialize() {}
4601
4361
  };
4602
- __name(_DefaultStateItem, "DefaultStateItem");
4603
- var DefaultStateItem = _DefaultStateItem;
4604
4362
 
4605
4363
  // src/state/dialogue.ts
4606
- var _Dialogue = class _Dialogue extends BaseStateItem {
4364
+ var Dialogue = class extends BaseStateItem {
4607
4365
  constructor(name) {
4608
4366
  super(name, []);
4609
4367
  __publicField(this, "name");
@@ -4651,6 +4409,12 @@ var _Dialogue = class _Dialogue extends BaseStateItem {
4651
4409
  return this;
4652
4410
  }
4653
4411
  setFunctionCallMessage(input) {
4412
+ if (!input?.function_call) {
4413
+ throw new LlmExeError(`Invalid arguments`, "state", {
4414
+ error: `Invalid arguments: missing required function_call`,
4415
+ module: "dialogue"
4416
+ });
4417
+ }
4654
4418
  this.value.push({
4655
4419
  role: "assistant",
4656
4420
  function_call: {
@@ -4699,17 +4463,14 @@ var _Dialogue = class _Dialogue extends BaseStateItem {
4699
4463
  return {
4700
4464
  class: "Dialogue",
4701
4465
  name: this.name,
4702
- value: [
4703
- ...this.value
4704
- ]
4466
+ value: [...this.value]
4705
4467
  };
4706
4468
  }
4469
+ // deserialize() {}
4707
4470
  };
4708
- __name(_Dialogue, "Dialogue");
4709
- var Dialogue = _Dialogue;
4710
4471
 
4711
4472
  // src/state/_base.ts
4712
- var _BaseState = class _BaseState {
4473
+ var BaseState = class {
4713
4474
  constructor() {
4714
4475
  __publicField(this, "dialogues", {});
4715
4476
  __publicField(this, "attributes", {});
@@ -4734,8 +4495,14 @@ var _BaseState = class _BaseState {
4734
4495
  return dialogue;
4735
4496
  }
4736
4497
  createContextItem(item) {
4737
- assert(item instanceof BaseStateItem, "Invalid context item. Must be instance of BaseStateItem");
4738
- assert(!this.context[item?.getKey()], `key (${item?.getKey()}) already exists`);
4498
+ assert(
4499
+ item instanceof BaseStateItem,
4500
+ "Invalid context item. Must be instance of BaseStateItem"
4501
+ );
4502
+ assert(
4503
+ !this.context[item?.getKey()],
4504
+ `key (${item?.getKey()}) already exists`
4505
+ );
4739
4506
  this.context[item.getKey()] = item;
4740
4507
  return this.context[item.getKey()];
4741
4508
  }
@@ -4757,14 +4524,16 @@ var _BaseState = class _BaseState {
4757
4524
  serialize() {
4758
4525
  const dialogues = {};
4759
4526
  const context = {};
4760
- const attributes = {
4761
- ...this.attributes
4762
- };
4763
- const dialogueKeys = Object.keys(this.dialogues);
4527
+ const attributes = { ...this.attributes };
4528
+ const dialogueKeys = Object.keys(
4529
+ this.dialogues
4530
+ );
4764
4531
  for (const dialogueKey of dialogueKeys) {
4765
4532
  dialogues[dialogueKey] = this.dialogues[dialogueKey].serialize();
4766
4533
  }
4767
- const contextKeys = Object.keys(this.context);
4534
+ const contextKeys = Object.keys(
4535
+ this.context
4536
+ );
4768
4537
  for (const contextKey of contextKeys) {
4769
4538
  context[contextKey] = this.context[contextKey].serialize();
4770
4539
  }
@@ -4775,9 +4544,7 @@ var _BaseState = class _BaseState {
4775
4544
  };
4776
4545
  }
4777
4546
  };
4778
- __name(_BaseState, "BaseState");
4779
- var BaseState = _BaseState;
4780
- var _DefaultState = class _DefaultState extends BaseState {
4547
+ var DefaultState = class extends BaseState {
4781
4548
  constructor() {
4782
4549
  super();
4783
4550
  }
@@ -4785,22 +4552,17 @@ var _DefaultState = class _DefaultState extends BaseState {
4785
4552
  console.log("Save not implemented in default state.");
4786
4553
  }
4787
4554
  };
4788
- __name(_DefaultState, "DefaultState");
4789
- var DefaultState = _DefaultState;
4790
4555
 
4791
4556
  // src/state/_functions.ts
4792
4557
  function createState() {
4793
4558
  return new DefaultState();
4794
4559
  }
4795
- __name(createState, "createState");
4796
4560
  function createDialogue(name) {
4797
4561
  return new Dialogue(name);
4798
4562
  }
4799
- __name(createDialogue, "createDialogue");
4800
4563
  function createStateItem(name, defaultValue) {
4801
4564
  return new DefaultStateItem(name, defaultValue);
4802
4565
  }
4803
- __name(createStateItem, "createStateItem");
4804
4566
  export {
4805
4567
  BaseExecutor,
4806
4568
  BaseParser,
@@ -4811,6 +4573,8 @@ export {
4811
4573
  DefaultState,
4812
4574
  DefaultStateItem,
4813
4575
  LlmExecutorOpenAiFunctions,
4576
+ LlmExecutorWithFunctions,
4577
+ LlmNativeFunctionParser,
4814
4578
  OpenAiFunctionParser,
4815
4579
  TextPrompt,
4816
4580
  createCallableExecutor,
@@ -4820,10 +4584,14 @@ export {
4820
4584
  createDialogue,
4821
4585
  createEmbedding,
4822
4586
  createLlmExecutor,
4587
+ createLlmFunctionExecutor,
4823
4588
  createParser,
4824
4589
  createPrompt,
4825
4590
  createState,
4826
4591
  createStateItem,
4592
+ defineSchema,
4593
+ registerHelpers,
4594
+ registerPartials,
4827
4595
  useExecutors,
4828
4596
  useLlm,
4829
4597
  utils_exports as utils