@inkeep/agents-api 0.0.1 → 0.42.0

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 (45) hide show
  1. package/dist/.well-known/workflow/v1/flow.cjs +43 -106
  2. package/dist/.well-known/workflow/v1/flow.cjs.debug.json +2 -4
  3. package/dist/.well-known/workflow/v1/manifest.debug.json +16 -54
  4. package/dist/.well-known/workflow/v1/step.cjs +406 -1646
  5. package/dist/.well-known/workflow/v1/step.cjs.debug.json +2 -4
  6. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  7. package/dist/domains/evals/routes/index.d.ts +2 -2
  8. package/dist/domains/evals/workflow/functions/evaluateConversation.d.ts +4 -1
  9. package/dist/domains/evals/workflow/functions/evaluateConversation.js +2 -1
  10. package/dist/domains/evals/workflow/functions/runDatasetItem.d.ts +4 -1
  11. package/dist/domains/evals/workflow/functions/runDatasetItem.js +2 -1
  12. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  13. package/dist/domains/manage/routes/agent.js +2 -0
  14. package/dist/domains/manage/routes/index.d.ts +2 -2
  15. package/dist/domains/manage/routes/triggers.js +37 -5
  16. package/dist/domains/run/a2a/handlers.js +2 -10
  17. package/dist/domains/run/a2a/types.d.ts +2 -6
  18. package/dist/domains/run/agents/generateTaskHandler.js +14 -2
  19. package/dist/domains/run/agents/relationTools.d.ts +2 -2
  20. package/dist/domains/run/handlers/executionHandler.d.ts +3 -1
  21. package/dist/domains/run/handlers/executionHandler.js +6 -5
  22. package/dist/domains/run/routes/webhooks.js +24 -5
  23. package/dist/domains/run/types/xml.d.ts +1 -5
  24. package/dist/domains/run/utils/token-estimator.d.ts +2 -2
  25. package/dist/factory.d.ts +272 -266
  26. package/dist/index.d.ts +269 -263
  27. package/dist/index.js +16 -1
  28. package/dist/middleware/evalsAuth.d.ts +2 -2
  29. package/dist/middleware/manageAuth.d.ts +2 -2
  30. package/dist/middleware/projectAccess.d.ts +2 -2
  31. package/dist/middleware/projectConfig.d.ts +3 -3
  32. package/dist/middleware/requirePermission.d.ts +2 -2
  33. package/dist/middleware/runAuth.d.ts +4 -4
  34. package/dist/middleware/sessionAuth.d.ts +3 -3
  35. package/dist/middleware/tenantAccess.d.ts +2 -2
  36. package/dist/middleware/tracing.d.ts +3 -3
  37. package/dist/templates/v1/phase1/system-prompt.js +1 -1
  38. package/dist/templates/v1/phase1/thinking-preparation.js +1 -1
  39. package/dist/templates/v1/phase1/tool.js +1 -1
  40. package/dist/templates/v1/phase2/data-component.js +1 -1
  41. package/dist/templates/v1/phase2/data-components.js +1 -1
  42. package/dist/templates/v1/phase2/system-prompt.js +1 -1
  43. package/dist/templates/v1/shared/artifact-retrieval-guidance.js +1 -1
  44. package/dist/templates/v1/shared/artifact.js +1 -1
  45. package/package.json +21 -22
@@ -4918,19 +4918,19 @@ var require_compile = __commonJS({
4918
4918
  static {
4919
4919
  __name(this, "SchemaEnv");
4920
4920
  }
4921
- constructor(env4) {
4921
+ constructor(env3) {
4922
4922
  var _a26;
4923
4923
  this.refs = {};
4924
4924
  this.dynamicAnchors = {};
4925
4925
  let schema;
4926
- if (typeof env4.schema == "object") schema = env4.schema;
4927
- this.schema = env4.schema;
4928
- this.schemaId = env4.schemaId;
4929
- this.root = env4.root || this;
4930
- this.baseId = (_a26 = env4.baseId) !== null && _a26 !== void 0 ? _a26 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env4.schemaId || "$id"]);
4931
- this.schemaPath = env4.schemaPath;
4932
- this.localRefs = env4.localRefs;
4933
- this.meta = env4.meta;
4926
+ if (typeof env3.schema == "object") schema = env3.schema;
4927
+ this.schema = env3.schema;
4928
+ this.schemaId = env3.schemaId;
4929
+ this.root = env3.root || this;
4930
+ this.baseId = (_a26 = env3.baseId) !== null && _a26 !== void 0 ? _a26 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env3.schemaId || "$id"]);
4931
+ this.schemaPath = env3.schemaPath;
4932
+ this.localRefs = env3.localRefs;
4933
+ this.meta = env3.meta;
4934
4934
  this.$async = schema === null || schema === void 0 ? void 0 : schema.$async;
4935
4935
  this.refs = {};
4936
4936
  }
@@ -5131,19 +5131,19 @@ var require_compile = __commonJS({
5131
5131
  baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
5132
5132
  }
5133
5133
  }
5134
- let env4;
5134
+ let env3;
5135
5135
  if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
5136
5136
  const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
5137
- env4 = resolveSchema.call(this, root, $ref);
5137
+ env3 = resolveSchema.call(this, root, $ref);
5138
5138
  }
5139
5139
  const { schemaId } = this.opts;
5140
- env4 = env4 || new SchemaEnv({
5140
+ env3 = env3 || new SchemaEnv({
5141
5141
  schema,
5142
5142
  schemaId,
5143
5143
  root,
5144
5144
  baseId
5145
5145
  });
5146
- if (env4.schema !== env4.root.schema) return env4;
5146
+ if (env3.schema !== env3.root.schema) return env3;
5147
5147
  return void 0;
5148
5148
  }
5149
5149
  __name(getJsonPointer, "getJsonPointer");
@@ -6529,10 +6529,10 @@ var require_core = __commonJS({
6529
6529
  error() {
6530
6530
  }
6531
6531
  };
6532
- function getLogger2(logger27) {
6533
- if (logger27 === false) return noLogs;
6534
- if (logger27 === void 0) return console;
6535
- if (logger27.log && logger27.warn && logger27.error) return logger27;
6532
+ function getLogger2(logger24) {
6533
+ if (logger24 === false) return noLogs;
6534
+ if (logger24 === void 0) return console;
6535
+ if (logger24.log && logger24.warn && logger24.error) return logger24;
6536
6536
  throw new Error("logger must implement log, warn and error methods");
6537
6537
  }
6538
6538
  __name(getLogger2, "getLogger");
@@ -6646,15 +6646,15 @@ var require_ref = __commonJS({
6646
6646
  schemaType: "string",
6647
6647
  code(cxt) {
6648
6648
  const { gen, schema: $ref, it: it3 } = cxt;
6649
- const { baseId, schemaEnv: env4, validateName, opts, self: self2 } = it3;
6650
- const { root } = env4;
6649
+ const { baseId, schemaEnv: env3, validateName, opts, self: self2 } = it3;
6650
+ const { root } = env3;
6651
6651
  if (($ref === "#" || $ref === "#/") && baseId === root.baseId) return callRootRef();
6652
6652
  const schOrEnv = compile_1.resolveRef.call(self2, root, baseId, $ref);
6653
6653
  if (schOrEnv === void 0) throw new ref_error_1.default(it3.opts.uriResolver, baseId, $ref);
6654
6654
  if (schOrEnv instanceof compile_1.SchemaEnv) return callValidate(schOrEnv);
6655
6655
  return inlineRefSchema(schOrEnv);
6656
6656
  function callRootRef() {
6657
- if (env4 === root) return callRef(cxt, validateName, env4, env4.$async);
6657
+ if (env3 === root) return callRef(cxt, validateName, env3, env3.$async);
6658
6658
  const rootName = gen.scopeValue("root", {
6659
6659
  ref: root
6660
6660
  });
@@ -6699,12 +6699,12 @@ var require_ref = __commonJS({
6699
6699
  exports2.getValidate = getValidate;
6700
6700
  function callRef(cxt, v3, sch, $async) {
6701
6701
  const { gen, it: it3 } = cxt;
6702
- const { allErrors, schemaEnv: env4, opts } = it3;
6702
+ const { allErrors, schemaEnv: env3, opts } = it3;
6703
6703
  const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil;
6704
6704
  if ($async) callAsyncRef();
6705
6705
  else callSyncRef();
6706
6706
  function callAsyncRef() {
6707
- if (!env4.$async) throw new Error("async schema referenced by sync schema");
6707
+ if (!env3.$async) throw new Error("async schema referenced by sync schema");
6708
6708
  const valid = gen.let("valid");
6709
6709
  gen.try(() => {
6710
6710
  gen.code((0, codegen_1._)`await ${(0, code_1.callValidateCode)(cxt, v3, passCxt)}`);
@@ -10153,7 +10153,7 @@ var require_main2 = __commonJS({
10153
10153
  }
10154
10154
  __name(_resolveEscapeSequences, "_resolveEscapeSequences");
10155
10155
  function expandValue(value, processEnv, runningParsed) {
10156
- const env4 = {
10156
+ const env3 = {
10157
10157
  ...runningParsed,
10158
10158
  ...processEnv
10159
10159
  };
@@ -10176,11 +10176,11 @@ var require_main2 = __commonJS({
10176
10176
  ":+",
10177
10177
  "+"
10178
10178
  ].includes(splitter)) {
10179
- defaultValue = env4[key] ? r.join(splitter) : "";
10179
+ defaultValue = env3[key] ? r.join(splitter) : "";
10180
10180
  value2 = null;
10181
10181
  } else {
10182
10182
  defaultValue = r.join(splitter);
10183
- value2 = env4[key];
10183
+ value2 = env3[key];
10184
10184
  }
10185
10185
  if (value2) {
10186
10186
  if (seen.has(value2)) {
@@ -14639,13 +14639,13 @@ var require_colorette = __commonJS({
14639
14639
  }
14640
14640
  __name(_interopNamespace, "_interopNamespace");
14641
14641
  var tty__namespace = /* @__PURE__ */ _interopNamespace(tty);
14642
- var { env: env4 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
14643
- var isDisabled = "NO_COLOR" in env4 || argv.includes("--no-color");
14644
- var isForced = "FORCE_COLOR" in env4 || argv.includes("--color");
14642
+ var { env: env3 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
14643
+ var isDisabled = "NO_COLOR" in env3 || argv.includes("--no-color");
14644
+ var isForced = "FORCE_COLOR" in env3 || argv.includes("--color");
14645
14645
  var isWindows = platform === "win32";
14646
- var isDumbTerminal = env4.TERM === "dumb";
14647
- var isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env4.TERM && !isDumbTerminal;
14648
- var isCI = "CI" in env4 && ("GITHUB_ACTIONS" in env4 || "GITLAB_CI" in env4 || "CIRCLECI" in env4);
14646
+ var isDumbTerminal = env3.TERM === "dumb";
14647
+ var isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env3.TERM && !isDumbTerminal;
14648
+ var isCI = "CI" in env3 && ("GITHUB_ACTIONS" in env3 || "GITLAB_CI" in env3 || "CIRCLECI" in env3);
14649
14649
  var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
14650
14650
  var replaceClose = /* @__PURE__ */ __name((index2, string4, close, replace, head = string4.substring(0, index2) + replace, tail = string4.substring(index2 + close.length), next2 = tail.indexOf(close)) => head + (next2 < 0 ? tail : replaceClose(next2, tail, close, replace)), "replaceClose");
14651
14651
  var clearBleed = /* @__PURE__ */ __name((index2, string4, open, close, replace) => index2 < 0 ? open + string4 + close : open + replaceClose(index2, string4, close, replace) + close, "clearBleed");
@@ -22137,8 +22137,8 @@ var require_logging = __commonJS({
22137
22137
  return _logger;
22138
22138
  }, "getLogger");
22139
22139
  exports2.getLogger = getLogger2;
22140
- var setLogger = /* @__PURE__ */ __name((logger27) => {
22141
- _logger = logger27;
22140
+ var setLogger = /* @__PURE__ */ __name((logger24) => {
22141
+ _logger = logger24;
22142
22142
  }, "setLogger");
22143
22143
  exports2.setLogger = setLogger;
22144
22144
  var setLoggerVerbosity = /* @__PURE__ */ __name((verbosity) => {
@@ -46719,8 +46719,8 @@ var require_src3 = __commonJS({
46719
46719
  throw new Error("Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead");
46720
46720
  }, "load");
46721
46721
  exports2.load = load;
46722
- var setLogger = /* @__PURE__ */ __name((logger27) => {
46723
- logging.setLogger(logger27);
46722
+ var setLogger = /* @__PURE__ */ __name((logger24) => {
46723
+ logging.setLogger(logger24);
46724
46724
  }, "setLogger");
46725
46725
  exports2.setLogger = setLogger;
46726
46726
  var setLogVerbosity = /* @__PURE__ */ __name((verbosity) => {
@@ -59489,7 +59489,7 @@ var require_ms = __commonJS({
59489
59489
  // ../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js
59490
59490
  var require_common2 = __commonJS({
59491
59491
  "../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js"(exports2, module2) {
59492
- function setup(env4) {
59492
+ function setup(env3) {
59493
59493
  createDebug.debug = createDebug;
59494
59494
  createDebug.default = createDebug;
59495
59495
  createDebug.coerce = coerce2;
@@ -59498,8 +59498,8 @@ var require_common2 = __commonJS({
59498
59498
  createDebug.enabled = enabled;
59499
59499
  createDebug.humanize = require_ms();
59500
59500
  createDebug.destroy = destroy;
59501
- Object.keys(env4).forEach((key) => {
59502
- createDebug[key] = env4[key];
59501
+ Object.keys(env3).forEach((key) => {
59502
+ createDebug[key] = env3[key];
59503
59503
  });
59504
59504
  createDebug.names = [];
59505
59505
  createDebug.skips = [];
@@ -59869,7 +59869,7 @@ var require_supports_color = __commonJS({
59869
59869
  var os4 = require("os");
59870
59870
  var tty = require("tty");
59871
59871
  var hasFlag = require_has_flag();
59872
- var { env: env4 } = process;
59872
+ var { env: env3 } = process;
59873
59873
  var flagForceColor;
59874
59874
  if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
59875
59875
  flagForceColor = 0;
@@ -59877,14 +59877,14 @@ var require_supports_color = __commonJS({
59877
59877
  flagForceColor = 1;
59878
59878
  }
59879
59879
  function envForceColor() {
59880
- if ("FORCE_COLOR" in env4) {
59881
- if (env4.FORCE_COLOR === "true") {
59880
+ if ("FORCE_COLOR" in env3) {
59881
+ if (env3.FORCE_COLOR === "true") {
59882
59882
  return 1;
59883
59883
  }
59884
- if (env4.FORCE_COLOR === "false") {
59884
+ if (env3.FORCE_COLOR === "false") {
59885
59885
  return 0;
59886
59886
  }
59887
- return env4.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env4.FORCE_COLOR, 10), 3);
59887
+ return env3.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env3.FORCE_COLOR, 10), 3);
59888
59888
  }
59889
59889
  }
59890
59890
  __name(envForceColor, "envForceColor");
@@ -59921,7 +59921,7 @@ var require_supports_color = __commonJS({
59921
59921
  return 0;
59922
59922
  }
59923
59923
  const min = forceColor || 0;
59924
- if (env4.TERM === "dumb") {
59924
+ if (env3.TERM === "dumb") {
59925
59925
  return min;
59926
59926
  }
59927
59927
  if (process.platform === "win32") {
@@ -59931,7 +59931,7 @@ var require_supports_color = __commonJS({
59931
59931
  }
59932
59932
  return 1;
59933
59933
  }
59934
- if ("CI" in env4) {
59934
+ if ("CI" in env3) {
59935
59935
  if ([
59936
59936
  "TRAVIS",
59937
59937
  "CIRCLECI",
@@ -59940,33 +59940,33 @@ var require_supports_color = __commonJS({
59940
59940
  "GITHUB_ACTIONS",
59941
59941
  "BUILDKITE",
59942
59942
  "DRONE"
59943
- ].some((sign) => sign in env4) || env4.CI_NAME === "codeship") {
59943
+ ].some((sign) => sign in env3) || env3.CI_NAME === "codeship") {
59944
59944
  return 1;
59945
59945
  }
59946
59946
  return min;
59947
59947
  }
59948
- if ("TEAMCITY_VERSION" in env4) {
59949
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env4.TEAMCITY_VERSION) ? 1 : 0;
59948
+ if ("TEAMCITY_VERSION" in env3) {
59949
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env3.TEAMCITY_VERSION) ? 1 : 0;
59950
59950
  }
59951
- if (env4.COLORTERM === "truecolor") {
59951
+ if (env3.COLORTERM === "truecolor") {
59952
59952
  return 3;
59953
59953
  }
59954
- if ("TERM_PROGRAM" in env4) {
59955
- const version4 = Number.parseInt((env4.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
59956
- switch (env4.TERM_PROGRAM) {
59954
+ if ("TERM_PROGRAM" in env3) {
59955
+ const version4 = Number.parseInt((env3.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
59956
+ switch (env3.TERM_PROGRAM) {
59957
59957
  case "iTerm.app":
59958
59958
  return version4 >= 3 ? 3 : 2;
59959
59959
  case "Apple_Terminal":
59960
59960
  return 2;
59961
59961
  }
59962
59962
  }
59963
- if (/-256(color)?$/i.test(env4.TERM)) {
59963
+ if (/-256(color)?$/i.test(env3.TERM)) {
59964
59964
  return 2;
59965
59965
  }
59966
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env4.TERM)) {
59966
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env3.TERM)) {
59967
59967
  return 1;
59968
59968
  }
59969
- if ("COLORTERM" in env4) {
59969
+ if ("COLORTERM" in env3) {
59970
59970
  return 1;
59971
59971
  }
59972
59972
  return min;
@@ -63444,7 +63444,7 @@ var require_utils_webcrypto = __commonJS({
63444
63444
  var nodeCrypto = require("crypto");
63445
63445
  module2.exports = {
63446
63446
  postgresMd5PasswordHash,
63447
- randomBytes: randomBytes2,
63447
+ randomBytes: randomBytes3,
63448
63448
  deriveKey,
63449
63449
  sha256: sha2562,
63450
63450
  hashByName,
@@ -63454,10 +63454,10 @@ var require_utils_webcrypto = __commonJS({
63454
63454
  var webCrypto = nodeCrypto.webcrypto || globalThis.crypto;
63455
63455
  var subtleCrypto = webCrypto.subtle;
63456
63456
  var textEncoder2 = new TextEncoder();
63457
- function randomBytes2(length) {
63457
+ function randomBytes3(length) {
63458
63458
  return webCrypto.getRandomValues(Buffer.alloc(length));
63459
63459
  }
63460
- __name(randomBytes2, "randomBytes");
63460
+ __name(randomBytes3, "randomBytes");
63461
63461
  async function md5(string4) {
63462
63462
  try {
63463
63463
  return nodeCrypto.createHash("md5").update(string4, "utf-8").digest("hex");
@@ -65746,8 +65746,8 @@ var require_helper = __commonJS({
65746
65746
  return old;
65747
65747
  };
65748
65748
  module2.exports.getFileName = function(rawEnv) {
65749
- var env4 = rawEnv || process.env;
65750
- var file2 = env4.PGPASSFILE || (isWin ? path9.join(env4.APPDATA || "./", "postgresql", "pgpass.conf") : path9.join(env4.HOME || "./", ".pgpass"));
65749
+ var env3 = rawEnv || process.env;
65750
+ var file2 = env3.PGPASSFILE || (isWin ? path9.join(env3.APPDATA || "./", "postgresql", "pgpass.conf") : path9.join(env3.HOME || "./", ".pgpass"));
65751
65751
  return file2;
65752
65752
  };
65753
65753
  module2.exports.usePgPass = function(stats, fname) {
@@ -66455,7 +66455,7 @@ var require_pg_pool = __commonJS({
66455
66455
  throw new Error("Release called on client which has already been released to the pool.");
66456
66456
  }
66457
66457
  __name(throwOnDoubleRelease, "throwOnDoubleRelease");
66458
- function promisify3(Promise2, callback) {
66458
+ function promisify4(Promise2, callback) {
66459
66459
  if (callback) {
66460
66460
  return {
66461
66461
  callback,
@@ -66479,7 +66479,7 @@ var require_pg_pool = __commonJS({
66479
66479
  result
66480
66480
  };
66481
66481
  }
66482
- __name(promisify3, "promisify");
66482
+ __name(promisify4, "promisify");
66483
66483
  function makeIdleListener(pool2, client) {
66484
66484
  return /* @__PURE__ */ __name(function idleListener(err2) {
66485
66485
  err2.client = client;
@@ -66597,7 +66597,7 @@ var require_pg_pool = __commonJS({
66597
66597
  const err2 = new Error("Cannot use a pool after calling end on the pool");
66598
66598
  return cb ? cb(err2) : this.Promise.reject(err2);
66599
66599
  }
66600
- const response = promisify3(this.Promise, cb);
66600
+ const response = promisify4(this.Promise, cb);
66601
66601
  const result = response.result;
66602
66602
  if (this._isFull() || this._idle.length) {
66603
66603
  if (this._idle.length) {
@@ -66751,7 +66751,7 @@ var require_pg_pool = __commonJS({
66751
66751
  }
66752
66752
  query(text3, values, cb) {
66753
66753
  if (typeof text3 === "function") {
66754
- const response2 = promisify3(this.Promise, text3);
66754
+ const response2 = promisify4(this.Promise, text3);
66755
66755
  setImmediate(function() {
66756
66756
  return response2.callback(new Error("Passing a function as the first parameter to pool.query is not supported"));
66757
66757
  });
@@ -66761,7 +66761,7 @@ var require_pg_pool = __commonJS({
66761
66761
  cb = values;
66762
66762
  values = void 0;
66763
66763
  }
66764
- const response = promisify3(this.Promise, cb);
66764
+ const response = promisify4(this.Promise, cb);
66765
66765
  cb = response.callback;
66766
66766
  this.connect((err2, client) => {
66767
66767
  if (err2) {
@@ -66806,7 +66806,7 @@ var require_pg_pool = __commonJS({
66806
66806
  return cb ? cb(err2) : this.Promise.reject(err2);
66807
66807
  }
66808
66808
  this.ending = true;
66809
- const promised = promisify3(this.Promise, cb);
66809
+ const promised = promisify4(this.Promise, cb);
66810
66810
  this._endCallback = promised.callback;
66811
66811
  this._pulseQueue();
66812
66812
  return promised.result;
@@ -74024,12 +74024,12 @@ var require_ComponentLogger = __commonJS({
74024
74024
  };
74025
74025
  exports2.DiagComponentLogger = DiagComponentLogger;
74026
74026
  function logProxy(funcName, namespace, args2) {
74027
- const logger27 = (0, global_utils_1.getGlobal)("diag");
74028
- if (!logger27) {
74027
+ const logger24 = (0, global_utils_1.getGlobal)("diag");
74028
+ if (!logger24) {
74029
74029
  return;
74030
74030
  }
74031
74031
  args2.unshift(namespace);
74032
- return logger27[funcName](...args2);
74032
+ return logger24[funcName](...args2);
74033
74033
  }
74034
74034
  __name(logProxy, "logProxy");
74035
74035
  }
@@ -74065,17 +74065,17 @@ var require_logLevelLogger = __commonJS({
74065
74065
  });
74066
74066
  exports2.createLogLevelDiagLogger = void 0;
74067
74067
  var types_1 = require_types3();
74068
- function createLogLevelDiagLogger(maxLevel, logger27) {
74068
+ function createLogLevelDiagLogger(maxLevel, logger24) {
74069
74069
  if (maxLevel < types_1.DiagLogLevel.NONE) {
74070
74070
  maxLevel = types_1.DiagLogLevel.NONE;
74071
74071
  } else if (maxLevel > types_1.DiagLogLevel.ALL) {
74072
74072
  maxLevel = types_1.DiagLogLevel.ALL;
74073
74073
  }
74074
- logger27 = logger27 || {};
74074
+ logger24 = logger24 || {};
74075
74075
  function _filterFunc(funcName, theLevel) {
74076
- const theFunc = logger27[funcName];
74076
+ const theFunc = logger24[funcName];
74077
74077
  if (typeof theFunc === "function" && maxLevel >= theLevel) {
74078
- return theFunc.bind(logger27);
74078
+ return theFunc.bind(logger24);
74079
74079
  }
74080
74080
  return function() {
74081
74081
  };
@@ -74118,18 +74118,18 @@ var require_diag = __commonJS({
74118
74118
  constructor() {
74119
74119
  function _logProxy(funcName) {
74120
74120
  return function(...args2) {
74121
- const logger27 = (0, global_utils_1.getGlobal)("diag");
74122
- if (!logger27) return;
74123
- return logger27[funcName](...args2);
74121
+ const logger24 = (0, global_utils_1.getGlobal)("diag");
74122
+ if (!logger24) return;
74123
+ return logger24[funcName](...args2);
74124
74124
  };
74125
74125
  }
74126
74126
  __name(_logProxy, "_logProxy");
74127
74127
  const self2 = this;
74128
- const setLogger = /* @__PURE__ */ __name((logger27, optionsOrLogLevel = {
74128
+ const setLogger = /* @__PURE__ */ __name((logger24, optionsOrLogLevel = {
74129
74129
  logLevel: types_1.DiagLogLevel.INFO
74130
74130
  }) => {
74131
74131
  var _a26, _b17, _c;
74132
- if (logger27 === self2) {
74132
+ if (logger24 === self2) {
74133
74133
  const err2 = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
74134
74134
  self2.error((_a26 = err2.stack) !== null && _a26 !== void 0 ? _a26 : err2.message);
74135
74135
  return false;
@@ -74140,7 +74140,7 @@ var require_diag = __commonJS({
74140
74140
  };
74141
74141
  }
74142
74142
  const oldLogger = (0, global_utils_1.getGlobal)("diag");
74143
- const newLogger = (0, logLevelLogger_1.createLogLevelDiagLogger)((_b17 = optionsOrLogLevel.logLevel) !== null && _b17 !== void 0 ? _b17 : types_1.DiagLogLevel.INFO, logger27);
74143
+ const newLogger = (0, logLevelLogger_1.createLogLevelDiagLogger)((_b17 = optionsOrLogLevel.logLevel) !== null && _b17 !== void 0 ? _b17 : types_1.DiagLogLevel.INFO, logger24);
74144
74144
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
74145
74145
  const stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
74146
74146
  oldLogger.warn(`Current logger will be overwritten from ${stack}`);
@@ -77839,20 +77839,20 @@ var require_supports_color2 = __commonJS({
77839
77839
  var os4 = require("os");
77840
77840
  var tty = require("tty");
77841
77841
  var hasFlag = require_has_flag();
77842
- var { env: env4 } = process;
77842
+ var { env: env3 } = process;
77843
77843
  var forceColor;
77844
77844
  if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
77845
77845
  forceColor = 0;
77846
77846
  } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
77847
77847
  forceColor = 1;
77848
77848
  }
77849
- if ("FORCE_COLOR" in env4) {
77850
- if (env4.FORCE_COLOR === "true") {
77849
+ if ("FORCE_COLOR" in env3) {
77850
+ if (env3.FORCE_COLOR === "true") {
77851
77851
  forceColor = 1;
77852
- } else if (env4.FORCE_COLOR === "false") {
77852
+ } else if (env3.FORCE_COLOR === "false") {
77853
77853
  forceColor = 0;
77854
77854
  } else {
77855
- forceColor = env4.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env4.FORCE_COLOR, 10), 3);
77855
+ forceColor = env3.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env3.FORCE_COLOR, 10), 3);
77856
77856
  }
77857
77857
  }
77858
77858
  function translateLevel(level) {
@@ -77881,7 +77881,7 @@ var require_supports_color2 = __commonJS({
77881
77881
  return 0;
77882
77882
  }
77883
77883
  const min = forceColor || 0;
77884
- if (env4.TERM === "dumb") {
77884
+ if (env3.TERM === "dumb") {
77885
77885
  return min;
77886
77886
  }
77887
77887
  if (process.platform === "win32") {
@@ -77891,7 +77891,7 @@ var require_supports_color2 = __commonJS({
77891
77891
  }
77892
77892
  return 1;
77893
77893
  }
77894
- if ("CI" in env4) {
77894
+ if ("CI" in env3) {
77895
77895
  if ([
77896
77896
  "TRAVIS",
77897
77897
  "CIRCLECI",
@@ -77899,33 +77899,33 @@ var require_supports_color2 = __commonJS({
77899
77899
  "GITLAB_CI",
77900
77900
  "GITHUB_ACTIONS",
77901
77901
  "BUILDKITE"
77902
- ].some((sign) => sign in env4) || env4.CI_NAME === "codeship") {
77902
+ ].some((sign) => sign in env3) || env3.CI_NAME === "codeship") {
77903
77903
  return 1;
77904
77904
  }
77905
77905
  return min;
77906
77906
  }
77907
- if ("TEAMCITY_VERSION" in env4) {
77908
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env4.TEAMCITY_VERSION) ? 1 : 0;
77907
+ if ("TEAMCITY_VERSION" in env3) {
77908
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env3.TEAMCITY_VERSION) ? 1 : 0;
77909
77909
  }
77910
- if (env4.COLORTERM === "truecolor") {
77910
+ if (env3.COLORTERM === "truecolor") {
77911
77911
  return 3;
77912
77912
  }
77913
- if ("TERM_PROGRAM" in env4) {
77914
- const version4 = parseInt((env4.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
77915
- switch (env4.TERM_PROGRAM) {
77913
+ if ("TERM_PROGRAM" in env3) {
77914
+ const version4 = parseInt((env3.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
77915
+ switch (env3.TERM_PROGRAM) {
77916
77916
  case "iTerm.app":
77917
77917
  return version4 >= 3 ? 3 : 2;
77918
77918
  case "Apple_Terminal":
77919
77919
  return 2;
77920
77920
  }
77921
77921
  }
77922
- if (/-256(color)?$/i.test(env4.TERM)) {
77922
+ if (/-256(color)?$/i.test(env3.TERM)) {
77923
77923
  return 2;
77924
77924
  }
77925
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env4.TERM)) {
77925
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env3.TERM)) {
77926
77926
  return 1;
77927
77927
  }
77928
- if ("COLORTERM" in env4) {
77928
+ if ("COLORTERM" in env3) {
77929
77929
  return 1;
77930
77930
  }
77931
77931
  return min;
@@ -91427,7 +91427,7 @@ var require_mock_interceptor = __commonJS({
91427
91427
  var require_mock_client = __commonJS({
91428
91428
  "../node_modules/.pnpm/undici@6.22.0/node_modules/undici/lib/mock/mock-client.js"(exports2, module2) {
91429
91429
  "use strict";
91430
- var { promisify: promisify3 } = require("node:util");
91430
+ var { promisify: promisify4 } = require("node:util");
91431
91431
  var Client10 = require_client4();
91432
91432
  var { buildMockDispatch } = require_mock_utils();
91433
91433
  var { kDispatches, kMockAgent, kClose, kOriginalClose, kOrigin, kOriginalDispatch, kConnected } = require_mock_symbols();
@@ -91462,7 +91462,7 @@ var require_mock_client = __commonJS({
91462
91462
  return new MockInterceptor(opts, this[kDispatches]);
91463
91463
  }
91464
91464
  async [kClose]() {
91465
- await promisify3(this[kOriginalClose])();
91465
+ await promisify4(this[kOriginalClose])();
91466
91466
  this[kConnected] = 0;
91467
91467
  this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
91468
91468
  }
@@ -91475,7 +91475,7 @@ var require_mock_client = __commonJS({
91475
91475
  var require_mock_pool = __commonJS({
91476
91476
  "../node_modules/.pnpm/undici@6.22.0/node_modules/undici/lib/mock/mock-pool.js"(exports2, module2) {
91477
91477
  "use strict";
91478
- var { promisify: promisify3 } = require("node:util");
91478
+ var { promisify: promisify4 } = require("node:util");
91479
91479
  var Pool3 = require_pool2();
91480
91480
  var { buildMockDispatch } = require_mock_utils();
91481
91481
  var { kDispatches, kMockAgent, kClose, kOriginalClose, kOrigin, kOriginalDispatch, kConnected } = require_mock_symbols();
@@ -91510,7 +91510,7 @@ var require_mock_pool = __commonJS({
91510
91510
  return new MockInterceptor(opts, this[kDispatches]);
91511
91511
  }
91512
91512
  async [kClose]() {
91513
- await promisify3(this[kOriginalClose])();
91513
+ await promisify4(this[kOriginalClose])();
91514
91514
  this[kConnected] = 0;
91515
91515
  this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
91516
91516
  }
@@ -99918,39 +99918,39 @@ var require_get_env = __commonJS({
99918
99918
  getEnv: /* @__PURE__ */ __name(() => getEnv2, "getEnv")
99919
99919
  });
99920
99920
  module2.exports = __toCommonJS2(get_env_exports);
99921
- var getEnv2 = /* @__PURE__ */ __name((env4 = process.env) => ({
99921
+ var getEnv2 = /* @__PURE__ */ __name((env3 = process.env) => ({
99922
99922
  /**
99923
99923
  * An indicator to show that System Environment Variables have been exposed to your project's Deployments.
99924
99924
  * @example "1"
99925
99925
  */
99926
- VERCEL: get(env4, "VERCEL"),
99926
+ VERCEL: get(env3, "VERCEL"),
99927
99927
  /**
99928
99928
  * An indicator that the code is running in a Continuous Integration environment.
99929
99929
  * @example "1"
99930
99930
  */
99931
- CI: get(env4, "CI"),
99931
+ CI: get(env3, "CI"),
99932
99932
  /**
99933
99933
  * The Environment that the app is deployed and running on.
99934
99934
  * @example "production"
99935
99935
  */
99936
- VERCEL_ENV: get(env4, "VERCEL_ENV"),
99936
+ VERCEL_ENV: get(env3, "VERCEL_ENV"),
99937
99937
  /**
99938
99938
  * The domain name of the generated deployment URL. The value does not include the protocol scheme https://.
99939
99939
  * NOTE: This Variable cannot be used in conjunction with Standard Deployment Protection.
99940
99940
  * @example "*.vercel.app"
99941
99941
  */
99942
- VERCEL_URL: get(env4, "VERCEL_URL"),
99942
+ VERCEL_URL: get(env3, "VERCEL_URL"),
99943
99943
  /**
99944
99944
  * The domain name of the generated Git branch URL. The value does not include the protocol scheme https://.
99945
99945
  * @example "*-git-*.vercel.app"
99946
99946
  */
99947
- VERCEL_BRANCH_URL: get(env4, "VERCEL_BRANCH_URL"),
99947
+ VERCEL_BRANCH_URL: get(env3, "VERCEL_BRANCH_URL"),
99948
99948
  /**
99949
99949
  * A production domain name of the project. This is useful to reliably generate links that point to production such as OG-image URLs.
99950
99950
  * The value does not include the protocol scheme https://.
99951
99951
  * @example "myproject.vercel.app"
99952
99952
  */
99953
- VERCEL_PROJECT_PRODUCTION_URL: get(env4, "VERCEL_PROJECT_PRODUCTION_URL"),
99953
+ VERCEL_PROJECT_PRODUCTION_URL: get(env3, "VERCEL_PROJECT_PRODUCTION_URL"),
99954
99954
  /**
99955
99955
  * The ID of the Region where the app is running.
99956
99956
  *
@@ -99977,80 +99977,80 @@ var require_get_env = __commonJS({
99977
99977
  *
99978
99978
  * @example "iad1"
99979
99979
  */
99980
- VERCEL_REGION: get(env4, "VERCEL_REGION"),
99980
+ VERCEL_REGION: get(env3, "VERCEL_REGION"),
99981
99981
  /**
99982
99982
  * The unique identifier for the deployment, which can be used to implement Skew Protection.
99983
99983
  * @example "dpl_7Gw5ZMBpQA8h9GF832KGp7nwbuh3"
99984
99984
  */
99985
- VERCEL_DEPLOYMENT_ID: get(env4, "VERCEL_DEPLOYMENT_ID"),
99985
+ VERCEL_DEPLOYMENT_ID: get(env3, "VERCEL_DEPLOYMENT_ID"),
99986
99986
  /**
99987
99987
  * When Skew Protection is enabled in Project Settings, this value is set to 1.
99988
99988
  * @example "1"
99989
99989
  */
99990
- VERCEL_SKEW_PROTECTION_ENABLED: get(env4, "VERCEL_SKEW_PROTECTION_ENABLED"),
99990
+ VERCEL_SKEW_PROTECTION_ENABLED: get(env3, "VERCEL_SKEW_PROTECTION_ENABLED"),
99991
99991
  /**
99992
99992
  * The Protection Bypass for Automation value, if the secret has been generated in the project's Deployment Protection settings.
99993
99993
  */
99994
- VERCEL_AUTOMATION_BYPASS_SECRET: get(env4, "VERCEL_AUTOMATION_BYPASS_SECRET"),
99994
+ VERCEL_AUTOMATION_BYPASS_SECRET: get(env3, "VERCEL_AUTOMATION_BYPASS_SECRET"),
99995
99995
  /**
99996
99996
  * The Git Provider the deployment is triggered from.
99997
99997
  * @example "github"
99998
99998
  */
99999
- VERCEL_GIT_PROVIDER: get(env4, "VERCEL_GIT_PROVIDER"),
99999
+ VERCEL_GIT_PROVIDER: get(env3, "VERCEL_GIT_PROVIDER"),
100000
100000
  /**
100001
100001
  * The origin repository the deployment is triggered from.
100002
100002
  * @example "my-site"
100003
100003
  */
100004
- VERCEL_GIT_REPO_SLUG: get(env4, "VERCEL_GIT_REPO_SLUG"),
100004
+ VERCEL_GIT_REPO_SLUG: get(env3, "VERCEL_GIT_REPO_SLUG"),
100005
100005
  /**
100006
100006
  * The account that owns the repository the deployment is triggered from.
100007
100007
  * @example "acme"
100008
100008
  */
100009
- VERCEL_GIT_REPO_OWNER: get(env4, "VERCEL_GIT_REPO_OWNER"),
100009
+ VERCEL_GIT_REPO_OWNER: get(env3, "VERCEL_GIT_REPO_OWNER"),
100010
100010
  /**
100011
100011
  * The ID of the repository the deployment is triggered from.
100012
100012
  * @example "117716146"
100013
100013
  */
100014
- VERCEL_GIT_REPO_ID: get(env4, "VERCEL_GIT_REPO_ID"),
100014
+ VERCEL_GIT_REPO_ID: get(env3, "VERCEL_GIT_REPO_ID"),
100015
100015
  /**
100016
100016
  * The git branch of the commit the deployment was triggered by.
100017
100017
  * @example "improve-about-page"
100018
100018
  */
100019
- VERCEL_GIT_COMMIT_REF: get(env4, "VERCEL_GIT_COMMIT_REF"),
100019
+ VERCEL_GIT_COMMIT_REF: get(env3, "VERCEL_GIT_COMMIT_REF"),
100020
100020
  /**
100021
100021
  * The git SHA of the commit the deployment was triggered by.
100022
100022
  * @example "fa1eade47b73733d6312d5abfad33ce9e4068081"
100023
100023
  */
100024
- VERCEL_GIT_COMMIT_SHA: get(env4, "VERCEL_GIT_COMMIT_SHA"),
100024
+ VERCEL_GIT_COMMIT_SHA: get(env3, "VERCEL_GIT_COMMIT_SHA"),
100025
100025
  /**
100026
100026
  * The message attached to the commit the deployment was triggered by.
100027
100027
  * @example "Update about page"
100028
100028
  */
100029
- VERCEL_GIT_COMMIT_MESSAGE: get(env4, "VERCEL_GIT_COMMIT_MESSAGE"),
100029
+ VERCEL_GIT_COMMIT_MESSAGE: get(env3, "VERCEL_GIT_COMMIT_MESSAGE"),
100030
100030
  /**
100031
100031
  * The username attached to the author of the commit that the project was deployed by.
100032
100032
  * @example "johndoe"
100033
100033
  */
100034
- VERCEL_GIT_COMMIT_AUTHOR_LOGIN: get(env4, "VERCEL_GIT_COMMIT_AUTHOR_LOGIN"),
100034
+ VERCEL_GIT_COMMIT_AUTHOR_LOGIN: get(env3, "VERCEL_GIT_COMMIT_AUTHOR_LOGIN"),
100035
100035
  /**
100036
100036
  * The name attached to the author of the commit that the project was deployed by.
100037
100037
  * @example "John Doe"
100038
100038
  */
100039
- VERCEL_GIT_COMMIT_AUTHOR_NAME: get(env4, "VERCEL_GIT_COMMIT_AUTHOR_NAME"),
100039
+ VERCEL_GIT_COMMIT_AUTHOR_NAME: get(env3, "VERCEL_GIT_COMMIT_AUTHOR_NAME"),
100040
100040
  /**
100041
100041
  * The git SHA of the last successful deployment for the project and branch.
100042
100042
  * NOTE: This Variable is only exposed when an Ignored Build Step is provided.
100043
100043
  * @example "fa1eade47b73733d6312d5abfad33ce9e4068080"
100044
100044
  */
100045
- VERCEL_GIT_PREVIOUS_SHA: get(env4, "VERCEL_GIT_PREVIOUS_SHA"),
100045
+ VERCEL_GIT_PREVIOUS_SHA: get(env3, "VERCEL_GIT_PREVIOUS_SHA"),
100046
100046
  /**
100047
100047
  * The pull request id the deployment was triggered by. If a deployment is created on a branch before a pull request is made, this value will be an empty string.
100048
100048
  * @example "23"
100049
100049
  */
100050
- VERCEL_GIT_PULL_REQUEST_ID: get(env4, "VERCEL_GIT_PULL_REQUEST_ID")
100050
+ VERCEL_GIT_PULL_REQUEST_ID: get(env3, "VERCEL_GIT_PULL_REQUEST_ID")
100051
100051
  }), "getEnv");
100052
- var get = /* @__PURE__ */ __name((env4, key) => {
100053
- const value = env4[key];
100052
+ var get = /* @__PURE__ */ __name((env3, key) => {
100053
+ const value = env3[key];
100054
100054
  return value === "" ? void 0 : value;
100055
100055
  }, "get");
100056
100056
  }
@@ -109225,7 +109225,7 @@ var triggers = pgTable("triggers", {
109225
109225
  enabled: boolean("enabled").notNull().default(true),
109226
109226
  inputSchema: jsonb("input_schema").$type(),
109227
109227
  outputTransform: jsonb("output_transform").$type(),
109228
- messageTemplate: text("message_template").notNull(),
109228
+ messageTemplate: text("message_template"),
109229
109229
  authentication: jsonb("authentication").$type(),
109230
109230
  signingSecret: text("signing_secret"),
109231
109231
  ...timestamps
@@ -127196,34 +127196,29 @@ var AgentApiInsertSchema = createApiInsertSchema(AgentInsertSchema).extend({
127196
127196
  id: resourceIdSchema
127197
127197
  }).openapi("AgentCreate");
127198
127198
  var AgentApiUpdateSchema = createApiUpdateSchema(AgentUpdateSchema).openapi("AgentUpdate");
127199
- var TriggerAuthenticationSchema = external_exports.discriminatedUnion("type", [
127200
- external_exports.object({
127201
- type: external_exports.literal("api_key"),
127202
- data: external_exports.object({
127203
- name: external_exports.string().describe("Header name for the API key"),
127204
- value: external_exports.string().describe("Expected API key value")
127205
- }),
127206
- add_position: external_exports.literal("header")
127207
- }),
127208
- external_exports.object({
127209
- type: external_exports.literal("basic_auth"),
127210
- data: external_exports.object({
127211
- username: external_exports.string().describe("Expected username"),
127212
- password: external_exports.string().describe("Expected password")
127213
- }),
127214
- add_position: external_exports.literal("header")
127215
- }),
127216
- external_exports.object({
127217
- type: external_exports.literal("bearer_token"),
127218
- data: external_exports.object({
127219
- token: external_exports.string().describe("Expected bearer token")
127220
- }),
127221
- add_position: external_exports.literal("header")
127222
- }),
127223
- external_exports.object({
127224
- type: external_exports.literal("none")
127225
- })
127226
- ]).openapi("TriggerAuthentication");
127199
+ var TriggerAuthHeaderInputSchema = external_exports.object({
127200
+ name: external_exports.string().min(1).describe("Header name (e.g., X-API-Key, Authorization)"),
127201
+ value: external_exports.string().min(1).describe("Expected header value (plaintext)")
127202
+ });
127203
+ var TriggerAuthHeaderUpdateSchema = external_exports.object({
127204
+ name: external_exports.string().min(1).describe("Header name (e.g., X-API-Key, Authorization)"),
127205
+ value: external_exports.string().optional().describe("New header value (plaintext). If omitted, existing value is kept."),
127206
+ keepExisting: external_exports.boolean().optional().describe("If true, keep the existing hashed value for this header")
127207
+ });
127208
+ var TriggerAuthenticationInputSchema = external_exports.object({
127209
+ headers: external_exports.array(TriggerAuthHeaderInputSchema).optional().describe("Array of headers to validate on incoming requests")
127210
+ }).openapi("TriggerAuthenticationInput");
127211
+ var TriggerAuthenticationUpdateSchema = external_exports.object({
127212
+ headers: external_exports.array(TriggerAuthHeaderUpdateSchema).optional().describe("Array of headers. Use keepExisting:true to preserve existing hashed value.")
127213
+ }).openapi("TriggerAuthenticationUpdate");
127214
+ var TriggerAuthHeaderStoredSchema = external_exports.object({
127215
+ name: external_exports.string().describe("Header name"),
127216
+ valueHash: external_exports.string().describe("Hash of the expected header value"),
127217
+ valuePrefix: external_exports.string().describe("First 8 chars of value for display")
127218
+ });
127219
+ var TriggerAuthenticationStoredSchema = external_exports.object({
127220
+ headers: external_exports.array(TriggerAuthHeaderStoredSchema).optional().describe("Array of headers with hashed values")
127221
+ }).openapi("TriggerAuthenticationStored");
127227
127222
  var TriggerOutputTransformSchema = external_exports.object({
127228
127223
  jmespath: external_exports.string().optional().describe("JMESPath expression for payload transformation"),
127229
127224
  objectTransformation: external_exports.record(external_exports.string(), external_exports.string()).optional().describe("Object transformation mapping")
@@ -127241,8 +127236,8 @@ var TriggerInsertSchema = createInsertSchema2(triggers, {
127241
127236
  enabled: /* @__PURE__ */ __name(() => external_exports.boolean().default(true).describe("Whether the trigger is enabled"), "enabled"),
127242
127237
  inputSchema: /* @__PURE__ */ __name(() => external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("JSON Schema for input validation"), "inputSchema"),
127243
127238
  outputTransform: /* @__PURE__ */ __name(() => TriggerOutputTransformSchema.optional(), "outputTransform"),
127244
- messageTemplate: /* @__PURE__ */ __name(() => external_exports.string().trim().nonempty().describe("Message template with {{placeholder}} syntax"), "messageTemplate"),
127245
- authentication: /* @__PURE__ */ __name(() => TriggerAuthenticationSchema.optional(), "authentication"),
127239
+ messageTemplate: /* @__PURE__ */ __name(() => external_exports.string().trim().nonempty().describe("Message template with {{placeholder}} syntax").optional(), "messageTemplate"),
127240
+ authentication: /* @__PURE__ */ __name(() => TriggerAuthenticationInputSchema.optional(), "authentication"),
127246
127241
  signingSecret: /* @__PURE__ */ __name(() => external_exports.string().optional().describe("HMAC-SHA256 signing secret"), "signingSecret")
127247
127242
  });
127248
127243
  var TriggerUpdateSchema = external_exports.object({
@@ -127252,8 +127247,9 @@ var TriggerUpdateSchema = external_exports.object({
127252
127247
  inputSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("JSON Schema for input validation"),
127253
127248
  outputTransform: TriggerOutputTransformSchema.optional(),
127254
127249
  messageTemplate: external_exports.string().trim().nonempty().describe("Message template with {{placeholder}} syntax").optional(),
127255
- authentication: TriggerAuthenticationSchema.optional(),
127256
- signingSecret: external_exports.string().optional().describe("HMAC-SHA256 signing secret")
127250
+ authentication: TriggerAuthenticationUpdateSchema.optional(),
127251
+ signingSecret: external_exports.string().optional().describe("New HMAC-SHA256 signing secret"),
127252
+ keepExistingSigningSecret: external_exports.boolean().optional().describe("If true, keep existing signing secret")
127257
127253
  });
127258
127254
  var TriggerApiSelectSchema = createAgentScopedApiSchema(TriggerSelectSchema).openapi("Trigger");
127259
127255
  var TriggerApiInsertSchema = createAgentScopedApiInsertSchema(TriggerInsertSchema).extend({
@@ -130623,7 +130619,7 @@ var envSchema = external_exports.object({
130623
130619
  POSTGRES_POOL_SIZE: external_exports.string().optional(),
130624
130620
  INKEEP_AGENTS_JWT_SIGNING_SECRET: external_exports.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional(),
130625
130621
  INKEEP_AGENTS_MANAGE_UI_URL: external_exports.string().optional(),
130626
- INKEEP_AGENTS_MANAGE_API_URL: external_exports.string().optional(),
130622
+ INKEEP_AGENTS_API_URL: external_exports.string().optional(),
130627
130623
  BETTER_AUTH_SECRET: external_exports.string().optional(),
130628
130624
  TRUSTED_ORIGIN: external_exports.string().optional(),
130629
130625
  OAUTH_PROXY_PRODUCTION_URL: external_exports.string().optional()
@@ -130790,12 +130786,12 @@ var LoggerFactory = class {
130790
130786
  if (!logger$12) throw new Error(`Logger '${name18}' not found in cache`);
130791
130787
  return logger$12;
130792
130788
  }
130793
- let logger27;
130794
- if (this.config.loggerFactory) logger27 = this.config.loggerFactory(name18);
130795
- else if (this.config.defaultLogger) logger27 = this.config.defaultLogger;
130796
- else logger27 = new PinoLogger(name18, this.config.pinoConfig);
130797
- this.loggers.set(name18, logger27);
130798
- return logger27;
130789
+ let logger24;
130790
+ if (this.config.loggerFactory) logger24 = this.config.loggerFactory(name18);
130791
+ else if (this.config.defaultLogger) logger24 = this.config.defaultLogger;
130792
+ else logger24 = new PinoLogger(name18, this.config.pinoConfig);
130793
+ this.loggers.set(name18, logger24);
130794
+ return logger24;
130799
130795
  }
130800
130796
  /**
130801
130797
  * Reset factory to default state
@@ -149816,8 +149812,8 @@ var test = /* @__PURE__ */ __name((fn2, ...args2) => {
149816
149812
  return false;
149817
149813
  }
149818
149814
  }, "test");
149819
- var factory = /* @__PURE__ */ __name((env4) => {
149820
- const { fetch: fetch2, Request: Request2, Response: Response2 } = Object.assign({}, globalFetchAPI, env4);
149815
+ var factory = /* @__PURE__ */ __name((env3) => {
149816
+ const { fetch: fetch2, Request: Request2, Response: Response2 } = Object.assign({}, globalFetchAPI, env3);
149821
149817
  const isFetchSupported = isFunction2(fetch2);
149822
149818
  const isRequestSupported = isFunction2(Request2);
149823
149819
  const isResponseSupported = isFunction2(Response2);
@@ -149973,10 +149969,10 @@ var factory = /* @__PURE__ */ __name((env4) => {
149973
149969
  }, "factory");
149974
149970
  var seedCache = /* @__PURE__ */ new Map();
149975
149971
  var getFetch = /* @__PURE__ */ __name((config3) => {
149976
- let env4 = utils_default.merge.call({
149972
+ let env3 = utils_default.merge.call({
149977
149973
  skipUndefined: true
149978
149974
  }, globalFetchAPI, config3 ? config3.env : null);
149979
- const { fetch: fetch2, Request: Request2, Response: Response2 } = env4;
149975
+ const { fetch: fetch2, Request: Request2, Response: Response2 } = env3;
149980
149976
  const seeds = [
149981
149977
  Request2,
149982
149978
  Response2,
@@ -149986,7 +149982,7 @@ var getFetch = /* @__PURE__ */ __name((config3) => {
149986
149982
  while (i3--) {
149987
149983
  seed = seeds[i3];
149988
149984
  target = map2.get(seed);
149989
- target === void 0 && map2.set(seed, target = i3 ? /* @__PURE__ */ new Map() : factory(env4));
149985
+ target === void 0 && map2.set(seed, target = i3 ? /* @__PURE__ */ new Map() : factory(env3));
149990
149986
  map2 = target;
149991
149987
  }
149992
149988
  return target;
@@ -162144,7 +162140,7 @@ var PglitePreparedQuery = class extends PgPreparedQuery {
162144
162140
  static {
162145
162141
  __name(this, "PglitePreparedQuery");
162146
162142
  }
162147
- constructor(client, queryString, params, logger27, cache, queryMetadata, cacheConfig, fields, name18, _isResponseInArrayMode, customResultMapper) {
162143
+ constructor(client, queryString, params, logger24, cache, queryMetadata, cacheConfig, fields, name18, _isResponseInArrayMode, customResultMapper) {
162148
162144
  super({
162149
162145
  sql: queryString,
162150
162146
  params
@@ -162152,7 +162148,7 @@ var PglitePreparedQuery = class extends PgPreparedQuery {
162152
162148
  this.client = client;
162153
162149
  this.queryString = queryString;
162154
162150
  this.params = params;
162155
- this.logger = logger27;
162151
+ this.logger = logger24;
162156
162152
  this.fields = fields;
162157
162153
  this._isResponseInArrayMode = _isResponseInArrayMode;
162158
162154
  this.customResultMapper = customResultMapper;
@@ -162305,11 +162301,11 @@ function construct(client, config3 = {}) {
162305
162301
  const dialect = new PgDialect({
162306
162302
  casing: config3.casing
162307
162303
  });
162308
- let logger27;
162304
+ let logger24;
162309
162305
  if (config3.logger === true) {
162310
- logger27 = new DefaultLogger();
162306
+ logger24 = new DefaultLogger();
162311
162307
  } else if (config3.logger !== false) {
162312
- logger27 = config3.logger;
162308
+ logger24 = config3.logger;
162313
162309
  }
162314
162310
  let schema;
162315
162311
  if (config3.schema) {
@@ -162321,7 +162317,7 @@ function construct(client, config3 = {}) {
162321
162317
  };
162322
162318
  }
162323
162319
  const driver = new PgliteDriver(client, dialect, {
162324
- logger: logger27,
162320
+ logger: logger24,
162325
162321
  cache: config3.cache
162326
162322
  });
162327
162323
  const session2 = driver.createSession(schema);
@@ -162390,7 +162386,7 @@ var NodePgPreparedQuery = class extends PgPreparedQuery {
162390
162386
  static {
162391
162387
  __name(this, "NodePgPreparedQuery");
162392
162388
  }
162393
- constructor(client, queryString, params, logger27, cache, queryMetadata, cacheConfig, fields, name18, _isResponseInArrayMode, customResultMapper) {
162389
+ constructor(client, queryString, params, logger24, cache, queryMetadata, cacheConfig, fields, name18, _isResponseInArrayMode, customResultMapper) {
162394
162390
  super({
162395
162391
  sql: queryString,
162396
162392
  params
@@ -162398,7 +162394,7 @@ var NodePgPreparedQuery = class extends PgPreparedQuery {
162398
162394
  this.client = client;
162399
162395
  this.queryString = queryString;
162400
162396
  this.params = params;
162401
- this.logger = logger27;
162397
+ this.logger = logger24;
162402
162398
  this.fields = fields;
162403
162399
  this._isResponseInArrayMode = _isResponseInArrayMode;
162404
162400
  this.customResultMapper = customResultMapper;
@@ -162622,11 +162618,11 @@ function construct2(client, config3 = {}) {
162622
162618
  const dialect = new PgDialect({
162623
162619
  casing: config3.casing
162624
162620
  });
162625
- let logger27;
162621
+ let logger24;
162626
162622
  if (config3.logger === true) {
162627
- logger27 = new DefaultLogger();
162623
+ logger24 = new DefaultLogger();
162628
162624
  } else if (config3.logger !== false) {
162629
- logger27 = config3.logger;
162625
+ logger24 = config3.logger;
162630
162626
  }
162631
162627
  let schema;
162632
162628
  if (config3.schema) {
@@ -162638,7 +162634,7 @@ function construct2(client, config3 = {}) {
162638
162634
  };
162639
162635
  }
162640
162636
  const driver = new NodePgDriver(client, dialect, {
162641
- logger: logger27,
162637
+ logger: logger24,
162642
162638
  cache: config3.cache
162643
162639
  });
162644
162640
  const session2 = driver.createSession(schema);
@@ -171461,12 +171457,12 @@ var logWarnings = /* @__PURE__ */ __name((options) => {
171461
171457
  if (options.warnings.length === 0) {
171462
171458
  return;
171463
171459
  }
171464
- const logger27 = globalThis.AI_SDK_LOG_WARNINGS;
171465
- if (logger27 === false) {
171460
+ const logger24 = globalThis.AI_SDK_LOG_WARNINGS;
171461
+ if (logger24 === false) {
171466
171462
  return;
171467
171463
  }
171468
- if (typeof logger27 === "function") {
171469
- logger27(options);
171464
+ if (typeof logger24 === "function") {
171465
+ logger24(options);
171470
171466
  return;
171471
171467
  }
171472
171468
  if (!hasLoggedBefore) {
@@ -199882,11 +199878,11 @@ var parseLogLevel = /* @__PURE__ */ __name((maybeLevel, sourceName, client) => {
199882
199878
  function noop4() {
199883
199879
  }
199884
199880
  __name(noop4, "noop");
199885
- function makeLogFn(fnLevel, logger27, logLevel) {
199886
- if (!logger27 || levelNumbers[fnLevel] > levelNumbers[logLevel]) {
199881
+ function makeLogFn(fnLevel, logger24, logLevel) {
199882
+ if (!logger24 || levelNumbers[fnLevel] > levelNumbers[logLevel]) {
199887
199883
  return noop4;
199888
199884
  } else {
199889
- return logger27[fnLevel].bind(logger27);
199885
+ return logger24[fnLevel].bind(logger24);
199890
199886
  }
199891
199887
  }
199892
199888
  __name(makeLogFn, "makeLogFn");
@@ -199898,22 +199894,22 @@ var noopLogger = {
199898
199894
  };
199899
199895
  var cachedLoggers = /* @__PURE__ */ new WeakMap();
199900
199896
  function loggerFor(client) {
199901
- const logger27 = client.logger;
199897
+ const logger24 = client.logger;
199902
199898
  const logLevel = client.logLevel ?? "off";
199903
- if (!logger27) {
199899
+ if (!logger24) {
199904
199900
  return noopLogger;
199905
199901
  }
199906
- const cachedLogger = cachedLoggers.get(logger27);
199902
+ const cachedLogger = cachedLoggers.get(logger24);
199907
199903
  if (cachedLogger && cachedLogger[0] === logLevel) {
199908
199904
  return cachedLogger[1];
199909
199905
  }
199910
199906
  const levelLogger = {
199911
- error: makeLogFn("error", logger27, logLevel),
199912
- warn: makeLogFn("warn", logger27, logLevel),
199913
- info: makeLogFn("info", logger27, logLevel),
199914
- debug: makeLogFn("debug", logger27, logLevel)
199907
+ error: makeLogFn("error", logger24, logLevel),
199908
+ warn: makeLogFn("warn", logger24, logLevel),
199909
+ info: makeLogFn("info", logger24, logLevel),
199910
+ debug: makeLogFn("debug", logger24, logLevel)
199915
199911
  };
199916
- cachedLoggers.set(logger27, [
199912
+ cachedLoggers.set(logger24, [
199917
199913
  logLevel,
199918
199914
  levelLogger
199919
199915
  ]);
@@ -200122,12 +200118,12 @@ var buildHeaders = /* @__PURE__ */ __name((newHeaders) => {
200122
200118
  }, "buildHeaders");
200123
200119
 
200124
200120
  // ../node_modules/.pnpm/@composio+client@0.1.0-alpha.40/node_modules/@composio/client/internal/utils/env.mjs
200125
- var readEnv = /* @__PURE__ */ __name((env4) => {
200121
+ var readEnv = /* @__PURE__ */ __name((env3) => {
200126
200122
  if (typeof globalThis.process !== "undefined") {
200127
- return globalThis.process.env?.[env4]?.trim() ?? void 0;
200123
+ return globalThis.process.env?.[env3]?.trim() ?? void 0;
200128
200124
  }
200129
200125
  if (typeof globalThis.Deno !== "undefined") {
200130
- return globalThis.Deno.env?.get?.(env4)?.trim();
200126
+ return globalThis.Deno.env?.get?.(env3)?.trim();
200131
200127
  }
200132
200128
  return void 0;
200133
200129
  }, "readEnv");
@@ -201694,11 +201690,11 @@ var parseLogLevel2 = /* @__PURE__ */ __name((maybeLevel, sourceName, client) =>
201694
201690
  function noop5() {
201695
201691
  }
201696
201692
  __name(noop5, "noop");
201697
- function makeLogFn2(fnLevel, logger27, logLevel) {
201698
- if (!logger27 || levelNumbers2[fnLevel] > levelNumbers2[logLevel]) {
201693
+ function makeLogFn2(fnLevel, logger24, logLevel) {
201694
+ if (!logger24 || levelNumbers2[fnLevel] > levelNumbers2[logLevel]) {
201699
201695
  return noop5;
201700
201696
  } else {
201701
- return logger27[fnLevel].bind(logger27);
201697
+ return logger24[fnLevel].bind(logger24);
201702
201698
  }
201703
201699
  }
201704
201700
  __name(makeLogFn2, "makeLogFn");
@@ -201710,22 +201706,22 @@ var noopLogger2 = {
201710
201706
  };
201711
201707
  var cachedLoggers2 = /* @__PURE__ */ new WeakMap();
201712
201708
  function loggerFor2(client) {
201713
- const logger27 = client.logger;
201709
+ const logger24 = client.logger;
201714
201710
  const logLevel = client.logLevel ?? "off";
201715
- if (!logger27) {
201711
+ if (!logger24) {
201716
201712
  return noopLogger2;
201717
201713
  }
201718
- const cachedLogger = cachedLoggers2.get(logger27);
201714
+ const cachedLogger = cachedLoggers2.get(logger24);
201719
201715
  if (cachedLogger && cachedLogger[0] === logLevel) {
201720
201716
  return cachedLogger[1];
201721
201717
  }
201722
201718
  const levelLogger = {
201723
- error: makeLogFn2("error", logger27, logLevel),
201724
- warn: makeLogFn2("warn", logger27, logLevel),
201725
- info: makeLogFn2("info", logger27, logLevel),
201726
- debug: makeLogFn2("debug", logger27, logLevel)
201719
+ error: makeLogFn2("error", logger24, logLevel),
201720
+ warn: makeLogFn2("warn", logger24, logLevel),
201721
+ info: makeLogFn2("info", logger24, logLevel),
201722
+ debug: makeLogFn2("debug", logger24, logLevel)
201727
201723
  };
201728
- cachedLoggers2.set(logger27, [
201724
+ cachedLoggers2.set(logger24, [
201729
201725
  logLevel,
201730
201726
  levelLogger
201731
201727
  ]);
@@ -201770,7 +201766,7 @@ var Stream = class _Stream {
201770
201766
  }
201771
201767
  static fromSSEResponse(response, controller, client) {
201772
201768
  let consumed = false;
201773
- const logger27 = client ? loggerFor2(client) : console;
201769
+ const logger24 = client ? loggerFor2(client) : console;
201774
201770
  async function* iterator2() {
201775
201771
  if (consumed) {
201776
201772
  throw new OpenAIError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
@@ -201789,8 +201785,8 @@ var Stream = class _Stream {
201789
201785
  try {
201790
201786
  data = JSON.parse(sse.data);
201791
201787
  } catch (e) {
201792
- logger27.error(`Could not parse message into JSON:`, sse.data);
201793
- logger27.error(`From chunk:`, sse.raw);
201788
+ logger24.error(`Could not parse message into JSON:`, sse.data);
201789
+ logger24.error(`From chunk:`, sse.raw);
201794
201790
  throw e;
201795
201791
  }
201796
201792
  if (data && data.error) {
@@ -204607,12 +204603,12 @@ var toFloat32Array = /* @__PURE__ */ __name((base64Str) => {
204607
204603
  }, "toFloat32Array");
204608
204604
 
204609
204605
  // ../node_modules/.pnpm/openai@5.23.2_ws@8.18.3_zod@4.2.1/node_modules/openai/internal/utils/env.mjs
204610
- var readEnv2 = /* @__PURE__ */ __name((env4) => {
204606
+ var readEnv2 = /* @__PURE__ */ __name((env3) => {
204611
204607
  if (typeof globalThis.process !== "undefined") {
204612
- return globalThis.process.env?.[env4]?.trim() ?? void 0;
204608
+ return globalThis.process.env?.[env3]?.trim() ?? void 0;
204613
204609
  }
204614
204610
  if (typeof globalThis.Deno !== "undefined") {
204615
- return globalThis.Deno.env?.get?.(env4)?.trim();
204611
+ return globalThis.Deno.env?.get?.(env3)?.trim();
204616
204612
  }
204617
204613
  return void 0;
204618
204614
  }, "readEnv");
@@ -210252,6 +210248,11 @@ var logger$1 = getLogger("composio-client");
210252
210248
  // ../packages/agents-core/dist/utils/third-party-mcp-servers/third-party-check.js
210253
210249
  var logger15 = getLogger("third-party-check");
210254
210250
 
210251
+ // ../packages/agents-core/dist/utils/trigger-auth.js
210252
+ var import_node_crypto6 = require("node:crypto");
210253
+ var import_node_util3 = require("node:util");
210254
+ var scryptAsync2 = (0, import_node_util3.promisify)(import_node_crypto6.scrypt);
210255
+
210255
210256
  // ../packages/agents-core/dist/utils/tracer-factory.js
210256
210257
  var logger16 = getLogger("tracer");
210257
210258
 
@@ -210702,10 +210703,10 @@ var defaultLogger = {
210702
210703
  error: /* @__PURE__ */ __name(() => {
210703
210704
  }, "error")
210704
210705
  };
210705
- var getFullAgent = /* @__PURE__ */ __name((db, logger27 = defaultLogger) => async (params) => {
210706
+ var getFullAgent = /* @__PURE__ */ __name((db, logger24 = defaultLogger) => async (params) => {
210706
210707
  const { scopes } = params;
210707
210708
  const { tenantId, projectId } = scopes;
210708
- logger27.info({
210709
+ logger24.info({
210709
210710
  tenantId,
210710
210711
  agentId: scopes.agentId
210711
210712
  }, "Retrieving full agent definition");
@@ -210718,20 +210719,20 @@ var getFullAgent = /* @__PURE__ */ __name((db, logger27 = defaultLogger) => asyn
210718
210719
  }
210719
210720
  });
210720
210721
  if (!agent) {
210721
- logger27.info({
210722
+ logger24.info({
210722
210723
  tenantId,
210723
210724
  agentId: scopes.agentId
210724
210725
  }, "Agent not found");
210725
210726
  return null;
210726
210727
  }
210727
- logger27.info({
210728
+ logger24.info({
210728
210729
  tenantId,
210729
210730
  agentId: scopes.agentId,
210730
210731
  agentCount: Object.keys(agent.subAgents).length
210731
210732
  }, "Full agent retrieved successfully");
210732
210733
  return agent;
210733
210734
  } catch (error46) {
210734
- logger27.error({
210735
+ logger24.error({
210735
210736
  tenantId,
210736
210737
  agentId: scopes.agentId,
210737
210738
  error: error46 instanceof Error ? error46.message : "Unknown error"
@@ -210794,7 +210795,7 @@ var doltAbortMerge = /* @__PURE__ */ __name((db) => async () => {
210794
210795
  }, "doltAbortMerge");
210795
210796
 
210796
210797
  // ../packages/agents-core/dist/dolt/schema-sync.js
210797
- var import_node_crypto6 = require("node:crypto");
210798
+ var import_node_crypto7 = require("node:crypto");
210798
210799
  var SCHEMA_SOURCE_BRANCH = "main";
210799
210800
  var getActiveBranch = /* @__PURE__ */ __name((db) => async () => {
210800
210801
  return (await db.execute(sql`SELECT active_branch() as branch`)).rows[0]?.branch;
@@ -210820,7 +210821,7 @@ var commitPendingChanges = /* @__PURE__ */ __name((db) => async (options) => {
210820
210821
  var SCHEMA_SYNC_LOCK_PREFIX = "schema_sync_";
210821
210822
  var getSchemaSyncLockKey = /* @__PURE__ */ __name((branchName) => {
210822
210823
  const lockKey = `${SCHEMA_SYNC_LOCK_PREFIX}${branchName}`;
210823
- return (0, import_node_crypto6.createHash)("sha256").update(lockKey).digest().readBigInt64BE(0);
210824
+ return (0, import_node_crypto7.createHash)("sha256").update(lockKey).digest().readBigInt64BE(0);
210824
210825
  }, "getSchemaSyncLockKey");
210825
210826
  var tryAcquireSchemaSyncLock = /* @__PURE__ */ __name((db) => async (branchName) => {
210826
210827
  const key = getSchemaSyncLockKey(branchName);
@@ -212284,1162 +212285,12 @@ Generate the next user message:`;
212284
212285
  */
212285
212286
  buildEvalInputEvaluationPrompt(evaluatorPrompt, agentDefinitionText, conversationText, traceText, schema, expectedOutputText) {
212286
212287
  const schemaDescription = JSON.stringify(schema, null, 2);
212287
- const expectedOutputSection = expectedOutputText ? `
212288
-
212289
- Expected Output:
212290
-
212291
- ${expectedOutputText}
212292
- ` : "";
212293
- return `${evaluatorPrompt}
212294
-
212295
- Agent Definition:
212296
-
212297
- ${agentDefinitionText}
212298
-
212299
- Conversation History:
212300
-
212301
- ${conversationText}
212302
-
212303
- Execution Trace:
212304
-
212305
- ${traceText}
212306
- ${expectedOutputSection}
212307
- Please evaluate this conversation according to the following schema and return your evaluation as JSON:
212308
-
212309
- ${schemaDescription}
212310
-
212311
- Return your evaluation as a JSON object matching the schema above.`;
212312
- }
212313
- /**
212314
- * Call LLM API using AI SDK's generateObject for structured output
212315
- */
212316
- async callLLM(params) {
212317
- const { prompt, modelConfig, schema } = params;
212318
- const languageModel = ModelFactory.prepareGenerationConfig(modelConfig);
212319
- const providerOptions = modelConfig?.providerOptions || {};
212320
- let resultSchema;
212321
- try {
212322
- resultSchema = jsonSchemaToZod3(schema);
212323
- logger21.info({
212324
- schemaType: typeof schema,
212325
- schemaKeys: schema && typeof schema === "object" ? Object.keys(schema) : [],
212326
- convertedSchema: "success"
212327
- }, "Converted JSON schema to Zod");
212328
- } catch (error46) {
212329
- logger21.error({
212330
- error: error46,
212331
- schema
212332
- }, "Failed to convert JSON schema to Zod, using fallback");
212333
- resultSchema = external_exports.record(external_exports.string(), external_exports.unknown());
212334
- }
212335
- const evaluationSchema = resultSchema;
212336
- try {
212337
- logger21.info({
212338
- promptLength: prompt.length,
212339
- model: modelConfig.model
212340
- }, "Calling generateObject");
212341
- const result = await generateObject({
212342
- ...languageModel,
212343
- schema: evaluationSchema,
212344
- prompt,
212345
- temperature: providerOptions.temperature ?? 0.3
212346
- });
212347
- return {
212348
- result: result.object,
212349
- metadata: {
212350
- usage: result.usage
212351
- }
212352
- };
212353
- } catch (error46) {
212354
- const errorMessage = error46 instanceof Error ? error46.message : String(error46);
212355
- logger21.error({
212356
- error: errorMessage,
212357
- schema: JSON.stringify(schema, null, 2),
212358
- promptPreview: prompt.substring(0, 500)
212359
- }, "Evaluation failed with generateObject");
212360
- throw new Error(`Evaluation failed: ${errorMessage}`);
212361
- }
212362
- }
212363
- /**
212364
- * Fetch trace from SigNoz (similar to the example)
212365
- */
212366
- async fetchTraceFromSigNoz(conversationId) {
212367
- const manageUIUrl = env2.INKEEP_AGENTS_MANAGE_UI_URL;
212368
- const maxRetries = 2;
212369
- const retryDelayMs = 2e4;
212370
- const initialDelayMs = 3e4;
212371
- try {
212372
- logger21.info({
212373
- conversationId,
212374
- manageUIUrl,
212375
- initialDelayMs
212376
- }, "Waiting 30s before fetching trace from SigNoz");
212377
- await new Promise((resolve4) => setTimeout(resolve4, initialDelayMs));
212378
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
212379
- try {
212380
- logger21.info({
212381
- conversationId,
212382
- attempt: attempt + 1,
212383
- maxRetries: maxRetries + 1
212384
- }, "Fetching trace from SigNoz");
212385
- const traceResponse = await fetch(`${manageUIUrl}/api/signoz/conversations/${conversationId}`);
212386
- if (!traceResponse.ok) {
212387
- logger21.warn({
212388
- conversationId,
212389
- status: traceResponse.status,
212390
- statusText: traceResponse.statusText,
212391
- attempt: attempt + 1
212392
- }, "Failed to fetch trace from SigNoz");
212393
- if (attempt < maxRetries) {
212394
- logger21.info({
212395
- conversationId,
212396
- retryDelayMs
212397
- }, "Retrying trace fetch after delay");
212398
- await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
212399
- continue;
212400
- }
212401
- return null;
212402
- }
212403
- const conversationDetail = await traceResponse.json();
212404
- logger21.debug({
212405
- conversationId,
212406
- activityTypes: conversationDetail.activities?.map((a2) => a2.type) || [],
212407
- activityCount: conversationDetail.activities?.length || 0
212408
- }, "Checking activities for ai_assistant_message type");
212409
- const hasAssistantMessage = conversationDetail.activities?.some((activity) => activity.type === "ai_assistant_message");
212410
- if (!hasAssistantMessage) {
212411
- logger21.warn({
212412
- conversationId,
212413
- attempt: attempt + 1,
212414
- activityCount: conversationDetail.activities?.length || 0,
212415
- activityTypes: conversationDetail.activities?.slice(0, 5).map((a2) => a2.type) || []
212416
- }, "Trace fetched but ai_assistant_message not found in activities");
212417
- if (attempt < maxRetries) {
212418
- logger21.info({
212419
- conversationId,
212420
- retryDelayMs
212421
- }, "Retrying trace fetch after delay to wait for assistant message");
212422
- await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
212423
- continue;
212424
- }
212425
- logger21.warn({
212426
- conversationId,
212427
- maxRetries,
212428
- activityCount: conversationDetail.activities?.length || 0
212429
- }, "Max retries reached, ai_assistant_message not found - proceeding with available trace data");
212430
- } else {
212431
- logger21.info({
212432
- conversationId,
212433
- activityCount: conversationDetail.activities?.length || 0,
212434
- attempt: attempt + 1
212435
- }, "Trace fetched successfully with ai_assistant_message");
212436
- }
212437
- const prettifiedTrace = this.formatConversationAsPrettifiedTrace(conversationDetail);
212438
- return prettifiedTrace;
212439
- } catch (fetchError) {
212440
- logger21.warn({
212441
- error: fetchError,
212442
- conversationId,
212443
- attempt: attempt + 1
212444
- }, "Error fetching trace from SigNoz");
212445
- if (attempt < maxRetries) {
212446
- logger21.info({
212447
- conversationId,
212448
- retryDelayMs
212449
- }, "Retrying trace fetch after delay");
212450
- await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
212451
- continue;
212452
- }
212453
- return null;
212454
- }
212455
- }
212456
- return null;
212457
- } catch (error46) {
212458
- logger21.warn({
212459
- error: error46,
212460
- conversationId,
212461
- manageUIUrl
212462
- }, "Failed to fetch trace from SigNoz, will continue without trace");
212463
- return null;
212464
- }
212465
- }
212466
- /**
212467
- * Format conversation detail as prettified trace
212468
- */
212469
- formatConversationAsPrettifiedTrace(conversation) {
212470
- const trace3 = {
212471
- metadata: {
212472
- conversationId: conversation.conversationId,
212473
- traceId: conversation.traceId,
212474
- agentName: conversation.agentName,
212475
- agentId: conversation.agentId,
212476
- exportedAt: (/* @__PURE__ */ new Date()).toISOString()
212477
- },
212478
- timing: {
212479
- startTime: conversation.conversationStartTime || "",
212480
- endTime: conversation.conversationEndTime || "",
212481
- durationMs: conversation.duration || 0
212482
- },
212483
- timeline: (conversation.activities || []).map((activity) => {
212484
- const { id: _id, ...rest } = activity;
212485
- return {
212486
- ...rest
212487
- };
212488
- })
212489
- };
212490
- return trace3;
212491
- }
212492
- };
212493
-
212494
- // src/domains/evals/workflow/functions/runDatasetItem.ts
212495
- var logger22 = getLogger("workflow-run-dataset-item");
212496
- async function callChatApiStep(payload) {
212497
- const { tenantId, projectId, agentId, datasetItemId, datasetItemInput, datasetItemSimulationAgent, datasetRunId } = payload;
212498
- const evaluationService = new EvaluationService();
212499
- const datasetItem2 = {
212500
- id: datasetItemId,
212501
- input: datasetItemInput,
212502
- simulationAgent: datasetItemSimulationAgent
212503
- };
212504
- const result = await evaluationService.runDatasetItem({
212505
- tenantId,
212506
- projectId,
212507
- agentId,
212508
- datasetItem: datasetItem2,
212509
- datasetRunId
212510
- });
212511
- logger22.info({
212512
- tenantId,
212513
- projectId,
212514
- datasetItemId,
212515
- datasetRunId,
212516
- conversationId: result.conversationId,
212517
- hasError: !!result.error
212518
- }, "Chat API call completed");
212519
- return result;
212520
- }
212521
- __name(callChatApiStep, "callChatApiStep");
212522
- async function createRelationStep(payload, conversationId) {
212523
- const { tenantId, projectId, datasetItemId, datasetRunId } = payload;
212524
- const relationId = generateId();
212525
- try {
212526
- await createDatasetRunConversationRelation(runDbClient_default)({
212527
- tenantId,
212528
- projectId,
212529
- id: relationId,
212530
- datasetRunId,
212531
- conversationId,
212532
- datasetItemId
212533
- });
212534
- logger22.info({
212535
- tenantId,
212536
- projectId,
212537
- datasetItemId,
212538
- datasetRunId,
212539
- conversationId,
212540
- relationId
212541
- }, "Created conversation relation");
212542
- return {
212543
- relationId,
212544
- success: true
212545
- };
212546
- } catch (error46) {
212547
- if (error46?.cause?.code === "23503" || error46?.code === "23503") {
212548
- logger22.warn({
212549
- tenantId,
212550
- projectId,
212551
- datasetItemId,
212552
- datasetRunId,
212553
- conversationId
212554
- }, "Conversation does not exist, skipping relation creation");
212555
- return {
212556
- relationId: null,
212557
- success: false,
212558
- reason: "conversation_not_found"
212559
- };
212560
- }
212561
- throw error46;
212562
- }
212563
- }
212564
- __name(createRelationStep, "createRelationStep");
212565
- async function executeEvaluatorStep(tenantId, projectId, conversationId, evaluatorId, evaluationRunId, expectedOutput) {
212566
- const ref = getProjectScopedRef(tenantId, projectId, "main");
212567
- const resolvedRef = await resolveRef2(manageDbClient_default)(ref);
212568
- if (!resolvedRef) {
212569
- throw new Error("Failed to resolve ref");
212570
- }
212571
- const evaluator2 = await withRef(manageDbPool_default, resolvedRef, (db) => getEvaluatorById(db)({
212572
- scopes: {
212573
- tenantId,
212574
- projectId,
212575
- evaluatorId
212576
- }
212577
- }));
212578
- if (!evaluator2) {
212579
- logger22.warn({
212580
- evaluatorId
212581
- }, "Evaluator not found");
212582
- return null;
212583
- }
212584
- const conversation = await getConversation(runDbClient_default)({
212585
- scopes: {
212586
- tenantId,
212587
- projectId
212588
- },
212589
- conversationId
212590
- });
212591
- if (!conversation) {
212592
- throw new Error(`Conversation not found: ${conversationId}`);
212593
- }
212594
- const evalResult = await createEvaluationResult(runDbClient_default)({
212595
- id: generateId(),
212596
- tenantId,
212597
- projectId,
212598
- conversationId,
212599
- evaluatorId: evaluator2.id,
212600
- evaluationRunId
212601
- });
212602
- try {
212603
- const evaluationService = new EvaluationService();
212604
- const output = await evaluationService.executeEvaluation({
212605
- conversation,
212606
- evaluator: evaluator2,
212607
- tenantId,
212608
- projectId,
212609
- expectedOutput
212610
- });
212611
- await updateEvaluationResult(runDbClient_default)({
212612
- scopes: {
212613
- tenantId,
212614
- projectId,
212615
- evaluationResultId: evalResult.id
212616
- },
212617
- data: {
212618
- output
212619
- }
212620
- });
212621
- logger22.info({
212622
- conversationId,
212623
- evaluatorId: evaluator2.id,
212624
- resultId: evalResult.id
212625
- }, "Evaluation completed");
212626
- return evalResult.id;
212627
- } catch (error46) {
212628
- const errorMessage = error46 instanceof Error ? error46.message : "Unknown error";
212629
- logger22.error({
212630
- error: error46,
212631
- conversationId,
212632
- evaluatorId: evaluator2.id
212633
- }, "Evaluation failed");
212634
- await updateEvaluationResult(runDbClient_default)({
212635
- scopes: {
212636
- tenantId,
212637
- projectId,
212638
- evaluationResultId: evalResult.id
212639
- },
212640
- data: {
212641
- output: {
212642
- text: `Evaluation failed: ${errorMessage}`
212643
- }
212644
- }
212645
- });
212646
- return evalResult.id;
212647
- }
212648
- }
212649
- __name(executeEvaluatorStep, "executeEvaluatorStep");
212650
- async function logStep(message, data) {
212651
- logger22.info(data, message);
212652
- }
212653
- __name(logStep, "logStep");
212654
- async function runDatasetItemWorkflow(payload) {
212655
- throw new Error("You attempted to execute workflow runDatasetItemWorkflow function directly. To start a workflow, use start(runDatasetItemWorkflow) from workflow/api");
212656
- }
212657
- __name(runDatasetItemWorkflow, "runDatasetItemWorkflow");
212658
- runDatasetItemWorkflow.workflowId = "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//runDatasetItemWorkflow";
212659
- registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//callChatApiStep", callChatApiStep);
212660
- registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//createRelationStep", createRelationStep);
212661
- registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//executeEvaluatorStep", executeEvaluatorStep);
212662
- registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//logStep", logStep);
212663
-
212664
- // dist/env.js
212665
- loadEnvironmentFiles();
212666
- var envSchema3 = external_exports.object({
212667
- NODE_ENV: external_exports.enum([
212668
- "development",
212669
- "production",
212670
- "test"
212671
- ]).default("development"),
212672
- ENVIRONMENT: external_exports.enum([
212673
- "development",
212674
- "production",
212675
- "pentest",
212676
- "test"
212677
- ]).default("development"),
212678
- LOG_LEVEL: external_exports.enum([
212679
- "trace",
212680
- "debug",
212681
- "info",
212682
- "warn",
212683
- "error"
212684
- ]).default("info"),
212685
- INKEEP_AGENTS_MANAGE_DATABASE_URL: external_exports.string(),
212686
- INKEEP_AGENTS_RUN_DATABASE_URL: external_exports.string(),
212687
- INKEEP_AGENTS_MANAGE_UI_URL: external_exports.string().optional(),
212688
- INKEEP_AGENTS_API_URL: external_exports.string().optional().default("http://localhost:3002"),
212689
- BETTER_AUTH_SECRET: external_exports.string().optional(),
212690
- INKEEP_AGENTS_MANAGE_UI_USERNAME: external_exports.string().optional().refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
212691
- message: "Invalid email address"
212692
- }),
212693
- INKEEP_AGENTS_MANAGE_UI_PASSWORD: external_exports.string().optional().refine((val) => !val || val.length >= 8, {
212694
- message: "Password must be at least 8 characters"
212695
- }),
212696
- INKEEP_AGENTS_API_BYPASS_SECRET: external_exports.string().optional(),
212697
- INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET: external_exports.string().optional(),
212698
- INKEEP_AGENTS_RUN_API_BYPASS_SECRET: external_exports.string().optional(),
212699
- INKEEP_AGENTS_EVAL_API_BYPASS_SECRET: external_exports.string().optional(),
212700
- INKEEP_AGENTS_TEMP_JWT_PUBLIC_KEY: external_exports.string().optional(),
212701
- INKEEP_AGENTS_TEMP_JWT_PRIVATE_KEY: external_exports.string().optional(),
212702
- NANGO_SERVER_URL: external_exports.string().optional().default("https://api.nango.dev"),
212703
- NANGO_SECRET_KEY: external_exports.string().optional(),
212704
- OTEL_BSP_SCHEDULE_DELAY: external_exports.coerce.number().optional().default(500),
212705
- OTEL_BSP_MAX_EXPORT_BATCH_SIZE: external_exports.coerce.number().optional().default(64),
212706
- DISABLE_AUTH: external_exports.string().optional().default("false").transform((val) => val === "true"),
212707
- TENANT_ID: external_exports.string().optional().default("default"),
212708
- SIGNOZ_URL: external_exports.string().optional(),
212709
- SIGNOZ_API_KEY: external_exports.string().optional(),
212710
- PUBLIC_SIGNOZ_URL: external_exports.string().optional(),
212711
- ANTHROPIC_API_KEY: external_exports.string(),
212712
- OPENAI_API_KEY: external_exports.string().optional(),
212713
- GOOGLE_GENERATIVE_AI_API_KEY: external_exports.string().optional(),
212714
- WORKFLOW_TARGET_WORLD: external_exports.string().optional(),
212715
- WORKFLOW_POSTGRES_URL: external_exports.string().optional(),
212716
- WORKFLOW_POSTGRES_JOB_PREFIX: external_exports.string().optional(),
212717
- WORKFLOW_POSTGRES_WORKER_CONCURRENCY: external_exports.string().optional()
212718
- });
212719
- var parseEnv3 = /* @__PURE__ */ __name(() => {
212720
- try {
212721
- return envSchema3.parse(process.env);
212722
- } catch (error46) {
212723
- if (error46 instanceof external_exports.ZodError) {
212724
- const missingVars = error46.issues.map((issue2) => issue2.path.join("."));
212725
- throw new Error(`\u274C Invalid environment variables: ${missingVars.join(", ")}
212726
- ${error46.message}`);
212727
- }
212728
- throw error46;
212729
- }
212730
- }, "parseEnv");
212731
- var env3 = parseEnv3();
212732
-
212733
- // dist/data/db/manageDbClient.js
212734
- var manageDbClient2 = createAgentsManageDatabaseClient({
212735
- connectionString: env3.INKEEP_AGENTS_MANAGE_DATABASE_URL
212736
- });
212737
- var manageDbClient_default2 = manageDbClient2;
212738
-
212739
- // dist/data/db/manageDbPool.js
212740
- var manageDbPool2 = createAgentsManageDatabasePool({
212741
- connectionString: env3.INKEEP_AGENTS_MANAGE_DATABASE_URL
212742
- });
212743
- var manageDbPool_default2 = manageDbPool2;
212744
-
212745
- // dist/data/db/runDbClient.js
212746
- var runDbClient2 = createAgentsRunDatabaseClient({
212747
- connectionString: env3.INKEEP_AGENTS_RUN_DATABASE_URL
212748
- });
212749
- var runDbClient_default2 = runDbClient2;
212750
-
212751
- // dist/domains/evals/services/EvaluationService.js
212752
- var logger23 = getLogger("EvaluationService");
212753
- function jsonSchemaToZod4(jsonSchema3) {
212754
- if (!jsonSchema3 || typeof jsonSchema3 !== "object") {
212755
- logger23.warn({
212756
- jsonSchema: jsonSchema3
212757
- }, "Invalid JSON schema provided, using string fallback");
212758
- return external_exports.string();
212759
- }
212760
- switch (jsonSchema3.type) {
212761
- case "object":
212762
- if (jsonSchema3.properties) {
212763
- const shape = {};
212764
- const required2 = jsonSchema3.required || [];
212765
- for (const [key, prop] of Object.entries(jsonSchema3.properties)) {
212766
- const propSchema = prop;
212767
- let zodType = jsonSchemaToZod4(propSchema);
212768
- if (propSchema.description) zodType = zodType.describe(String(propSchema.description));
212769
- if (!required2.includes(key)) zodType = zodType.optional();
212770
- shape[key] = zodType;
212771
- }
212772
- return external_exports.object(shape);
212773
- }
212774
- return external_exports.record(external_exports.string(), external_exports.unknown());
212775
- case "array": {
212776
- const itemSchema = jsonSchema3.items ? jsonSchemaToZod4(jsonSchema3.items) : external_exports.unknown();
212777
- return external_exports.array(itemSchema);
212778
- }
212779
- case "string":
212780
- return external_exports.string();
212781
- case "number":
212782
- return external_exports.number();
212783
- case "integer":
212784
- return external_exports.number().int();
212785
- case "boolean":
212786
- return external_exports.boolean();
212787
- case "null":
212788
- return external_exports.null();
212789
- default:
212790
- logger23.warn({
212791
- unsupportedType: jsonSchema3.type,
212792
- schema: jsonSchema3
212793
- }, "Unsupported JSON schema type, using unknown validation");
212794
- return external_exports.unknown();
212795
- }
212796
- }
212797
- __name(jsonSchemaToZod4, "jsonSchemaToZod");
212798
- var EvaluationService2 = class {
212799
- static {
212800
- __name(this, "EvaluationService");
212801
- }
212802
- agentsApiUrl;
212803
- runApiBypassSecret;
212804
- constructor() {
212805
- this.runApiBypassSecret = env3.INKEEP_AGENTS_RUN_API_BYPASS_SECRET ?? void 0;
212806
- this.agentsApiUrl = env3.INKEEP_AGENTS_API_URL ?? "";
212807
- }
212808
- /**
212809
- * Run a dataset item through the chat API endpoint
212810
- * Supports multi-turn conversations with simulation agents
212811
- */
212812
- async runDatasetItem(options) {
212813
- const { tenantId, projectId, agentId, datasetItem: datasetItem2, datasetRunId, apiKey } = options;
212814
- try {
212815
- const initialMessages = this.extractMessagesFromDatasetItem(datasetItem2);
212816
- if (!initialMessages || initialMessages.length === 0) return {
212817
- error: "Dataset item has no valid input messages"
212818
- };
212819
- const finalConversationId = generateId();
212820
- if (datasetItem2.simulationAgent && typeof datasetItem2.simulationAgent === "object" && datasetItem2.simulationAgent !== null && !Array.isArray(datasetItem2.simulationAgent) && datasetItem2.simulationAgent.prompt && datasetItem2.simulationAgent.model?.model) return await this.runDatasetItemWithSimulation({
212821
- tenantId,
212822
- projectId,
212823
- agentId,
212824
- datasetItem: datasetItem2,
212825
- datasetRunId,
212826
- conversationId: finalConversationId,
212827
- apiKey,
212828
- initialMessages,
212829
- simulationAgent: datasetItem2.simulationAgent
212830
- });
212831
- return await this.runSingleTurn({
212832
- tenantId,
212833
- projectId,
212834
- agentId,
212835
- datasetItem: datasetItem2,
212836
- datasetRunId,
212837
- conversationId: finalConversationId,
212838
- apiKey,
212839
- messages: initialMessages
212840
- });
212841
- } catch (error46) {
212842
- logger23.error({
212843
- error: error46 instanceof Error ? error46.message : String(error46),
212844
- datasetItemId: datasetItem2.id
212845
- }, "Error running dataset item through chat API");
212846
- return {
212847
- error: error46 instanceof Error ? error46.message : "Unknown error occurred"
212848
- };
212849
- }
212850
- }
212851
- /**
212852
- * Run a single-turn conversation (original behavior)
212853
- */
212854
- async runSingleTurn(params) {
212855
- const { tenantId, projectId, agentId, datasetItem: datasetItem2, datasetRunId, conversationId, apiKey, messages: messages2 } = params;
212856
- const chatUrl = `${this.agentsApiUrl}/run/api/chat`;
212857
- const chatPayload = {
212858
- messages: messages2,
212859
- conversationId,
212860
- stream: true
212861
- };
212862
- const authToken = apiKey || this.runApiBypassSecret;
212863
- const headers$1 = {
212864
- "Content-Type": "application/json",
212865
- ...authToken && {
212866
- Authorization: `Bearer ${authToken}`
212867
- },
212868
- "x-inkeep-tenant-id": tenantId,
212869
- "x-inkeep-project-id": projectId,
212870
- "x-inkeep-agent-id": agentId,
212871
- ...datasetRunId && {
212872
- "x-inkeep-dataset-run-id": datasetRunId
212873
- }
212874
- };
212875
- logger23.info({
212876
- tenantId,
212877
- projectId,
212878
- agentId,
212879
- datasetItemId: datasetItem2.id,
212880
- datasetRunId,
212881
- conversationId
212882
- }, "Running dataset item through chat API");
212883
- const response = await fetch(chatUrl, {
212884
- method: "POST",
212885
- headers: headers$1,
212886
- body: JSON.stringify(chatPayload)
212887
- });
212888
- if (!response.ok) {
212889
- const errorText = await response.text();
212890
- logger23.error({
212891
- status: response.status,
212892
- statusText: response.statusText,
212893
- errorText,
212894
- datasetItemId: datasetItem2.id,
212895
- conversationId
212896
- }, "Chat API request failed");
212897
- return {
212898
- conversationId,
212899
- error: `Chat API error: ${response.status} ${response.statusText}`
212900
- };
212901
- }
212902
- const responseText = await response.text();
212903
- const parseResult = this.parseSSEResponse(responseText);
212904
- if (parseResult.error) {
212905
- logger23.error({
212906
- datasetItemId: datasetItem2.id,
212907
- conversationId,
212908
- errorMessage: parseResult.error
212909
- }, "Chat API returned error operation");
212910
- return {
212911
- conversationId,
212912
- error: parseResult.error
212913
- };
212914
- }
212915
- logger23.info({
212916
- datasetItemId: datasetItem2.id,
212917
- conversationId,
212918
- responseLength: parseResult.text?.length || 0
212919
- }, "Successfully processed dataset item");
212920
- return {
212921
- conversationId,
212922
- response: parseResult.text
212923
- };
212924
- }
212925
- /**
212926
- * Run a multi-turn conversation with simulation agent
212927
- */
212928
- async runDatasetItemWithSimulation(params) {
212929
- const { tenantId, projectId, agentId, datasetItem: datasetItem2, datasetRunId, conversationId, apiKey, initialMessages, simulationAgent } = params;
212930
- logger23.info({
212931
- tenantId,
212932
- projectId,
212933
- agentId,
212934
- datasetItemId: datasetItem2.id,
212935
- conversationId,
212936
- hasSimulationAgent: true,
212937
- stopWhen: simulationAgent.stopWhen
212938
- }, "Running dataset item with simulation agent");
212939
- const simulationModelConfig = ModelFactory.prepareGenerationConfig(simulationAgent.model);
212940
- const maxSteps = (simulationAgent.stopWhen || {}).stepCountIs ?? 10;
212941
- const conversationHistory = [];
212942
- let stepCount = 0;
212943
- const initialResult = await this.runSingleTurn({
212944
- tenantId,
212945
- projectId,
212946
- agentId,
212947
- datasetItem: datasetItem2,
212948
- datasetRunId,
212949
- conversationId,
212950
- apiKey,
212951
- messages: initialMessages
212952
- });
212953
- if (initialResult.error || !initialResult.response) return initialResult;
212954
- const lastUserMessage = initialMessages.filter((m4) => m4.role === "user").map((m4) => typeof m4.content === "string" ? m4.content : JSON.stringify(m4.content)).join("\n");
212955
- conversationHistory.push({
212956
- role: "user",
212957
- content: lastUserMessage
212958
- });
212959
- conversationHistory.push({
212960
- role: "assistant",
212961
- content: initialResult.response
212962
- });
212963
- stepCount++;
212964
- while (stepCount < maxSteps) try {
212965
- const simulationPrompt = this.buildSimulationPrompt(simulationAgent.prompt, conversationHistory);
212966
- logger23.debug({
212967
- stepCount,
212968
- maxSteps,
212969
- conversationHistoryLength: conversationHistory.length
212970
- }, "Generating next user message with simulation agent");
212971
- const nextUserMessage = (await generateText({
212972
- ...simulationModelConfig,
212973
- prompt: simulationPrompt
212974
- })).text.trim();
212975
- if (!nextUserMessage) {
212976
- logger23.warn({
212977
- stepCount,
212978
- datasetItemId: datasetItem2.id
212979
- }, "Simulation agent returned empty message, stopping conversation");
212980
- break;
212981
- }
212982
- conversationHistory.push({
212983
- role: "user",
212984
- content: nextUserMessage
212985
- });
212986
- const agentResponse = await this.runSingleTurn({
212987
- tenantId,
212988
- projectId,
212989
- agentId,
212990
- datasetItem: datasetItem2,
212991
- datasetRunId,
212992
- conversationId,
212993
- apiKey,
212994
- messages: [
212995
- {
212996
- role: "user",
212997
- content: nextUserMessage
212998
- }
212999
- ]
213000
- });
213001
- if (agentResponse.error || !agentResponse.response) {
213002
- logger23.warn({
213003
- stepCount,
213004
- error: agentResponse.error,
213005
- datasetItemId: datasetItem2.id
213006
- }, "Agent response failed, stopping conversation");
213007
- break;
213008
- }
213009
- conversationHistory.push({
213010
- role: "assistant",
213011
- content: agentResponse.response
213012
- });
213013
- stepCount++;
213014
- } catch (error46) {
213015
- logger23.error({
213016
- error: error46 instanceof Error ? error46.message : String(error46),
213017
- stepCount,
213018
- datasetItemId: datasetItem2.id
213019
- }, "Error in simulation agent loop");
213020
- break;
213021
- }
213022
- logger23.info({
213023
- datasetItemId: datasetItem2.id,
213024
- conversationId,
213025
- finalStepCount: stepCount,
213026
- maxSteps,
213027
- conversationHistoryLength: conversationHistory.length
213028
- }, "Completed multi-turn conversation with simulation agent");
213029
- return {
213030
- conversationId,
213031
- response: conversationHistory.filter((m4) => m4.role === "assistant").pop()?.content || ""
213032
- };
213033
- }
213034
- /**
213035
- * Build prompt for simulation agent based on persona and conversation history
213036
- */
213037
- buildSimulationPrompt(personaPrompt, conversationHistory) {
213038
- return `${personaPrompt}
213039
-
213040
- You are simulating a user in a conversation. Based on the conversation history below, generate the next user message that would naturally follow. Keep your response concise and realistic.
213041
-
213042
- Conversation History:
213043
- ${conversationHistory.map((msg) => `${msg.role === "user" ? "User" : "Assistant"}: ${msg.content}`).join("\n\n")}
213044
-
213045
- Generate the next user message:`;
213046
- }
213047
- /**
213048
- * Extract messages from dataset item input
213049
- */
213050
- extractMessagesFromDatasetItem(datasetItem2) {
213051
- if (!datasetItem2.input) return null;
213052
- const roleMap = {
213053
- agent: "assistant",
213054
- user: "user",
213055
- system: "system",
213056
- assistant: "assistant",
213057
- function: "function",
213058
- tool: "tool"
213059
- };
213060
- if (typeof datasetItem2.input === "object" && "messages" in datasetItem2.input) {
213061
- const input = datasetItem2.input;
213062
- const validMessages = input.messages.map((msg) => {
213063
- const mappedRole = roleMap[msg.role.toLowerCase()];
213064
- if (!mappedRole) {
213065
- logger23.warn({
213066
- datasetItemId: datasetItem2.id,
213067
- invalidRole: msg.role
213068
- }, "Invalid message role found, skipping message");
213069
- return null;
213070
- }
213071
- return {
213072
- role: mappedRole,
213073
- content: msg.content
213074
- };
213075
- }).filter((msg) => msg !== null);
213076
- if (validMessages.length === 0) {
213077
- logger23.warn({
213078
- datasetItemId: datasetItem2.id,
213079
- totalMessages: input.messages.length
213080
- }, "No valid messages found after filtering roles");
213081
- return null;
213082
- }
213083
- return validMessages;
213084
- }
213085
- if (typeof datasetItem2.input === "string") try {
213086
- const parsed = JSON.parse(datasetItem2.input);
213087
- if (parsed.messages && Array.isArray(parsed.messages)) {
213088
- const validMessages = parsed.messages.map((msg) => {
213089
- const mappedRole = roleMap[msg.role?.toLowerCase()];
213090
- if (!mappedRole) {
213091
- logger23.warn({
213092
- datasetItemId: datasetItem2.id,
213093
- invalidRole: msg.role
213094
- }, "Invalid message role found in parsed input, skipping message");
213095
- return null;
213096
- }
213097
- return {
213098
- role: mappedRole,
213099
- content: msg.content
213100
- };
213101
- }).filter((msg) => msg !== null);
213102
- return validMessages.length > 0 ? validMessages : null;
213103
- }
213104
- } catch {
213105
- return [
213106
- {
213107
- role: "user",
213108
- content: datasetItem2.input
213109
- }
213110
- ];
213111
- }
213112
- return null;
213113
- }
213114
- /**
213115
- * Parse SSE (Server-Sent Events) response from chat API
213116
- * Handles text deltas, error operations, and other data operations
213117
- */
213118
- parseSSEResponse(sseText) {
213119
- let textContent = "";
213120
- let hasError = false;
213121
- let errorMessage = "";
213122
- const lines = sseText.split("\n").filter((line2) => line2.startsWith("data: "));
213123
- for (const line2 of lines) try {
213124
- const data = JSON.parse(line2.slice(6));
213125
- if (data.object === "chat.completion.chunk" && data.choices?.[0]?.delta) {
213126
- const delta = data.choices[0].delta;
213127
- if (delta.content) textContent += delta.content;
213128
- if (delta.content && typeof delta.content === "string") try {
213129
- const parsedContent = JSON.parse(delta.content);
213130
- if (parsedContent.type === "data-operation" && parsedContent.data?.type === "error") {
213131
- hasError = true;
213132
- errorMessage = parsedContent.data.message || "Unknown error occurred";
213133
- logger23.warn({
213134
- errorMessage,
213135
- errorData: parsedContent.data
213136
- }, "Received error operation from chat API");
213137
- }
213138
- } catch {
213139
- }
213140
- } else if (data.type === "text-delta" && data.delta) textContent += data.delta;
213141
- else if (data.type === "data-operation" && data.data?.type === "error") {
213142
- hasError = true;
213143
- errorMessage = data.data.message || "Unknown error occurred";
213144
- logger23.warn({
213145
- errorMessage,
213146
- errorData: data.data
213147
- }, "Received error operation from chat API");
213148
- } else if (data.type === "error") {
213149
- hasError = true;
213150
- errorMessage = data.message || "Unknown error occurred";
213151
- logger23.warn({
213152
- errorMessage,
213153
- errorData: data
213154
- }, "Received error event from chat API");
213155
- } else if (data.content) textContent += typeof data.content === "string" ? data.content : JSON.stringify(data.content);
213156
- } catch {
213157
- }
213158
- if (hasError) return {
213159
- text: textContent.trim(),
213160
- error: errorMessage
213161
- };
213162
- return {
213163
- text: textContent.trim()
213164
- };
213165
- }
213166
- /**
213167
- * Run an evaluation job based on an evaluation job config
213168
- * Filters conversations based on jobFilters and runs evaluations with configured evaluators
213169
- */
213170
- async runEvaluationJob(params) {
213171
- const { tenantId, projectId, evaluationJobConfigId, sampleRate } = params;
213172
- const ref = getProjectScopedRef(tenantId, projectId, "main");
213173
- const resolvedRef = await resolveRef2(manageDbClient_default2)(ref);
213174
- if (!resolvedRef) throw new Error("Failed to resolve ref");
213175
- logger23.info({
213176
- tenantId,
213177
- projectId,
213178
- evaluationJobConfigId,
213179
- sampleRate
213180
- }, "Starting evaluation job");
213181
- const config3 = await withRef(manageDbPool_default2, resolvedRef, (db) => getEvaluationJobConfigById(db)({
213182
- scopes: {
213183
- tenantId,
213184
- projectId,
213185
- evaluationJobConfigId
213186
- }
213187
- }));
213188
- if (!config3) throw new Error(`Evaluation job config not found: ${evaluationJobConfigId}`);
213189
- const evaluatorRelations = await withRef(manageDbPool_default2, resolvedRef, (db) => getEvaluationJobConfigEvaluatorRelations(db)({
213190
- scopes: {
213191
- tenantId,
213192
- projectId,
213193
- evaluationJobConfigId
213194
- }
213195
- }));
213196
- if (evaluatorRelations.length === 0) throw new Error(`No evaluators found for job config: ${evaluationJobConfigId}`);
213197
- const validEvaluators = (await Promise.all(evaluatorRelations.map((relation) => withRef(manageDbPool_default2, resolvedRef, (db) => getEvaluatorById(db)({
213198
- scopes: {
213199
- tenantId,
213200
- projectId,
213201
- evaluatorId: relation.evaluatorId
213202
- }
213203
- }))))).filter((e) => e !== null);
213204
- if (validEvaluators.length === 0) throw new Error(`No valid evaluators found for job config: ${evaluationJobConfigId}`);
213205
- logger23.info({
213206
- tenantId,
213207
- projectId,
213208
- evaluationJobConfigId,
213209
- evaluatorCount: validEvaluators.length
213210
- }, "Found evaluators for job config");
213211
- let conversationsToEvaluate = await filterConversationsForJob(runDbClient_default2)({
213212
- scopes: {
213213
- tenantId,
213214
- projectId
213215
- },
213216
- jobFilters: config3.jobFilters
213217
- });
213218
- if (sampleRate !== void 0 && sampleRate !== null) {
213219
- const originalCount = conversationsToEvaluate.length;
213220
- conversationsToEvaluate = this.applySampleRate(conversationsToEvaluate, sampleRate);
213221
- logger23.info({
213222
- tenantId,
213223
- projectId,
213224
- evaluationJobConfigId,
213225
- originalCount,
213226
- sampledCount: conversationsToEvaluate.length,
213227
- sampleRate
213228
- }, "Applied sample rate to conversations");
213229
- }
213230
- logger23.info({
213231
- tenantId,
213232
- projectId,
213233
- evaluationJobConfigId,
213234
- conversationCount: conversationsToEvaluate.length
213235
- }, "Found conversations for evaluation");
213236
- if (conversationsToEvaluate.length === 0) {
213237
- logger23.warn({
213238
- tenantId,
213239
- projectId,
213240
- evaluationJobConfigId
213241
- }, "No conversations found matching job filters");
213242
- return [];
213243
- }
213244
- const evaluationRun2 = await createEvaluationRun(runDbClient_default2)({
213245
- id: generateId(),
213246
- tenantId,
213247
- projectId,
213248
- evaluationJobConfigId
213249
- });
213250
- const results = [];
213251
- for (const conversation of conversationsToEvaluate) for (const evaluator2 of validEvaluators) try {
213252
- logger23.info({
213253
- tenantId,
213254
- conversationId: conversation.id,
213255
- evaluatorId: evaluator2.id
213256
- }, "Running evaluation");
213257
- const evalResult = await createEvaluationResult(runDbClient_default2)({
213258
- id: generateId(),
213259
- tenantId,
213260
- projectId,
213261
- conversationId: conversation.id,
213262
- evaluatorId: evaluator2.id,
213263
- evaluationRunId: evaluationRun2.id
213264
- });
213265
- try {
213266
- const evaluationResult2 = await this.executeEvaluation({
213267
- conversation,
213268
- evaluator: evaluator2,
213269
- tenantId,
213270
- projectId
213271
- });
213272
- const updatedResult = await updateEvaluationResult(runDbClient_default2)({
213273
- scopes: {
213274
- tenantId,
213275
- projectId,
213276
- evaluationResultId: evalResult.id
213277
- },
213278
- data: {
213279
- output: evaluationResult2.output
213280
- }
213281
- });
213282
- if (updatedResult) results.push(updatedResult);
213283
- logger23.info({
213284
- tenantId,
213285
- conversationId: conversation.id,
213286
- evaluatorId: evaluator2.id,
213287
- resultId: evalResult.id
213288
- }, "Evaluation completed successfully");
213289
- } catch (error46) {
213290
- logger23.error({
213291
- error: error46,
213292
- tenantId,
213293
- conversationId: conversation.id,
213294
- evaluatorId: evaluator2.id,
213295
- resultId: evalResult.id
213296
- }, "Evaluation execution failed");
213297
- const errorMessage = error46 instanceof Error ? error46.message : "Unknown error";
213298
- const failedResult = await updateEvaluationResult(runDbClient_default2)({
213299
- scopes: {
213300
- tenantId,
213301
- projectId,
213302
- evaluationResultId: evalResult.id
213303
- },
213304
- data: {
213305
- output: {
213306
- text: `Evaluation failed: ${errorMessage}`
213307
- }
213308
- }
213309
- });
213310
- if (failedResult) results.push(failedResult);
213311
- }
213312
- } catch (error46) {
213313
- logger23.error({
213314
- error: error46 instanceof Error ? error46.message : String(error46),
213315
- tenantId,
213316
- conversationId: conversation.id,
213317
- evaluatorId: evaluator2.id
213318
- }, "Failed to create or update eval result");
213319
- }
213320
- logger23.info({
213321
- tenantId,
213322
- projectId,
213323
- evaluationJobConfigId,
213324
- resultCount: results.length
213325
- }, "Evaluation job completed");
213326
- return results;
213327
- }
213328
- /**
213329
- * Apply sample rate to conversations
213330
- */
213331
- applySampleRate(items, sampleRate) {
213332
- if (!sampleRate || sampleRate >= 1) return items;
213333
- if (sampleRate <= 0) return [];
213334
- const targetCount = Math.ceil(items.length * sampleRate);
213335
- const sampled = [];
213336
- const indices = /* @__PURE__ */ new Set();
213337
- while (sampled.length < targetCount && sampled.length < items.length) {
213338
- const randomIndex = Math.floor(Math.random() * items.length);
213339
- if (!indices.has(randomIndex)) {
213340
- indices.add(randomIndex);
213341
- sampled.push(items[randomIndex]);
213342
- }
213343
- }
213344
- return sampled;
213345
- }
213346
- /**
213347
- * Execute an evaluation by calling the LLM with the evaluator prompt and conversation data
213348
- */
213349
- async executeEvaluation(params) {
213350
- const { conversation, evaluator: evaluator2, tenantId, projectId, expectedOutput } = params;
213351
- let resolvedRef = null;
213352
- if (conversation.ref) resolvedRef = conversation.ref;
213353
- else {
213354
- const ref = getProjectScopedRef(tenantId, projectId, "main");
213355
- resolvedRef = await resolveRef2(manageDbClient_default2)(ref);
213356
- }
213357
- if (!resolvedRef) throw new Error("Failed to resolve ref");
213358
- const conversationHistory = await getConversationHistory(runDbClient_default2)({
213359
- scopes: {
213360
- tenantId,
213361
- projectId
213362
- },
213363
- conversationId: conversation.id,
213364
- options: {
213365
- includeInternal: false,
213366
- limit: 100
213367
- }
213368
- });
213369
- let agentDefinition = null;
213370
- let agentId = null;
213371
- try {
213372
- agentId = conversation.agentId ?? null;
213373
- if (agentId) {
213374
- const agentIdForLookup = agentId;
213375
- agentDefinition = await withRef(manageDbPool_default2, resolvedRef, (db) => getFullAgent(db)({
213376
- scopes: {
213377
- tenantId,
213378
- projectId,
213379
- agentId: agentIdForLookup
213380
- }
213381
- }));
213382
- } else logger23.warn({
213383
- conversationId: conversation.id,
213384
- agentId: conversation.agentId
213385
- }, "AgentId not found, cannot get agent definition");
213386
- } catch (error46) {
213387
- logger23.warn({
213388
- error: error46,
213389
- conversationId: conversation.id,
213390
- agentId: conversation.agentId
213391
- }, "Failed to fetch agent definition for evaluation");
213392
- }
213393
- const prettifiedTrace = await this.fetchTraceFromSigNoz(conversation.id);
213394
- logger23.info({
213395
- conversationId: conversation.id,
213396
- hasTrace: !!prettifiedTrace,
213397
- traceActivityCount: prettifiedTrace?.timeline?.length || 0
213398
- }, "Trace fetch completed");
213399
- const conversationText = JSON.stringify(conversationHistory, null, 2);
213400
- const agentDefinitionText = agentDefinition ? JSON.stringify(agentDefinition, null, 2) : "Agent definition not available";
213401
- const traceText = prettifiedTrace ? JSON.stringify(prettifiedTrace, null, 2) : "Trace data not available";
213402
- const modelConfig = evaluator2.model ?? {};
213403
- let schemaObj;
213404
- if (typeof evaluator2.schema === "string") try {
213405
- schemaObj = JSON.parse(evaluator2.schema);
213406
- } catch (error46) {
213407
- logger23.error({
213408
- error: error46,
213409
- schemaString: evaluator2.schema
213410
- }, "Failed to parse evaluator schema string");
213411
- throw new Error("Invalid evaluator schema format");
213412
- }
213413
- else schemaObj = evaluator2.schema;
213414
- logger23.info({
213415
- evaluatorId: evaluator2.id,
213416
- schemaType: typeof schemaObj,
213417
- schemaKeys: schemaObj && typeof schemaObj === "object" ? Object.keys(schemaObj) : []
213418
- }, "Using evaluator schema");
213419
- const expectedOutputText = expectedOutput ? JSON.stringify(expectedOutput, null, 2) : void 0;
213420
- const evaluationPrompt = this.buildEvalInputEvaluationPrompt(evaluator2.prompt, agentDefinitionText, conversationText, traceText, schemaObj, expectedOutputText);
213421
- const llmResponse = await this.callLLM({
213422
- prompt: evaluationPrompt,
213423
- modelConfig,
213424
- schema: schemaObj
213425
- });
213426
- return {
213427
- output: llmResponse.result,
213428
- metadata: {
213429
- ...llmResponse.metadata,
213430
- model: modelConfig.model || "unknown",
213431
- agentId,
213432
- hasAgentDefinition: !!agentDefinition,
213433
- hasTrace: !!prettifiedTrace,
213434
- traceActivityCount: prettifiedTrace?.timeline?.length || 0
213435
- }
213436
- };
213437
- }
213438
- /**
213439
- * Build evaluation prompt with agent definition, conversation history, trace, and expected output
213440
- */
213441
- buildEvalInputEvaluationPrompt(evaluatorPrompt, agentDefinitionText, conversationText, traceText, schema, expectedOutputText) {
213442
- const schemaDescription = JSON.stringify(schema, null, 2);
212288
+ const expectedOutputSection = expectedOutputText ? `
212289
+
212290
+ Expected Output:
212291
+
212292
+ ${expectedOutputText}
212293
+ ` : "";
213443
212294
  return `${evaluatorPrompt}
213444
212295
 
213445
212296
  Agent Definition:
@@ -213453,12 +212304,7 @@ ${conversationText}
213453
212304
  Execution Trace:
213454
212305
 
213455
212306
  ${traceText}
213456
- ${expectedOutputText ? `
213457
-
213458
- Expected Output:
213459
-
213460
- ${expectedOutputText}
213461
- ` : ""}
212307
+ ${expectedOutputSection}
213462
212308
  Please evaluate this conversation according to the following schema and return your evaluation as JSON:
213463
212309
 
213464
212310
  ${schemaDescription}
@@ -213474,14 +212320,14 @@ Return your evaluation as a JSON object matching the schema above.`;
213474
212320
  const providerOptions = modelConfig?.providerOptions || {};
213475
212321
  let resultSchema;
213476
212322
  try {
213477
- resultSchema = jsonSchemaToZod4(schema);
213478
- logger23.info({
212323
+ resultSchema = jsonSchemaToZod3(schema);
212324
+ logger21.info({
213479
212325
  schemaType: typeof schema,
213480
212326
  schemaKeys: schema && typeof schema === "object" ? Object.keys(schema) : [],
213481
212327
  convertedSchema: "success"
213482
212328
  }, "Converted JSON schema to Zod");
213483
212329
  } catch (error46) {
213484
- logger23.error({
212330
+ logger21.error({
213485
212331
  error: error46,
213486
212332
  schema
213487
212333
  }, "Failed to convert JSON schema to Zod, using fallback");
@@ -213489,7 +212335,7 @@ Return your evaluation as a JSON object matching the schema above.`;
213489
212335
  }
213490
212336
  const evaluationSchema = resultSchema;
213491
212337
  try {
213492
- logger23.info({
212338
+ logger21.info({
213493
212339
  promptLength: prompt.length,
213494
212340
  model: modelConfig.model
213495
212341
  }, "Calling generateObject");
@@ -213507,7 +212353,7 @@ Return your evaluation as a JSON object matching the schema above.`;
213507
212353
  };
213508
212354
  } catch (error46) {
213509
212355
  const errorMessage = error46 instanceof Error ? error46.message : String(error46);
213510
- logger23.error({
212356
+ logger21.error({
213511
212357
  error: errorMessage,
213512
212358
  schema: JSON.stringify(schema, null, 2),
213513
212359
  promptPreview: prompt.substring(0, 500)
@@ -213519,92 +212365,98 @@ Return your evaluation as a JSON object matching the schema above.`;
213519
212365
  * Fetch trace from SigNoz (similar to the example)
213520
212366
  */
213521
212367
  async fetchTraceFromSigNoz(conversationId) {
213522
- const manageUIUrl = env3.INKEEP_AGENTS_MANAGE_UI_URL;
212368
+ const manageUIUrl = env2.INKEEP_AGENTS_MANAGE_UI_URL;
213523
212369
  const maxRetries = 2;
213524
212370
  const retryDelayMs = 2e4;
213525
212371
  const initialDelayMs = 3e4;
213526
212372
  try {
213527
- logger23.info({
212373
+ logger21.info({
213528
212374
  conversationId,
213529
212375
  manageUIUrl,
213530
212376
  initialDelayMs
213531
212377
  }, "Waiting 30s before fetching trace from SigNoz");
213532
212378
  await new Promise((resolve4) => setTimeout(resolve4, initialDelayMs));
213533
- for (let attempt = 0; attempt <= maxRetries; attempt++) try {
213534
- logger23.info({
213535
- conversationId,
213536
- attempt: attempt + 1,
213537
- maxRetries: maxRetries + 1
213538
- }, "Fetching trace from SigNoz");
213539
- const traceResponse = await fetch(`${manageUIUrl}/api/signoz/conversations/${conversationId}`);
213540
- if (!traceResponse.ok) {
213541
- logger23.warn({
212379
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
212380
+ try {
212381
+ logger21.info({
213542
212382
  conversationId,
213543
- status: traceResponse.status,
213544
- statusText: traceResponse.statusText,
213545
- attempt: attempt + 1
213546
- }, "Failed to fetch trace from SigNoz");
213547
- if (attempt < maxRetries) {
213548
- logger23.info({
212383
+ attempt: attempt + 1,
212384
+ maxRetries: maxRetries + 1
212385
+ }, "Fetching trace from SigNoz");
212386
+ const traceResponse = await fetch(`${manageUIUrl}/api/signoz/conversations/${conversationId}`);
212387
+ if (!traceResponse.ok) {
212388
+ logger21.warn({
213549
212389
  conversationId,
213550
- retryDelayMs
213551
- }, "Retrying trace fetch after delay");
213552
- await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
213553
- continue;
212390
+ status: traceResponse.status,
212391
+ statusText: traceResponse.statusText,
212392
+ attempt: attempt + 1
212393
+ }, "Failed to fetch trace from SigNoz");
212394
+ if (attempt < maxRetries) {
212395
+ logger21.info({
212396
+ conversationId,
212397
+ retryDelayMs
212398
+ }, "Retrying trace fetch after delay");
212399
+ await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
212400
+ continue;
212401
+ }
212402
+ return null;
213554
212403
  }
213555
- return null;
213556
- }
213557
- const conversationDetail = await traceResponse.json();
213558
- logger23.debug({
213559
- conversationId,
213560
- activityTypes: conversationDetail.activities?.map((a2) => a2.type) || [],
213561
- activityCount: conversationDetail.activities?.length || 0
213562
- }, "Checking activities for ai_assistant_message type");
213563
- if (!conversationDetail.activities?.some((activity) => activity.type === "ai_assistant_message")) {
213564
- logger23.warn({
212404
+ const conversationDetail = await traceResponse.json();
212405
+ logger21.debug({
213565
212406
  conversationId,
213566
- attempt: attempt + 1,
213567
- activityCount: conversationDetail.activities?.length || 0,
213568
- activityTypes: conversationDetail.activities?.slice(0, 5).map((a2) => a2.type) || []
213569
- }, "Trace fetched but ai_assistant_message not found in activities");
212407
+ activityTypes: conversationDetail.activities?.map((a2) => a2.type) || [],
212408
+ activityCount: conversationDetail.activities?.length || 0
212409
+ }, "Checking activities for ai_assistant_message type");
212410
+ const hasAssistantMessage = conversationDetail.activities?.some((activity) => activity.type === "ai_assistant_message");
212411
+ if (!hasAssistantMessage) {
212412
+ logger21.warn({
212413
+ conversationId,
212414
+ attempt: attempt + 1,
212415
+ activityCount: conversationDetail.activities?.length || 0,
212416
+ activityTypes: conversationDetail.activities?.slice(0, 5).map((a2) => a2.type) || []
212417
+ }, "Trace fetched but ai_assistant_message not found in activities");
212418
+ if (attempt < maxRetries) {
212419
+ logger21.info({
212420
+ conversationId,
212421
+ retryDelayMs
212422
+ }, "Retrying trace fetch after delay to wait for assistant message");
212423
+ await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
212424
+ continue;
212425
+ }
212426
+ logger21.warn({
212427
+ conversationId,
212428
+ maxRetries,
212429
+ activityCount: conversationDetail.activities?.length || 0
212430
+ }, "Max retries reached, ai_assistant_message not found - proceeding with available trace data");
212431
+ } else {
212432
+ logger21.info({
212433
+ conversationId,
212434
+ activityCount: conversationDetail.activities?.length || 0,
212435
+ attempt: attempt + 1
212436
+ }, "Trace fetched successfully with ai_assistant_message");
212437
+ }
212438
+ const prettifiedTrace = this.formatConversationAsPrettifiedTrace(conversationDetail);
212439
+ return prettifiedTrace;
212440
+ } catch (fetchError) {
212441
+ logger21.warn({
212442
+ error: fetchError,
212443
+ conversationId,
212444
+ attempt: attempt + 1
212445
+ }, "Error fetching trace from SigNoz");
213570
212446
  if (attempt < maxRetries) {
213571
- logger23.info({
212447
+ logger21.info({
213572
212448
  conversationId,
213573
212449
  retryDelayMs
213574
- }, "Retrying trace fetch after delay to wait for assistant message");
212450
+ }, "Retrying trace fetch after delay");
213575
212451
  await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
213576
212452
  continue;
213577
212453
  }
213578
- logger23.warn({
213579
- conversationId,
213580
- maxRetries,
213581
- activityCount: conversationDetail.activities?.length || 0
213582
- }, "Max retries reached, ai_assistant_message not found - proceeding with available trace data");
213583
- } else logger23.info({
213584
- conversationId,
213585
- activityCount: conversationDetail.activities?.length || 0,
213586
- attempt: attempt + 1
213587
- }, "Trace fetched successfully with ai_assistant_message");
213588
- return this.formatConversationAsPrettifiedTrace(conversationDetail);
213589
- } catch (fetchError) {
213590
- logger23.warn({
213591
- error: fetchError,
213592
- conversationId,
213593
- attempt: attempt + 1
213594
- }, "Error fetching trace from SigNoz");
213595
- if (attempt < maxRetries) {
213596
- logger23.info({
213597
- conversationId,
213598
- retryDelayMs
213599
- }, "Retrying trace fetch after delay");
213600
- await new Promise((resolve4) => setTimeout(resolve4, retryDelayMs));
213601
- continue;
212454
+ return null;
213602
212455
  }
213603
- return null;
213604
212456
  }
213605
212457
  return null;
213606
212458
  } catch (error46) {
213607
- logger23.warn({
212459
+ logger21.warn({
213608
212460
  error: error46,
213609
212461
  conversationId,
213610
212462
  manageUIUrl
@@ -213616,13 +212468,13 @@ Return your evaluation as a JSON object matching the schema above.`;
213616
212468
  * Format conversation detail as prettified trace
213617
212469
  */
213618
212470
  formatConversationAsPrettifiedTrace(conversation) {
213619
- return {
212471
+ const trace3 = {
213620
212472
  metadata: {
213621
212473
  conversationId: conversation.conversationId,
213622
212474
  traceId: conversation.traceId,
213623
212475
  agentName: conversation.agentName,
213624
212476
  agentId: conversation.agentId,
213625
- exportedAt: /* @__PURE__ */ (/* @__PURE__ */ new Date()).toISOString()
212477
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString()
213626
212478
  },
213627
212479
  timing: {
213628
212480
  startTime: conversation.conversationStartTime || "",
@@ -213636,46 +212488,54 @@ Return your evaluation as a JSON object matching the schema above.`;
213636
212488
  };
213637
212489
  })
213638
212490
  };
212491
+ return trace3;
213639
212492
  }
213640
212493
  };
213641
212494
 
213642
- // dist/domains/evals/workflow/functions/evaluateConversation.js
213643
- var logger24 = getLogger("workflow-evaluate-conversation");
212495
+ // src/domains/evals/workflow/functions/evaluateConversation.ts
212496
+ var logger22 = getLogger("workflow-evaluate-conversation");
213644
212497
  async function getConversationStep(payload) {
213645
212498
  const { tenantId, projectId, conversationId } = payload;
213646
- const conv = await getConversation(runDbClient_default2)({
212499
+ const conv = await getConversation(runDbClient_default)({
213647
212500
  scopes: {
213648
212501
  tenantId,
213649
212502
  projectId
213650
212503
  },
213651
212504
  conversationId
213652
212505
  });
213653
- if (!conv) throw new Error(`Conversation not found: ${conversationId}`);
212506
+ if (!conv) {
212507
+ throw new Error(`Conversation not found: ${conversationId}`);
212508
+ }
213654
212509
  return conv;
213655
212510
  }
213656
212511
  __name(getConversationStep, "getConversationStep");
213657
212512
  async function getEvaluatorsStep(payload) {
213658
212513
  const { tenantId, projectId, evaluatorIds } = payload;
213659
- return await withRef(manageDbPool_default2, await getProjectMainResolvedRef(manageDbClient_default2)(tenantId, projectId), (db) => getEvaluatorsByIds(db)({
212514
+ const projectMain = await getProjectMainResolvedRef(manageDbClient_default)(tenantId, projectId);
212515
+ const evals = await withRef(manageDbPool_default, projectMain, (db) => getEvaluatorsByIds(db)({
213660
212516
  scopes: {
213661
212517
  tenantId,
213662
212518
  projectId
213663
212519
  },
213664
212520
  evaluatorIds
213665
212521
  }));
212522
+ return evals;
213666
212523
  }
213667
212524
  __name(getEvaluatorsStep, "getEvaluatorsStep");
213668
- async function executeEvaluatorStep2(payload, evaluatorId, conversation) {
212525
+ async function executeEvaluatorStep(payload, evaluatorId, conversation) {
213669
212526
  const { tenantId, projectId, conversationId, evaluationRunId } = payload;
213670
- const evaluator2 = await withRef(manageDbPool_default2, await getProjectMainResolvedRef(manageDbClient_default2)(tenantId, projectId), (db) => getEvaluatorById(db)({
212527
+ const projectMain = await getProjectMainResolvedRef(manageDbClient_default)(tenantId, projectId);
212528
+ const evaluator2 = await withRef(manageDbPool_default, projectMain, (db) => getEvaluatorById(db)({
213671
212529
  scopes: {
213672
212530
  tenantId,
213673
212531
  projectId,
213674
212532
  evaluatorId
213675
212533
  }
213676
212534
  }));
213677
- if (!evaluator2) throw new Error(`Evaluator not found: ${evaluatorId}`);
213678
- const evalResult = await createEvaluationResult(runDbClient_default2)({
212535
+ if (!evaluator2) {
212536
+ throw new Error(`Evaluator not found: ${evaluatorId}`);
212537
+ }
212538
+ const evalResult = await createEvaluationResult(runDbClient_default)({
213679
212539
  id: generateId(),
213680
212540
  tenantId,
213681
212541
  projectId,
@@ -213684,13 +212544,14 @@ async function executeEvaluatorStep2(payload, evaluatorId, conversation) {
213684
212544
  evaluationRunId
213685
212545
  });
213686
212546
  try {
213687
- const output = await new EvaluationService2().executeEvaluation({
212547
+ const evaluationService = new EvaluationService();
212548
+ const output = await evaluationService.executeEvaluation({
213688
212549
  conversation,
213689
212550
  evaluator: evaluator2,
213690
212551
  tenantId,
213691
212552
  projectId
213692
212553
  });
213693
- const updated = await updateEvaluationResult(runDbClient_default2)({
212554
+ const updated = await updateEvaluationResult(runDbClient_default)({
213694
212555
  scopes: {
213695
212556
  tenantId,
213696
212557
  projectId,
@@ -213700,7 +212561,7 @@ async function executeEvaluatorStep2(payload, evaluatorId, conversation) {
213700
212561
  output
213701
212562
  }
213702
212563
  });
213703
- logger24.info({
212564
+ logger22.info({
213704
212565
  conversationId,
213705
212566
  evaluatorId: evaluator2.id,
213706
212567
  resultId: evalResult.id
@@ -213708,13 +212569,13 @@ async function executeEvaluatorStep2(payload, evaluatorId, conversation) {
213708
212569
  return updated;
213709
212570
  } catch (error46) {
213710
212571
  const errorMessage = error46 instanceof Error ? error46.message : "Unknown error";
213711
- logger24.error({
212572
+ logger22.error({
213712
212573
  error: error46,
213713
212574
  conversationId,
213714
212575
  evaluatorId: evaluator2.id,
213715
212576
  resultId: evalResult.id
213716
212577
  }, "Evaluation execution failed");
213717
- return await updateEvaluationResult(runDbClient_default2)({
212578
+ const failed = await updateEvaluationResult(runDbClient_default)({
213718
212579
  scopes: {
213719
212580
  tenantId,
213720
212581
  projectId,
@@ -213726,28 +212587,32 @@ async function executeEvaluatorStep2(payload, evaluatorId, conversation) {
213726
212587
  }
213727
212588
  }
213728
212589
  });
212590
+ return failed;
213729
212591
  }
213730
212592
  }
213731
- __name(executeEvaluatorStep2, "executeEvaluatorStep");
213732
- async function logStep2(message, data) {
213733
- logger24.info(data, message);
212593
+ __name(executeEvaluatorStep, "executeEvaluatorStep");
212594
+ async function logStep(message, data) {
212595
+ logger22.info(data, message);
213734
212596
  }
213735
- __name(logStep2, "logStep");
213736
- async function evaluateConversationWorkflow(payload) {
213737
- throw new Error("You attempted to execute workflow evaluateConversationWorkflow function directly. To start a workflow, use start(evaluateConversationWorkflow) from workflow/api");
213738
- }
213739
- __name(evaluateConversationWorkflow, "evaluateConversationWorkflow");
213740
- evaluateConversationWorkflow.workflowId = "workflow//dist/domains/evals/workflow/functions/evaluateConversation.js//evaluateConversationWorkflow";
213741
- registerStepFunction("step//dist/domains/evals/workflow/functions/evaluateConversation.js//getConversationStep", getConversationStep);
213742
- registerStepFunction("step//dist/domains/evals/workflow/functions/evaluateConversation.js//getEvaluatorsStep", getEvaluatorsStep);
213743
- registerStepFunction("step//dist/domains/evals/workflow/functions/evaluateConversation.js//executeEvaluatorStep", executeEvaluatorStep2);
213744
- registerStepFunction("step//dist/domains/evals/workflow/functions/evaluateConversation.js//logStep", logStep2);
213745
-
213746
- // dist/domains/evals/workflow/functions/runDatasetItem.js
213747
- var logger25 = getLogger("workflow-run-dataset-item");
213748
- async function callChatApiStep2(payload) {
212597
+ __name(logStep, "logStep");
212598
+ async function _evaluateConversationWorkflow(payload) {
212599
+ throw new Error("You attempted to execute workflow _evaluateConversationWorkflow function directly. To start a workflow, use start(_evaluateConversationWorkflow) from workflow/api");
212600
+ }
212601
+ __name(_evaluateConversationWorkflow, "_evaluateConversationWorkflow");
212602
+ _evaluateConversationWorkflow.workflowId = "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//_evaluateConversationWorkflow";
212603
+ var evaluateConversationWorkflow = Object.assign(_evaluateConversationWorkflow, {
212604
+ workflowId: "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//_evaluateConversationWorkflow"
212605
+ });
212606
+ registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//getConversationStep", getConversationStep);
212607
+ registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//getEvaluatorsStep", getEvaluatorsStep);
212608
+ registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//executeEvaluatorStep", executeEvaluatorStep);
212609
+ registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//logStep", logStep);
212610
+
212611
+ // src/domains/evals/workflow/functions/runDatasetItem.ts
212612
+ var logger23 = getLogger("workflow-run-dataset-item");
212613
+ async function callChatApiStep(payload) {
213749
212614
  const { tenantId, projectId, agentId, datasetItemId, datasetItemInput, datasetItemSimulationAgent, datasetRunId } = payload;
213750
- const evaluationService = new EvaluationService2();
212615
+ const evaluationService = new EvaluationService();
213751
212616
  const datasetItem2 = {
213752
212617
  id: datasetItemId,
213753
212618
  input: datasetItemInput,
@@ -213760,7 +212625,7 @@ async function callChatApiStep2(payload) {
213760
212625
  datasetItem: datasetItem2,
213761
212626
  datasetRunId
213762
212627
  });
213763
- logger25.info({
212628
+ logger23.info({
213764
212629
  tenantId,
213765
212630
  projectId,
213766
212631
  datasetItemId,
@@ -213770,12 +212635,12 @@ async function callChatApiStep2(payload) {
213770
212635
  }, "Chat API call completed");
213771
212636
  return result;
213772
212637
  }
213773
- __name(callChatApiStep2, "callChatApiStep");
213774
- async function createRelationStep2(payload, conversationId) {
212638
+ __name(callChatApiStep, "callChatApiStep");
212639
+ async function createRelationStep(payload, conversationId) {
213775
212640
  const { tenantId, projectId, datasetItemId, datasetRunId } = payload;
213776
212641
  const relationId = generateId();
213777
212642
  try {
213778
- await createDatasetRunConversationRelation(runDbClient_default2)({
212643
+ await createDatasetRunConversationRelation(runDbClient_default)({
213779
212644
  tenantId,
213780
212645
  projectId,
213781
212646
  id: relationId,
@@ -213783,7 +212648,7 @@ async function createRelationStep2(payload, conversationId) {
213783
212648
  conversationId,
213784
212649
  datasetItemId
213785
212650
  });
213786
- logger25.info({
212651
+ logger23.info({
213787
212652
  tenantId,
213788
212653
  projectId,
213789
212654
  datasetItemId,
@@ -213797,7 +212662,7 @@ async function createRelationStep2(payload, conversationId) {
213797
212662
  };
213798
212663
  } catch (error46) {
213799
212664
  if (error46?.cause?.code === "23503" || error46?.code === "23503") {
213800
- logger25.warn({
212665
+ logger23.warn({
213801
212666
  tenantId,
213802
212667
  projectId,
213803
212668
  datasetItemId,
@@ -213813,12 +212678,14 @@ async function createRelationStep2(payload, conversationId) {
213813
212678
  throw error46;
213814
212679
  }
213815
212680
  }
213816
- __name(createRelationStep2, "createRelationStep");
213817
- async function executeEvaluatorStep3(tenantId, projectId, conversationId, evaluatorId, evaluationRunId, expectedOutput) {
212681
+ __name(createRelationStep, "createRelationStep");
212682
+ async function executeEvaluatorStep2(tenantId, projectId, conversationId, evaluatorId, evaluationRunId, expectedOutput) {
213818
212683
  const ref = getProjectScopedRef(tenantId, projectId, "main");
213819
- const resolvedRef = await resolveRef2(manageDbClient_default2)(ref);
213820
- if (!resolvedRef) throw new Error("Failed to resolve ref");
213821
- const evaluator2 = await withRef(manageDbPool_default2, resolvedRef, (db) => getEvaluatorById(db)({
212684
+ const resolvedRef = await resolveRef2(manageDbClient_default)(ref);
212685
+ if (!resolvedRef) {
212686
+ throw new Error("Failed to resolve ref");
212687
+ }
212688
+ const evaluator2 = await withRef(manageDbPool_default, resolvedRef, (db) => getEvaluatorById(db)({
213822
212689
  scopes: {
213823
212690
  tenantId,
213824
212691
  projectId,
@@ -213826,20 +212693,22 @@ async function executeEvaluatorStep3(tenantId, projectId, conversationId, evalua
213826
212693
  }
213827
212694
  }));
213828
212695
  if (!evaluator2) {
213829
- logger25.warn({
212696
+ logger23.warn({
213830
212697
  evaluatorId
213831
212698
  }, "Evaluator not found");
213832
212699
  return null;
213833
212700
  }
213834
- const conversation = await getConversation(runDbClient_default2)({
212701
+ const conversation = await getConversation(runDbClient_default)({
213835
212702
  scopes: {
213836
212703
  tenantId,
213837
212704
  projectId
213838
212705
  },
213839
212706
  conversationId
213840
212707
  });
213841
- if (!conversation) throw new Error(`Conversation not found: ${conversationId}`);
213842
- const evalResult = await createEvaluationResult(runDbClient_default2)({
212708
+ if (!conversation) {
212709
+ throw new Error(`Conversation not found: ${conversationId}`);
212710
+ }
212711
+ const evalResult = await createEvaluationResult(runDbClient_default)({
213843
212712
  id: generateId(),
213844
212713
  tenantId,
213845
212714
  projectId,
@@ -213848,14 +212717,15 @@ async function executeEvaluatorStep3(tenantId, projectId, conversationId, evalua
213848
212717
  evaluationRunId
213849
212718
  });
213850
212719
  try {
213851
- const output = await new EvaluationService2().executeEvaluation({
212720
+ const evaluationService = new EvaluationService();
212721
+ const output = await evaluationService.executeEvaluation({
213852
212722
  conversation,
213853
212723
  evaluator: evaluator2,
213854
212724
  tenantId,
213855
212725
  projectId,
213856
212726
  expectedOutput
213857
212727
  });
213858
- await updateEvaluationResult(runDbClient_default2)({
212728
+ await updateEvaluationResult(runDbClient_default)({
213859
212729
  scopes: {
213860
212730
  tenantId,
213861
212731
  projectId,
@@ -213865,7 +212735,7 @@ async function executeEvaluatorStep3(tenantId, projectId, conversationId, evalua
213865
212735
  output
213866
212736
  }
213867
212737
  });
213868
- logger25.info({
212738
+ logger23.info({
213869
212739
  conversationId,
213870
212740
  evaluatorId: evaluator2.id,
213871
212741
  resultId: evalResult.id
@@ -213873,12 +212743,12 @@ async function executeEvaluatorStep3(tenantId, projectId, conversationId, evalua
213873
212743
  return evalResult.id;
213874
212744
  } catch (error46) {
213875
212745
  const errorMessage = error46 instanceof Error ? error46.message : "Unknown error";
213876
- logger25.error({
212746
+ logger23.error({
213877
212747
  error: error46,
213878
212748
  conversationId,
213879
212749
  evaluatorId: evaluator2.id
213880
212750
  }, "Evaluation failed");
213881
- await updateEvaluationResult(runDbClient_default2)({
212751
+ await updateEvaluationResult(runDbClient_default)({
213882
212752
  scopes: {
213883
212753
  tenantId,
213884
212754
  projectId,
@@ -213893,133 +212763,23 @@ async function executeEvaluatorStep3(tenantId, projectId, conversationId, evalua
213893
212763
  return evalResult.id;
213894
212764
  }
213895
212765
  }
213896
- __name(executeEvaluatorStep3, "executeEvaluatorStep");
213897
- async function logStep3(message, data) {
213898
- logger25.info(data, message);
213899
- }
213900
- __name(logStep3, "logStep");
213901
- async function runDatasetItemWorkflow2(payload) {
213902
- throw new Error("You attempted to execute workflow runDatasetItemWorkflow function directly. To start a workflow, use start(runDatasetItemWorkflow) from workflow/api");
213903
- }
213904
- __name(runDatasetItemWorkflow2, "runDatasetItemWorkflow");
213905
- runDatasetItemWorkflow2.workflowId = "workflow//dist/domains/evals/workflow/functions/runDatasetItem.js//runDatasetItemWorkflow";
213906
- registerStepFunction("step//dist/domains/evals/workflow/functions/runDatasetItem.js//callChatApiStep", callChatApiStep2);
213907
- registerStepFunction("step//dist/domains/evals/workflow/functions/runDatasetItem.js//createRelationStep", createRelationStep2);
213908
- registerStepFunction("step//dist/domains/evals/workflow/functions/runDatasetItem.js//executeEvaluatorStep", executeEvaluatorStep3);
213909
- registerStepFunction("step//dist/domains/evals/workflow/functions/runDatasetItem.js//logStep", logStep3);
213910
-
213911
- // src/domains/evals/workflow/functions/evaluateConversation.ts
213912
- var logger26 = getLogger("workflow-evaluate-conversation");
213913
- async function getConversationStep2(payload) {
213914
- const { tenantId, projectId, conversationId } = payload;
213915
- const conv = await getConversation(runDbClient_default)({
213916
- scopes: {
213917
- tenantId,
213918
- projectId
213919
- },
213920
- conversationId
213921
- });
213922
- if (!conv) {
213923
- throw new Error(`Conversation not found: ${conversationId}`);
213924
- }
213925
- return conv;
213926
- }
213927
- __name(getConversationStep2, "getConversationStep");
213928
- async function getEvaluatorsStep2(payload) {
213929
- const { tenantId, projectId, evaluatorIds } = payload;
213930
- const projectMain = await getProjectMainResolvedRef(manageDbClient_default)(tenantId, projectId);
213931
- const evals = await withRef(manageDbPool_default, projectMain, (db) => getEvaluatorsByIds(db)({
213932
- scopes: {
213933
- tenantId,
213934
- projectId
213935
- },
213936
- evaluatorIds
213937
- }));
213938
- return evals;
213939
- }
213940
- __name(getEvaluatorsStep2, "getEvaluatorsStep");
213941
- async function executeEvaluatorStep4(payload, evaluatorId, conversation) {
213942
- const { tenantId, projectId, conversationId, evaluationRunId } = payload;
213943
- const projectMain = await getProjectMainResolvedRef(manageDbClient_default)(tenantId, projectId);
213944
- const evaluator2 = await withRef(manageDbPool_default, projectMain, (db) => getEvaluatorById(db)({
213945
- scopes: {
213946
- tenantId,
213947
- projectId,
213948
- evaluatorId
213949
- }
213950
- }));
213951
- if (!evaluator2) {
213952
- throw new Error(`Evaluator not found: ${evaluatorId}`);
213953
- }
213954
- const evalResult = await createEvaluationResult(runDbClient_default)({
213955
- id: generateId(),
213956
- tenantId,
213957
- projectId,
213958
- conversationId,
213959
- evaluatorId: evaluator2.id,
213960
- evaluationRunId
213961
- });
213962
- try {
213963
- const evaluationService = new EvaluationService();
213964
- const output = await evaluationService.executeEvaluation({
213965
- conversation,
213966
- evaluator: evaluator2,
213967
- tenantId,
213968
- projectId
213969
- });
213970
- const updated = await updateEvaluationResult(runDbClient_default)({
213971
- scopes: {
213972
- tenantId,
213973
- projectId,
213974
- evaluationResultId: evalResult.id
213975
- },
213976
- data: {
213977
- output
213978
- }
213979
- });
213980
- logger26.info({
213981
- conversationId,
213982
- evaluatorId: evaluator2.id,
213983
- resultId: evalResult.id
213984
- }, "Evaluation completed successfully");
213985
- return updated;
213986
- } catch (error46) {
213987
- const errorMessage = error46 instanceof Error ? error46.message : "Unknown error";
213988
- logger26.error({
213989
- error: error46,
213990
- conversationId,
213991
- evaluatorId: evaluator2.id,
213992
- resultId: evalResult.id
213993
- }, "Evaluation execution failed");
213994
- const failed = await updateEvaluationResult(runDbClient_default)({
213995
- scopes: {
213996
- tenantId,
213997
- projectId,
213998
- evaluationResultId: evalResult.id
213999
- },
214000
- data: {
214001
- output: {
214002
- text: `Evaluation failed: ${errorMessage}`
214003
- }
214004
- }
214005
- });
214006
- return failed;
214007
- }
214008
- }
214009
- __name(executeEvaluatorStep4, "executeEvaluatorStep");
214010
- async function logStep4(message, data) {
214011
- logger26.info(data, message);
212766
+ __name(executeEvaluatorStep2, "executeEvaluatorStep");
212767
+ async function logStep2(message, data) {
212768
+ logger23.info(data, message);
214012
212769
  }
214013
- __name(logStep4, "logStep");
214014
- async function evaluateConversationWorkflow2(payload) {
214015
- throw new Error("You attempted to execute workflow evaluateConversationWorkflow function directly. To start a workflow, use start(evaluateConversationWorkflow) from workflow/api");
212770
+ __name(logStep2, "logStep");
212771
+ async function _runDatasetItemWorkflow(payload) {
212772
+ throw new Error("You attempted to execute workflow _runDatasetItemWorkflow function directly. To start a workflow, use start(_runDatasetItemWorkflow) from workflow/api");
214016
212773
  }
214017
- __name(evaluateConversationWorkflow2, "evaluateConversationWorkflow");
214018
- evaluateConversationWorkflow2.workflowId = "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//evaluateConversationWorkflow";
214019
- registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//getConversationStep", getConversationStep2);
214020
- registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//getEvaluatorsStep", getEvaluatorsStep2);
214021
- registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//executeEvaluatorStep", executeEvaluatorStep4);
214022
- registerStepFunction("step//src/domains/evals/workflow/functions/evaluateConversation.ts//logStep", logStep4);
212774
+ __name(_runDatasetItemWorkflow, "_runDatasetItemWorkflow");
212775
+ _runDatasetItemWorkflow.workflowId = "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//_runDatasetItemWorkflow";
212776
+ var runDatasetItemWorkflow = Object.assign(_runDatasetItemWorkflow, {
212777
+ workflowId: "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//_runDatasetItemWorkflow"
212778
+ });
212779
+ registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//callChatApiStep", callChatApiStep);
212780
+ registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//createRelationStep", createRelationStep);
212781
+ registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//executeEvaluatorStep", executeEvaluatorStep2);
212782
+ registerStepFunction("step//src/domains/evals/workflow/functions/runDatasetItem.ts//logStep", logStep2);
214023
212783
 
214024
212784
  // ../node_modules/.pnpm/@workflow+utils@4.0.1-beta.7/node_modules/@workflow/utils/dist/index.js
214025
212785
  var import_ms2 = __toESM(require_ms(), 1);
@@ -214651,7 +213411,7 @@ __name(linkToCurrentContext, "linkToCurrentContext");
214651
213411
  // ../node_modules/.pnpm/@workflow+core@4.0.1-beta.28_@aws-sdk+client-sts@3.970.0_@opentelemetry+api@1.9.0/node_modules/@workflow/core/dist/logger.js
214652
213412
  function createLogger(namespace) {
214653
213413
  const baseDebug = (0, import_debug2.default)(`workflow:${namespace}`);
214654
- const logger27 = /* @__PURE__ */ __name((level) => {
213414
+ const logger24 = /* @__PURE__ */ __name((level) => {
214655
213415
  const levelDebug = baseDebug.extend(level);
214656
213416
  return (message, metadata2) => {
214657
213417
  levelDebug(message, metadata2);
@@ -214667,10 +213427,10 @@ function createLogger(namespace) {
214667
213427
  };
214668
213428
  }, "logger");
214669
213429
  return {
214670
- debug: logger27("debug"),
214671
- info: logger27("info"),
214672
- warn: logger27("warn"),
214673
- error: logger27("error")
213430
+ debug: logger24("debug"),
213431
+ info: logger24("info"),
213432
+ warn: logger24("warn"),
213433
+ error: logger24("error")
214674
213434
  };
214675
213435
  }
214676
213436
  __name(createLogger, "createLogger");
@@ -214686,9 +213446,9 @@ var import_node_path7 = require("node:path");
214686
213446
 
214687
213447
  // ../node_modules/.pnpm/@workflow+utils@4.0.1-beta.7/node_modules/@workflow/utils/dist/get-port.js
214688
213448
  var import_promises = require("node:fs/promises");
214689
- var import_node_util3 = require("node:util");
213449
+ var import_node_util4 = require("node:util");
214690
213450
  var import_node_child_process = require("node:child_process");
214691
- var execFileAsync = (0, import_node_util3.promisify)(import_node_child_process.execFile);
213451
+ var execFileAsync = (0, import_node_util4.promisify)(import_node_child_process.execFile);
214692
213452
  function parsePort(value, radix = 10) {
214693
213453
  const port = parseInt(value, radix);
214694
213454
  if (!Number.isNaN(port) && port >= 0 && port <= 65535) {
@@ -216525,7 +215285,7 @@ var Client9 = class {
216525
215285
  var import_async_sema = __toESM(require_lib3(), 1);
216526
215286
 
216527
215287
  // ../node_modules/.pnpm/ulid@3.0.1/node_modules/ulid/dist/node/index.js
216528
- var import_node_crypto7 = __toESM(require("node:crypto"), 1);
215288
+ var import_node_crypto8 = __toESM(require("node:crypto"), 1);
216529
215289
  var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
216530
215290
  var ENCODING_LEN = 32;
216531
215291
  var RANDOM_LEN = 16;
@@ -216606,7 +215366,7 @@ function decodeTime(id) {
216606
215366
  __name(decodeTime, "decodeTime");
216607
215367
  function detectPRNG(root) {
216608
215368
  const rootLookup = detectRoot();
216609
- const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof import_node_crypto7.default !== "undefined" ? import_node_crypto7.default : null);
215369
+ const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof import_node_crypto8.default !== "undefined" ? import_node_crypto8.default : null);
216610
215370
  if (typeof globalCrypto?.getRandomValues === "function") {
216611
215371
  return () => {
216612
215372
  const buffer = new Uint8Array(1);
@@ -216615,8 +215375,8 @@ function detectPRNG(root) {
216615
215375
  };
216616
215376
  } else if (typeof globalCrypto?.randomBytes === "function") {
216617
215377
  return () => globalCrypto.randomBytes(1).readUInt8() / 255;
216618
- } else if (import_node_crypto7.default?.randomBytes) {
216619
- return () => import_node_crypto7.default.randomBytes(1).readUInt8() / 255;
215378
+ } else if (import_node_crypto8.default?.randomBytes) {
215379
+ return () => import_node_crypto8.default.randomBytes(1).readUInt8() / 255;
216620
215380
  }
216621
215381
  throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
216622
215382
  }
@@ -219524,16 +218284,16 @@ for (let i3 = 0; i3 < chars.length; i3++) {
219524
218284
  var bufLength = 1024 * 16;
219525
218285
 
219526
218286
  // ../node_modules/.pnpm/@workflow+core@4.0.1-beta.28_@aws-sdk+client-sts@3.970.0_@opentelemetry+api@1.9.0/node_modules/@workflow/core/dist/types.js
219527
- var import_node_util4 = require("node:util");
218287
+ var import_node_util5 = require("node:util");
219528
218288
  function getErrorName(v3) {
219529
- if (import_node_util4.types.isNativeError(v3)) {
218289
+ if (import_node_util5.types.isNativeError(v3)) {
219530
218290
  return v3.name;
219531
218291
  }
219532
218292
  return "Error";
219533
218293
  }
219534
218294
  __name(getErrorName, "getErrorName");
219535
218295
  function getErrorStack(v3) {
219536
- if (import_node_util4.types.isNativeError(v3)) {
218296
+ if (import_node_util5.types.isNativeError(v3)) {
219537
218297
  return v3.stack ?? "";
219538
218298
  }
219539
218299
  return "";