@digipair/skill-dsp 0.88.3 → 0.88.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs.js +340 -817
  2. package/index.esm.js +344 -821
  3. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1,5 +1,4 @@
1
- import crypto$6, { createHash } from 'crypto';
2
- import { TransformStream, ReadableStream, TextDecoderStream } from 'stream/web';
1
+ import { TransformStream, ReadableStream as ReadableStream$1, TextDecoderStream } from 'stream/web';
3
2
  import require$$2$3 from 'child_process';
4
3
  import require$$0$4 from 'fs';
5
4
  import require$$1$2 from 'https';
@@ -19,11 +18,18 @@ import require$$0$5 from 'node:events';
19
18
  import require$$1$6 from 'node:process';
20
19
  import require$$2$2 from 'node:util';
21
20
  import require$$3 from 'path';
22
- import require$$0$6 from 'buffer';
23
- import require$$0$7 from 'events';
24
- import 'process';
25
- import 'vm';
26
- import 'readline';
21
+ import require$$0$6, { createHash } from 'crypto';
22
+ import require$$0$7 from 'buffer';
23
+ import require$$0$8 from 'events';
24
+ import { ReadableStream } from 'node:stream/web';
25
+ import 'node:fs';
26
+ import 'node:crypto';
27
+ import 'node:http';
28
+ import 'node:https';
29
+ import 'node:os';
30
+ import 'node:vm';
31
+ import 'node:child_process';
32
+ import 'node:readline';
27
33
 
28
34
  function _extends() {
29
35
  _extends = Object.assign || function assign(target) {
@@ -23945,14 +23951,14 @@ function indent(str, spaces) {
23945
23951
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23946
23952
  // match is required
23947
23953
  if (!match) {
23948
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
23954
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23949
23955
  v: nextMatch1
23950
23956
  };
23951
23957
  }
23952
23958
  var token = match.token, offset = match.offset;
23953
23959
  i1 += offset;
23954
23960
  if (token === " ") {
23955
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23961
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23956
23962
  }
23957
23963
  tokens1 = _to_consumable_array$5(tokens1).concat([
23958
23964
  token
@@ -23971,7 +23977,7 @@ function indent(str, spaces) {
23971
23977
  if (contextKeys.some(function(el) {
23972
23978
  return el.startsWith(name);
23973
23979
  })) {
23974
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23980
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23975
23981
  }
23976
23982
  if (dateTimeIdentifiers.some(function(el) {
23977
23983
  return el === name;
@@ -23990,9 +23996,9 @@ function indent(str, spaces) {
23990
23996
  if (dateTimeIdentifiers.some(function(el) {
23991
23997
  return el.startsWith(name);
23992
23998
  })) {
23993
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23999
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23994
24000
  }
23995
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
24001
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23996
24002
  v: nextMatch1
23997
24003
  };
23998
24004
  };
@@ -120848,7 +120854,7 @@ Object.defineProperty(crypto$3, "__esModule", {
120848
120854
  value: true
120849
120855
  });
120850
120856
  crypto$3.NodeCrypto = void 0;
120851
- var crypto$2 = crypto$6;
120857
+ var crypto$2 = require$$0$6;
120852
120858
  var NodeCrypto = /*#__PURE__*/ function() {
120853
120859
  function NodeCrypto() {
120854
120860
  _class_call_check$r(this, NodeCrypto);
@@ -121347,7 +121353,7 @@ var safeBuffer = {
121347
121353
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
121348
121354
 
121349
121355
  (function (module, exports) {
121350
- /* eslint-disable node/no-deprecated-api */ var buffer = require$$0$6;
121356
+ /* eslint-disable node/no-deprecated-api */ var buffer = require$$0$7;
121351
121357
  var Buffer = buffer.Buffer;
121352
121358
  // alternative to using Object.keys for old browsers
121353
121359
  function copyProps(src, dst) {
@@ -121821,7 +121827,7 @@ Object.defineProperty(exports, "__esModule", {
121821
121827
  value: true
121822
121828
  });
121823
121829
  exports.AuthClient = exports.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS = exports.DEFAULT_UNIVERSE = void 0;
121824
- var events_1 = require$$0$7;
121830
+ var events_1 = require$$0$8;
121825
121831
  var gaxios_1 = src$3;
121826
121832
  var transporters_1 = transporters;
121827
121833
  var util_1 = util$4;
@@ -124648,8 +124654,8 @@ DataStream$2.prototype.end = function end(data) {
124648
124654
  var dataStream = DataStream$2;
124649
124655
 
124650
124656
  /*jshint node:true */
124651
- var Buffer$5 = require$$0$6.Buffer; // browserify
124652
- var SlowBuffer = require$$0$6.SlowBuffer;
124657
+ var Buffer$5 = require$$0$7.Buffer; // browserify
124658
+ var SlowBuffer = require$$0$7.SlowBuffer;
124653
124659
  var bufferEqualConstantTime = bufferEq;
124654
124660
  function bufferEq(a, b) {
124655
124661
  // shortcutting on type is necessary for correctness
@@ -124682,7 +124688,7 @@ bufferEq.restore = function() {
124682
124688
 
124683
124689
  var bufferEqual = bufferEqualConstantTime;
124684
124690
  var Buffer$4 = safeBuffer.exports.Buffer;
124685
- var crypto$1 = crypto$6;
124691
+ var crypto$1 = require$$0$6;
124686
124692
  var formatEcdsa = ecdsaSigFormatter;
124687
124693
  var util$2 = require$$5;
124688
124694
  var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".';
@@ -124890,7 +124896,7 @@ var jwa$2 = function jwa(algorithm) {
124890
124896
 
124891
124897
  /*global module*/
124892
124898
 
124893
- var Buffer$3 = require$$0$6.Buffer;
124899
+ var Buffer$3 = require$$0$7.Buffer;
124894
124900
  var tostring = function toString(obj) {
124895
124901
  if (typeof obj === "string") return obj;
124896
124902
  if (typeof obj === "number" || Buffer$3.isBuffer(obj)) return obj.toString();
@@ -143467,7 +143473,7 @@ var AxAIServiceError = (_Symbol_for = Symbol.for("nodejs.util.inspect.custom"),
143467
143473
  _this.responseBody = responseBody;
143468
143474
  _this.name = _this.constructor.name;
143469
143475
  _this.timestamp = /* @__PURE__ */ new Date().toISOString();
143470
- _this.errorId = crypto$6.randomUUID();
143476
+ _this.errorId = crypto.randomUUID();
143471
143477
  _this.context = context3;
143472
143478
  _this.stack = _this.toString();
143473
143479
  return _this;
@@ -143565,7 +143571,7 @@ var AxAIServiceTimeoutError = /*#__PURE__*/ function(AxAIServiceError) {
143565
143571
  function AxAIServiceTimeoutError(url, timeoutMs, requestBody, context3) {
143566
143572
  _class_call_check(this, AxAIServiceTimeoutError);
143567
143573
  var _this;
143568
- _this = _super.call(this, "Request timed out after ".concat(timeoutMs, "ms"), url, requestBody, void 0, _object_spread({
143574
+ _this = _super.call(this, "Request timeout after ".concat(timeoutMs, "ms"), url, requestBody, void 0, _object_spread({
143569
143575
  timeoutMs: timeoutMs
143570
143576
  }, context3));
143571
143577
  _this.name = _this.constructor.name;
@@ -143573,20 +143579,6 @@ var AxAIServiceTimeoutError = /*#__PURE__*/ function(AxAIServiceError) {
143573
143579
  }
143574
143580
  return AxAIServiceTimeoutError;
143575
143581
  }(AxAIServiceError);
143576
- var AxAIServiceAbortedError = /*#__PURE__*/ function(AxAIServiceError) {
143577
- _inherits(AxAIServiceAbortedError, AxAIServiceError);
143578
- var _super = _create_super(AxAIServiceAbortedError);
143579
- function AxAIServiceAbortedError(url, reason, requestBody, context3) {
143580
- _class_call_check(this, AxAIServiceAbortedError);
143581
- var _this;
143582
- _this = _super.call(this, "Request aborted".concat(reason ? ": ".concat(reason) : ""), url, requestBody, void 0, _object_spread({
143583
- abortReason: reason
143584
- }, context3));
143585
- _this.name = _this.constructor.name;
143586
- return _this;
143587
- }
143588
- return AxAIServiceAbortedError;
143589
- }(AxAIServiceError);
143590
143582
  var AxAIServiceAuthenticationError = /*#__PURE__*/ function(AxAIServiceError) {
143591
143583
  _inherits(AxAIServiceAuthenticationError, AxAIServiceError);
143592
143584
  var _super = _create_super(AxAIServiceAuthenticationError);
@@ -143625,31 +143617,13 @@ var apiCall = function() {
143625
143617
  switch(_state.label){
143626
143618
  case 0:
143627
143619
  _loop = function() {
143628
- var combinedAbortController, userAbortHandler, originalAbort, _api_fetch, res, _api_span, delay, _api_span1, resJson, isValid, lastChunk, chunkCount, trackingStream, closed, error, _api_span2, _api_abortSignal, _api_span3, delay1;
143620
+ var controller, _api_fetch, res, _api_span, delay, _api_span1, resJson, isValid, lastChunk, chunkCount, trackingStream, closed, error, _api_span2, _api_span3, delay1;
143629
143621
  return _ts_generator(this, function(_state) {
143630
143622
  switch(_state.label){
143631
143623
  case 0:
143632
- combinedAbortController = new AbortController();
143633
- if (api.abortSignal) {
143634
- if (api.abortSignal.aborted) {
143635
- throw new AxAIServiceAbortedError(apiUrl.href, api.abortSignal.reason, json, {
143636
- metrics: metrics
143637
- });
143638
- }
143639
- userAbortHandler = function() {
143640
- combinedAbortController.abort(api.abortSignal.reason || "User aborted request");
143641
- };
143642
- api.abortSignal.addEventListener("abort", userAbortHandler, {
143643
- once: true
143644
- });
143645
- originalAbort = combinedAbortController.abort.bind(combinedAbortController);
143646
- combinedAbortController.abort = function(reason) {
143647
- api.abortSignal.removeEventListener("abort", userAbortHandler);
143648
- originalAbort(reason);
143649
- };
143650
- }
143624
+ controller = new AbortController();
143651
143625
  timeoutId = setTimeout(function() {
143652
- combinedAbortController.abort("Request timeout");
143626
+ controller.abort("Request timeout");
143653
143627
  }, timeoutMs);
143654
143628
  _state.label = 1;
143655
143629
  case 1:
@@ -143669,7 +143643,7 @@ var apiCall = function() {
143669
143643
  "X-Retry-Count": attempt.toString()
143670
143644
  }, api.headers),
143671
143645
  body: JSON.stringify(json),
143672
- signal: combinedAbortController.signal
143646
+ signal: controller.signal
143673
143647
  })
143674
143648
  ];
143675
143649
  case 2:
@@ -143759,13 +143733,13 @@ var apiCall = function() {
143759
143733
  lastChunk = void 0;
143760
143734
  chunkCount = 0;
143761
143735
  trackingStream = new TransformStream({
143762
- transform: function transform(chunk, controller) {
143736
+ transform: function transform(chunk, controller2) {
143763
143737
  var _api_span;
143764
143738
  lastChunk = chunk;
143765
143739
  chunkCount++;
143766
143740
  metrics.streamChunks = chunkCount;
143767
143741
  metrics.lastChunkTime = Date.now();
143768
- controller.enqueue(chunk);
143742
+ controller2.enqueue(chunk);
143769
143743
  (_api_span = api.span) === null || _api_span === void 0 ? void 0 : _api_span.addEvent("stream.chunk", {
143770
143744
  "stream.chunks": chunkCount,
143771
143745
  "stream.duration": Date.now() - metrics.startTime,
@@ -143777,8 +143751,8 @@ var apiCall = function() {
143777
143751
  return [
143778
143752
  2,
143779
143753
  {
143780
- v: new ReadableStream({
143781
- start: function start(controller) {
143754
+ v: new ReadableStream$1({
143755
+ start: function start(controller2) {
143782
143756
  var reader = res.body.pipeThrough(new textDecoderStream()).pipeThrough(new SSEParser()).pipeThrough(trackingStream).getReader();
143783
143757
  function read() {
143784
143758
  return _read.apply(this, arguments);
@@ -143806,7 +143780,7 @@ var apiCall = function() {
143806
143780
  if (done) {
143807
143781
  if (!closed) {
143808
143782
  closed = true;
143809
- controller.close();
143783
+ controller2.close();
143810
143784
  }
143811
143785
  return [
143812
143786
  3,
@@ -143817,7 +143791,7 @@ var apiCall = function() {
143817
143791
  3,
143818
143792
  3
143819
143793
  ];
143820
- controller.enqueue(value);
143794
+ controller2.enqueue(value);
143821
143795
  return [
143822
143796
  3,
143823
143797
  1
@@ -143834,16 +143808,16 @@ var apiCall = function() {
143834
143808
  streamDuration: Date.now() - metrics.startTime
143835
143809
  });
143836
143810
  if (_$error.name === "AbortError" || ((_error_message = _$error.message) === null || _error_message === void 0 ? void 0 : _error_message.includes("aborted"))) {
143837
- controller.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
143811
+ controller2.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
143838
143812
  streamMetrics: streamMetrics
143839
143813
  }));
143840
143814
  } else if (_instanceof(_$error, TypeError) && _$error.message.includes("cancelled")) {
143841
- controller.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
143815
+ controller2.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
143842
143816
  streamMetrics: streamMetrics,
143843
143817
  cancelReason: "Stream cancelled by client"
143844
143818
  }));
143845
143819
  } else {
143846
- controller.error(new AxAIServiceNetworkError(_$error, apiUrl.href, json, res.body, {
143820
+ controller2.error(new AxAIServiceNetworkError(_$error, apiUrl.href, json, res.body, {
143847
143821
  streamMetrics: streamMetrics
143848
143822
  }));
143849
143823
  }
@@ -143875,15 +143849,9 @@ var apiCall = function() {
143875
143849
  case 9:
143876
143850
  error = _state.sent();
143877
143851
  if (_instanceof(error, Error) && error.name === "AbortError") {
143878
- if ((_api_abortSignal = api.abortSignal) === null || _api_abortSignal === void 0 ? void 0 : _api_abortSignal.aborted) {
143879
- throw new AxAIServiceAbortedError(apiUrl.href, api.abortSignal.reason, json, {
143880
- metrics: metrics
143881
- });
143882
- } else {
143883
- throw new AxAIServiceTimeoutError(apiUrl.href, timeoutMs, json, {
143884
- metrics: metrics
143885
- });
143886
- }
143852
+ throw new AxAIServiceTimeoutError(apiUrl.href, timeoutMs, json, {
143853
+ metrics: metrics
143854
+ });
143887
143855
  }
143888
143856
  if ((_api_span2 = api.span) === null || _api_span2 === void 0 ? void 0 : _api_span2.isRecording()) {
143889
143857
  api.span.recordException(error);
@@ -143947,7 +143915,7 @@ var apiCall = function() {
143947
143915
  api.name
143948
143916
  ].filter(Boolean).join("/").replace(/\/+/g, "/")).concat(baseUrl.search);
143949
143917
  apiUrl = new URL(apiPath, baseUrl);
143950
- requestId = crypto$6.randomUUID();
143918
+ requestId = crypto.randomUUID();
143951
143919
  if (!api.validateRequest) return [
143952
143920
  3,
143953
143921
  2
@@ -144121,66 +144089,31 @@ var ColorLog = /*#__PURE__*/ function() {
144121
144089
  }();
144122
144090
  // ai/debug.ts
144123
144091
  var colorLog = new ColorLog();
144124
- var defaultOutput = function(message) {
144125
- process.stdout.write(message);
144126
- };
144127
- var createDefaultLogger = function() {
144128
- var output = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultOutput;
144129
- return function(message, options) {
144130
- var _options_tags;
144131
- var tags = (_options_tags = options === null || options === void 0 ? void 0 : options.tags) !== null && _options_tags !== void 0 ? _options_tags : [];
144132
- var formattedMessage = message;
144133
- if (tags.includes("error")) {
144134
- formattedMessage = colorLog.red(formattedMessage);
144135
- } else if (tags.includes("success") || tags.includes("responseContent")) {
144136
- formattedMessage = colorLog.greenBright(formattedMessage);
144137
- } else if (tags.includes("functionName")) {
144138
- formattedMessage = colorLog.whiteBright(formattedMessage);
144139
- } else if (tags.includes("functionArg") || tags.includes("systemContent") || tags.includes("assistantContent")) {
144140
- formattedMessage = colorLog.blueBright(formattedMessage);
144141
- } else if (tags.includes("warning") || tags.includes("discovery")) {
144142
- formattedMessage = colorLog.yellow(formattedMessage);
144143
- }
144144
- if (tags.includes("responseStart") || tags.includes("systemStart") || tags.includes("userStart")) {
144145
- formattedMessage = "\n".concat(formattedMessage);
144146
- } else if (tags.includes("responseEnd") || tags.includes("systemEnd") || tags.includes("userEnd")) {
144147
- formattedMessage = "".concat(formattedMessage, "\n");
144148
- } else if (tags.includes("assistantStart")) {
144149
- formattedMessage = "\n".concat(formattedMessage, "\n");
144150
- } else if (tags.includes("error")) {
144151
- formattedMessage = "\n".concat(formattedMessage, "\n");
144152
- } else if (tags.includes("functionEnd")) {
144153
- formattedMessage = "".concat(formattedMessage, "\n");
144154
- }
144155
- output(formattedMessage);
144156
- };
144157
- };
144158
- var defaultLogger = createDefaultLogger();
144159
144092
  var formatChatMessage = function(msg, hideContent, hideSystemPrompt) {
144160
144093
  switch(msg.role){
144161
144094
  case "system":
144162
144095
  if (hideSystemPrompt) {
144163
144096
  return "";
144164
144097
  }
144165
- return "\nSystem:\n".concat(msg.content);
144098
+ return "\n".concat(colorLog.blueBright("System:"), "\n").concat(colorLog.whiteBright(msg.content));
144166
144099
  case "function":
144167
- return "\nFunction Result:\n".concat(msg.result);
144100
+ return "\n".concat(colorLog.blueBright("Function Result:"), "\n").concat(colorLog.whiteBright(msg.result));
144168
144101
  case "user":
144169
144102
  {
144170
144103
  if (typeof msg.content === "string") {
144171
- return "\nUser:\n".concat(msg.content);
144104
+ return "\n".concat(colorLog.blueBright("User:"), "\n").concat(colorLog.whiteBright(msg.content));
144172
144105
  }
144173
144106
  var items = msg.content.map(function(v) {
144174
144107
  switch(v.type){
144175
144108
  case "text":
144176
- return v.text;
144109
+ return "".concat(colorLog.whiteBright(v.text));
144177
144110
  case "image":
144178
- return "(Image, ".concat(v.mimeType, ") ").concat(v.image.substring(0, 10));
144111
+ return "(Image, ".concat(v.mimeType, ") ").concat(colorLog.whiteBright(v.image.substring(0, 10)));
144179
144112
  default:
144180
144113
  throw new Error("Invalid content type");
144181
144114
  }
144182
144115
  });
144183
- return "\nUser:\n".concat(items.join("\n"));
144116
+ return "\n".concat(colorLog.blueBright("User:"), "\n").concat(items.join("\n"));
144184
144117
  }
144185
144118
  case "assistant":
144186
144119
  {
@@ -144191,106 +144124,46 @@ var formatChatMessage = function(msg, hideContent, hideSystemPrompt) {
144191
144124
  var args = typeof fn.params !== "string" ? JSON.stringify(fn.params, null, 2) : fn.params;
144192
144125
  return "".concat(fn.name, "(").concat(args, ")");
144193
144126
  });
144194
- return "\nFunctions:\n".concat(fns.join("\n"));
144127
+ return "\n".concat(colorLog.blueBright("\nFunctions:"), "\n").concat(colorLog.whiteBright(fns.join("\n")));
144195
144128
  }
144196
144129
  var _msg_content;
144197
- return "\nAssistant:\n".concat(hideContent ? "" : (_msg_content = msg.content) !== null && _msg_content !== void 0 ? _msg_content : "<empty>");
144130
+ return "\n".concat(colorLog.blueBright("\nAssistant:"), "\n").concat(hideContent ? "" : colorLog.whiteBright((_msg_content = msg.content) !== null && _msg_content !== void 0 ? _msg_content : "<empty>"));
144198
144131
  }
144199
144132
  default:
144200
144133
  throw new Error("Invalid role");
144201
144134
  }
144202
144135
  };
144203
144136
  var logChatRequestMessage = function(msg, hideSystemPrompt) {
144204
- var logger = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultLogger;
144205
- var formattedMessage = formatChatMessage(msg, false, hideSystemPrompt);
144206
- if (formattedMessage) {
144207
- var tags = msg.role === "system" ? [
144208
- "systemStart",
144209
- "systemContent"
144210
- ] : msg.role === "function" ? [
144211
- "functionName"
144212
- ] : msg.role === "user" ? [
144213
- "userStart",
144214
- "userContent"
144215
- ] : [];
144216
- logger(formattedMessage, {
144217
- tags: tags
144218
- });
144219
- }
144220
- logger("Assistant:", {
144221
- tags: [
144222
- "assistantStart"
144223
- ]
144224
- });
144137
+ process.stdout.write("".concat(formatChatMessage(msg, hideSystemPrompt), "\n"));
144138
+ process.stdout.write(colorLog.blueBright("\nAssistant:\n"));
144225
144139
  };
144226
144140
  var logChatRequest = function(chatPrompt, hideSystemPrompt) {
144227
- var logger = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultLogger;
144228
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
144229
- try {
144230
- for(var _iterator = (chatPrompt !== null && chatPrompt !== void 0 ? chatPrompt : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
144231
- var msg = _step.value;
144232
- var formattedMessage = formatChatMessage(msg, false, hideSystemPrompt);
144233
- if (formattedMessage) {
144234
- var tags = msg.role === "system" ? [
144235
- "systemContent"
144236
- ] : msg.role === "function" ? [
144237
- "functionName"
144238
- ] : msg.role === "user" ? [
144239
- "userContent"
144240
- ] : [];
144241
- logger(formattedMessage, {
144242
- tags: tags
144243
- });
144244
- }
144245
- }
144246
- } catch (err) {
144247
- _didIteratorError = true;
144248
- _iteratorError = err;
144249
- } finally{
144250
- try {
144251
- if (!_iteratorNormalCompletion && _iterator.return != null) {
144252
- _iterator.return();
144253
- }
144254
- } finally{
144255
- if (_didIteratorError) {
144256
- throw _iteratorError;
144257
- }
144258
- }
144259
- }
144260
- logger("Assistant:", {
144261
- tags: [
144262
- "assistantStart"
144263
- ]
144141
+ var items = chatPrompt === null || chatPrompt === void 0 ? void 0 : chatPrompt.map(function(msg) {
144142
+ return formatChatMessage(msg, hideSystemPrompt);
144264
144143
  });
144144
+ if (items) {
144145
+ process.stdout.write(items.join("\n"));
144146
+ process.stdout.write(colorLog.blueBright("\nAssistant:\n"));
144147
+ }
144265
144148
  };
144266
144149
  var logResponseResult = function(r) {
144267
- var logger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogger;
144268
144150
  if (r.content) {
144269
- logger(r.content, {
144270
- tags: [
144271
- "responseContent"
144272
- ]
144273
- });
144151
+ process.stdout.write(colorLog.greenBright(r.content));
144274
144152
  }
144275
- if (r.functionCalls && r.functionCalls.length > 0) {
144153
+ if (r.functionCalls) {
144276
144154
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
144277
144155
  try {
144278
144156
  for(var _iterator = r.functionCalls.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
144279
144157
  var _step_value = _sliced_to_array(_step.value, 2), i = _step_value[0], f = _step_value[1];
144280
144158
  if (f.function.name) {
144281
- logger("[".concat(i + 1, "] ").concat(f.function.name), {
144282
- tags: [
144283
- "functionName"
144284
- ]
144285
- });
144159
+ if (i > 0) {
144160
+ process.stdout.write("\n");
144161
+ }
144162
+ process.stdout.write("Function ".concat(i + 1, " -> ").concat(colorLog.greenBright(f.function.name)));
144286
144163
  }
144287
144164
  if (f.function.params) {
144288
144165
  var params = typeof f.function.params === "string" ? f.function.params : JSON.stringify(f.function.params, null, 2);
144289
- logger(params, {
144290
- tags: [
144291
- "functionArg"
144292
- ]
144293
- });
144166
+ process.stdout.write("".concat(colorLog.greenBright(params)));
144294
144167
  }
144295
144168
  }
144296
144169
  } catch (err) {
@@ -144307,15 +144180,9 @@ var logResponseResult = function(r) {
144307
144180
  }
144308
144181
  }
144309
144182
  }
144310
- logger("", {
144311
- tags: [
144312
- "functionEnd"
144313
- ]
144314
- });
144315
144183
  }
144316
144184
  };
144317
144185
  var logResponse = function(resp) {
144318
- var logger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogger;
144319
144186
  if (!resp.results) {
144320
144187
  return;
144321
144188
  }
@@ -144323,7 +144190,7 @@ var logResponse = function(resp) {
144323
144190
  try {
144324
144191
  for(var _iterator = resp.results[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
144325
144192
  var r = _step.value;
144326
- logResponseResult(r, logger);
144193
+ logResponseResult(r);
144327
144194
  }
144328
144195
  } catch (err) {
144329
144196
  _didIteratorError = true;
@@ -144341,24 +144208,17 @@ var logResponse = function(resp) {
144341
144208
  }
144342
144209
  };
144343
144210
  var logResponseDelta = function(delta) {
144344
- var logger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogger;
144345
- logger(delta, {
144346
- tags: [
144347
- "responseContent"
144348
- ]
144349
- });
144211
+ process.stdout.write(colorLog.greenBright(delta));
144350
144212
  };
144351
144213
  // ai/base.ts
144352
144214
  var axBaseAIDefaultConfig = function() {
144353
144215
  return structuredClone({
144216
+ maxTokens: 2e3,
144354
144217
  temperature: 0,
144355
144218
  topK: 40,
144356
144219
  topP: 0.9
144357
144220
  });
144358
144221
  };
144359
- var defaultLogger2 = function(message, _options) {
144360
- process.stdout.write(message);
144361
- };
144362
144222
  var AxBaseAI = /*#__PURE__*/ function() {
144363
144223
  function AxBaseAI(aiImpl, param) {
144364
144224
  var name = param.name, apiURL = param.apiURL, headers = param.headers, modelInfo = param.modelInfo, defaults = param.defaults, _param_options = param.options, options = _param_options === void 0 ? {} : _param_options, supportFor = param.supportFor, models = param.models;
@@ -144370,8 +144230,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
144370
144230
  _define_property(this, "timeout", void 0);
144371
144231
  _define_property(this, "excludeContentFromTrace", void 0);
144372
144232
  _define_property(this, "models", void 0);
144373
- _define_property(this, "abortSignal", void 0);
144374
- _define_property(this, "logger", defaultLogger2);
144375
144233
  _define_property(this, "modelInfo", void 0);
144376
144234
  _define_property(this, "modelUsage", void 0);
144377
144235
  _define_property(this, "embedModelUsage", void 0);
@@ -144421,7 +144279,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144421
144279
  this.tracer = options.tracer;
144422
144280
  this.modelInfo = modelInfo;
144423
144281
  this.models = models;
144424
- this.id = crypto$6.randomUUID();
144282
+ this.id = crypto.randomUUID();
144425
144283
  var _this_getModel;
144426
144284
  var model = (_this_getModel = this.getModel(defaults.model)) !== null && _this_getModel !== void 0 ? _this_getModel : defaults.model;
144427
144285
  var _this_getEmbedModel;
@@ -144473,9 +144331,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
144473
144331
  this.timeout = options.timeout;
144474
144332
  this.tracer = options.tracer;
144475
144333
  this.excludeContentFromTrace = options.excludeContentFromTrace;
144476
- this.abortSignal = options.abortSignal;
144477
- var _options_logger;
144478
- this.logger = (_options_logger = options.logger) !== null && _options_logger !== void 0 ? _options_logger : defaultLogger2;
144479
144334
  }
144480
144335
  },
144481
144336
  {
@@ -144487,18 +144342,10 @@ var AxBaseAI = /*#__PURE__*/ function() {
144487
144342
  fetch: this.fetch,
144488
144343
  tracer: this.tracer,
144489
144344
  timeout: this.timeout,
144490
- excludeContentFromTrace: this.excludeContentFromTrace,
144491
- abortSignal: this.abortSignal,
144492
- logger: this.logger
144345
+ excludeContentFromTrace: this.excludeContentFromTrace
144493
144346
  };
144494
144347
  }
144495
144348
  },
144496
- {
144497
- key: "getLogger",
144498
- value: function getLogger() {
144499
- return this.logger;
144500
- }
144501
- },
144502
144349
  {
144503
144350
  key: "getModelList",
144504
144351
  value: function getModelList() {
@@ -144675,7 +144522,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144675
144522
  value: function _chat1(req, options) {
144676
144523
  var _this = this;
144677
144524
  return _async_to_generator(function() {
144678
- var _this_getModel, _ref, model, modelConfig, _ref1, canStream, _modelConfig_stopSequences, _modelConfig_maxTokens, _modelConfig_topP, _modelConfig_topK, _modelConfig_frequencyPenalty, _modelConfig_presencePenalty, _modelConfig_stopSequences_join, _modelConfig_stream, _options_traceContext, _obj;
144525
+ var _this_getModel, _ref, model, modelConfig, _ref1, canStream, _modelConfig_stopSequences, _options_traceContext, _obj;
144679
144526
  return _ts_generator(this, function(_state) {
144680
144527
  switch(_state.label){
144681
144528
  case 0:
@@ -144684,9 +144531,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
144684
144531
  if ((options === null || options === void 0 ? void 0 : options.thinkingTokenBudget) && !_this.getFeatures(model).hasThinkingBudget) {
144685
144532
  throw new Error("Model ".concat(model, " does not support thinkingTokenBudget."));
144686
144533
  }
144687
- if ((options === null || options === void 0 ? void 0 : options.showThoughts) && !_this.getFeatures(model).hasShowThoughts) {
144688
- throw new Error("Model ".concat(model, " does not support showThoughts."));
144689
- }
144690
144534
  modelConfig.stream = (_ref1 = (options === null || options === void 0 ? void 0 : options.stream) !== void 0 ? options.stream : modelConfig.stream) !== null && _ref1 !== void 0 ? _ref1 : true;
144691
144535
  canStream = _this.getFeatures(model).streaming;
144692
144536
  if (!canStream) {
@@ -144700,7 +144544,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144700
144544
  4,
144701
144545
  _this.tracer.startActiveSpan("AI Chat Request", {
144702
144546
  kind: SpanKind.SERVER,
144703
- attributes: (_obj = {}, _define_property(_obj, axSpanAttributes.LLM_SYSTEM, _this.name), _define_property(_obj, axSpanAttributes.LLM_OPERATION_NAME, "chat"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MODEL, model), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MAX_TOKENS, (_modelConfig_maxTokens = modelConfig.maxTokens) !== null && _modelConfig_maxTokens !== void 0 ? _modelConfig_maxTokens : "Not set"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TEMPERATURE, modelConfig.temperature), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TOP_P, (_modelConfig_topP = modelConfig.topP) !== null && _modelConfig_topP !== void 0 ? _modelConfig_topP : "Not set"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TOP_K, (_modelConfig_topK = modelConfig.topK) !== null && _modelConfig_topK !== void 0 ? _modelConfig_topK : "Not set"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_FREQUENCY_PENALTY, (_modelConfig_frequencyPenalty = modelConfig.frequencyPenalty) !== null && _modelConfig_frequencyPenalty !== void 0 ? _modelConfig_frequencyPenalty : "Not set"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_PRESENCE_PENALTY, (_modelConfig_presencePenalty = modelConfig.presencePenalty) !== null && _modelConfig_presencePenalty !== void 0 ? _modelConfig_presencePenalty : "Not set"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_STOP_SEQUENCES, (_modelConfig_stopSequences_join = (_modelConfig_stopSequences = modelConfig.stopSequences) === null || _modelConfig_stopSequences === void 0 ? void 0 : _modelConfig_stopSequences.join(", ")) !== null && _modelConfig_stopSequences_join !== void 0 ? _modelConfig_stopSequences_join : "Not set"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_LLM_IS_STREAMING, (_modelConfig_stream = modelConfig.stream) !== null && _modelConfig_stream !== void 0 ? _modelConfig_stream : "Not set"), _obj)
144547
+ attributes: (_obj = {}, _define_property(_obj, axSpanAttributes.LLM_SYSTEM, _this.name), _define_property(_obj, axSpanAttributes.LLM_OPERATION_NAME, "chat"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MODEL, model), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MAX_TOKENS, modelConfig.maxTokens), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TEMPERATURE, modelConfig.temperature), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TOP_P, modelConfig.topP), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TOP_K, modelConfig.topK), _define_property(_obj, axSpanAttributes.LLM_REQUEST_FREQUENCY_PENALTY, modelConfig.frequencyPenalty), _define_property(_obj, axSpanAttributes.LLM_REQUEST_PRESENCE_PENALTY, modelConfig.presencePenalty), _define_property(_obj, axSpanAttributes.LLM_REQUEST_STOP_SEQUENCES, (_modelConfig_stopSequences = modelConfig.stopSequences) === null || _modelConfig_stopSequences === void 0 ? void 0 : _modelConfig_stopSequences.join(", ")), _define_property(_obj, axSpanAttributes.LLM_REQUEST_LLM_IS_STREAMING, modelConfig.stream), _obj)
144704
144548
  }, (_options_traceContext = options === null || options === void 0 ? void 0 : options.traceContext) !== null && _options_traceContext !== void 0 ? _options_traceContext : context.active(), function() {
144705
144549
  var _ref = _async_to_generator(function(span) {
144706
144550
  return _ts_generator(this, function(_state) {
@@ -144769,7 +144613,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144769
144613
  value: function _chat2(model, modelConfig, chatReq, options, span) {
144770
144614
  var _this = this;
144771
144615
  return _async_to_generator(function() {
144772
- var _options_debug, debug, functions, req, fn, _options_logger, _options_rateLimiter, rt, rv, _tmp, respFn, wrappedRespFn, doneCb, st, res, tokenUsage, _options_logger1;
144616
+ var _options_debug, debug, functions, req, fn, _options_rateLimiter, rt, rv, _tmp, respFn, wrappedRespFn, doneCb, st, res, tokenUsage;
144773
144617
  return _ts_generator(this, function(_state) {
144774
144618
  switch(_state.label){
144775
144619
  case 0:
@@ -144791,7 +144635,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144791
144635
  _this.lastUsedModelConfig = modelConfig;
144792
144636
  fn = function() {
144793
144637
  var _ref = _async_to_generator(function() {
144794
- var _this_aiImpl_createChatReq, apiConfig, reqValue, _options_abortSignal, res2, _tmp;
144638
+ var _this_aiImpl_createChatReq, apiConfig, reqValue, res2, _tmp;
144795
144639
  return _ts_generator(this, function(_state) {
144796
144640
  switch(_state.label){
144797
144641
  case 0:
@@ -144811,7 +144655,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144811
144655
  return [
144812
144656
  4,
144813
144657
  apiCall.apply(void 0, [
144814
- (_tmp.headers = _state.sent(), _tmp.stream = modelConfig.stream, _tmp.timeout = _this.timeout, _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.span = span, _tmp.abortSignal = (_options_abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal) !== null && _options_abortSignal !== void 0 ? _options_abortSignal : _this.abortSignal, _tmp),
144658
+ (_tmp.headers = _state.sent(), _tmp.stream = modelConfig.stream, _tmp.timeout = _this.timeout, _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.span = span, _tmp),
144815
144659
  reqValue
144816
144660
  ])
144817
144661
  ];
@@ -144829,7 +144673,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144829
144673
  };
144830
144674
  }();
144831
144675
  if (debug) {
144832
- logChatRequest(req.chatPrompt, options === null || options === void 0 ? void 0 : options.debugHideSystemPrompt, (_options_logger = options === null || options === void 0 ? void 0 : options.logger) !== null && _options_logger !== void 0 ? _options_logger : _this.logger);
144676
+ logChatRequest(req.chatPrompt, options === null || options === void 0 ? void 0 : options.debugHideSystemPrompt);
144833
144677
  }
144834
144678
  rt = (_options_rateLimiter = options === null || options === void 0 ? void 0 : options.rateLimiter) !== null && _options_rateLimiter !== void 0 ? _options_rateLimiter : _this.rt;
144835
144679
  if (!rt) return [
@@ -144867,6 +144711,13 @@ var AxBaseAI = /*#__PURE__*/ function() {
144867
144711
  return function(resp) {
144868
144712
  var res2 = respFn(resp, state);
144869
144713
  res2.sessionId = options === null || options === void 0 ? void 0 : options.sessionId;
144714
+ if (options === null || options === void 0 ? void 0 : options.hideThought) {
144715
+ res2.results.forEach(function(result) {
144716
+ if (result.thought) {
144717
+ result.thought = void 0;
144718
+ }
144719
+ });
144720
+ }
144870
144721
  if (!res2.modelUsage) {
144871
144722
  res2.modelUsage = {
144872
144723
  ai: _this.name,
@@ -144879,23 +144730,16 @@ var AxBaseAI = /*#__PURE__*/ function() {
144879
144730
  setChatResponseEvents(res2, span, _this.excludeContentFromTrace);
144880
144731
  }
144881
144732
  if (debug) {
144882
- var _options_logger;
144883
- logResponse(res2, (_options_logger = options === null || options === void 0 ? void 0 : options.logger) !== null && _options_logger !== void 0 ? _options_logger : _this.logger);
144733
+ logResponse(res2);
144884
144734
  }
144885
144735
  return res2;
144886
144736
  };
144887
144737
  };
144888
144738
  doneCb = function() {
144889
144739
  var _ref = _async_to_generator(function(_values) {
144890
- var _options_logger, logger;
144891
144740
  return _ts_generator(this, function(_state) {
144892
144741
  if (debug) {
144893
- logger = (_options_logger = options === null || options === void 0 ? void 0 : options.logger) !== null && _options_logger !== void 0 ? _options_logger : _this.logger;
144894
- logger("", {
144895
- tags: [
144896
- "responseEnd"
144897
- ]
144898
- });
144742
+ process.stdout.write("\n");
144899
144743
  }
144900
144744
  if (span === null || span === void 0 ? void 0 : span.isRecording()) {
144901
144745
  span.end();
@@ -144920,6 +144764,13 @@ var AxBaseAI = /*#__PURE__*/ function() {
144920
144764
  }
144921
144765
  res = _this.aiImpl.createChatResp(rv);
144922
144766
  res.sessionId = options === null || options === void 0 ? void 0 : options.sessionId;
144767
+ if (options === null || options === void 0 ? void 0 : options.hideThought) {
144768
+ res.results.forEach(function(result) {
144769
+ if (result.thought) {
144770
+ result.thought = void 0;
144771
+ }
144772
+ });
144773
+ }
144923
144774
  if (!res.modelUsage) {
144924
144775
  tokenUsage = _this.aiImpl.getTokenUsage();
144925
144776
  if (tokenUsage) {
@@ -144938,14 +144789,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
144938
144789
  span.end();
144939
144790
  }
144940
144791
  if (debug) {
144941
- logResponse(res, (_options_logger1 = options === null || options === void 0 ? void 0 : options.logger) !== null && _options_logger1 !== void 0 ? _options_logger1 : _this.logger);
144942
- }
144943
- if (debug) {
144944
- _this.logger("", {
144945
- tags: [
144946
- "responseEnd"
144947
- ]
144948
- });
144792
+ logResponse(res);
144949
144793
  }
144950
144794
  return [
144951
144795
  2,
@@ -145079,7 +144923,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
145079
144923
  _this.lastUsedEmbedModel = embedModel;
145080
144924
  fn = function() {
145081
144925
  var _ref = _async_to_generator(function() {
145082
- var _this_aiImpl_createEmbedReq, apiConfig, reqValue, _options_abortSignal, res2, _tmp;
144926
+ var _this_aiImpl_createEmbedReq, apiConfig, reqValue, res2, _tmp;
145083
144927
  return _ts_generator(this, function(_state) {
145084
144928
  switch(_state.label){
145085
144929
  case 0:
@@ -145096,7 +144940,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
145096
144940
  return [
145097
144941
  4,
145098
144942
  apiCall.apply(void 0, [
145099
- (_tmp.headers = _state.sent(), _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.timeout = _this.timeout, _tmp.span = span, _tmp.abortSignal = (_options_abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal) !== null && _options_abortSignal !== void 0 ? _options_abortSignal : _this.abortSignal, _tmp),
144943
+ (_tmp.headers = _state.sent(), _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.timeout = _this.timeout, _tmp.span = span, _tmp),
145100
144944
  reqValue
145101
144945
  ])
145102
144946
  ];
@@ -145336,40 +145180,50 @@ function setChatResponseEvents(res, span, excludeContentFromTrace) {
145336
145180
  if (!res.results) {
145337
145181
  return;
145338
145182
  }
145339
- for(var index = 0; index < res.results.length; index++){
145340
- var _result_functionCalls, _result_functionCalls1;
145341
- var result = res.results[index];
145342
- if (!result) {
145343
- continue;
145344
- }
145345
- if (!result.content && !result.thought && !((_result_functionCalls = result.functionCalls) === null || _result_functionCalls === void 0 ? void 0 : _result_functionCalls.length) && !result.finishReason) {
145346
- continue;
145183
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
145184
+ try {
145185
+ for(var _iterator = res.results.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
145186
+ var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], result = _step_value[1];
145187
+ var _result_functionCalls;
145188
+ var toolCalls = (_result_functionCalls = result.functionCalls) === null || _result_functionCalls === void 0 ? void 0 : _result_functionCalls.map(function(call) {
145189
+ return {
145190
+ id: call.id,
145191
+ type: call.type,
145192
+ function: call.function.name,
145193
+ arguments: call.function.params
145194
+ };
145195
+ });
145196
+ var message = {};
145197
+ if (toolCalls && toolCalls.length > 0) {
145198
+ if (!excludeContentFromTrace) {
145199
+ message.content = result.content;
145200
+ }
145201
+ message.tool_calls = toolCalls;
145202
+ } else {
145203
+ if (!excludeContentFromTrace) {
145204
+ var _result_content;
145205
+ message.content = (_result_content = result.content) !== null && _result_content !== void 0 ? _result_content : "";
145206
+ }
145207
+ }
145208
+ span.addEvent(axSpanEvents.GEN_AI_CHOICE, {
145209
+ finish_reason: result.finishReason,
145210
+ index: index,
145211
+ message: JSON.stringify(message, null, 2)
145212
+ });
145347
145213
  }
145348
- var toolCalls = (_result_functionCalls1 = result.functionCalls) === null || _result_functionCalls1 === void 0 ? void 0 : _result_functionCalls1.map(function(call) {
145349
- return {
145350
- id: call.id,
145351
- type: call.type,
145352
- function: call.function.name,
145353
- arguments: call.function.params
145354
- };
145355
- });
145356
- var message = {};
145357
- if (toolCalls && toolCalls.length > 0) {
145358
- if (!excludeContentFromTrace) {
145359
- message.content = result.content;
145214
+ } catch (err) {
145215
+ _didIteratorError = true;
145216
+ _iteratorError = err;
145217
+ } finally{
145218
+ try {
145219
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
145220
+ _iterator.return();
145360
145221
  }
145361
- message.tool_calls = toolCalls;
145362
- } else {
145363
- if (!excludeContentFromTrace) {
145364
- var _result_content;
145365
- message.content = (_result_content = result.content) !== null && _result_content !== void 0 ? _result_content : "";
145222
+ } finally{
145223
+ if (_didIteratorError) {
145224
+ throw _iteratorError;
145366
145225
  }
145367
145226
  }
145368
- span.addEvent(axSpanEvents.GEN_AI_CHOICE, {
145369
- finish_reason: result.finishReason,
145370
- index: index,
145371
- message: JSON.stringify(message, null, 2)
145372
- });
145373
145227
  }
145374
145228
  }
145375
145229
  function validateModels(models) {
@@ -145478,80 +145332,50 @@ var GoogleVertexAuth = /*#__PURE__*/ function() {
145478
145332
  }();
145479
145333
  // ai/anthropic/info.ts
145480
145334
  var axModelInfoAnthropic = [
145481
- // 4
145482
- {
145483
- name: "claude-opus-4-20250514" /* Claude4Opus */ ,
145484
- currency: "usd",
145485
- promptTokenCostPer1M: 15,
145486
- completionTokenCostPer1M: 75,
145487
- maxTokens: 32e3
145488
- },
145489
- {
145490
- name: "claude-sonnet-4-20250514" /* Claude4Sonnet */ ,
145491
- currency: "usd",
145492
- promptTokenCostPer1M: 3,
145493
- completionTokenCostPer1M: 15,
145494
- maxTokens: 64e3
145495
- },
145496
- // 3.7
145497
- {
145498
- name: "claude-3-7-sonnet-latest" /* Claude37Sonnet */ ,
145499
- currency: "usd",
145500
- promptTokenCostPer1M: 3,
145501
- completionTokenCostPer1M: 15,
145502
- maxTokens: 64e3
145503
- },
145504
- // 3.5
145335
+ // 35
145505
145336
  {
145506
145337
  name: "claude-3-5-sonnet-latest" /* Claude35Sonnet */ ,
145507
145338
  currency: "usd",
145508
145339
  promptTokenCostPer1M: 3,
145509
- completionTokenCostPer1M: 15,
145510
- maxTokens: 8192
145340
+ completionTokenCostPer1M: 15
145511
145341
  },
145512
145342
  {
145513
145343
  name: "claude-3-5-haiku-latest" /* Claude35Haiku */ ,
145514
145344
  currency: "usd",
145515
145345
  promptTokenCostPer1M: 0.8,
145516
- completionTokenCostPer1M: 4,
145517
- maxTokens: 8192
145346
+ completionTokenCostPer1M: 4
145518
145347
  },
145519
145348
  // 3
145520
145349
  {
145521
145350
  name: "claude-3-opus-latest" /* Claude3Opus */ ,
145522
145351
  currency: "usd",
145523
145352
  promptTokenCostPer1M: 15,
145524
- completionTokenCostPer1M: 75,
145525
- maxTokens: 4096
145353
+ completionTokenCostPer1M: 75
145526
145354
  },
145527
145355
  {
145528
145356
  name: "claude-3-sonnet-20240229" /* Claude3Sonnet */ ,
145529
145357
  currency: "usd",
145530
145358
  promptTokenCostPer1M: 3,
145531
- completionTokenCostPer1M: 15,
145532
- maxTokens: 4096
145359
+ completionTokenCostPer1M: 15
145533
145360
  },
145534
145361
  {
145535
145362
  name: "claude-3-haiku-20240307" /* Claude3Haiku */ ,
145536
145363
  currency: "usd",
145537
145364
  promptTokenCostPer1M: 0.25,
145538
- completionTokenCostPer1M: 1.25,
145539
- maxTokens: 4096
145365
+ completionTokenCostPer1M: 1.25
145540
145366
  },
145541
- // 2.1
145367
+ // 21
145542
145368
  {
145543
145369
  name: "claude-2.1" /* Claude21 */ ,
145544
145370
  currency: "usd",
145545
145371
  promptTokenCostPer1M: 8,
145546
- completionTokenCostPer1M: 25,
145547
- maxTokens: 4096
145372
+ completionTokenCostPer1M: 25
145548
145373
  },
145549
145374
  {
145550
145375
  name: "claude-instant-1.2" /* ClaudeInstant12 */ ,
145551
145376
  currency: "usd",
145552
145377
  promptTokenCostPer1M: 0.8,
145553
- completionTokenCostPer1M: 2.24,
145554
- maxTokens: 4096
145378
+ completionTokenCostPer1M: 2.24
145555
145379
  }
145556
145380
  ];
145557
145381
  // ai/anthropic/api.ts
@@ -145635,31 +145459,18 @@ var AxAIAnthropicImpl = /*#__PURE__*/ function() {
145635
145459
  input_schema: v.parameters
145636
145460
  };
145637
145461
  });
145638
- var _req_modelConfig_maxTokens;
145639
- var maxTokens = (_req_modelConfig_maxTokens = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens;
145640
- var _req_modelConfig_stopSequences;
145641
- var stopSequences = (_req_modelConfig_stopSequences = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stopSequences;
145642
- var _req_modelConfig_temperature;
145643
- var temperature = (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : _this.config.temperature;
145644
- var _req_modelConfig_topP;
145645
- var topP = (_req_modelConfig_topP = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : _this.config.topP;
145646
- var _req_modelConfig_topK;
145647
- var topK = (_req_modelConfig_topK = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.topK) !== null && _req_modelConfig_topK !== void 0 ? _req_modelConfig_topK : _this.config.topK;
145648
- var reqValue = _object_spread_props(_object_spread({}, _this.isVertex ? {
145462
+ var _req_modelConfig_maxTokens, _req_modelConfig_stopSequences, _req_modelConfig_temperature, _req_modelConfig_topP, _req_modelConfig_topK;
145463
+ var reqValue = _object_spread_props(_object_spread(_object_spread_props(_object_spread({}, _this.isVertex ? {
145649
145464
  anthropic_version: "vertex-2023-10-16"
145650
145465
  } : {
145651
145466
  model: model
145652
- }, maxTokens ? {
145653
- max_tokens: maxTokens
145654
- } : {}, stopSequences && stopSequences.length > 0 ? {
145655
- stop_sequences: stopSequences
145656
- } : {}, temperature ? {
145657
- temperature: temperature
145658
- } : {}, topP ? {
145659
- top_p: topP
145660
- } : {}, topK ? {
145661
- top_k: topK
145662
- } : {}, toolsChoice, tools && tools.length > 0 ? {
145467
+ }), {
145468
+ max_tokens: (_req_modelConfig_maxTokens = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens,
145469
+ stop_sequences: (_req_modelConfig_stopSequences = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stopSequences,
145470
+ temperature: (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : _this.config.temperature,
145471
+ top_p: (_req_modelConfig_topP = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : _this.config.topP,
145472
+ top_k: (_req_modelConfig_topK = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.topK) !== null && _req_modelConfig_topK !== void 0 ? _req_modelConfig_topK : _this.config.topK
145473
+ }), toolsChoice, tools && tools.length > 0 ? {
145663
145474
  tools: tools
145664
145475
  } : {}, stream ? {
145665
145476
  stream: true
@@ -145850,9 +145661,8 @@ var AxAIAnthropicImpl = /*#__PURE__*/ function() {
145850
145661
  key: "getModelConfig",
145851
145662
  value: function getModelConfig() {
145852
145663
  var config = this.config;
145853
- var _config_maxTokens;
145854
145664
  return {
145855
- maxTokens: (_config_maxTokens = config.maxTokens) !== null && _config_maxTokens !== void 0 ? _config_maxTokens : 4096,
145665
+ maxTokens: config.maxTokens,
145856
145666
  temperature: config.temperature,
145857
145667
  topP: config.topP,
145858
145668
  topK: config.topK,
@@ -146285,7 +146095,7 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
146285
146095
  var _req_modelConfig_stream;
146286
146096
  var stream = (_req_modelConfig_stream = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.stream) !== null && _req_modelConfig_stream !== void 0 ? _req_modelConfig_stream : this.config.stream;
146287
146097
  var store = this.config.store;
146288
- var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_topP, _ref, _req_modelConfig_n, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
146098
+ var _req_modelConfig_maxTokens, _ref, _req_modelConfig_temperature, _req_modelConfig_topP, _ref1, _req_modelConfig_n, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
146289
146099
  var reqValue = _object_spread({
146290
146100
  model: model,
146291
146101
  messages: messages,
@@ -146294,9 +146104,9 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
146294
146104
  } : void 0,
146295
146105
  tools: tools,
146296
146106
  tool_choice: toolsChoice,
146297
- max_completion_tokens: (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : this.config.maxTokens,
146107
+ max_completion_tokens: (_ref = (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : this.config.maxTokens) !== null && _ref !== void 0 ? _ref : 500,
146298
146108
  temperature: (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : this.config.temperature,
146299
- top_p: (_ref = (_req_modelConfig_topP = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : this.config.topP) !== null && _ref !== void 0 ? _ref : 1,
146109
+ top_p: (_ref1 = (_req_modelConfig_topP = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : this.config.topP) !== null && _ref1 !== void 0 ? _ref1 : 1,
146300
146110
  n: (_req_modelConfig_n = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.n) !== null && _req_modelConfig_n !== void 0 ? _req_modelConfig_n : this.config.n,
146301
146111
  stop: (_req_modelConfig_stopSequences = (_req_modelConfig6 = req.modelConfig) === null || _req_modelConfig6 === void 0 ? void 0 : _req_modelConfig6.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : this.config.stop,
146302
146112
  presence_penalty: (_req_modelConfig_presencePenalty = (_req_modelConfig7 = req.modelConfig) === null || _req_modelConfig7 === void 0 ? void 0 : _req_modelConfig7.presencePenalty) !== null && _req_modelConfig_presencePenalty !== void 0 ? _req_modelConfig_presencePenalty : this.config.presencePenalty,
@@ -146339,9 +146149,6 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
146339
146149
  }
146340
146150
  if (config.thinkingTokenBudget) {
146341
146151
  switch(config.thinkingTokenBudget){
146342
- case "none":
146343
- reqValue.reasoning_effort = void 0;
146344
- break;
146345
146152
  case "minimal":
146346
146153
  reqValue.reasoning_effort = "low";
146347
146154
  break;
@@ -147489,9 +147296,6 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
147489
147296
  }
147490
147297
  if (config.thinkingTokenBudget) {
147491
147298
  switch(config.thinkingTokenBudget){
147492
- case "none":
147493
- thinkingConfig.thinkingBudget = 0;
147494
- break;
147495
147299
  case "minimal":
147496
147300
  thinkingConfig.thinkingBudget = 200;
147497
147301
  break;
@@ -147509,9 +147313,6 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
147509
147313
  break;
147510
147314
  }
147511
147315
  }
147512
- if (config.showThoughts !== void 0) {
147513
- thinkingConfig.includeThoughts = config.showThoughts;
147514
- }
147515
147316
  var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_topP, _req_modelConfig_topK, _req_modelConfig_frequencyPenalty, _req_modelConfig_stopSequences;
147516
147317
  var generationConfig = _object_spread({
147517
147318
  maxOutputTokens: (_req_modelConfig_maxTokens = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens,
@@ -147522,7 +147323,7 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
147522
147323
  candidateCount: 1,
147523
147324
  stopSequences: (_req_modelConfig_stopSequences = (_req_modelConfig6 = req.modelConfig) === null || _req_modelConfig6 === void 0 ? void 0 : _req_modelConfig6.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stopSequences,
147524
147325
  responseMimeType: "text/plain"
147525
- }, Object.keys(thinkingConfig).length > 0 ? {
147326
+ }, thinkingConfig ? {
147526
147327
  thinkingConfig: thinkingConfig
147527
147328
  } : {});
147528
147329
  var safetySettings2 = _this.config.safetySettings;
@@ -148243,6 +148044,7 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
148243
148044
  function AxAIMistral(param) {
148244
148045
  var apiKey = param.apiKey, config = param.config, options = param.options, models = param.models, modelInfo = param.modelInfo;
148245
148046
  _class_call_check(this, AxAIMistral);
148047
+ var _this;
148246
148048
  if (!apiKey || apiKey === "") {
148247
148049
  throw new Error("Mistral API key not set");
148248
148050
  }
@@ -148255,15 +148057,17 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
148255
148057
  hasShowThoughts: false
148256
148058
  };
148257
148059
  var chatReqUpdater = function(req) {
148258
- var max_completion_tokens = req.max_completion_tokens; req.stream_options; var result = _object_without_properties(req, [
148060
+ var max_completion_tokens = req.max_completion_tokens; req.stream_options; var messages = req.messages, result = _object_without_properties(req, [
148259
148061
  "max_completion_tokens",
148260
- "stream_options"
148062
+ "stream_options",
148063
+ "messages"
148261
148064
  ]);
148262
148065
  return _object_spread_props(_object_spread({}, result), {
148066
+ messages: _this.updateMessages(messages),
148263
148067
  max_tokens: max_completion_tokens
148264
148068
  });
148265
148069
  };
148266
- var _this = _super.call(this, {
148070
+ _this = _super.call(this, {
148267
148071
  apiKey: apiKey,
148268
148072
  config: _config,
148269
148073
  options: options,
@@ -148271,11 +148075,60 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
148271
148075
  modelInfo: modelInfo,
148272
148076
  models: models,
148273
148077
  supportFor: supportFor,
148078
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148274
148079
  chatReqUpdater: chatReqUpdater
148275
148080
  });
148276
148081
  _get((_assert_this_initialized(_this), _get_prototype_of(AxAIMistral.prototype)), "setName", _this).call(_this, "Mistral");
148277
148082
  return _this;
148278
148083
  }
148084
+ _create_class(AxAIMistral, [
148085
+ {
148086
+ key: "updateMessages",
148087
+ value: function updateMessages(messages) {
148088
+ var messagesUpdated = [];
148089
+ if (!Array.isArray(messages)) {
148090
+ return messages;
148091
+ }
148092
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
148093
+ try {
148094
+ for(var _iterator = messages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
148095
+ var message = _step.value;
148096
+ if (message.role === "user" && Array.isArray(message.content)) {
148097
+ var contentUpdated = message.content.map(function(item) {
148098
+ if (typeof item === "object" && item !== null && item.type === "image_url") {
148099
+ var _item_image_url;
148100
+ return {
148101
+ type: "image_url",
148102
+ image_url: (_item_image_url = item.image_url) === null || _item_image_url === void 0 ? void 0 : _item_image_url.url
148103
+ };
148104
+ }
148105
+ return item;
148106
+ });
148107
+ messagesUpdated.push(_object_spread_props(_object_spread({}, message), {
148108
+ content: contentUpdated
148109
+ }));
148110
+ } else {
148111
+ messagesUpdated.push(message);
148112
+ }
148113
+ }
148114
+ } catch (err) {
148115
+ _didIteratorError = true;
148116
+ _iteratorError = err;
148117
+ } finally{
148118
+ try {
148119
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
148120
+ _iterator.return();
148121
+ }
148122
+ } finally{
148123
+ if (_didIteratorError) {
148124
+ throw _iteratorError;
148125
+ }
148126
+ }
148127
+ }
148128
+ return messagesUpdated;
148129
+ }
148130
+ }
148131
+ ]);
148279
148132
  return AxAIMistral;
148280
148133
  }(AxAIOpenAIBase);
148281
148134
  // ai/ollama/api.ts
@@ -148498,7 +148351,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
148498
148351
  },
148499
148352
  {
148500
148353
  key: "createChatReq",
148501
- value: function createChatReq(req, config) {
148354
+ value: function createChatReq(req, _config) {
148502
148355
  var _req_functions, _req_modelConfig, _req_modelConfig1, _req_modelConfig2, _req_modelConfig3, _req_chatPrompt_, _req_chatPrompt_1;
148503
148356
  var model = req.model;
148504
148357
  var apiConfig = {
@@ -148543,10 +148396,6 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
148543
148396
  parameters: (_v_parameters = v.parameters) !== null && _v_parameters !== void 0 ? _v_parameters : {}
148544
148397
  };
148545
148398
  });
148546
- var includeFields = [];
148547
- if (config.showThoughts) {
148548
- includeFields.push("reasoning.encrypted_content");
148549
- }
148550
148399
  var _req_modelConfig_maxTokens, _ref1, _req_modelConfig_temperature, _ref2, _req_modelConfig_topP, _ref3, _req_modelConfig_stream, _ref4;
148551
148400
  var mutableReq = {
148552
148401
  model: model,
@@ -148565,7 +148414,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
148565
148414
  // Sourced from modelConfig or global config
148566
148415
  // Optional fields from AxAIOpenAIResponsesRequest that need to be in Mutable for initialization
148567
148416
  background: void 0,
148568
- include: includeFields.length > 0 ? includeFields : void 0,
148417
+ include: void 0,
148569
148418
  metadata: void 0,
148570
148419
  parallel_tool_calls: this.config.parallelToolCalls,
148571
148420
  previous_response_id: void 0,
@@ -148640,13 +148489,9 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
148640
148489
  break;
148641
148490
  case "reasoning":
148642
148491
  currentResult.id = item.id;
148643
- if (item.encrypted_content) {
148644
- currentResult.thought = item.encrypted_content;
148645
- } else {
148646
- currentResult.thought = item.summary.map(function(s) {
148647
- return typeof s === "object" ? JSON.stringify(s) : s;
148648
- }).join("\n");
148649
- }
148492
+ currentResult.thought = item.summary.map(function(s) {
148493
+ return typeof s === "object" ? JSON.stringify(s) : s;
148494
+ }).join("\n");
148650
148495
  break;
148651
148496
  case "file_search_call":
148652
148497
  currentResult.id = item.id;
@@ -148986,9 +148831,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
148986
148831
  {
148987
148832
  var reasoningItem = event.item;
148988
148833
  baseResult.id = event.item.id;
148989
- if (reasoningItem.encrypted_content) {
148990
- baseResult.thought = reasoningItem.encrypted_content;
148991
- } else if (reasoningItem.summary) {
148834
+ if (reasoningItem.summary) {
148992
148835
  baseResult.thought = reasoningItem.summary.map(function(s) {
148993
148836
  return typeof s === "object" ? JSON.stringify(s) : s;
148994
148837
  }).join("\n");
@@ -149216,6 +149059,7 @@ var axAIOpenAIResponsesDefaultConfig = function() {
149216
149059
  model: "gpt-4o" /* GPT4O */ ,
149217
149060
  embedModel: "text-embedding-ada-002" /* TextEmbeddingAda002 */ ,
149218
149061
  temperature: 0.7,
149062
+ maxTokens: 2048,
149219
149063
  topP: 1,
149220
149064
  stream: true
149221
149065
  };
@@ -149341,14 +149185,14 @@ var AxAIRekaImpl = /*#__PURE__*/ function() {
149341
149185
  var frequencyPenalty = (_req_modelConfig_frequencyPenalty = (_req_modelConfig = req.modelConfig) === null || _req_modelConfig === void 0 ? void 0 : _req_modelConfig.frequencyPenalty) !== null && _req_modelConfig_frequencyPenalty !== void 0 ? _req_modelConfig_frequencyPenalty : _this.config.frequencyPenalty;
149342
149186
  var _req_modelConfig_stream;
149343
149187
  var stream = (_req_modelConfig_stream = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.stream) !== null && _req_modelConfig_stream !== void 0 ? _req_modelConfig_stream : _this.config.stream;
149344
- var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_n, _req_modelConfig_topP, _ref, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
149188
+ var _req_modelConfig_maxTokens, _ref, _req_modelConfig_temperature, _req_modelConfig_n, _req_modelConfig_topP, _ref1, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
149345
149189
  var reqValue = _object_spread({
149346
149190
  model: model,
149347
149191
  messages: messages,
149348
- max_tokens: (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens,
149192
+ max_tokens: (_ref = (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens) !== null && _ref !== void 0 ? _ref : 500,
149349
149193
  temperature: (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : _this.config.temperature,
149350
149194
  top_k: (_req_modelConfig_n = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.n) !== null && _req_modelConfig_n !== void 0 ? _req_modelConfig_n : _this.config.n,
149351
- top_p: (_ref = (_req_modelConfig_topP = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : _this.config.topP) !== null && _ref !== void 0 ? _ref : 1,
149195
+ top_p: (_ref1 = (_req_modelConfig_topP = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : _this.config.topP) !== null && _ref1 !== void 0 ? _ref1 : 1,
149352
149196
  stop: (_req_modelConfig_stopSequences = (_req_modelConfig6 = req.modelConfig) === null || _req_modelConfig6 === void 0 ? void 0 : _req_modelConfig6.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stop,
149353
149197
  presence_penalty: (_req_modelConfig_presencePenalty = (_req_modelConfig7 = req.modelConfig) === null || _req_modelConfig7 === void 0 ? void 0 : _req_modelConfig7.presencePenalty) !== null && _req_modelConfig_presencePenalty !== void 0 ? _req_modelConfig_presencePenalty : _this.config.presencePenalty
149354
149198
  }, frequencyPenalty ? {
@@ -149747,12 +149591,6 @@ var AxAI = /*#__PURE__*/ function() {
149747
149591
  value: function getOptions() {
149748
149592
  return this.ai.getOptions();
149749
149593
  }
149750
- },
149751
- {
149752
- key: "getLogger",
149753
- value: function getLogger() {
149754
- return this.ai.getLogger();
149755
- }
149756
149594
  }
149757
149595
  ]);
149758
149596
  return AxAI;
@@ -149902,7 +149740,7 @@ var MemoryImpl = /*#__PURE__*/ function() {
149902
149740
  if ((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.debug) {
149903
149741
  if (delta && typeof delta === "string") {
149904
149742
  debugResponseDelta(delta);
149905
- } else if (!delta && (content || functionCalls)) {
149743
+ } else if (lastItem) {
149906
149744
  debugResponse({
149907
149745
  content: content,
149908
149746
  name: name,
@@ -150321,8 +150159,6 @@ var validateValue = function(field, value) {
150321
150159
  };
150322
150160
  var validateSingleValue = function(expectedType, val) {
150323
150161
  switch(expectedType){
150324
- case "class":
150325
- return typeof val === "string";
150326
150162
  case "code":
150327
150163
  return typeof val === "string";
150328
150164
  case "string":
@@ -150377,7 +150213,7 @@ var validateValue = function(field, value) {
150377
150213
  msg = "object ({ mimeType: string; data: string })";
150378
150214
  }
150379
150215
  if (msg) {
150380
- throw new Error("Validation failed: Expected '".concat(field.name, "' to be type '").concat(msg, "' instead got '").concat(value, "'"));
150216
+ throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg, " instead got '").concat(value, "'"));
150381
150217
  }
150382
150218
  return;
150383
150219
  }
@@ -150417,7 +150253,7 @@ var validateValue = function(field, value) {
150417
150253
  msg1 = "object ({ data: string; format?: string })";
150418
150254
  }
150419
150255
  if (msg1) {
150420
- throw new Error("Validation failed: Expected '".concat(field.name, "' to be type '").concat(msg1, "' instead got '").concat(value, "'"));
150256
+ throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg1, " instead got '").concat(value, "'"));
150421
150257
  }
150422
150258
  return;
150423
150259
  }
@@ -150455,8 +150291,7 @@ var validateValue = function(field, value) {
150455
150291
  }
150456
150292
  if (!isValid) {
150457
150293
  var _field_type3;
150458
- var gotType = Array.isArray(value) ? "array" : typeof value === "undefined" ? "undefined" : _type_of(value);
150459
- throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(((_field_type3 = field.type) === null || _field_type3 === void 0 ? void 0 : _field_type3.isArray) ? "an array of " : "").concat(ft.name, " instead got '").concat(gotType, "' (").concat(JSON.stringify(value), ")"));
150294
+ throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(((_field_type3 = field.type) === null || _field_type3 === void 0 ? void 0 : _field_type3.isArray) ? "an array of " : "").concat(ft.name, " instead got '").concat(typeof value === "undefined" ? "undefined" : _type_of(value), "' (").concat(value, ")"));
150460
150295
  }
150461
150296
  };
150462
150297
  function mergeProgramUsage(usages) {
@@ -150657,15 +150492,13 @@ function matchesContent(content, prefix) {
150657
150492
  // dsp/prompt.ts
150658
150493
  var functionCallInstructions = "\n## Function Call Instructions\n- Complete the task, using the functions defined earlier in this prompt. \n- Call functions step-by-step, using the output of one function as input to the next.\n- Use the function results to generate the output fields.";
150659
150494
  var formattingRules = "\n## Strict Output Formatting Rules\n- Output must strictly follow the defined plain-text `field name: value` field format.\n- Output field, values must strictly adhere to the specified output field formatting rules.\n- Do not add any text before or after the output fields, just the field name and value.\n- Do not use code blocks.";
150660
- var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150495
+ var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates) {
150661
150496
  var _this = this;
150662
150497
  _class_call_check(this, AxPromptTemplate);
150663
- var _this_functions_map, _this_functions;
150498
+ var _functions_map;
150664
150499
  _define_property(this, "sig", void 0);
150665
150500
  _define_property(this, "fieldTemplates", void 0);
150666
150501
  _define_property(this, "task", void 0);
150667
- _define_property(this, "thoughtFieldName", void 0);
150668
- _define_property(this, "functions", void 0);
150669
150502
  _define_property(this, "render", function(values, param) {
150670
150503
  var examples = param.examples, demos = param.demos;
150671
150504
  var renderedExamples = examples ? [
@@ -150675,6 +150508,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150675
150508
  }
150676
150509
  ].concat(_to_consumable_array(_this.renderExamples(examples))) : [];
150677
150510
  var renderedDemos = demos ? _this.renderDemos(demos) : [];
150511
+ var completion = _this.renderInputFields(values);
150678
150512
  var allTextExamples = renderedExamples.every(function(v) {
150679
150513
  return v.type === "text";
150680
150514
  });
@@ -150699,92 +150533,23 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150699
150533
  role: "system",
150700
150534
  content: systemContent
150701
150535
  };
150702
- var userMessages = [];
150703
- if (Array.isArray(values)) {
150704
- var history = values;
150705
- var lastRole = void 0;
150706
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
150707
- try {
150708
- for(var _iterator = history[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
150709
- var message = _step.value;
150710
- var messageContent = "";
150711
- if (message.role === "user") {
150712
- var userMsgParts = _this.renderInputFields(message.values);
150713
- messageContent = userMsgParts.map(function(part) {
150714
- return part.type === "text" ? part.text : "";
150715
- }).join("").trim();
150716
- } else if (message.role === "assistant") {
150717
- var assistantMsgParts = _this.renderInputFields(message.values);
150718
- messageContent = assistantMsgParts.map(function(part) {
150719
- return part.type === "text" ? part.text : "";
150720
- }).join("").trim();
150721
- }
150722
- if (messageContent) {
150723
- if (lastRole === message.role && userMessages.length > 0) {
150724
- var lastMessage = userMessages[userMessages.length - 1];
150725
- if (lastMessage) {
150726
- lastMessage.content += "\n" + messageContent;
150727
- }
150728
- } else {
150729
- if (message.role === "user") {
150730
- userMessages.push({
150731
- role: "user",
150732
- content: messageContent
150733
- });
150734
- } else if (message.role === "assistant") {
150735
- userMessages.push({
150736
- role: "assistant",
150737
- content: messageContent
150738
- });
150739
- }
150740
- }
150741
- lastRole = message.role;
150742
- }
150743
- }
150744
- } catch (err) {
150745
- _didIteratorError = true;
150746
- _iteratorError = err;
150747
- } finally{
150748
- try {
150749
- if (!_iteratorNormalCompletion && _iterator.return != null) {
150750
- _iterator.return();
150751
- }
150752
- } finally{
150753
- if (_didIteratorError) {
150754
- throw _iteratorError;
150755
- }
150756
- }
150757
- }
150758
- } else {
150759
- var currentValues = values;
150760
- var completion = _this.renderInputFields(currentValues);
150761
- var promptList = examplesInSystemPrompt ? completion : _to_consumable_array(renderedExamples).concat(_to_consumable_array(renderedDemos), _to_consumable_array(completion));
150762
- var promptFilter = promptList.filter(function(v) {
150763
- return v !== void 0;
150764
- });
150765
- var userContent;
150766
- if (promptFilter.every(function(v) {
150767
- return v.type === "text";
150768
- })) {
150769
- userContent = promptFilter.map(function(v) {
150770
- return v.text;
150771
- }).join("\n");
150772
- } else {
150773
- userContent = promptFilter.map(function(part) {
150774
- if (part.type === "text") return part.text;
150775
- if (part.type === "image") return "[IMAGE]";
150776
- if (part.type === "audio") return "[AUDIO]";
150777
- return "";
150778
- }).join("\n").trim();
150779
- }
150780
- userMessages.push({
150781
- role: "user",
150782
- content: userContent
150783
- });
150784
- }
150536
+ var promptList = examplesInSystemPrompt ? completion : _to_consumable_array(renderedExamples).concat(_to_consumable_array(renderedDemos), _to_consumable_array(completion));
150537
+ var prompt = promptList.filter(function(v) {
150538
+ return v !== void 0;
150539
+ });
150540
+ var userContent = prompt.every(function(v) {
150541
+ return v.type === "text";
150542
+ }) ? prompt.map(function(v) {
150543
+ return v.text;
150544
+ }).join("\n") : prompt.reduce(combineConsecutiveStrings("\n"), []);
150545
+ var userPrompt = {
150546
+ role: "user",
150547
+ content: userContent
150548
+ };
150785
150549
  return [
150786
- systemPrompt
150787
- ].concat(_to_consumable_array(userMessages));
150550
+ systemPrompt,
150551
+ userPrompt
150552
+ ];
150788
150553
  });
150789
150554
  _define_property(this, "renderExtraFields", function(extraFields) {
150790
150555
  var prompt = [];
@@ -150830,28 +150595,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150830
150595
  });
150831
150596
  _define_property(this, "renderExamples", function(data) {
150832
150597
  var list = [];
150833
- var exampleContext = {
150834
- isExample: true
150835
- };
150836
150598
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
150837
150599
  try {
150838
150600
  var _loop = function() {
150839
150601
  var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], item = _step_value[1];
150840
150602
  var _renderedItem_;
150841
150603
  var renderedInputItem = _this.sig.getInputFields().map(function(field) {
150842
- return _this.renderInField(field, item, _object_spread_props(_object_spread({}, exampleContext), {
150843
- isInputField: true
150844
- }));
150604
+ return _this.renderInField(field, item, true);
150845
150605
  }).filter(function(v) {
150846
150606
  return v !== void 0;
150847
150607
  }).flat();
150848
150608
  var renderedOutputItem = _this.sig.getOutputFields().map(function(field) {
150849
- return _this.renderInField(field, item, _object_spread_props(_object_spread({}, exampleContext), {
150850
- isInputField: false
150851
- }));
150609
+ return _this.renderInField(field, item, true);
150852
150610
  }).filter(function(v) {
150853
150611
  return v !== void 0;
150854
150612
  }).flat();
150613
+ if (renderedOutputItem.length === 0) {
150614
+ throw new Error("Output fields are required in examples: index: ".concat(index, ", data: ").concat(JSON.stringify(item)));
150615
+ }
150855
150616
  var renderedItem = _to_consumable_array(renderedInputItem).concat(_to_consumable_array(renderedOutputItem));
150856
150617
  if (index > 0 && renderedItem.length > 0 && ((_renderedItem_ = renderedItem[0]) === null || _renderedItem_ === void 0 ? void 0 : _renderedItem_.type) === "text") {
150857
150618
  list.push({
@@ -150888,30 +150649,16 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150888
150649
  });
150889
150650
  _define_property(this, "renderDemos", function(data) {
150890
150651
  var list = [];
150891
- var inputFields = _this.sig.getInputFields();
150892
- var outputFields = _this.sig.getOutputFields();
150893
- var demoContext = {
150894
- isExample: true
150895
- };
150652
+ var fields = _to_consumable_array(_this.sig.getInputFields()).concat(_to_consumable_array(_this.sig.getOutputFields()));
150896
150653
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
150897
150654
  try {
150898
150655
  var _loop = function() {
150899
150656
  var item = _step.value;
150900
- var inputRenderedItems = inputFields.map(function(field) {
150901
- return _this.renderInField(field, item, _object_spread_props(_object_spread({}, demoContext), {
150902
- isInputField: true
150903
- }));
150904
- }).filter(function(v) {
150905
- return v !== void 0;
150906
- }).flat();
150907
- var outputRenderedItems = outputFields.map(function(field) {
150908
- return _this.renderInField(field, item, _object_spread_props(_object_spread({}, demoContext), {
150909
- isInputField: false
150910
- }));
150657
+ var renderedItem = fields.map(function(field) {
150658
+ return _this.renderInField(field, item, true);
150911
150659
  }).filter(function(v) {
150912
150660
  return v !== void 0;
150913
150661
  }).flat();
150914
- var renderedItem = _to_consumable_array(inputRenderedItems).concat(_to_consumable_array(outputRenderedItems));
150915
150662
  renderedItem.slice(0, -1).forEach(function(v) {
150916
150663
  if ("text" in v) {
150917
150664
  v.text = v.text + "\n";
@@ -150941,7 +150688,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150941
150688
  });
150942
150689
  _define_property(this, "renderInputFields", function(values) {
150943
150690
  var renderedItems = _this.sig.getInputFields().map(function(field) {
150944
- return _this.renderInField(field, values, void 0);
150691
+ return _this.renderInField(field, values);
150945
150692
  }).filter(function(v) {
150946
150693
  return v !== void 0;
150947
150694
  }).flat();
@@ -150952,10 +150699,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150952
150699
  });
150953
150700
  return renderedItems;
150954
150701
  });
150955
- _define_property(this, "renderInField", function(field, values, context3) {
150702
+ _define_property(this, "renderInField", function(field, values, skipMissing) {
150956
150703
  var _this_fieldTemplates;
150957
150704
  var value = values[field.name];
150958
- if (isEmptyValue(field, value, context3)) {
150705
+ if (skipMissing && !value) {
150706
+ return;
150707
+ }
150708
+ if (isEmptyValue(field, value)) {
150959
150709
  return;
150960
150710
  }
150961
150711
  if (field.type) {
@@ -150995,19 +150745,19 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
150995
150745
  throw new Error("Image field value must be an array.");
150996
150746
  }
150997
150747
  result = result.concat(value.map(function(v) {
150998
- var validated = validateImage(v);
150748
+ v = validateImage(v);
150999
150749
  return {
151000
150750
  type: "image",
151001
- mimeType: validated.mimeType,
151002
- image: validated.data
150751
+ mimeType: v.mimeType,
150752
+ image: v.data
151003
150753
  };
151004
150754
  }));
151005
150755
  } else {
151006
- var validated = validateImage(value);
150756
+ var v = validateImage(value);
151007
150757
  result.push({
151008
150758
  type: "image",
151009
- mimeType: validated.mimeType,
151010
- image: validated.data
150759
+ mimeType: v.mimeType,
150760
+ image: v.data
151011
150761
  });
151012
150762
  }
151013
150763
  return result;
@@ -151033,24 +150783,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
151033
150783
  ];
151034
150784
  if (field.type.isArray) {
151035
150785
  if (!Array.isArray(value)) {
151036
- throw new Error("Audio field value must be an array.");
150786
+ throw new Error("Image field value must be an array.");
151037
150787
  }
151038
150788
  result1 = result1.concat(value.map(function(v) {
151039
- var validated = validateAudio(v);
151040
- var _validated_format;
150789
+ v = validateAudio(v);
150790
+ var _v_format;
151041
150791
  return {
151042
150792
  type: "audio",
151043
- format: (_validated_format = validated.format) !== null && _validated_format !== void 0 ? _validated_format : "wav",
151044
- data: validated.data
150793
+ format: (_v_format = v.format) !== null && _v_format !== void 0 ? _v_format : "wav",
150794
+ data: v.data
151045
150795
  };
151046
150796
  }));
151047
150797
  } else {
151048
- var validated1 = validateAudio(value);
151049
- var _validated_format;
150798
+ var v1 = validateAudio(value);
150799
+ var _v_format;
151050
150800
  result1.push({
151051
150801
  type: "audio",
151052
- format: (_validated_format = validated1.format) !== null && _validated_format !== void 0 ? _validated_format : "wav",
151053
- data: validated1.data
150802
+ format: (_v_format = v1.format) !== null && _v_format !== void 0 ? _v_format : "wav",
150803
+ data: v1.data
151054
150804
  });
151055
150805
  }
151056
150806
  return result1;
@@ -151076,16 +150826,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
151076
150826
  });
151077
150827
  this.sig = sig;
151078
150828
  this.fieldTemplates = fieldTemplates;
151079
- var _options_thoughtFieldName;
151080
- this.thoughtFieldName = (_options_thoughtFieldName = options === null || options === void 0 ? void 0 : options.thoughtFieldName) !== null && _options_thoughtFieldName !== void 0 ? _options_thoughtFieldName : "thought";
151081
- this.functions = options === null || options === void 0 ? void 0 : options.functions;
151082
150829
  var task = [];
151083
150830
  var inArgs = renderDescFields(this.sig.getInputFields());
151084
150831
  var outArgs = renderDescFields(this.sig.getOutputFields());
151085
150832
  task.push("You will be provided with the following fields: ".concat(inArgs, ". Your task is to generate new fields: ").concat(outArgs, "."));
151086
- var funcs = (_this_functions = this.functions) === null || _this_functions === void 0 ? void 0 : (_this_functions_map = _this_functions.map(function(f) {
150833
+ var funcs = functions === null || functions === void 0 ? void 0 : (_functions_map = functions.map(function(f) {
151087
150834
  return "toFunction" in f ? f.toFunction() : f;
151088
- })) === null || _this_functions_map === void 0 ? void 0 : _this_functions_map.flat();
150835
+ })) === null || _functions_map === void 0 ? void 0 : _functions_map.flat();
151089
150836
  var funcList = funcs === null || funcs === void 0 ? void 0 : funcs.map(function(fn) {
151090
150837
  return "- `".concat(fn.name, "`: ").concat(formatDescription(fn.description));
151091
150838
  }).join("\n");
@@ -151198,19 +150945,15 @@ function combineConsecutiveStrings(separator) {
151198
150945
  return acc;
151199
150946
  };
151200
150947
  }
151201
- var isEmptyValue = function(field, value, context3) {
150948
+ var isEmptyValue = function(field, value) {
151202
150949
  if (typeof value === "boolean") {
151203
150950
  return false;
151204
150951
  }
151205
150952
  if (!value || (Array.isArray(value) || typeof value === "string") && value.length === 0) {
151206
- if (context3 === null || context3 === void 0 ? void 0 : context3.isExample) {
151207
- return true;
151208
- }
151209
- if (field.isOptional || field.isInternal) {
150953
+ if (field.isOptional) {
151210
150954
  return true;
151211
150955
  }
151212
- var fieldType = (context3 === null || context3 === void 0 ? void 0 : context3.isInputField) !== false ? "input" : "output";
151213
- throw new Error("Value for ".concat(fieldType, " field '").concat(field.name, "' is required."));
150956
+ throw new Error("Value for input field '".concat(field.name, "' is required."));
151214
150957
  }
151215
150958
  return false;
151216
150959
  };
@@ -151219,6 +150962,7 @@ function formatDescription(str) {
151219
150962
  return value.length > 0 ? "".concat(value.charAt(0).toUpperCase()).concat(value.slice(1)).concat(value.endsWith(".") ? "" : ".") : "";
151220
150963
  }
151221
150964
  // dsp/validate.ts
150965
+ var colorLog4 = new ColorLog();
151222
150966
  var ValidationError = (_Symbol_for2 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
151223
150967
  _inherits(_class, Error1);
151224
150968
  var _super = _create_super(_class);
@@ -151271,12 +151015,7 @@ function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId)
151271
151015
  var errors = errorFields.map(function(field) {
151272
151016
  return "- ".concat(field.title, ": ").concat(field.description);
151273
151017
  }).join("\n");
151274
- var logger = ai.getLogger();
151275
- logger("❌ Error Correction:\n".concat(errors), {
151276
- tags: [
151277
- "error"
151278
- ]
151279
- });
151018
+ process.stdout.write(colorLog4.red("\n❌ Error Correction:\n".concat(errors, "\n")));
151280
151019
  }
151281
151020
  }
151282
151021
  // dsp/datetime.ts
@@ -152088,9 +151827,6 @@ var validateJSONSchema = function(schema) {
152088
151827
  var errors = [];
152089
151828
  var validateSchemaObject = function(schema2) {
152090
151829
  var path = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
152091
- if (!schema2 || typeof schema2 !== "object") {
152092
- return;
152093
- }
152094
151830
  var validTypes = [
152095
151831
  "array",
152096
151832
  "integer",
@@ -152100,174 +151836,42 @@ var validateJSONSchema = function(schema) {
152100
151836
  "null",
152101
151837
  "object"
152102
151838
  ];
152103
- if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
152104
- if (schema2.anyOf.length === 0) {
152105
- errors.push({
152106
- path: path || "root",
152107
- issue: "anyOf array is empty",
152108
- fix: "Add at least one schema to the anyOf array",
152109
- example: 'anyOf: [{ type: "string" }, { type: "null" }]'
152110
- });
152111
- }
152112
- schema2.anyOf.forEach(function(subSchema, index) {
152113
- validateSchemaObject(subSchema, "".concat(path, "anyOf[").concat(index, "]."));
152114
- });
152115
- return;
152116
- }
152117
- if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
152118
- if (schema2.oneOf.length === 0) {
152119
- errors.push({
152120
- path: path || "root",
152121
- issue: "oneOf array is empty",
152122
- fix: "Add at least one schema to the oneOf array",
152123
- example: 'oneOf: [{ type: "string" }, { type: "number" }]'
152124
- });
152125
- }
152126
- schema2.oneOf.forEach(function(subSchema, index) {
152127
- validateSchemaObject(subSchema, "".concat(path, "oneOf[").concat(index, "]."));
152128
- });
152129
- return;
152130
- }
152131
- if (schema2.allOf && Array.isArray(schema2.allOf)) {
152132
- if (schema2.allOf.length === 0) {
152133
- errors.push({
152134
- path: path || "root",
152135
- issue: "allOf array is empty",
152136
- fix: "Add at least one schema to the allOf array",
152137
- example: 'allOf: [{ type: "object" }, { properties: { name: { type: "string" } } }]'
152138
- });
152139
- }
152140
- schema2.allOf.forEach(function(subSchema, index) {
152141
- validateSchemaObject(subSchema, "".concat(path, "allOf[").concat(index, "]."));
152142
- });
152143
- return;
152144
- }
152145
- if (!schema2.type) {
152146
- return;
152147
- }
152148
151839
  if (!validTypes.includes(schema2.type)) {
152149
- errors.push({
152150
- path: path || "root",
152151
- issue: "Invalid type '".concat(schema2.type, "'"),
152152
- fix: "Change type to one of: ".concat(validTypes.join(", ")),
152153
- example: '{ type: "string" } or { type: "object" }'
152154
- });
151840
+ errors.push("Invalid type '".concat(schema2.type, "' at ").concat(path || "root"));
152155
151841
  return;
152156
151842
  }
152157
- if (schema2.type === "object") {
152158
- if (schema2.properties) {
152159
- if (typeof schema2.properties !== "object" || Array.isArray(schema2.properties)) {
152160
- errors.push({
152161
- path: path || "root",
152162
- issue: "properties must be an object, not an array or primitive",
152163
- fix: "Change properties to be an object with property names as keys",
152164
- example: 'properties: { name: { type: "string" }, age: { type: "number" } }'
152165
- });
152166
- } else {
152167
- for(var key in schema2.properties){
152168
- var value = schema2.properties[key];
152169
- if (value === void 0 || value === null) {
152170
- continue;
152171
- }
152172
- if (typeof value !== "object") {
152173
- errors.push({
152174
- path: "".concat(path).concat(key),
152175
- issue: "Property schema must be an object, got ".concat(typeof value === "undefined" ? "undefined" : _type_of(value)),
152176
- fix: "Define the property as a proper schema object",
152177
- example: "".concat(key, ': { type: "string", description: "..." }')
152178
- });
152179
- continue;
152180
- }
152181
- validateSchemaObject(value, "".concat(path).concat(key, "."));
151843
+ if (schema2.type === "object" && schema2.properties) {
151844
+ if (typeof schema2.properties !== "object" || Array.isArray(schema2.properties)) {
151845
+ errors.push("Invalid properties object at ".concat(path || "root"));
151846
+ } else {
151847
+ for(var key in schema2.properties){
151848
+ var value = schema2.properties[key];
151849
+ if (typeof value !== "object") {
151850
+ errors.push("Invalid schema object at ".concat(path).concat(key));
151851
+ continue;
152182
151852
  }
151853
+ validateSchemaObject(value, "".concat(path).concat(key, "."));
152183
151854
  }
152184
151855
  }
152185
- if (schema2.required) {
152186
- if (!Array.isArray(schema2.required)) {
152187
- errors.push({
152188
- path: path || "root",
152189
- issue: "'required' must be an array, got ".concat(_type_of(schema2.required)),
152190
- fix: "Change required to be an array of property names",
152191
- example: 'required: ["name", "email"] instead of required: "name,email"'
152192
- });
152193
- } else if (schema2.required.length === 0) ; else {
152194
- if (schema2.properties) {
152195
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
152196
- try {
152197
- for(var _iterator = schema2.required[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
152198
- var requiredProp = _step.value;
152199
- if (typeof requiredProp !== "string") {
152200
- errors.push({
152201
- path: "".concat(path, "required"),
152202
- issue: "Required property names must be strings, got ".concat(typeof requiredProp === "undefined" ? "undefined" : _type_of(requiredProp)),
152203
- fix: "Ensure all items in required array are strings",
152204
- example: 'required: ["name", "email"] not required: [123, "email"]'
152205
- });
152206
- } else if (!(requiredProp in schema2.properties)) {
152207
- errors.push({
152208
- path: "".concat(path, "required"),
152209
- issue: "Required property '".concat(requiredProp, "' is not defined in properties"),
152210
- fix: "Either add '".concat(requiredProp, "' to properties or remove it from required"),
152211
- example: "properties: { ".concat(requiredProp, ': { type: "string" } }')
152212
- });
152213
- }
152214
- }
152215
- } catch (err) {
152216
- _didIteratorError = true;
152217
- _iteratorError = err;
152218
- } finally{
152219
- try {
152220
- if (!_iteratorNormalCompletion && _iterator.return != null) {
152221
- _iterator.return();
152222
- }
152223
- } finally{
152224
- if (_didIteratorError) {
152225
- throw _iteratorError;
152226
- }
152227
- }
152228
- }
152229
- }
152230
- }
151856
+ if (schema2.required && !Array.isArray(schema2.required)) {
151857
+ errors.push("'required' should be an array at ".concat(path || "root"));
152231
151858
  }
152232
151859
  }
152233
- if (schema2.type === "array") {
152234
- if (schema2.items) {
152235
- if (typeof schema2.items !== "object") {
152236
- errors.push({
152237
- path: "".concat(path, "items"),
152238
- issue: "Array items schema must be an object, got ".concat(_type_of(schema2.items)),
152239
- fix: "Define items as a proper schema object",
152240
- example: 'items: { type: "string" } or items: { type: "object", properties: {...} }'
152241
- });
152242
- } else {
152243
- validateSchemaObject(schema2.items, "".concat(path, "items."));
152244
- }
151860
+ if (schema2.type === "array" && schema2.items) {
151861
+ if (typeof schema2.items !== "object") {
151862
+ errors.push("Invalid items schema at ".concat(path || "root"));
151863
+ } else {
151864
+ validateSchemaObject(schema2.items, "".concat(path, "items."));
152245
151865
  }
152246
151866
  }
152247
151867
  };
152248
151868
  validateSchemaObject(schema);
152249
151869
  if (errors.length > 0) {
152250
- var errorMessage = [
152251
- "JSON Schema validation failed:",
152252
- ""
152253
- ].concat(_to_consumable_array(errors.map(function(error, index) {
152254
- var parts = [
152255
- "".concat(index + 1, ". Path: ").concat(error.path),
152256
- " Issue: ".concat(error.issue),
152257
- " Fix: ".concat(error.fix)
152258
- ];
152259
- if (error.example) {
152260
- parts.push(" Example: ".concat(error.example));
152261
- }
152262
- return parts.join("\n");
152263
- })), [
152264
- "",
152265
- "Please fix these issues and try again."
152266
- ]).join("\n");
152267
- throw new Error(errorMessage);
151870
+ throw new Error(errors.join("; "));
152268
151871
  }
152269
151872
  };
152270
151873
  // dsp/functions.ts
151874
+ var colorLog5 = new ColorLog();
152271
151875
  var AxFunctionError = (_Symbol_for3 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
152272
151876
  _inherits(_class, Error1);
152273
151877
  var _super = _create_super(_class);
@@ -152593,12 +152197,7 @@ var processFunctions = function() {
152593
152197
  }, sessionId);
152594
152198
  mem.addTag("error");
152595
152199
  if (ai.getOptions().debug) {
152596
- var logger = ai.getLogger();
152597
- logger("❌ Function Error Correction:\n".concat(result), {
152598
- tags: [
152599
- "error"
152600
- ]
152601
- });
152200
+ process.stdout.write(colorLog5.red("\n❌ Function Error Correction:\n".concat(result, "\n")));
152602
152201
  }
152603
152202
  } else {
152604
152203
  throw e;
@@ -153341,7 +152940,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
153341
152940
  _define_property(this, "signature", void 0);
153342
152941
  _define_property(this, "sigHash", void 0);
153343
152942
  _define_property(this, "examples", void 0);
153344
- _define_property(this, "examplesOptions", void 0);
153345
152943
  _define_property(this, "demos", void 0);
153346
152944
  _define_property(this, "trace", void 0);
153347
152945
  _define_property(this, "usage", []);
@@ -153436,8 +153034,8 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
153436
153034
  },
153437
153035
  {
153438
153036
  key: "setExamples",
153439
- value: function setExamples(examples, options) {
153440
- this._setExamples(examples, options);
153037
+ value: function setExamples(examples) {
153038
+ this._setExamples(examples);
153441
153039
  if (!("programId" in examples)) {
153442
153040
  return;
153443
153041
  }
@@ -153445,7 +153043,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
153445
153043
  try {
153446
153044
  for(var _iterator = this.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
153447
153045
  var child = _step.value;
153448
- child.setExamples(examples, options);
153046
+ child.setExamples(examples);
153449
153047
  }
153450
153048
  } catch (err) {
153451
153049
  _didIteratorError = true;
@@ -153465,7 +153063,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
153465
153063
  },
153466
153064
  {
153467
153065
  key: "_setExamples",
153468
- value: function _setExamples(examples, options) {
153066
+ value: function _setExamples(examples) {
153469
153067
  var traces = [];
153470
153068
  if ("programId" in examples && examples.programId === this.key.id) {
153471
153069
  traces = examples.traces;
@@ -153474,7 +153072,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
153474
153072
  traces = examples;
153475
153073
  }
153476
153074
  if (traces) {
153477
- this.examplesOptions = options;
153478
153075
  var sig = this.signature;
153479
153076
  var fields = _to_consumable_array(sig.getInputFields()).concat(_to_consumable_array(sig.getOutputFields()));
153480
153077
  this.examples = traces.map(function(e) {
@@ -153484,7 +153081,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
153484
153081
  for(var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
153485
153082
  var f = _step.value;
153486
153083
  var value = e[f.name];
153487
- if (value !== void 0) {
153084
+ if (value) {
153488
153085
  validateValue(f, value);
153489
153086
  res[f.name] = value;
153490
153087
  }
@@ -153652,8 +153249,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
153652
153249
  _define_property(_assert_this_initialized(_this), "streamingFieldProcessors", []);
153653
153250
  _define_property(_assert_this_initialized(_this), "values", {});
153654
153251
  _define_property(_assert_this_initialized(_this), "excludeContentFromTrace", false);
153655
- _define_property(_assert_this_initialized(_this), "thoughtFieldName", void 0);
153656
- _define_property(_assert_this_initialized(_this), "logger", void 0);
153657
153252
  _define_property(_assert_this_initialized(_this), "addAssert", function(fn, message) {
153658
153253
  _this.asserts.push({
153659
153254
  fn: fn,
@@ -153700,15 +153295,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
153700
153295
  _this.addFieldProcessorInternal(fieldName, fn, false);
153701
153296
  });
153702
153297
  _this.options = options;
153703
- _this.logger = options === null || options === void 0 ? void 0 : options.logger;
153704
- var _options_thoughtFieldName;
153705
- _this.thoughtFieldName = (_options_thoughtFieldName = options === null || options === void 0 ? void 0 : options.thoughtFieldName) !== null && _options_thoughtFieldName !== void 0 ? _options_thoughtFieldName : "thought";
153706
- var promptTemplateOptions = {
153707
- functions: options === null || options === void 0 ? void 0 : options.functions,
153708
- thoughtFieldName: _this.thoughtFieldName
153709
- };
153710
153298
  var _options_promptTemplate;
153711
- _this.promptTemplate = new ((_options_promptTemplate = options === null || options === void 0 ? void 0 : options.promptTemplate) !== null && _options_promptTemplate !== void 0 ? _options_promptTemplate : AxPromptTemplate)(_this.signature, promptTemplateOptions);
153299
+ _this.promptTemplate = new ((_options_promptTemplate = options === null || options === void 0 ? void 0 : options.promptTemplate) !== null && _options_promptTemplate !== void 0 ? _options_promptTemplate : AxPromptTemplate)(_this.signature, options === null || options === void 0 ? void 0 : options.functions);
153712
153300
  var _this_options_asserts;
153713
153301
  _this.asserts = (_this_options_asserts = (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.asserts) !== null && _this_options_asserts !== void 0 ? _this_options_asserts : [];
153714
153302
  var _this_options_streamingAsserts;
@@ -153728,11 +153316,11 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
153728
153316
  var ai = param.ai, mem = param.mem, options = param.options, traceContext = param.traceContext, firstStep = param.firstStep;
153729
153317
  var _this = this;
153730
153318
  return _async_to_generator(function() {
153731
- var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget, showThoughts, _mem_history, chatPrompt, functions, functionCall, res;
153319
+ var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget, _mem_history, chatPrompt, functions, functionCall, res;
153732
153320
  return _ts_generator(this, function(_state) {
153733
153321
  switch(_state.label){
153734
153322
  case 0:
153735
- _ref = options !== null && options !== void 0 ? options : {}, sessionId = _ref.sessionId, traceId = _ref.traceId, modelConfig = _ref.modelConfig, model = _ref.model, rateLimiter = _ref.rateLimiter, stream = _ref.stream, _functions = _ref.functions, _functionCall = _ref.functionCall, thinkingTokenBudget = _ref.thinkingTokenBudget, showThoughts = _ref.showThoughts;
153323
+ _ref = options !== null && options !== void 0 ? options : {}, sessionId = _ref.sessionId, traceId = _ref.traceId, modelConfig = _ref.modelConfig, model = _ref.model, rateLimiter = _ref.rateLimiter, stream = _ref.stream, _functions = _ref.functions, _functionCall = _ref.functionCall, thinkingTokenBudget = _ref.thinkingTokenBudget;
153736
153324
  chatPrompt = (_mem_history = mem === null || mem === void 0 ? void 0 : mem.history(sessionId)) !== null && _mem_history !== void 0 ? _mem_history : [];
153737
153325
  if (chatPrompt.length === 0) {
153738
153326
  throw new Error("No chat prompt found");
@@ -153759,9 +153347,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
153759
153347
  stream: stream,
153760
153348
  debug: false,
153761
153349
  thinkingTokenBudget: thinkingTokenBudget,
153762
- showThoughts: showThoughts,
153763
- traceContext: traceContext,
153764
- abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal
153350
+ traceContext: traceContext
153765
153351
  })
153766
153352
  ];
153767
153353
  case 1:
@@ -153864,7 +153450,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
153864
153450
  var ai = param.ai, model = param.model, res = param.res, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, functions = param.functions, fastFail = param.fastFail, span = param.span;
153865
153451
  var _this = this;
153866
153452
  return _wrap_async_generator(function() {
153867
- var streamingValidation, functionCalls, xstate, content, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, v, result, _result_functionCalls__function, _result_functionCalls_, _result_functionCalls, skip, _this_values_this_thoughtFieldName, err, funcs, fx, logger;
153453
+ var streamingValidation, functionCalls, xstate, content, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, v, result, _result_functionCalls__function, _result_functionCalls_, _result_functionCalls, skip, _this_values_thought, err, funcs, fx;
153868
153454
  return _ts_generator(this, function(_state) {
153869
153455
  switch(_state.label){
153870
153456
  case 0:
@@ -153936,7 +153522,9 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
153936
153522
  ];
153937
153523
  return [
153938
153524
  4,
153939
- _define_property({}, _this.thoughtFieldName, result.thought)
153525
+ {
153526
+ thought: result.thought
153527
+ }
153940
153528
  ];
153941
153529
  case 5:
153942
153530
  _state.sent();
@@ -154000,10 +153588,12 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154000
153588
  3,
154001
153589
  15
154002
153590
  ];
154003
- _this.values[_this.thoughtFieldName] = ((_this_values_this_thoughtFieldName = _this.values[_this.thoughtFieldName]) !== null && _this_values_this_thoughtFieldName !== void 0 ? _this_values_this_thoughtFieldName : "") + result.thought;
153591
+ _this.values.thought = (_this_values_thought = _this.values.thought) !== null && _this_values_thought !== void 0 ? _this_values_thought : "" + result.thought;
154004
153592
  return [
154005
153593
  4,
154006
- _define_property({}, _this.thoughtFieldName, result.thought)
153594
+ {
153595
+ thought: result.thought
153596
+ }
154007
153597
  ];
154008
153598
  case 14:
154009
153599
  _state.sent();
@@ -154132,14 +153722,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154132
153722
  _state.sent();
154133
153723
  _state.label = 34;
154134
153724
  case 34:
154135
- if (ai.getOptions().debug) {
154136
- logger = ai.getLogger();
154137
- logger("", {
154138
- tags: [
154139
- "responseEnd"
154140
- ]
154141
- });
154142
- }
154143
153725
  return [
154144
153726
  2
154145
153727
  ];
@@ -154217,7 +153799,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154217
153799
  8
154218
153800
  ];
154219
153801
  if (result.thought && result.thought.length > 0) {
154220
- _this.values[_this.thoughtFieldName] = result.thought;
153802
+ _this.values.thought = result.thought;
154221
153803
  }
154222
153804
  extractValues(_this.signature, _this.values, result.content);
154223
153805
  return [
@@ -154311,7 +153893,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154311
153893
  value: function _forward2(ai, values, options, span, traceContext) {
154312
153894
  var _this = this;
154313
153895
  return _wrap_async_generator(function() {
154314
- var _loop, _this1, _this_options, _this_options1, _this_options2, _this_options3, _options_stopFunction, stopFunction, _options_maxRetries, _ref, maxRetries, _options_maxSteps, _ref1, maxSteps, _options_debug, debug, debugHideSystemPrompt, memOptions, _options_mem, _ref2, mem, _$err, _this_options4, _this_options_promptTemplate, promptTemplateClass, currentPromptTemplateOptions, prompt, n, _ret;
153896
+ var _loop, _this1, _this_options, _this_options1, _this_options2, _this_options3, _options_stopFunction, stopFunction, _options_maxRetries, _ref, maxRetries, _options_maxSteps, _ref1, maxSteps, _options_debug, debug, debugHideSystemPrompt, memOptions, _options_mem, _ref2, mem, _$err, _this_options4, _this_options_promptTemplate, promptTemplate, prompt, n, _ret;
154315
153897
  return _ts_generator(this, function(_state) {
154316
153898
  switch(_state.label){
154317
153899
  case 0:
@@ -154321,7 +153903,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154321
153903
  switch(_state.label){
154322
153904
  case 0:
154323
153905
  _loop = function(errCount) {
154324
- var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue, _options_logger, _ref, logger, e, errorFields, _errorFields_map_join, e1, _errorFields_map_join1;
153906
+ var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue, e, errorFields, _errorFields_map_join, e1, _errorFields_map_join1;
154325
153907
  return _ts_generator(this, function(_state) {
154326
153908
  switch(_state.label){
154327
153909
  case 0:
@@ -154439,12 +154021,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154439
154021
  ];
154440
154022
  }
154441
154023
  if (debug) {
154442
- logger = (_ref = (_options_logger = options.logger) !== null && _options_logger !== void 0 ? _options_logger : _this.logger) !== null && _ref !== void 0 ? _ref : ai.getLogger();
154443
- logger("", {
154444
- tags: [
154445
- "responseEnd"
154446
- ]
154447
- });
154024
+ process.stdout.write("\n");
154448
154025
  }
154449
154026
  return [
154450
154027
  2,
@@ -154546,25 +154123,13 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154546
154123
  };
154547
154124
  mem = (_ref2 = (_options_mem = options.mem) !== null && _options_mem !== void 0 ? _options_mem : (_this_options3 = _this.options) === null || _this_options3 === void 0 ? void 0 : _this_options3.mem) !== null && _ref2 !== void 0 ? _ref2 : new AxMemory(1e4, memOptions);
154548
154125
  if ((options === null || options === void 0 ? void 0 : options.functions) && options.functions.length > 0) {
154549
- promptTemplateClass = (_this_options_promptTemplate = (_this_options4 = _this.options) === null || _this_options4 === void 0 ? void 0 : _this_options4.promptTemplate) !== null && _this_options_promptTemplate !== void 0 ? _this_options_promptTemplate : AxPromptTemplate;
154550
- currentPromptTemplateOptions = {
154551
- functions: options.functions,
154552
- thoughtFieldName: _this.thoughtFieldName
154553
- };
154554
- _this.promptTemplate = new promptTemplateClass(_this.signature, currentPromptTemplateOptions);
154555
- }
154556
- if (Array.isArray(values)) {
154557
- prompt = _this.promptTemplate.render(values, {
154558
- examples: _this.examples,
154559
- demos: _this.demos
154560
- });
154561
- } else {
154562
- prompt = _this.promptTemplate.render(values, {
154563
- // Cast if necessary
154564
- examples: _this.examples,
154565
- demos: _this.demos
154566
- });
154126
+ promptTemplate = (_this_options_promptTemplate = (_this_options4 = _this.options) === null || _this_options4 === void 0 ? void 0 : _this_options4.promptTemplate) !== null && _this_options_promptTemplate !== void 0 ? _this_options_promptTemplate : AxPromptTemplate;
154127
+ _this.promptTemplate = new promptTemplate(_this.signature, options.functions);
154567
154128
  }
154129
+ prompt = _this.promptTemplate.render(values, {
154130
+ examples: _this.examples,
154131
+ demos: _this.demos
154132
+ });
154568
154133
  mem.add(prompt, options === null || options === void 0 ? void 0 : options.sessionId);
154569
154134
  n = 0;
154570
154135
  _state.label = 1;
@@ -154665,8 +154230,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154665
154230
  model: options.model
154666
154231
  } : {}, (options === null || options === void 0 ? void 0 : options.thinkingTokenBudget) ? {
154667
154232
  thinking_token_budget: options.thinkingTokenBudget
154668
- } : {}, (options === null || options === void 0 ? void 0 : options.showThoughts) ? {
154669
- show_thoughts: options.showThoughts
154670
154233
  } : {}, (options === null || options === void 0 ? void 0 : options.maxSteps) ? {
154671
154234
  max_steps: options.maxSteps
154672
154235
  } : {}, (options === null || options === void 0 ? void 0 : options.maxRetries) ? {
@@ -154854,12 +154417,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
154854
154417
  });
154855
154418
  })();
154856
154419
  }
154857
- },
154858
- {
154859
- key: "setExamples",
154860
- value: function setExamples(examples, options) {
154861
- _get(_get_prototype_of(AxGen.prototype), "setExamples", this).call(this, examples, options);
154862
- }
154863
154420
  }
154864
154421
  ]);
154865
154422
  return AxGen;
@@ -154915,32 +154472,13 @@ function processChildAgentFunction(childFunction, parentValues, parentInputKeys,
154915
154472
  var originalFunc = processedFunction.func;
154916
154473
  processedFunction.func = function() {
154917
154474
  var _ref = _async_to_generator(function(childArgs, funcOptions) {
154918
- var valuesToInject, lastUserMessage, updatedChildArgs, ai, logger;
154475
+ var updatedChildArgs;
154919
154476
  return _ts_generator(this, function(_state) {
154920
154477
  switch(_state.label){
154921
154478
  case 0:
154922
- valuesToInject = {};
154923
- if (Array.isArray(parentValues)) {
154924
- lastUserMessage = parentValues.filter(function(msg) {
154925
- return msg.role === "user";
154926
- }).pop();
154927
- if (lastUserMessage) {
154928
- valuesToInject = pick(lastUserMessage.values, injectionKeys);
154929
- }
154930
- } else {
154931
- valuesToInject = pick(parentValues, injectionKeys);
154932
- }
154933
- updatedChildArgs = _object_spread({}, childArgs, valuesToInject);
154479
+ updatedChildArgs = _object_spread({}, childArgs, pick(parentValues, injectionKeys));
154934
154480
  if (options.debug && injectionKeys.length > 0) {
154935
- ai = funcOptions === null || funcOptions === void 0 ? void 0 : funcOptions.ai;
154936
- if (ai) {
154937
- logger = ai.getLogger();
154938
- logger("Function Params: ".concat(JSON.stringify(updatedChildArgs, null, 2)), {
154939
- tags: [
154940
- "functionArg"
154941
- ]
154942
- });
154943
- }
154481
+ process.stdout.write("\nFunction Params: ".concat(JSON.stringify(updatedChildArgs, null, 2)));
154944
154482
  }
154945
154483
  return [
154946
154484
  4,
@@ -155039,8 +154577,8 @@ var AxAgent = /*#__PURE__*/ function() {
155039
154577
  _create_class(AxAgent, [
155040
154578
  {
155041
154579
  key: "setExamples",
155042
- value: function setExamples(examples, options) {
155043
- this.program.setExamples(examples, options);
154580
+ value: function setExamples(examples) {
154581
+ this.program.setExamples(examples);
155044
154582
  }
155045
154583
  },
155046
154584
  {
@@ -155086,7 +154624,7 @@ var AxAgent = /*#__PURE__*/ function() {
155086
154624
  var _this = this;
155087
154625
  var wrappedFunc = function() {
155088
154626
  var _ref = _async_to_generator(function(valuesAndModel, options) {
155089
- var model, values, _this_ai, ai, debug, logger, ret, logger1, sig, outFields, result;
154627
+ var model, values, _this_ai, ai, debug, ret, sig, outFields, result;
155090
154628
  return _ts_generator(this, function(_state) {
155091
154629
  switch(_state.label){
155092
154630
  case 0:
@@ -155099,12 +154637,7 @@ var AxAgent = /*#__PURE__*/ function() {
155099
154637
  }
155100
154638
  debug = _this.getDebug(ai, options);
155101
154639
  if (debug) {
155102
- logger = ai.getLogger();
155103
- logger("\uD83E\uDD16 Agent ".concat(_this.name, " starting..."), {
155104
- tags: [
155105
- "assistantStart"
155106
- ]
155107
- });
154640
+ process.stdout.write("\n--- Agent Engaged: ".concat(_this.name, " ---\n"));
155108
154641
  }
155109
154642
  return [
155110
154643
  4,
@@ -155115,12 +154648,7 @@ var AxAgent = /*#__PURE__*/ function() {
155115
154648
  case 1:
155116
154649
  ret = _state.sent();
155117
154650
  if (debug) {
155118
- logger1 = ai.getLogger();
155119
- logger1("\uD83E\uDD16 Agent ".concat(_this.name, " completed."), {
155120
- tags: [
155121
- "assistantEnd"
155122
- ]
155123
- });
154651
+ process.stdout.write("\n--- Agent Done: ".concat(_this.name, " ---\n"));
155124
154652
  }
155125
154653
  sig = _this.program.getSignature();
155126
154654
  outFields = sig.getOutputFields();
@@ -155686,12 +155214,6 @@ function pick(obj, keys) {
155686
155214
  value: function getOptions() {
155687
155215
  return this.currentService.getOptions();
155688
155216
  }
155689
- },
155690
- {
155691
- key: "getLogger",
155692
- value: function getLogger() {
155693
- return this.currentService.getLogger();
155694
- }
155695
155217
  }
155696
155218
  ]);
155697
155219
  return _AxBalancer;
@@ -155805,8 +155327,7 @@ var AxChainOfThought = /*#__PURE__*/ function(AxGen) {
155805
155327
  sig.setOutputFields([
155806
155328
  {
155807
155329
  name: "reason",
155808
- description: description,
155809
- isInternal: (options === null || options === void 0 ? void 0 : options.setVisibleReasoning) !== true
155330
+ description: description
155810
155331
  }
155811
155332
  ].concat(_to_consumable_array(sig.getOutputFields())));
155812
155333
  return _super.call(this, sig, options);
@@ -155821,8 +155342,10 @@ for(var i = 0; i < 256; ++i){
155821
155342
  byteToHex.push((i + 256).toString(16).slice(1));
155822
155343
  }
155823
155344
  ({
155824
- randomUUID: crypto$6.randomUUID
155345
+ randomUUID: require$$0$6.randomUUID
155825
155346
  });
155347
+ // mcp/client.ts
155348
+ new ColorLog();
155826
155349
 
155827
155350
  let DspService = class DspService {
155828
155351
  async prepareFunctions(functions, context) {