@inkeep/agents-core 0.31.7 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/{chunk-RBUBOGX6.js → chunk-FUJJ4OQ2.js} +62 -10
  2. package/dist/{chunk-T5TTDZ6L.js → chunk-VSQY72K5.js} +133 -133
  3. package/dist/{chunk-PPBBIDK4.js → chunk-X6ZMJ3G6.js} +1 -1
  4. package/dist/client-exports.cjs +283 -224
  5. package/dist/client-exports.d.cts +7 -7
  6. package/dist/client-exports.d.ts +7 -7
  7. package/dist/client-exports.js +15 -7
  8. package/dist/db/schema.cjs +211 -211
  9. package/dist/db/schema.d.cts +3 -3
  10. package/dist/db/schema.d.ts +3 -3
  11. package/dist/db/schema.js +1 -1
  12. package/dist/index.cjs +597 -402
  13. package/dist/index.d.cts +409 -352
  14. package/dist/index.d.ts +409 -352
  15. package/dist/index.js +281 -162
  16. package/dist/{schema-lEFnfOQ-.d.ts → schema-CuEjPQt7.d.ts} +876 -1014
  17. package/dist/{schema-ztSm-Iv6.d.cts → schema-D1P8r3qm.d.cts} +876 -1014
  18. package/dist/types/index.d.cts +3 -3
  19. package/dist/types/index.d.ts +3 -3
  20. package/dist/{utility-qLyZ45lb.d.cts → utility-DF5IUC9K.d.cts} +1230 -1394
  21. package/dist/{utility-qLyZ45lb.d.ts → utility-DF5IUC9K.d.ts} +1230 -1394
  22. package/dist/validation/index.cjs +270 -219
  23. package/dist/validation/index.d.cts +3 -3
  24. package/dist/validation/index.d.ts +3 -3
  25. package/dist/validation/index.js +2 -2
  26. package/drizzle/0000_exotic_mysterio.sql +398 -0
  27. package/drizzle/meta/0000_snapshot.json +1683 -1223
  28. package/drizzle/meta/_journal.json +4 -102
  29. package/package.json +6 -3
  30. package/drizzle/0000_material_menace.sql +0 -326
  31. package/drizzle/0001_eminent_fixer.sql +0 -43
  32. package/drizzle/0002_bumpy_romulus.sql +0 -3
  33. package/drizzle/0003_soft_forgotten_one.sql +0 -39
  34. package/drizzle/0004_melted_omega_flight.sql +0 -3
  35. package/drizzle/0005_wide_shriek.sql +0 -127
  36. package/drizzle/0006_damp_lenny_balinger.sql +0 -52
  37. package/drizzle/0007_mighty_typhoid_mary.sql +0 -227
  38. package/drizzle/0008_mysterious_crusher_hogan.sql +0 -20
  39. package/drizzle/0009_old_black_cat.sql +0 -1
  40. package/drizzle/0010_wet_vampiro.sql +0 -2
  41. package/drizzle/0011_slippery_korg.sql +0 -36
  42. package/drizzle/0012_salty_psynapse.sql +0 -17
  43. package/drizzle/0013_shocking_blur.sql +0 -19
  44. package/drizzle/0014_broad_hellfire_club.sql +0 -29
  45. package/drizzle/meta/0001_snapshot.json +0 -2435
  46. package/drizzle/meta/0002_snapshot.json +0 -2428
  47. package/drizzle/meta/0003_snapshot.json +0 -2559
  48. package/drizzle/meta/0004_snapshot.json +0 -2547
  49. package/drizzle/meta/0005_snapshot.json +0 -2558
  50. package/drizzle/meta/0006_snapshot.json +0 -2751
  51. package/drizzle/meta/0007_snapshot.json +0 -2766
  52. package/drizzle/meta/0008_snapshot.json +0 -2753
  53. package/drizzle/meta/0009_snapshot.json +0 -2744
  54. package/drizzle/meta/0010_snapshot.json +0 -2751
  55. package/drizzle/meta/0011_snapshot.json +0 -2849
  56. package/drizzle/meta/0012_snapshot.json +0 -2985
  57. package/drizzle/meta/0013_snapshot.json +0 -2988
  58. package/drizzle/meta/0014_snapshot.json +0 -2992
package/dist/index.cjs CHANGED
@@ -1,15 +1,24 @@
1
1
  'use strict';
2
2
 
3
3
  var zod = require('zod');
4
+ var fs = require('fs');
5
+ var os = require('os');
6
+ var path = require('path');
7
+ var dotenv = require('dotenv');
8
+ var dotenvExpand = require('dotenv-expand');
9
+ var findUp = require('find-up');
4
10
  var pino = require('pino');
5
11
  var pinoPretty = require('pino-pretty');
6
12
  var zodOpenapi = require('@hono/zod-openapi');
7
13
  var drizzleZod = require('drizzle-zod');
8
14
  var drizzleOrm = require('drizzle-orm');
9
- var sqliteCore = require('drizzle-orm/sqlite-core');
15
+ var pgCore = require('drizzle-orm/pg-core');
10
16
  var jmespath = require('jmespath');
11
- var client = require('@libsql/client');
12
- var libsql = require('drizzle-orm/libsql');
17
+ var nodePostgres = require('drizzle-orm/node-postgres');
18
+ var pg = require('pg');
19
+ var url = require('url');
20
+ var pglite = require('@electric-sql/pglite');
21
+ var pglite$1 = require('drizzle-orm/pglite');
13
22
  var nanoid = require('nanoid');
14
23
  var crypto = require('crypto');
15
24
  var util = require('util');
@@ -24,26 +33,21 @@ var ai = require('ai');
24
33
  var exitHook = require('exit-hook');
25
34
  var tsPattern = require('ts-pattern');
26
35
  var jose = require('jose');
27
- var fs = require('fs');
28
- var os = require('os');
29
- var path = require('path');
30
- var dotenv = require('dotenv');
31
- var dotenvExpand = require('dotenv-expand');
32
- var findUp = require('find-up');
33
36
  var api = require('@opentelemetry/api');
34
37
  var Ajv = require('ajv');
35
38
  var node = require('@nangohq/node');
36
39
 
40
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
37
41
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
38
42
 
39
- var pino__default = /*#__PURE__*/_interopDefault(pino);
40
- var pinoPretty__default = /*#__PURE__*/_interopDefault(pinoPretty);
41
- var jmespath__default = /*#__PURE__*/_interopDefault(jmespath);
42
- var crypto__default = /*#__PURE__*/_interopDefault(crypto);
43
43
  var fs__default = /*#__PURE__*/_interopDefault(fs);
44
44
  var os__default = /*#__PURE__*/_interopDefault(os);
45
45
  var path__default = /*#__PURE__*/_interopDefault(path);
46
46
  var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
47
+ var pino__default = /*#__PURE__*/_interopDefault(pino);
48
+ var pinoPretty__default = /*#__PURE__*/_interopDefault(pinoPretty);
49
+ var jmespath__default = /*#__PURE__*/_interopDefault(jmespath);
50
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
47
51
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
48
52
 
49
53
  var __defProp = Object.defineProperty;
@@ -247,7 +251,7 @@ var require_util = __commonJS({
247
251
  return path2;
248
252
  }
249
253
  exports.normalize = normalize;
250
- function join(aRoot, aPath) {
254
+ function join2(aRoot, aPath) {
251
255
  if (aRoot === "") {
252
256
  aRoot = ".";
253
257
  }
@@ -279,7 +283,7 @@ var require_util = __commonJS({
279
283
  }
280
284
  return joined;
281
285
  }
282
- exports.join = join;
286
+ exports.join = join2;
283
287
  exports.isAbsolute = function(aPath) {
284
288
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
285
289
  };
@@ -452,7 +456,7 @@ var require_util = __commonJS({
452
456
  parsed.path = parsed.path.substring(0, index2 + 1);
453
457
  }
454
458
  }
455
- sourceURL = join(urlGenerate(parsed), sourceURL);
459
+ sourceURL = join2(urlGenerate(parsed), sourceURL);
456
460
  }
457
461
  return normalize(sourceURL);
458
462
  }
@@ -4467,7 +4471,7 @@ var require_typescript = __commonJS({
4467
4471
  textSpanOverlapsWith: () => textSpanOverlapsWith,
4468
4472
  textSpansEqual: () => textSpansEqual,
4469
4473
  textToKeywordObj: () => textToKeywordObj,
4470
- timestamp: () => timestamp,
4474
+ timestamp: () => timestamp2,
4471
4475
  toArray: () => toArray,
4472
4476
  toBuilderFileEmit: () => toBuilderFileEmit,
4473
4477
  toBuilderStateFileInfoForMultiEmit: () => toBuilderStateFileInfoForMultiEmit,
@@ -7424,7 +7428,7 @@ ${lanes.join("\n")}
7424
7428
  function tryGetNativePerformanceHooks() {
7425
7429
  return nativePerformanceHooks;
7426
7430
  }
7427
- var timestamp = nativePerformanceTime ? () => nativePerformanceTime.now() : Date.now;
7431
+ var timestamp2 = nativePerformanceTime ? () => nativePerformanceTime.now() : Date.now;
7428
7432
  var ts_performance_exports = {};
7429
7433
  __export2(ts_performance_exports, {
7430
7434
  clearMarks: () => clearMarks,
@@ -7469,7 +7473,7 @@ ${lanes.join("\n")}
7469
7473
  }
7470
7474
  var nullTimer = { enter: noop, exit: noop };
7471
7475
  var enabled = false;
7472
- var timeorigin = timestamp();
7476
+ var timeorigin = timestamp2();
7473
7477
  var marks = /* @__PURE__ */ new Map();
7474
7478
  var counts = /* @__PURE__ */ new Map();
7475
7479
  var durations = /* @__PURE__ */ new Map();
@@ -7477,7 +7481,7 @@ ${lanes.join("\n")}
7477
7481
  if (enabled) {
7478
7482
  const count18 = counts.get(markName) ?? 0;
7479
7483
  counts.set(markName, count18 + 1);
7480
- marks.set(markName, timestamp());
7484
+ marks.set(markName, timestamp2());
7481
7485
  performanceImpl == null ? void 0 : performanceImpl.mark(markName);
7482
7486
  if (typeof onProfilerEvent === "function") {
7483
7487
  onProfilerEvent(markName);
@@ -7486,7 +7490,7 @@ ${lanes.join("\n")}
7486
7490
  }
7487
7491
  function measure(measureName, startMarkName, endMarkName) {
7488
7492
  if (enabled) {
7489
- const end = (endMarkName !== void 0 ? marks.get(endMarkName) : void 0) ?? timestamp();
7493
+ const end = (endMarkName !== void 0 ? marks.get(endMarkName) : void 0) ?? timestamp2();
7490
7494
  const start = (startMarkName !== void 0 ? marks.get(startMarkName) : void 0) ?? timeorigin;
7491
7495
  const previousDuration = durations.get(measureName) || 0;
7492
7496
  durations.set(measureName, previousDuration + (end - start));
@@ -7584,7 +7588,7 @@ ${lanes.join("\n")}
7584
7588
  });
7585
7589
  traceFd = fs2.openSync(tracePath, "w");
7586
7590
  tracing = tracingEnabled2;
7587
- const meta = { cat: "__metadata", ph: "M", ts: 1e3 * timestamp(), pid: 1, tid: 1 };
7591
+ const meta = { cat: "__metadata", ph: "M", ts: 1e3 * timestamp2(), pid: 1, tid: 1 };
7588
7592
  fs2.writeSync(
7589
7593
  traceFd,
7590
7594
  "[\n" + [{ name: "process_name", args: { name: "tsc" }, ...meta }, { name: "thread_name", args: { name: "Main" }, ...meta }, { name: "TracingStartedInBrowser", ...meta, cat: "disabled-by-default-devtools.timeline" }].map((v) => JSON.stringify(v)).join(",\n")
@@ -7630,17 +7634,17 @@ ${lanes.join("\n")}
7630
7634
  if (separateBeginAndEnd) {
7631
7635
  writeEvent("B", phase, name, args);
7632
7636
  }
7633
- eventStack.push({ phase, name, args, time: 1e3 * timestamp(), separateBeginAndEnd });
7637
+ eventStack.push({ phase, name, args, time: 1e3 * timestamp2(), separateBeginAndEnd });
7634
7638
  }
7635
7639
  tracingEnabled2.push = push;
7636
7640
  function pop(results) {
7637
7641
  Debug.assert(eventStack.length > 0);
7638
- writeStackEvent(eventStack.length - 1, 1e3 * timestamp(), results);
7642
+ writeStackEvent(eventStack.length - 1, 1e3 * timestamp2(), results);
7639
7643
  eventStack.length--;
7640
7644
  }
7641
7645
  tracingEnabled2.pop = pop;
7642
7646
  function popAll() {
7643
- const endTime = 1e3 * timestamp();
7647
+ const endTime = 1e3 * timestamp2();
7644
7648
  for (let i = eventStack.length - 1; i >= 0; i--) {
7645
7649
  writeStackEvent(i, endTime);
7646
7650
  }
@@ -7665,7 +7669,7 @@ ${lanes.join("\n")}
7665
7669
  writeEvent("X", phase, name, { ...args, results }, `"dur":${endTime - time}`, time);
7666
7670
  }
7667
7671
  }
7668
- function writeEvent(eventType, phase, name, args, extras, time = 1e3 * timestamp()) {
7672
+ function writeEvent(eventType, phase, name, args, extras, time = 1e3 * timestamp2()) {
7669
7673
  if (mode === "server" && phase === "checkTypes") return;
7670
7674
  mark("beginTracing");
7671
7675
  fs2.writeSync(traceFd, `,
@@ -10373,7 +10377,7 @@ ${lanes.join("\n")}
10373
10377
  var _a;
10374
10378
  timerToUpdateChildWatches = void 0;
10375
10379
  sysLog(`sysLog:: onTimerToUpdateChildWatches:: ${cacheToUpdateChildWatches.size}`);
10376
- const start = timestamp();
10380
+ const start = timestamp2();
10377
10381
  const invokeMap = /* @__PURE__ */ new Map();
10378
10382
  while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
10379
10383
  const result = cacheToUpdateChildWatches.entries().next();
@@ -10383,7 +10387,7 @@ ${lanes.join("\n")}
10383
10387
  const hasChanges = updateChildWatches(dirName, dirPath, options);
10384
10388
  if (!((_a = cache.get(dirPath)) == null ? void 0 : _a.targetWatcher)) invokeCallbacks(dirName, dirPath, invokeMap, hasChanges ? void 0 : fileNames);
10385
10389
  }
10386
- sysLog(`sysLog:: invokingWatchers:: Elapsed:: ${timestamp() - start}ms:: ${cacheToUpdateChildWatches.size}`);
10390
+ sysLog(`sysLog:: invokingWatchers:: Elapsed:: ${timestamp2() - start}ms:: ${cacheToUpdateChildWatches.size}`);
10387
10391
  callbackCache.forEach((callbacks, rootDirName) => {
10388
10392
  const existing = invokeMap.get(rootDirName);
10389
10393
  if (existing) {
@@ -10396,7 +10400,7 @@ ${lanes.join("\n")}
10396
10400
  });
10397
10401
  }
10398
10402
  });
10399
- const elapsed = timestamp() - start;
10403
+ const elapsed = timestamp2() - start;
10400
10404
  sysLog(`sysLog:: Elapsed:: ${elapsed}ms:: onTimerToUpdateChildWatches:: ${cacheToUpdateChildWatches.size} ${timerToUpdateChildWatches}`);
10401
10405
  }
10402
10406
  function removeChildWatches(parentWatcher) {
@@ -137376,17 +137380,17 @@ ${lanes.join("\n")}
137376
137380
  function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
137377
137381
  const watchInfo = `DirectoryWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
137378
137382
  log(watchInfo);
137379
- const start = timestamp();
137383
+ const start = timestamp2();
137380
137384
  const watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2);
137381
- const elapsed = timestamp() - start;
137385
+ const elapsed = timestamp2() - start;
137382
137386
  log(`Elapsed:: ${elapsed}ms ${watchInfo}`);
137383
137387
  return {
137384
137388
  close: () => {
137385
137389
  const watchInfo2 = `DirectoryWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
137386
137390
  log(watchInfo2);
137387
- const start2 = timestamp();
137391
+ const start2 = timestamp2();
137388
137392
  watcher.close();
137389
- const elapsed2 = timestamp() - start2;
137393
+ const elapsed2 = timestamp2() - start2;
137390
137394
  log(`Elapsed:: ${elapsed2}ms ${watchInfo2}`);
137391
137395
  }
137392
137396
  };
@@ -137399,13 +137403,13 @@ ${lanes.join("\n")}
137399
137403
  (...args) => {
137400
137404
  const triggerredInfo = `${key === "watchFile" ? "FileWatcher" : "DirectoryWatcher"}:: Triggered with ${args[0]} ${args[1] !== void 0 ? args[1] : ""}:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
137401
137405
  log(triggerredInfo);
137402
- const start = timestamp();
137406
+ const start = timestamp2();
137403
137407
  cb.call(
137404
137408
  /*thisArg*/
137405
137409
  void 0,
137406
137410
  ...args
137407
137411
  );
137408
- const elapsed = timestamp() - start;
137412
+ const elapsed = timestamp2() - start;
137409
137413
  log(`Elapsed:: ${elapsed}ms ${triggerredInfo}`);
137410
137414
  },
137411
137415
  flags,
@@ -154143,7 +154147,7 @@ ${lanes.join("\n")}
154143
154147
  ));
154144
154148
  const autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) == null ? void 0 : _a.call(host));
154145
154149
  if (autoImportProvider) {
154146
- const start = timestamp();
154150
+ const start = timestamp2();
154147
154151
  const checker = program.getTypeChecker();
154148
154152
  forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, host, (module22, file) => {
154149
154153
  if (file && !program.getSourceFile(file.fileName) || !file && !checker.resolveName(
@@ -154163,7 +154167,7 @@ ${lanes.join("\n")}
154163
154167
  );
154164
154168
  }
154165
154169
  });
154166
- (_b = host.log) == null ? void 0 : _b.call(host, `forEachExternalModuleToImportFrom autoImportProvider: ${timestamp() - start}`);
154170
+ (_b = host.log) == null ? void 0 : _b.call(host, `forEachExternalModuleToImportFrom autoImportProvider: ${timestamp2() - start}`);
154167
154171
  }
154168
154172
  }
154169
154173
  function getIsExcludedPatterns(preferences, useCaseSensitiveFileNames2) {
@@ -154218,7 +154222,7 @@ ${lanes.join("\n")}
154218
154222
  }
154219
154223
  function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
154220
154224
  var _a, _b, _c, _d, _e;
154221
- const start = timestamp();
154225
+ const start = timestamp2();
154222
154226
  (_a = host.getPackageJsonAutoImportProvider) == null ? void 0 : _a.call(host);
154223
154227
  const cache = ((_b = host.getCachedExportInfoMap) == null ? void 0 : _b.call(host)) || createCacheableExportInfoMap({
154224
154228
  getCurrentProgram: () => program,
@@ -154281,7 +154285,7 @@ ${lanes.join("\n")}
154281
154285
  cache.clear();
154282
154286
  throw err;
154283
154287
  }
154284
- (_e = host.log) == null ? void 0 : _e.call(host, `getExportInfoMap: done in ${timestamp() - start} ms`);
154288
+ (_e = host.log) == null ? void 0 : _e.call(host, `getExportInfoMap: done in ${timestamp2() - start} ms`);
154285
154289
  return cache;
154286
154290
  }
154287
154291
  function getDefaultLikeExportInfo(moduleSymbol, checker) {
@@ -164904,7 +164908,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164904
164908
  this.lastCancellationCheckTime = 0;
164905
164909
  }
164906
164910
  isCancellationRequested() {
164907
- const time = timestamp();
164911
+ const time = timestamp2();
164908
164912
  const duration = Math.abs(time - this.lastCancellationCheckTime);
164909
164913
  if (duration >= this.throttleWaitMilliseconds) {
164910
164914
  this.lastCancellationCheckTime = time;
@@ -165728,13 +165732,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
165728
165732
  return match2 ? [createTextSpanFromNode(token, sourceFile), createTextSpanFromNode(match2, sourceFile)].sort((a, b) => a.start - b.start) : emptyArray;
165729
165733
  }
165730
165734
  function getIndentationAtPosition(fileName, position, editorOptions) {
165731
- let start = timestamp();
165735
+ let start = timestamp2();
165732
165736
  const settings = toEditorSettings(editorOptions);
165733
165737
  const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
165734
- log("getIndentationAtPosition: getCurrentSourceFile: " + (timestamp() - start));
165735
- start = timestamp();
165738
+ log("getIndentationAtPosition: getCurrentSourceFile: " + (timestamp2() - start));
165739
+ start = timestamp2();
165736
165740
  const result = ts_formatting_exports.SmartIndenter.getIndentation(position, sourceFile, settings);
165737
- log("getIndentationAtPosition: computeIndentation : " + (timestamp() - start));
165741
+ log("getIndentationAtPosition: computeIndentation : " + (timestamp2() - start));
165738
165742
  return result;
165739
165743
  }
165740
165744
  function getFormattingEditsForRange(fileName, start, end, options) {
@@ -179423,7 +179427,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
179423
179427
  }
179424
179428
  function resolvingModuleSpecifiers(logPrefix, host, resolver, program, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
179425
179429
  var _a, _b, _c, _d;
179426
- const start = timestamp();
179430
+ const start = timestamp2();
179427
179431
  const needsFullResolution = isForImportStatementCompletion || getResolvePackageJsonExports(program.getCompilerOptions()) || ((_a = preferences.autoImportSpecifierExcludeRegexes) == null ? void 0 : _a.length);
179428
179432
  let skippedAny = false;
179429
179433
  let ambientCount = 0;
@@ -179439,7 +179443,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
179439
179443
  const hitRateMessage = cacheAttemptCount ? ` (${(resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1)}% hit rate)` : "";
179440
179444
  (_b = host.log) == null ? void 0 : _b.call(host, `${logPrefix}: resolved ${resolvedCount} module specifiers, plus ${ambientCount} ambient and ${resolvedFromCacheCount} from cache${hitRateMessage}`);
179441
179445
  (_c = host.log) == null ? void 0 : _c.call(host, `${logPrefix}: response is ${skippedAny ? "incomplete" : "complete"}`);
179442
- (_d = host.log) == null ? void 0 : _d.call(host, `${logPrefix}: ${timestamp() - start}`);
179446
+ (_d = host.log) == null ? void 0 : _d.call(host, `${logPrefix}: ${timestamp2() - start}`);
179443
179447
  return result;
179444
179448
  function tryResolve(exportInfo, isFromAmbientModule) {
179445
179449
  if (isFromAmbientModule) {
@@ -181026,7 +181030,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
181026
181030
  }
181027
181031
  }
181028
181032
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol = false) {
181029
- const start = timestamp();
181033
+ const start = timestamp2();
181030
181034
  const closestSymbolDeclaration = getClosestSymbolDeclaration(contextToken, location);
181031
181035
  const useSemicolons = probablyUsesSemicolons(sourceFile);
181032
181036
  const typeChecker = program.getTypeChecker();
@@ -181085,7 +181089,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
181085
181089
  true
181086
181090
  );
181087
181091
  }
181088
- log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start));
181092
+ log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp2() - start));
181089
181093
  return {
181090
181094
  has: (name) => uniques.has(name),
181091
181095
  add: (name) => uniques.set(name, true)
@@ -181508,12 +181512,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
181508
181512
  function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
181509
181513
  const typeChecker = program.getTypeChecker();
181510
181514
  const inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
181511
- let start = timestamp();
181515
+ let start = timestamp2();
181512
181516
  let currentToken = getTokenAtPosition(sourceFile, position);
181513
- log("getCompletionData: Get current token: " + (timestamp() - start));
181514
- start = timestamp();
181517
+ log("getCompletionData: Get current token: " + (timestamp2() - start));
181518
+ start = timestamp2();
181515
181519
  const insideComment = isInComment(sourceFile, position, currentToken);
181516
- log("getCompletionData: Is inside comment: " + (timestamp() - start));
181520
+ log("getCompletionData: Is inside comment: " + (timestamp2() - start));
181517
181521
  let insideJsDocTagTypeExpression = false;
181518
181522
  let insideJsDocImportTag = false;
181519
181523
  let isInSnippetScope = false;
@@ -181562,12 +181566,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
181562
181566
  return void 0;
181563
181567
  }
181564
181568
  }
181565
- start = timestamp();
181569
+ start = timestamp2();
181566
181570
  const isJsOnlyLocation = !insideJsDocTagTypeExpression && !insideJsDocImportTag && isSourceFileJS(sourceFile);
181567
181571
  const tokens = getRelevantTokens(position, sourceFile);
181568
181572
  const previousToken = tokens.previousToken;
181569
181573
  let contextToken = tokens.contextToken;
181570
- log("getCompletionData: Get previous token: " + (timestamp() - start));
181574
+ log("getCompletionData: Get previous token: " + (timestamp2() - start));
181571
181575
  let node = currentToken;
181572
181576
  let propertyAccessToConvert;
181573
181577
  let isRightOfDot = false;
@@ -181700,7 +181704,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
181700
181704
  }
181701
181705
  }
181702
181706
  }
181703
- const semanticStart = timestamp();
181707
+ const semanticStart = timestamp2();
181704
181708
  let completionKind = 5;
181705
181709
  let hasUnresolvedAutoImports = false;
181706
181710
  let symbols = [];
@@ -181733,7 +181737,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
181733
181737
  return keywordFilters ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierLocation) : void 0;
181734
181738
  }
181735
181739
  }
181736
- log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
181740
+ log("getCompletionData: Semantic work: " + (timestamp2() - semanticStart));
181737
181741
  const contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker);
181738
181742
  const isLiteralExpected = !tryCast(previousToken, isStringLiteralLike) && !isJsxIdentifierExpected;
181739
181743
  const literals = !isLiteralExpected ? [] : mapDefined(
@@ -182278,9 +182282,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
182278
182282
  return scope;
182279
182283
  }
182280
182284
  function isCompletionListBlocker(contextToken2) {
182281
- const start2 = timestamp();
182285
+ const start2 = timestamp2();
182282
182286
  const result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken2) || isSolelyIdentifierDefinitionLocation(contextToken2) || isDotOfNumericLiteral(contextToken2) || isInJsxText(contextToken2) || isBigIntLiteral(contextToken2);
182283
- log("getCompletionsAtPosition: isCompletionListBlocker: " + (timestamp() - start2));
182287
+ log("getCompletionsAtPosition: isCompletionListBlocker: " + (timestamp2() - start2));
182284
182288
  return result;
182285
182289
  }
182286
182290
  function isInJsxText(contextToken2) {
@@ -199802,7 +199806,7 @@ ${options.prefix}` : "\n" : options.prefix
199802
199806
  textSpanOverlapsWith: () => textSpanOverlapsWith,
199803
199807
  textSpansEqual: () => textSpansEqual,
199804
199808
  textToKeywordObj: () => textToKeywordObj,
199805
- timestamp: () => timestamp,
199809
+ timestamp: () => timestamp2,
199806
199810
  toArray: () => toArray,
199807
199811
  toBuilderFileEmit: () => toBuilderFileEmit,
199808
199812
  toBuilderStateFileInfoForMultiEmit: () => toBuilderStateFileInfoForMultiEmit,
@@ -202505,7 +202509,7 @@ ${options.prefix}` : "\n" : options.prefix
202505
202509
  Debug.assert(oldProgram === this.program);
202506
202510
  Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
202507
202511
  this.writeLog(`Starting updateGraphWorker: Project: ${this.getProjectName()}`);
202508
- const start = timestamp();
202512
+ const start = timestamp2();
202509
202513
  const { hasInvalidatedResolutions, hasInvalidatedLibResolutions } = this.resolutionCache.createHasInvalidatedResolutions(returnFalse, returnFalse);
202510
202514
  this.hasInvalidatedResolutions = hasInvalidatedResolutions;
202511
202515
  this.hasInvalidatedLibResolutions = hasInvalidatedLibResolutions;
@@ -202611,7 +202615,7 @@ ${options.prefix}` : "\n" : options.prefix
202611
202615
  },
202612
202616
  (removed) => this.detachScriptInfoFromProject(removed)
202613
202617
  );
202614
- const elapsed = timestamp() - start;
202618
+ const elapsed = timestamp2() - start;
202615
202619
  this.sendPerformanceEvent("UpdateGraph", elapsed);
202616
202620
  this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} projectStateVersion: ${this.projectStateVersion} projectProgramVersion: ${this.projectProgramVersion} structureChanged: ${hasNewProgram}${this.program ? ` structureIsReused:: ${StructureIsReused[this.program.structureIsReused]}` : ""} Elapsed: ${elapsed}ms`);
202617
202621
  if (this.projectService.logger.isTestLogger) {
@@ -203081,7 +203085,7 @@ ${options.prefix}` : "\n" : options.prefix
203081
203085
  const dependencySelection = this.includePackageJsonAutoImports();
203082
203086
  if (dependencySelection) {
203083
203087
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "getPackageJsonAutoImportProvider");
203084
- const start = timestamp();
203088
+ const start = timestamp2();
203085
203089
  this.autoImportProviderHost = AutoImportProviderProject.create(
203086
203090
  dependencySelection,
203087
203091
  this,
@@ -203089,7 +203093,7 @@ ${options.prefix}` : "\n" : options.prefix
203089
203093
  ) ?? false;
203090
203094
  if (this.autoImportProviderHost) {
203091
203095
  updateProjectIfDirty(this.autoImportProviderHost);
203092
- this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", timestamp() - start);
203096
+ this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", timestamp2() - start);
203093
203097
  (_b = tracing) == null ? void 0 : _b.pop();
203094
203098
  return this.autoImportProviderHost.getCurrentProgram();
203095
203099
  }
@@ -203332,7 +203336,7 @@ ${options.prefix}` : "\n" : options.prefix
203332
203336
  if (!program) {
203333
203337
  return emptyArray;
203334
203338
  }
203335
- const start = timestamp();
203339
+ const start = timestamp2();
203336
203340
  let dependencyNames;
203337
203341
  let rootNames;
203338
203342
  const rootFileName = combinePaths(hostProject.currentDirectory, inferredTypesContainingFile);
@@ -203424,7 +203428,7 @@ ${options.prefix}` : "\n" : options.prefix
203424
203428
  });
203425
203429
  }
203426
203430
  if (rootNames == null ? void 0 : rootNames.size) {
203427
- hostProject.log(`AutoImportProviderProject: found ${rootNames.size} root files in ${dependenciesAdded} dependencies ${referencesAddded} referenced projects in ${timestamp() - start} ms`);
203431
+ hostProject.log(`AutoImportProviderProject: found ${rootNames.size} root files in ${dependenciesAdded} dependencies ${referencesAddded} referenced projects in ${timestamp2() - start} ms`);
203428
203432
  }
203429
203433
  return rootNames ? arrayFrom(rootNames.values()) : emptyArray;
203430
203434
  function addRootNames(entrypoints) {
@@ -209762,7 +209766,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
209762
209766
  }
209763
209767
  semanticCheck(file, project) {
209764
209768
  var _a, _b;
209765
- const diagnosticsStartTime = timestamp();
209769
+ const diagnosticsStartTime = timestamp2();
209766
209770
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "semanticCheck", { file, configFilePath: project.canonicalConfigFilePath });
209767
209771
  const diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file) ? emptyArray2 : project.getLanguageService().getSemanticDiagnostics(file).filter((d) => !!d.file);
209768
209772
  this.sendDiagnosticsEvent(file, project, diags, "semanticDiag", diagnosticsStartTime);
@@ -209770,21 +209774,21 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
209770
209774
  }
209771
209775
  syntacticCheck(file, project) {
209772
209776
  var _a, _b;
209773
- const diagnosticsStartTime = timestamp();
209777
+ const diagnosticsStartTime = timestamp2();
209774
209778
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "syntacticCheck", { file, configFilePath: project.canonicalConfigFilePath });
209775
209779
  this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag", diagnosticsStartTime);
209776
209780
  (_b = tracing) == null ? void 0 : _b.pop();
209777
209781
  }
209778
209782
  suggestionCheck(file, project) {
209779
209783
  var _a, _b;
209780
- const diagnosticsStartTime = timestamp();
209784
+ const diagnosticsStartTime = timestamp2();
209781
209785
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "suggestionCheck", { file, configFilePath: project.canonicalConfigFilePath });
209782
209786
  this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag", diagnosticsStartTime);
209783
209787
  (_b = tracing) == null ? void 0 : _b.pop();
209784
209788
  }
209785
209789
  regionSemanticCheck(file, project, ranges) {
209786
209790
  var _a, _b, _c;
209787
- const diagnosticsStartTime = timestamp();
209791
+ const diagnosticsStartTime = timestamp2();
209788
209792
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "regionSemanticCheck", { file, configFilePath: project.canonicalConfigFilePath });
209789
209793
  let diagnosticsResult;
209790
209794
  if (!this.shouldDoRegionCheck(file) || !(diagnosticsResult = project.getLanguageService().getRegionSemanticDiagnostics(file, ranges))) {
@@ -209806,7 +209810,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
209806
209810
  sendDiagnosticsEvent(file, project, diagnostics, kind, diagnosticsStartTime, spans) {
209807
209811
  try {
209808
209812
  const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));
209809
- const duration = timestamp() - diagnosticsStartTime;
209813
+ const duration = timestamp2() - diagnosticsStartTime;
209810
209814
  const body = {
209811
209815
  file,
209812
209816
  diagnostics: diagnostics.map((diag2) => formatDiag(file, project, diag2)),
@@ -212898,6 +212902,112 @@ async function apiFetch(url, options = {}) {
212898
212902
  headers: headers2
212899
212903
  });
212900
212904
  }
212905
+ var loadEnvironmentFiles = () => {
212906
+ const environmentFiles = [];
212907
+ const currentEnv = path__default.default.resolve(process.cwd(), ".env");
212908
+ if (fs__default.default.existsSync(currentEnv)) {
212909
+ environmentFiles.push(currentEnv);
212910
+ }
212911
+ const rootEnv = findUp.findUpSync(".env", { cwd: path__default.default.dirname(process.cwd()) });
212912
+ if (rootEnv) {
212913
+ if (rootEnv !== currentEnv) {
212914
+ environmentFiles.push(rootEnv);
212915
+ }
212916
+ }
212917
+ const userConfigPath = path__default.default.join(os__default.default.homedir(), ".inkeep", "config");
212918
+ if (fs__default.default.existsSync(userConfigPath)) {
212919
+ dotenv__default.default.config({ path: userConfigPath, override: true, quiet: true });
212920
+ }
212921
+ if (environmentFiles.length > 0) {
212922
+ dotenv__default.default.config({
212923
+ path: environmentFiles,
212924
+ override: false,
212925
+ quiet: true
212926
+ });
212927
+ dotenvExpand.expand({ processEnv: process.env });
212928
+ }
212929
+ };
212930
+ loadEnvironmentFiles();
212931
+ var envSchema = zod.z.object({
212932
+ ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
212933
+ DATABASE_URL: zod.z.string().optional(),
212934
+ POSTGRES_POOL_SIZE: zod.z.string().optional(),
212935
+ INKEEP_AGENTS_JWT_SIGNING_SECRET: zod.z.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional()
212936
+ });
212937
+ var parseEnv = () => {
212938
+ try {
212939
+ const parsedEnv = envSchema.parse(process.env);
212940
+ return parsedEnv;
212941
+ } catch (error) {
212942
+ if (error instanceof zod.z.ZodError) {
212943
+ const missingVars = error.issues.map((issue) => issue.path.join("."));
212944
+ throw new Error(
212945
+ `\u274C Invalid environment variables: ${missingVars.join(", ")}
212946
+ ${error.message}`
212947
+ );
212948
+ }
212949
+ throw error;
212950
+ }
212951
+ };
212952
+ var env = parseEnv();
212953
+
212954
+ // src/constants/execution-limits-shared/defaults.ts
212955
+ var executionLimitsSharedDefaults = {
212956
+ // MCP Tool Connection and Retry Behavior
212957
+ // Model Context Protocol (MCP) enables agents to connect to external tools and services.
212958
+ // These constants control connection timeouts and retry strategy with exponential backoff.
212959
+ // CONNECTION_TIMEOUT_MS: Maximum wait time for initial MCP server connection
212960
+ // MAX_RETRIES: Maximum number of connection retry attempts before failing
212961
+ // INITIAL_RECONNECTION_DELAY_MS: Starting delay between retry attempts
212962
+ // MAX_RECONNECTION_DELAY_MS: Maximum delay between retry attempts (after exponential growth)
212963
+ // RECONNECTION_DELAY_GROWTH_FACTOR: Multiplier applied to delay after each failed retry (exponential backoff)
212964
+ MCP_TOOL_CONNECTION_TIMEOUT_MS: 3e3,
212965
+ // 3 seconds
212966
+ MCP_TOOL_MAX_RETRIES: 3,
212967
+ MCP_TOOL_MAX_RECONNECTION_DELAY_MS: 3e4,
212968
+ // 30 seconds
212969
+ MCP_TOOL_INITIAL_RECONNECTION_DELAY_MS: 1e3,
212970
+ // 1 second
212971
+ MCP_TOOL_RECONNECTION_DELAY_GROWTH_FACTOR: 1.5,
212972
+ // Conversation History Context Window
212973
+ // CONVERSATION_HISTORY_DEFAULT_LIMIT: Default number of recent messages to retrieve from conversation history.
212974
+ // Used when fetching conversation context for status updates and other operations.
212975
+ CONVERSATION_HISTORY_DEFAULT_LIMIT: 50,
212976
+ // CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT: Maximum number of tokens from previous conversation messages
212977
+ // to include in the LLM prompt. Prevents excessive token usage while maintaining relevant conversation context.
212978
+ // Messages exceeding this limit are truncated from the beginning of the conversation.
212979
+ CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT: 4e3
212980
+ };
212981
+
212982
+ // src/constants/execution-limits-shared/index.ts
212983
+ loadEnvironmentFiles();
212984
+ var constantsSchema = zod.z.object(
212985
+ Object.fromEntries(
212986
+ Object.keys(executionLimitsSharedDefaults).map((key) => [
212987
+ `AGENTS_${key}`,
212988
+ zod.z.coerce.number().optional()
212989
+ ])
212990
+ )
212991
+ );
212992
+ var parseConstants = () => {
212993
+ const envOverrides = constantsSchema.parse(process.env);
212994
+ return Object.fromEntries(
212995
+ Object.entries(executionLimitsSharedDefaults).map(([key, defaultValue]) => [
212996
+ key,
212997
+ envOverrides[`AGENTS_${key}`] ?? defaultValue
212998
+ ])
212999
+ );
213000
+ };
213001
+ var constants = parseConstants();
213002
+ var {
213003
+ MCP_TOOL_CONNECTION_TIMEOUT_MS,
213004
+ MCP_TOOL_MAX_RETRIES,
213005
+ MCP_TOOL_MAX_RECONNECTION_DELAY_MS,
213006
+ MCP_TOOL_INITIAL_RECONNECTION_DELAY_MS,
213007
+ MCP_TOOL_RECONNECTION_DELAY_GROWTH_FACTOR,
213008
+ CONVERSATION_HISTORY_DEFAULT_LIMIT,
213009
+ CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT
213010
+ } = constants;
212901
213011
 
212902
213012
  // src/constants/models.ts
212903
213013
  var ANTHROPIC_MODELS = {
@@ -213060,6 +213170,74 @@ var AI_TOOL_TYPES = {
213060
213170
  DELEGATION: "delegation"
213061
213171
  };
213062
213172
 
213173
+ // src/constants/schema-validation/defaults.ts
213174
+ var schemaValidationDefaults = {
213175
+ // Agent Execution Transfer Count
213176
+ // Controls how many times an agent can transfer control to sub-agents in a single conversation turn.
213177
+ // This prevents infinite transfer loops while allowing multi-agent collaboration workflows.
213178
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN: 1,
213179
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX: 1e3,
213180
+ AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT: 10,
213181
+ // Sub-Agent Turn Generation Steps
213182
+ // Limits how many AI generation steps a sub-agent can perform within a single turn.
213183
+ // Each generation step typically involves sending a prompt to the LLM and processing its response.
213184
+ // This prevents runaway token usage while allowing complex multi-step reasoning.
213185
+ SUB_AGENT_TURN_GENERATION_STEPS_MIN: 1,
213186
+ SUB_AGENT_TURN_GENERATION_STEPS_MAX: 1e3,
213187
+ SUB_AGENT_TURN_GENERATION_STEPS_DEFAULT: 12,
213188
+ // Status Update Thresholds
213189
+ // Real-time status updates are triggered when either threshold is exceeded during longer operations.
213190
+ // MAX_NUM_EVENTS: Maximum number of internal events before forcing a status update to the client.
213191
+ // MAX_INTERVAL_SECONDS: Maximum time between status updates regardless of event count.
213192
+ STATUS_UPDATE_MAX_NUM_EVENTS: 100,
213193
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS: 600,
213194
+ // 10 minutes
213195
+ // Prompt Text Length Validation
213196
+ // Maximum character limits for agent and sub-agent system prompts to prevent excessive token usage.
213197
+ // Enforced during agent configuration to ensure prompts remain focused and manageable.
213198
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: 2e3,
213199
+ VALIDATION_AGENT_PROMPT_MAX_CHARS: 5e3,
213200
+ // Context Fetcher HTTP Timeout
213201
+ // Maximum time allowed for HTTP requests made by Context Fetchers (e.g., CRM lookups, external API calls).
213202
+ // Context Fetchers automatically retrieve external data at the start of a conversation to enrich agent context.
213203
+ CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT: 1e4
213204
+ // 10 seconds
213205
+ };
213206
+
213207
+ // src/constants/schema-validation/index.ts
213208
+ loadEnvironmentFiles();
213209
+ var constantsSchema2 = zod.z.object(
213210
+ Object.fromEntries(
213211
+ Object.keys(schemaValidationDefaults).map((key) => [
213212
+ `AGENTS_${key}`,
213213
+ zod.z.coerce.number().optional()
213214
+ ])
213215
+ )
213216
+ );
213217
+ var parseConstants2 = () => {
213218
+ const envOverrides = constantsSchema2.parse(process.env);
213219
+ return Object.fromEntries(
213220
+ Object.entries(schemaValidationDefaults).map(([key, defaultValue]) => [
213221
+ key,
213222
+ envOverrides[`AGENTS_${key}`] ?? defaultValue
213223
+ ])
213224
+ );
213225
+ };
213226
+ var constants2 = parseConstants2();
213227
+ var {
213228
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN,
213229
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX,
213230
+ AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT,
213231
+ SUB_AGENT_TURN_GENERATION_STEPS_MIN,
213232
+ SUB_AGENT_TURN_GENERATION_STEPS_MAX,
213233
+ SUB_AGENT_TURN_GENERATION_STEPS_DEFAULT,
213234
+ STATUS_UPDATE_MAX_NUM_EVENTS,
213235
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS,
213236
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS,
213237
+ VALIDATION_AGENT_PROMPT_MAX_CHARS,
213238
+ CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT
213239
+ } = constants2;
213240
+
213063
213241
  // src/constants/signoz-queries.ts
213064
213242
  var DATA_TYPES = {
213065
213243
  STRING: "string",
@@ -213483,165 +213661,165 @@ __export(schema_exports, {
213483
213661
  toolsRelations: () => toolsRelations
213484
213662
  });
213485
213663
  var tenantScoped = {
213486
- tenantId: sqliteCore.text("tenant_id").notNull(),
213487
- id: sqliteCore.text("id").notNull()
213664
+ tenantId: pgCore.varchar("tenant_id", { length: 256 }).notNull(),
213665
+ id: pgCore.varchar("id", { length: 256 }).notNull()
213488
213666
  };
213489
213667
  var projectScoped = {
213490
213668
  ...tenantScoped,
213491
- projectId: sqliteCore.text("project_id").notNull()
213669
+ projectId: pgCore.varchar("project_id", { length: 256 }).notNull()
213492
213670
  };
213493
213671
  var agentScoped = {
213494
213672
  ...projectScoped,
213495
- agentId: sqliteCore.text("agent_id").notNull()
213673
+ agentId: pgCore.varchar("agent_id", { length: 256 }).notNull()
213496
213674
  };
213497
213675
  var subAgentScoped = {
213498
213676
  ...agentScoped,
213499
- subAgentId: sqliteCore.text("sub_agent_id").notNull()
213677
+ subAgentId: pgCore.varchar("sub_agent_id", { length: 256 }).notNull()
213500
213678
  };
213501
213679
  var uiProperties = {
213502
- name: sqliteCore.text("name").notNull(),
213503
- description: sqliteCore.text("description").notNull()
213680
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
213681
+ description: pgCore.text("description").notNull()
213504
213682
  };
213505
213683
  var timestamps = {
213506
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
213507
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
213684
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow(),
213685
+ updatedAt: pgCore.timestamp("updated_at", { mode: "string" }).notNull().defaultNow()
213508
213686
  };
213509
- var projects = sqliteCore.sqliteTable(
213687
+ var projects = pgCore.pgTable(
213510
213688
  "projects",
213511
213689
  {
213512
213690
  ...tenantScoped,
213513
213691
  ...uiProperties,
213514
- models: sqliteCore.text("models", { mode: "json" }).$type(),
213515
- stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
213692
+ models: pgCore.jsonb("models").$type(),
213693
+ stopWhen: pgCore.jsonb("stop_when").$type(),
213516
213694
  ...timestamps
213517
213695
  },
213518
- (table) => [sqliteCore.primaryKey({ columns: [table.tenantId, table.id] })]
213696
+ (table) => [pgCore.primaryKey({ columns: [table.tenantId, table.id] })]
213519
213697
  );
213520
- var agents = sqliteCore.sqliteTable(
213698
+ var agents = pgCore.pgTable(
213521
213699
  "agent",
213522
213700
  {
213523
213701
  ...projectScoped,
213524
- name: sqliteCore.text("name").notNull(),
213525
- description: sqliteCore.text("description"),
213526
- defaultSubAgentId: sqliteCore.text("default_sub_agent_id"),
213527
- contextConfigId: sqliteCore.text("context_config_id"),
213528
- models: sqliteCore.text("models", { mode: "json" }).$type(),
213529
- statusUpdates: sqliteCore.text("status_updates", { mode: "json" }).$type(),
213530
- prompt: sqliteCore.text("prompt"),
213531
- stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
213702
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
213703
+ description: pgCore.text("description"),
213704
+ defaultSubAgentId: pgCore.varchar("default_sub_agent_id", { length: 256 }),
213705
+ contextConfigId: pgCore.varchar("context_config_id", { length: 256 }),
213706
+ models: pgCore.jsonb("models").$type(),
213707
+ statusUpdates: pgCore.jsonb("status_updates").$type(),
213708
+ prompt: pgCore.text("prompt"),
213709
+ stopWhen: pgCore.jsonb("stop_when").$type(),
213532
213710
  ...timestamps
213533
213711
  },
213534
213712
  (table) => [
213535
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213536
- sqliteCore.foreignKey({
213713
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213714
+ pgCore.foreignKey({
213537
213715
  columns: [table.tenantId, table.projectId],
213538
213716
  foreignColumns: [projects.tenantId, projects.id],
213539
213717
  name: "agent_project_fk"
213540
213718
  }).onDelete("cascade")
213541
213719
  ]
213542
213720
  );
213543
- var contextConfigs = sqliteCore.sqliteTable(
213721
+ var contextConfigs = pgCore.pgTable(
213544
213722
  "context_configs",
213545
213723
  {
213546
213724
  ...agentScoped,
213547
- headersSchema: sqliteCore.blob("headers_schema", { mode: "json" }).$type(),
213548
- contextVariables: sqliteCore.blob("context_variables", { mode: "json" }).$type(),
213725
+ headersSchema: pgCore.jsonb("headers_schema").$type(),
213726
+ contextVariables: pgCore.jsonb("context_variables").$type(),
213549
213727
  ...timestamps
213550
213728
  },
213551
213729
  (table) => [
213552
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213553
- sqliteCore.foreignKey({
213730
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213731
+ pgCore.foreignKey({
213554
213732
  columns: [table.tenantId, table.projectId, table.agentId],
213555
213733
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
213556
213734
  name: "context_configs_agent_fk"
213557
213735
  }).onDelete("cascade")
213558
213736
  ]
213559
213737
  );
213560
- var contextCache = sqliteCore.sqliteTable(
213738
+ var contextCache = pgCore.pgTable(
213561
213739
  "context_cache",
213562
213740
  {
213563
213741
  ...projectScoped,
213564
- conversationId: sqliteCore.text("conversation_id").notNull(),
213565
- contextConfigId: sqliteCore.text("context_config_id").notNull(),
213566
- contextVariableKey: sqliteCore.text("context_variable_key").notNull(),
213567
- value: sqliteCore.blob("value", { mode: "json" }).$type().notNull(),
213568
- requestHash: sqliteCore.text("request_hash"),
213569
- fetchedAt: sqliteCore.text("fetched_at").notNull(),
213570
- fetchSource: sqliteCore.text("fetch_source"),
213571
- fetchDurationMs: sqliteCore.integer("fetch_duration_ms"),
213742
+ conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
213743
+ contextConfigId: pgCore.varchar("context_config_id", { length: 256 }).notNull(),
213744
+ contextVariableKey: pgCore.varchar("context_variable_key", { length: 256 }).notNull(),
213745
+ value: pgCore.jsonb("value").$type().notNull(),
213746
+ requestHash: pgCore.varchar("request_hash", { length: 256 }),
213747
+ fetchedAt: pgCore.timestamp("fetched_at", { mode: "string" }).notNull().defaultNow(),
213748
+ fetchSource: pgCore.varchar("fetch_source", { length: 256 }),
213749
+ fetchDurationMs: pgCore.integer("fetch_duration_ms"),
213572
213750
  ...timestamps
213573
213751
  },
213574
213752
  (table) => [
213575
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213576
- sqliteCore.foreignKey({
213753
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213754
+ pgCore.foreignKey({
213577
213755
  columns: [table.tenantId, table.projectId],
213578
213756
  foreignColumns: [projects.tenantId, projects.id],
213579
213757
  name: "context_cache_project_fk"
213580
213758
  }).onDelete("cascade"),
213581
- sqliteCore.index("context_cache_lookup_idx").on(
213759
+ pgCore.index("context_cache_lookup_idx").on(
213582
213760
  table.conversationId,
213583
213761
  table.contextConfigId,
213584
213762
  table.contextVariableKey
213585
213763
  )
213586
213764
  ]
213587
213765
  );
213588
- var subAgents = sqliteCore.sqliteTable(
213766
+ var subAgents = pgCore.pgTable(
213589
213767
  "sub_agents",
213590
213768
  {
213591
213769
  ...agentScoped,
213592
213770
  ...uiProperties,
213593
- prompt: sqliteCore.text("prompt").notNull(),
213594
- conversationHistoryConfig: sqliteCore.text("conversation_history_config", {
213595
- mode: "json"
213596
- }).$type(),
213597
- models: sqliteCore.text("models", { mode: "json" }).$type(),
213598
- stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
213771
+ prompt: pgCore.text("prompt").notNull(),
213772
+ conversationHistoryConfig: pgCore.jsonb(
213773
+ "conversation_history_config"
213774
+ ).$type(),
213775
+ models: pgCore.jsonb("models").$type(),
213776
+ stopWhen: pgCore.jsonb("stop_when").$type(),
213599
213777
  ...timestamps
213600
213778
  },
213601
213779
  (table) => [
213602
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213603
- sqliteCore.foreignKey({
213780
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213781
+ pgCore.foreignKey({
213604
213782
  columns: [table.tenantId, table.projectId, table.agentId],
213605
213783
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
213606
213784
  name: "sub_agents_agents_fk"
213607
213785
  }).onDelete("cascade")
213608
213786
  ]
213609
213787
  );
213610
- var subAgentRelations = sqliteCore.sqliteTable(
213788
+ var subAgentRelations = pgCore.pgTable(
213611
213789
  "sub_agent_relations",
213612
213790
  {
213613
213791
  ...agentScoped,
213614
- sourceSubAgentId: sqliteCore.text("source_sub_agent_id").notNull(),
213615
- targetSubAgentId: sqliteCore.text("target_sub_agent_id"),
213616
- relationType: sqliteCore.text("relation_type"),
213792
+ sourceSubAgentId: pgCore.varchar("source_sub_agent_id", { length: 256 }).notNull(),
213793
+ targetSubAgentId: pgCore.varchar("target_sub_agent_id", { length: 256 }),
213794
+ relationType: pgCore.varchar("relation_type", { length: 256 }),
213617
213795
  ...timestamps
213618
213796
  },
213619
213797
  (table) => [
213620
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213621
- sqliteCore.foreignKey({
213798
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213799
+ pgCore.foreignKey({
213622
213800
  columns: [table.tenantId, table.projectId, table.agentId],
213623
213801
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
213624
213802
  name: "sub_agent_relations_agent_fk"
213625
213803
  }).onDelete("cascade")
213626
213804
  ]
213627
213805
  );
213628
- var externalAgents = sqliteCore.sqliteTable(
213806
+ var externalAgents = pgCore.pgTable(
213629
213807
  "external_agents",
213630
213808
  {
213631
213809
  ...projectScoped,
213632
213810
  ...uiProperties,
213633
- baseUrl: sqliteCore.text("base_url").notNull(),
213634
- credentialReferenceId: sqliteCore.text("credential_reference_id"),
213811
+ baseUrl: pgCore.text("base_url").notNull(),
213812
+ credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
213635
213813
  ...timestamps
213636
213814
  },
213637
213815
  (table) => [
213638
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213639
- sqliteCore.foreignKey({
213816
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213817
+ pgCore.foreignKey({
213640
213818
  columns: [table.tenantId, table.projectId],
213641
213819
  foreignColumns: [projects.tenantId, projects.id],
213642
213820
  name: "external_agents_project_fk"
213643
213821
  }).onDelete("cascade"),
213644
- sqliteCore.foreignKey({
213822
+ pgCore.foreignKey({
213645
213823
  columns: [table.tenantId, table.projectId, table.credentialReferenceId],
213646
213824
  foreignColumns: [
213647
213825
  credentialReferences.tenantId,
@@ -213649,118 +213827,118 @@ var externalAgents = sqliteCore.sqliteTable(
213649
213827
  credentialReferences.id
213650
213828
  ],
213651
213829
  name: "external_agents_credential_reference_fk"
213652
- }).onDelete("set null")
213830
+ }).onDelete("cascade")
213653
213831
  ]
213654
213832
  );
213655
- var tasks = sqliteCore.sqliteTable(
213833
+ var tasks = pgCore.pgTable(
213656
213834
  "tasks",
213657
213835
  {
213658
213836
  ...subAgentScoped,
213659
- contextId: sqliteCore.text("context_id").notNull(),
213660
- status: sqliteCore.text("status").notNull(),
213661
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
213837
+ contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
213838
+ status: pgCore.varchar("status", { length: 256 }).notNull(),
213839
+ metadata: pgCore.jsonb("metadata").$type(),
213662
213840
  ...timestamps
213663
213841
  },
213664
213842
  (table) => [
213665
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213666
- sqliteCore.foreignKey({
213843
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213844
+ pgCore.foreignKey({
213667
213845
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213668
213846
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213669
213847
  name: "tasks_sub_agent_fk"
213670
213848
  }).onDelete("cascade")
213671
213849
  ]
213672
213850
  );
213673
- var taskRelations = sqliteCore.sqliteTable(
213851
+ var taskRelations = pgCore.pgTable(
213674
213852
  "task_relations",
213675
213853
  {
213676
213854
  ...projectScoped,
213677
- parentTaskId: sqliteCore.text("parent_task_id").notNull(),
213678
- childTaskId: sqliteCore.text("child_task_id").notNull(),
213679
- relationType: sqliteCore.text("relation_type").default("parent_child"),
213855
+ parentTaskId: pgCore.varchar("parent_task_id", { length: 256 }).notNull(),
213856
+ childTaskId: pgCore.varchar("child_task_id", { length: 256 }).notNull(),
213857
+ relationType: pgCore.varchar("relation_type", { length: 256 }).default("parent_child"),
213680
213858
  ...timestamps
213681
213859
  },
213682
213860
  (table) => [
213683
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213684
- sqliteCore.foreignKey({
213861
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213862
+ pgCore.foreignKey({
213685
213863
  columns: [table.tenantId, table.projectId],
213686
213864
  foreignColumns: [projects.tenantId, projects.id],
213687
213865
  name: "task_relations_project_fk"
213688
213866
  }).onDelete("cascade")
213689
213867
  ]
213690
213868
  );
213691
- var dataComponents = sqliteCore.sqliteTable(
213869
+ var dataComponents = pgCore.pgTable(
213692
213870
  "data_components",
213693
213871
  {
213694
213872
  ...projectScoped,
213695
213873
  ...uiProperties,
213696
- props: sqliteCore.blob("props", { mode: "json" }).$type(),
213697
- render: sqliteCore.blob("render", { mode: "json" }).$type(),
213874
+ props: pgCore.jsonb("props").$type(),
213875
+ render: pgCore.jsonb("render").$type(),
213698
213876
  ...timestamps
213699
213877
  },
213700
213878
  (table) => [
213701
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213702
- sqliteCore.foreignKey({
213879
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213880
+ pgCore.foreignKey({
213703
213881
  columns: [table.tenantId, table.projectId],
213704
213882
  foreignColumns: [projects.tenantId, projects.id],
213705
213883
  name: "data_components_project_fk"
213706
213884
  }).onDelete("cascade")
213707
213885
  ]
213708
213886
  );
213709
- var subAgentDataComponents = sqliteCore.sqliteTable(
213887
+ var subAgentDataComponents = pgCore.pgTable(
213710
213888
  "sub_agent_data_components",
213711
213889
  {
213712
213890
  ...subAgentScoped,
213713
- dataComponentId: sqliteCore.text("data_component_id").notNull(),
213714
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
213891
+ dataComponentId: pgCore.varchar("data_component_id", { length: 256 }).notNull(),
213892
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
213715
213893
  },
213716
213894
  (table) => [
213717
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213718
- sqliteCore.foreignKey({
213895
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213896
+ pgCore.foreignKey({
213719
213897
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213720
213898
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213721
213899
  name: "sub_agent_data_components_sub_agent_fk"
213722
213900
  }).onDelete("cascade"),
213723
- sqliteCore.foreignKey({
213901
+ pgCore.foreignKey({
213724
213902
  columns: [table.tenantId, table.projectId, table.dataComponentId],
213725
213903
  foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
213726
213904
  name: "sub_agent_data_components_data_component_fk"
213727
213905
  }).onDelete("cascade")
213728
213906
  ]
213729
213907
  );
213730
- var artifactComponents = sqliteCore.sqliteTable(
213908
+ var artifactComponents = pgCore.pgTable(
213731
213909
  "artifact_components",
213732
213910
  {
213733
213911
  ...projectScoped,
213734
213912
  ...uiProperties,
213735
- props: sqliteCore.blob("props", { mode: "json" }).$type(),
213913
+ props: pgCore.jsonb("props").$type(),
213736
213914
  ...timestamps
213737
213915
  },
213738
213916
  (table) => [
213739
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213740
- sqliteCore.foreignKey({
213917
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213918
+ pgCore.foreignKey({
213741
213919
  columns: [table.tenantId, table.projectId],
213742
213920
  foreignColumns: [projects.tenantId, projects.id],
213743
213921
  name: "artifact_components_project_fk"
213744
213922
  }).onDelete("cascade")
213745
213923
  ]
213746
213924
  );
213747
- var subAgentArtifactComponents = sqliteCore.sqliteTable(
213925
+ var subAgentArtifactComponents = pgCore.pgTable(
213748
213926
  "sub_agent_artifact_components",
213749
213927
  {
213750
213928
  ...subAgentScoped,
213751
- artifactComponentId: sqliteCore.text("artifact_component_id").notNull(),
213752
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
213929
+ artifactComponentId: pgCore.varchar("artifact_component_id", { length: 256 }).notNull(),
213930
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
213753
213931
  },
213754
213932
  (table) => [
213755
- sqliteCore.primaryKey({
213933
+ pgCore.primaryKey({
213756
213934
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId, table.id]
213757
213935
  }),
213758
- sqliteCore.foreignKey({
213936
+ pgCore.foreignKey({
213759
213937
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213760
213938
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213761
213939
  name: "sub_agent_artifact_components_sub_agent_fk"
213762
213940
  }).onDelete("cascade"),
213763
- sqliteCore.foreignKey({
213941
+ pgCore.foreignKey({
213764
213942
  columns: [table.tenantId, table.projectId, table.artifactComponentId],
213765
213943
  foreignColumns: [
213766
213944
  artifactComponents.tenantId,
@@ -213771,152 +213949,152 @@ var subAgentArtifactComponents = sqliteCore.sqliteTable(
213771
213949
  }).onDelete("cascade")
213772
213950
  ]
213773
213951
  );
213774
- var tools = sqliteCore.sqliteTable(
213952
+ var tools = pgCore.pgTable(
213775
213953
  "tools",
213776
213954
  {
213777
213955
  ...projectScoped,
213778
- name: sqliteCore.text("name").notNull(),
213779
- description: sqliteCore.text("description"),
213780
- config: sqliteCore.blob("config", { mode: "json" }).$type().notNull(),
213781
- credentialReferenceId: sqliteCore.text("credential_reference_id"),
213782
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
213783
- imageUrl: sqliteCore.text("image_url"),
213784
- capabilities: sqliteCore.blob("capabilities", { mode: "json" }).$type(),
213785
- lastError: sqliteCore.text("last_error"),
213956
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
213957
+ description: pgCore.text("description"),
213958
+ config: pgCore.jsonb("config").$type().notNull(),
213959
+ credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
213960
+ headers: pgCore.jsonb("headers").$type(),
213961
+ imageUrl: pgCore.text("image_url"),
213962
+ capabilities: pgCore.jsonb("capabilities").$type(),
213963
+ lastError: pgCore.text("last_error"),
213786
213964
  ...timestamps
213787
213965
  },
213788
213966
  (table) => [
213789
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213790
- sqliteCore.foreignKey({
213967
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213968
+ pgCore.foreignKey({
213791
213969
  columns: [table.tenantId, table.projectId],
213792
213970
  foreignColumns: [projects.tenantId, projects.id],
213793
213971
  name: "tools_project_fk"
213794
213972
  }).onDelete("cascade")
213795
213973
  ]
213796
213974
  );
213797
- var functionTools = sqliteCore.sqliteTable(
213975
+ var functionTools = pgCore.pgTable(
213798
213976
  "function_tools",
213799
213977
  {
213800
213978
  ...agentScoped,
213801
- name: sqliteCore.text("name").notNull(),
213802
- description: sqliteCore.text("description"),
213803
- functionId: sqliteCore.text("function_id").notNull(),
213979
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
213980
+ description: pgCore.text("description"),
213981
+ functionId: pgCore.varchar("function_id", { length: 256 }).notNull(),
213804
213982
  ...timestamps
213805
213983
  },
213806
213984
  (table) => [
213807
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213808
- sqliteCore.foreignKey({
213985
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213986
+ pgCore.foreignKey({
213809
213987
  columns: [table.tenantId, table.projectId, table.agentId],
213810
213988
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
213811
213989
  name: "function_tools_agent_fk"
213812
213990
  }).onDelete("cascade"),
213813
- sqliteCore.foreignKey({
213991
+ pgCore.foreignKey({
213814
213992
  columns: [table.tenantId, table.projectId, table.functionId],
213815
213993
  foreignColumns: [functions.tenantId, functions.projectId, functions.id],
213816
213994
  name: "function_tools_function_fk"
213817
213995
  }).onDelete("cascade")
213818
213996
  ]
213819
213997
  );
213820
- var functions = sqliteCore.sqliteTable(
213998
+ var functions = pgCore.pgTable(
213821
213999
  "functions",
213822
214000
  {
213823
214001
  ...projectScoped,
213824
- inputSchema: sqliteCore.blob("input_schema", { mode: "json" }).$type(),
213825
- executeCode: sqliteCore.text("execute_code").notNull(),
213826
- dependencies: sqliteCore.blob("dependencies", { mode: "json" }).$type(),
214002
+ inputSchema: pgCore.jsonb("input_schema").$type(),
214003
+ executeCode: pgCore.text("execute_code").notNull(),
214004
+ dependencies: pgCore.jsonb("dependencies").$type(),
213827
214005
  ...timestamps
213828
214006
  },
213829
214007
  (table) => [
213830
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213831
- sqliteCore.foreignKey({
214008
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
214009
+ pgCore.foreignKey({
213832
214010
  columns: [table.tenantId, table.projectId],
213833
214011
  foreignColumns: [projects.tenantId, projects.id],
213834
214012
  name: "functions_project_fk"
213835
214013
  }).onDelete("cascade")
213836
214014
  ]
213837
214015
  );
213838
- var subAgentToolRelations = sqliteCore.sqliteTable(
214016
+ var subAgentToolRelations = pgCore.pgTable(
213839
214017
  "sub_agent_tool_relations",
213840
214018
  {
213841
214019
  ...subAgentScoped,
213842
- toolId: sqliteCore.text("tool_id").notNull(),
213843
- selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
213844
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
214020
+ toolId: pgCore.varchar("tool_id", { length: 256 }).notNull(),
214021
+ selectedTools: pgCore.jsonb("selected_tools").$type(),
214022
+ headers: pgCore.jsonb("headers").$type(),
213845
214023
  ...timestamps
213846
214024
  },
213847
214025
  (table) => [
213848
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213849
- sqliteCore.foreignKey({
214026
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
214027
+ pgCore.foreignKey({
213850
214028
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213851
214029
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213852
214030
  name: "sub_agent_tool_relations_agent_fk"
213853
214031
  }).onDelete("cascade"),
213854
- sqliteCore.foreignKey({
214032
+ pgCore.foreignKey({
213855
214033
  columns: [table.tenantId, table.projectId, table.toolId],
213856
214034
  foreignColumns: [tools.tenantId, tools.projectId, tools.id],
213857
214035
  name: "sub_agent_tool_relations_tool_fk"
213858
214036
  }).onDelete("cascade")
213859
214037
  ]
213860
214038
  );
213861
- var subAgentExternalAgentRelations = sqliteCore.sqliteTable(
214039
+ var subAgentExternalAgentRelations = pgCore.pgTable(
213862
214040
  "sub_agent_external_agent_relations",
213863
214041
  {
213864
214042
  ...subAgentScoped,
213865
- externalAgentId: sqliteCore.text("external_agent_id").notNull(),
213866
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
214043
+ externalAgentId: pgCore.varchar("external_agent_id", { length: 256 }).notNull(),
214044
+ headers: pgCore.jsonb("headers").$type(),
213867
214045
  ...timestamps
213868
214046
  },
213869
214047
  (table) => [
213870
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213871
- sqliteCore.foreignKey({
214048
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
214049
+ pgCore.foreignKey({
213872
214050
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213873
214051
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213874
214052
  name: "sub_agent_external_agent_relations_sub_agent_fk"
213875
214053
  }).onDelete("cascade"),
213876
- sqliteCore.foreignKey({
214054
+ pgCore.foreignKey({
213877
214055
  columns: [table.tenantId, table.projectId, table.externalAgentId],
213878
214056
  foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
213879
214057
  name: "sub_agent_external_agent_relations_external_agent_fk"
213880
214058
  }).onDelete("cascade")
213881
214059
  ]
213882
214060
  );
213883
- var subAgentTeamAgentRelations = sqliteCore.sqliteTable(
214061
+ var subAgentTeamAgentRelations = pgCore.pgTable(
213884
214062
  "sub_agent_team_agent_relations",
213885
214063
  {
213886
214064
  ...subAgentScoped,
213887
- targetAgentId: sqliteCore.text("target_agent_id").notNull(),
213888
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
214065
+ targetAgentId: pgCore.varchar("target_agent_id", { length: 256 }).notNull(),
214066
+ headers: pgCore.jsonb("headers").$type(),
213889
214067
  ...timestamps
213890
214068
  },
213891
214069
  (table) => [
213892
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213893
- sqliteCore.foreignKey({
214070
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
214071
+ pgCore.foreignKey({
213894
214072
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213895
214073
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213896
214074
  name: "sub_agent_team_agent_relations_sub_agent_fk"
213897
214075
  }).onDelete("cascade"),
213898
- sqliteCore.foreignKey({
214076
+ pgCore.foreignKey({
213899
214077
  columns: [table.tenantId, table.projectId, table.targetAgentId],
213900
214078
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
213901
214079
  name: "sub_agent_team_agent_relations_target_agent_fk"
213902
214080
  }).onDelete("cascade")
213903
214081
  ]
213904
214082
  );
213905
- var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
214083
+ var subAgentFunctionToolRelations = pgCore.pgTable(
213906
214084
  "sub_agent_function_tool_relations",
213907
214085
  {
213908
214086
  ...subAgentScoped,
213909
- functionToolId: sqliteCore.text("function_tool_id").notNull(),
214087
+ functionToolId: pgCore.varchar("function_tool_id", { length: 256 }).notNull(),
213910
214088
  ...timestamps
213911
214089
  },
213912
214090
  (table) => [
213913
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
213914
- sqliteCore.foreignKey({
214091
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
214092
+ pgCore.foreignKey({
213915
214093
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
213916
214094
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
213917
214095
  name: "sub_agent_function_tool_relations_sub_agent_fk"
213918
214096
  }).onDelete("cascade"),
213919
- sqliteCore.foreignKey({
214097
+ pgCore.foreignKey({
213920
214098
  columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
213921
214099
  foreignColumns: [
213922
214100
  functionTools.tenantId,
@@ -213928,134 +214106,134 @@ var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
213928
214106
  }).onDelete("cascade")
213929
214107
  ]
213930
214108
  );
213931
- var conversations = sqliteCore.sqliteTable(
214109
+ var conversations = pgCore.pgTable(
213932
214110
  "conversations",
213933
214111
  {
213934
214112
  ...projectScoped,
213935
- userId: sqliteCore.text("user_id"),
213936
- activeSubAgentId: sqliteCore.text("active_sub_agent_id").notNull(),
213937
- title: sqliteCore.text("title"),
213938
- lastContextResolution: sqliteCore.text("last_context_resolution"),
213939
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
214113
+ userId: pgCore.varchar("user_id", { length: 256 }),
214114
+ activeSubAgentId: pgCore.varchar("active_sub_agent_id", { length: 256 }).notNull(),
214115
+ title: pgCore.text("title"),
214116
+ lastContextResolution: pgCore.timestamp("last_context_resolution", { mode: "string" }),
214117
+ metadata: pgCore.jsonb("metadata").$type(),
213940
214118
  ...timestamps
213941
214119
  },
213942
214120
  (table) => [
213943
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213944
- sqliteCore.foreignKey({
214121
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
214122
+ pgCore.foreignKey({
213945
214123
  columns: [table.tenantId, table.projectId],
213946
214124
  foreignColumns: [projects.tenantId, projects.id],
213947
214125
  name: "conversations_project_fk"
213948
214126
  }).onDelete("cascade")
213949
214127
  ]
213950
214128
  );
213951
- var messages = sqliteCore.sqliteTable(
214129
+ var messages = pgCore.pgTable(
213952
214130
  "messages",
213953
214131
  {
213954
214132
  ...projectScoped,
213955
- conversationId: sqliteCore.text("conversation_id").notNull(),
213956
- role: sqliteCore.text("role").notNull(),
213957
- fromSubAgentId: sqliteCore.text("from_sub_agent_id"),
213958
- toSubAgentId: sqliteCore.text("to_sub_agent_id"),
213959
- fromExternalAgentId: sqliteCore.text("from_external_sub_agent_id"),
213960
- toExternalAgentId: sqliteCore.text("to_external_sub_agent_id"),
213961
- fromTeamAgentId: sqliteCore.text("from_team_agent_id"),
213962
- toTeamAgentId: sqliteCore.text("to_team_agent_id"),
213963
- content: sqliteCore.blob("content", { mode: "json" }).$type().notNull(),
213964
- visibility: sqliteCore.text("visibility").notNull().default("user-facing"),
213965
- messageType: sqliteCore.text("message_type").notNull().default("chat"),
213966
- taskId: sqliteCore.text("task_id"),
213967
- parentMessageId: sqliteCore.text("parent_message_id"),
213968
- a2aTaskId: sqliteCore.text("a2a_task_id"),
213969
- a2aSessionId: sqliteCore.text("a2a_session_id"),
213970
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
214133
+ conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
214134
+ role: pgCore.varchar("role", { length: 256 }).notNull(),
214135
+ fromSubAgentId: pgCore.varchar("from_sub_agent_id", { length: 256 }),
214136
+ toSubAgentId: pgCore.varchar("to_sub_agent_id", { length: 256 }),
214137
+ fromExternalAgentId: pgCore.varchar("from_external_sub_agent_id", { length: 256 }),
214138
+ toExternalAgentId: pgCore.varchar("to_external_sub_agent_id", { length: 256 }),
214139
+ fromTeamAgentId: pgCore.varchar("from_team_agent_id", { length: 256 }),
214140
+ toTeamAgentId: pgCore.varchar("to_team_agent_id", { length: 256 }),
214141
+ content: pgCore.jsonb("content").$type().notNull(),
214142
+ visibility: pgCore.varchar("visibility", { length: 256 }).notNull().default("user-facing"),
214143
+ messageType: pgCore.varchar("message_type", { length: 256 }).notNull().default("chat"),
214144
+ taskId: pgCore.varchar("task_id", { length: 256 }),
214145
+ parentMessageId: pgCore.varchar("parent_message_id", { length: 256 }),
214146
+ a2aTaskId: pgCore.varchar("a2a_task_id", { length: 256 }),
214147
+ a2aSessionId: pgCore.varchar("a2a_session_id", { length: 256 }),
214148
+ metadata: pgCore.jsonb("metadata").$type(),
213971
214149
  ...timestamps
213972
214150
  },
213973
214151
  (table) => [
213974
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
213975
- sqliteCore.foreignKey({
214152
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
214153
+ pgCore.foreignKey({
213976
214154
  columns: [table.tenantId, table.projectId],
213977
214155
  foreignColumns: [projects.tenantId, projects.id],
213978
214156
  name: "messages_project_fk"
213979
214157
  }).onDelete("cascade")
213980
214158
  ]
213981
214159
  );
213982
- var ledgerArtifacts = sqliteCore.sqliteTable(
214160
+ var ledgerArtifacts = pgCore.pgTable(
213983
214161
  "ledger_artifacts",
213984
214162
  {
213985
214163
  ...projectScoped,
213986
- taskId: sqliteCore.text("task_id").notNull(),
213987
- toolCallId: sqliteCore.text("tool_call_id"),
213988
- contextId: sqliteCore.text("context_id").notNull(),
213989
- type: sqliteCore.text("type").notNull().default("source"),
213990
- name: sqliteCore.text("name"),
213991
- description: sqliteCore.text("description"),
213992
- parts: sqliteCore.blob("parts", { mode: "json" }).$type(),
213993
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
213994
- summary: sqliteCore.text("summary"),
213995
- mime: sqliteCore.blob("mime", { mode: "json" }).$type(),
213996
- visibility: sqliteCore.text("visibility").default("context"),
213997
- allowedAgents: sqliteCore.blob("allowed_agents", { mode: "json" }).$type(),
213998
- derivedFrom: sqliteCore.text("derived_from"),
214164
+ taskId: pgCore.varchar("task_id", { length: 256 }).notNull(),
214165
+ toolCallId: pgCore.varchar("tool_call_id", { length: 256 }),
214166
+ contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
214167
+ type: pgCore.varchar("type", { length: 256 }).notNull().default("source"),
214168
+ name: pgCore.varchar("name", { length: 256 }),
214169
+ description: pgCore.text("description"),
214170
+ parts: pgCore.jsonb("parts").$type(),
214171
+ metadata: pgCore.jsonb("metadata").$type(),
214172
+ summary: pgCore.text("summary"),
214173
+ mime: pgCore.jsonb("mime").$type(),
214174
+ visibility: pgCore.varchar("visibility", { length: 256 }).default("context"),
214175
+ allowedAgents: pgCore.jsonb("allowed_agents").$type(),
214176
+ derivedFrom: pgCore.varchar("derived_from", { length: 256 }),
213999
214177
  ...timestamps
214000
214178
  },
214001
214179
  (table) => [
214002
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
214003
- sqliteCore.foreignKey({
214180
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
214181
+ pgCore.foreignKey({
214004
214182
  columns: [table.tenantId, table.projectId],
214005
214183
  foreignColumns: [projects.tenantId, projects.id],
214006
214184
  name: "ledger_artifacts_project_fk"
214007
214185
  }).onDelete("cascade"),
214008
- sqliteCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
214009
- sqliteCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
214010
- sqliteCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
214011
- sqliteCore.unique("ledger_artifacts_task_context_name_unique").on(
214186
+ pgCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
214187
+ pgCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
214188
+ pgCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
214189
+ pgCore.unique("ledger_artifacts_task_context_name_unique").on(
214012
214190
  table.taskId,
214013
214191
  table.contextId,
214014
214192
  table.name
214015
214193
  )
214016
214194
  ]
214017
214195
  );
214018
- var apiKeys = sqliteCore.sqliteTable(
214196
+ var apiKeys = pgCore.pgTable(
214019
214197
  "api_keys",
214020
214198
  {
214021
214199
  ...agentScoped,
214022
- publicId: sqliteCore.text("public_id").notNull().unique(),
214023
- keyHash: sqliteCore.text("key_hash").notNull(),
214024
- keyPrefix: sqliteCore.text("key_prefix").notNull(),
214025
- name: sqliteCore.text("name"),
214026
- lastUsedAt: sqliteCore.text("last_used_at"),
214027
- expiresAt: sqliteCore.text("expires_at"),
214200
+ publicId: pgCore.varchar("public_id", { length: 256 }).notNull().unique(),
214201
+ keyHash: pgCore.varchar("key_hash", { length: 256 }).notNull(),
214202
+ keyPrefix: pgCore.varchar("key_prefix", { length: 256 }).notNull(),
214203
+ name: pgCore.varchar("name", { length: 256 }),
214204
+ lastUsedAt: pgCore.timestamp("last_used_at", { mode: "string" }),
214205
+ expiresAt: pgCore.timestamp("expires_at", { mode: "string" }),
214028
214206
  ...timestamps
214029
214207
  },
214030
214208
  (t) => [
214031
- sqliteCore.foreignKey({
214209
+ pgCore.foreignKey({
214032
214210
  columns: [t.tenantId, t.projectId],
214033
214211
  foreignColumns: [projects.tenantId, projects.id],
214034
214212
  name: "api_keys_project_fk"
214035
214213
  }).onDelete("cascade"),
214036
- sqliteCore.foreignKey({
214214
+ pgCore.foreignKey({
214037
214215
  columns: [t.tenantId, t.projectId, t.agentId],
214038
214216
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
214039
214217
  name: "api_keys_agent_fk"
214040
214218
  }).onDelete("cascade"),
214041
- sqliteCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
214042
- sqliteCore.index("api_keys_prefix_idx").on(t.keyPrefix),
214043
- sqliteCore.index("api_keys_public_id_idx").on(t.publicId)
214219
+ pgCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
214220
+ pgCore.index("api_keys_prefix_idx").on(t.keyPrefix),
214221
+ pgCore.index("api_keys_public_id_idx").on(t.publicId)
214044
214222
  ]
214045
214223
  );
214046
- var credentialReferences = sqliteCore.sqliteTable(
214224
+ var credentialReferences = pgCore.pgTable(
214047
214225
  "credential_references",
214048
214226
  {
214049
214227
  ...projectScoped,
214050
- name: sqliteCore.text("name").notNull(),
214051
- type: sqliteCore.text("type").notNull(),
214052
- credentialStoreId: sqliteCore.text("credential_store_id").notNull(),
214053
- retrievalParams: sqliteCore.blob("retrieval_params", { mode: "json" }).$type(),
214228
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
214229
+ type: pgCore.varchar("type", { length: 256 }).notNull(),
214230
+ credentialStoreId: pgCore.varchar("credential_store_id", { length: 256 }).notNull(),
214231
+ retrievalParams: pgCore.jsonb("retrieval_params").$type(),
214054
214232
  ...timestamps
214055
214233
  },
214056
214234
  (t) => [
214057
- sqliteCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
214058
- sqliteCore.foreignKey({
214235
+ pgCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
214236
+ pgCore.foreignKey({
214059
214237
  columns: [t.tenantId, t.projectId],
214060
214238
  foreignColumns: [projects.tenantId, projects.id],
214061
214239
  name: "credential_references_project_fk"
@@ -214431,9 +214609,20 @@ var CredentialStoreType = {
214431
214609
  };
214432
214610
 
214433
214611
  // src/validation/schemas.ts
214612
+ var {
214613
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX: AGENT_EXECUTION_TRANSFER_COUNT_MAX2,
214614
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN: AGENT_EXECUTION_TRANSFER_COUNT_MIN2,
214615
+ CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT: CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT2,
214616
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS: STATUS_UPDATE_MAX_INTERVAL_SECONDS2,
214617
+ STATUS_UPDATE_MAX_NUM_EVENTS: STATUS_UPDATE_MAX_NUM_EVENTS2,
214618
+ SUB_AGENT_TURN_GENERATION_STEPS_MAX: SUB_AGENT_TURN_GENERATION_STEPS_MAX2,
214619
+ SUB_AGENT_TURN_GENERATION_STEPS_MIN: SUB_AGENT_TURN_GENERATION_STEPS_MIN2,
214620
+ VALIDATION_AGENT_PROMPT_MAX_CHARS: VALIDATION_AGENT_PROMPT_MAX_CHARS2,
214621
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS2
214622
+ } = schemaValidationDefaults;
214434
214623
  var StopWhenSchema = zodOpenapi.z.object({
214435
- transferCountIs: zodOpenapi.z.number().min(1).max(100).optional().describe("The maximum number of transfers to trigger the stop condition."),
214436
- stepCountIs: zodOpenapi.z.number().min(1).max(1e3).optional().describe("The maximum number of steps to trigger the stop condition.")
214624
+ transferCountIs: zodOpenapi.z.number().min(AGENT_EXECUTION_TRANSFER_COUNT_MIN2).max(AGENT_EXECUTION_TRANSFER_COUNT_MAX2).optional().describe("The maximum number of transfers to trigger the stop condition."),
214625
+ stepCountIs: zodOpenapi.z.number().min(SUB_AGENT_TURN_GENERATION_STEPS_MIN2).max(SUB_AGENT_TURN_GENERATION_STEPS_MAX2).optional().describe("The maximum number of steps to trigger the stop condition.")
214437
214626
  }).openapi("StopWhen");
214438
214627
  var AgentStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true }).openapi(
214439
214628
  "AgentStopWhen"
@@ -214552,7 +214741,8 @@ var ExternalSubAgentRelationApiInsertSchema = createApiInsertSchema(
214552
214741
  );
214553
214742
  var AgentSelectSchema = drizzleZod.createSelectSchema(agents);
214554
214743
  var AgentInsertSchema = drizzleZod.createInsertSchema(agents).extend({
214555
- id: resourceIdSchema
214744
+ id: resourceIdSchema,
214745
+ name: zodOpenapi.z.string().trim().nonempty()
214556
214746
  });
214557
214747
  var AgentUpdateSchema = AgentInsertSchema.partial();
214558
214748
  var AgentApiSelectSchema = createApiSchema(AgentSelectSchema).openapi("Agent");
@@ -214912,7 +215102,7 @@ var FetchConfigSchema = zodOpenapi.z.object({
214912
215102
  body: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
214913
215103
  transform: zodOpenapi.z.string().optional(),
214914
215104
  // JSONPath or JS transform function
214915
- timeout: zodOpenapi.z.number().min(0).optional().default(1e4).optional()
215105
+ timeout: zodOpenapi.z.number().min(0).optional().default(CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT2).optional()
214916
215106
  }).openapi("FetchConfig");
214917
215107
  var FetchDefinitionSchema = zodOpenapi.z.object({
214918
215108
  id: zodOpenapi.z.string().min(1, "Fetch definition ID is required"),
@@ -215031,9 +215221,12 @@ var StatusComponentSchema = zodOpenapi.z.object({
215031
215221
  }).openapi("StatusComponent");
215032
215222
  var StatusUpdateSchema = zodOpenapi.z.object({
215033
215223
  enabled: zodOpenapi.z.boolean().optional(),
215034
- numEvents: zodOpenapi.z.number().min(1).max(100).optional(),
215035
- timeInSeconds: zodOpenapi.z.number().min(1).max(600).optional(),
215036
- prompt: zodOpenapi.z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
215224
+ numEvents: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_NUM_EVENTS2).optional(),
215225
+ timeInSeconds: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_INTERVAL_SECONDS2).optional(),
215226
+ prompt: zodOpenapi.z.string().max(
215227
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS2,
215228
+ `Custom prompt cannot exceed ${VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS2} characters`
215229
+ ).optional(),
215037
215230
  statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
215038
215231
  }).openapi("StatusUpdate");
215039
215232
  var CanUseItemSchema = zodOpenapi.z.object({
@@ -215064,6 +215257,7 @@ var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
215064
215257
  dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
215065
215258
  artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
215066
215259
  canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
215260
+ prompt: zodOpenapi.z.string().trim().nonempty(),
215067
215261
  canDelegateTo: zodOpenapi.z.array(
215068
215262
  zodOpenapi.z.union([
215069
215263
  zodOpenapi.z.string(),
@@ -215092,7 +215286,10 @@ var AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
215092
215286
  statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
215093
215287
  models: ModelSchema.optional(),
215094
215288
  stopWhen: AgentStopWhenSchema.optional(),
215095
- prompt: zodOpenapi.z.string().max(5e3, "Agent prompt cannot exceed 5000 characters").optional()
215289
+ prompt: zodOpenapi.z.string().max(
215290
+ VALIDATION_AGENT_PROMPT_MAX_CHARS2,
215291
+ `Agent prompt cannot exceed ${VALIDATION_AGENT_PROMPT_MAX_CHARS2} characters`
215292
+ ).optional()
215096
215293
  });
215097
215294
  var PaginationSchema = zodOpenapi.z.object({
215098
215295
  page: zodOpenapi.z.coerce.number().min(1).default(1),
@@ -215973,20 +216170,38 @@ var CredentialStuffer = class {
215973
216170
  };
215974
216171
  }
215975
216172
  };
215976
- function createDatabaseClient(config) {
215977
- const client$1 = client.createClient({
215978
- url: config.url,
215979
- authToken: config.authToken
216173
+ var __filename2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
216174
+ path.dirname(__filename2);
216175
+ function createTestDatabaseClientNoMigrations() {
216176
+ const client = new pglite.PGlite();
216177
+ const db = pglite$1.drizzle(client, { schema: schema_exports });
216178
+ return db;
216179
+ }
216180
+
216181
+ // src/db/client.ts
216182
+ loadEnvironmentFiles();
216183
+ function createDatabaseClient(config = {}) {
216184
+ const connectionString = config.connectionString || process.env.DATABASE_URL;
216185
+ if (env.ENVIRONMENT === "test") {
216186
+ return createTestDatabaseClientNoMigrations();
216187
+ }
216188
+ if (!connectionString) {
216189
+ throw new Error(
216190
+ "DATABASE_URL environment variable is required. Please set it to your PostgreSQL connection string."
216191
+ );
216192
+ }
216193
+ const pool = new pg.Pool({
216194
+ connectionString,
216195
+ max: config.poolSize || Number(env.POSTGRES_POOL_SIZE) || 10
216196
+ });
216197
+ pool.on("error", (err) => {
216198
+ console.error("Unexpected PostgreSQL pool error:", err);
215980
216199
  });
215981
- return libsql.drizzle(client$1, {
216200
+ return nodePostgres.drizzle(pool, {
215982
216201
  schema: schema_exports,
215983
216202
  logger: config.logger
215984
216203
  });
215985
216204
  }
215986
- function createInMemoryDatabaseClient() {
215987
- const db = createDatabaseClient({ url: ":memory:" });
215988
- return db;
215989
- }
215990
216205
  var generateId = nanoid.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789", 21);
215991
216206
  function getConversationId() {
215992
216207
  return generateId();
@@ -217079,8 +217294,8 @@ var deleteSubAgentExternalAgentRelation = (db) => async (params) => {
217079
217294
  drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
217080
217295
  drizzleOrm.eq(subAgentExternalAgentRelations.id, params.relationId)
217081
217296
  )
217082
- );
217083
- return (result.rowsAffected || 0) > 0;
217297
+ ).returning();
217298
+ return result.length > 0;
217084
217299
  };
217085
217300
  var deleteSubAgentExternalAgentRelationsBySubAgent = (db) => async (params) => {
217086
217301
  const result = await db.delete(subAgentExternalAgentRelations).where(
@@ -217090,8 +217305,8 @@ var deleteSubAgentExternalAgentRelationsBySubAgent = (db) => async (params) => {
217090
217305
  drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
217091
217306
  drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
217092
217307
  )
217093
- );
217094
- return (result.rowsAffected || 0) > 0;
217308
+ ).returning();
217309
+ return result.length > 0;
217095
217310
  };
217096
217311
  var deleteSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
217097
217312
  const result = await db.delete(subAgentExternalAgentRelations).where(
@@ -217100,8 +217315,8 @@ var deleteSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
217100
217315
  drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
217101
217316
  drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId)
217102
217317
  )
217103
- );
217104
- return (result.rowsAffected || 0) > 0;
217318
+ ).returning();
217319
+ return result.length > 0;
217105
217320
  };
217106
217321
  var getAgentRelationById = (db) => async (params) => {
217107
217322
  return db.query.subAgentRelations.findFirst({
@@ -217288,8 +217503,8 @@ var deleteSubAgentRelation = (db) => async (params) => {
217288
217503
  drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
217289
217504
  drizzleOrm.eq(subAgentRelations.id, params.relationId)
217290
217505
  )
217291
- );
217292
- return (result.rowsAffected || 0) > 0;
217506
+ ).returning();
217507
+ return result.length > 0;
217293
217508
  };
217294
217509
  var deleteAgentRelationsByAgent = (db) => async (params) => {
217295
217510
  const result = await db.delete(subAgentRelations).where(
@@ -217297,8 +217512,8 @@ var deleteAgentRelationsByAgent = (db) => async (params) => {
217297
217512
  drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
217298
217513
  drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId)
217299
217514
  )
217300
- );
217301
- return (result.rowsAffected || 0) > 0;
217515
+ ).returning();
217516
+ return result.length > 0;
217302
217517
  };
217303
217518
  var createAgentToolRelation = (db) => async (params) => {
217304
217519
  const finalRelationId = params.relationId ?? generateId();
@@ -217337,8 +217552,8 @@ var deleteAgentToolRelation = (db) => async (params) => {
217337
217552
  drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
217338
217553
  drizzleOrm.eq(subAgentToolRelations.id, params.relationId)
217339
217554
  )
217340
- );
217341
- return (result.rowsAffected || 0) > 0;
217555
+ ).returning();
217556
+ return result.length > 0;
217342
217557
  };
217343
217558
  var deleteAgentToolRelationByAgent = (db) => async (params) => {
217344
217559
  const result = await db.delete(subAgentToolRelations).where(
@@ -217348,8 +217563,8 @@ var deleteAgentToolRelationByAgent = (db) => async (params) => {
217348
217563
  drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
217349
217564
  drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
217350
217565
  )
217351
- );
217352
- return (result.rowsAffected || 0) > 0;
217566
+ ).returning();
217567
+ return result.length > 0;
217353
217568
  };
217354
217569
  var getAgentToolRelationById = (db) => async (params) => {
217355
217570
  return await db.query.subAgentToolRelations.findFirst({
@@ -217951,8 +218166,8 @@ var deleteSubAgentTeamAgentRelation = (db) => async (params) => {
217951
218166
  drizzleOrm.eq(subAgentTeamAgentRelations.subAgentId, params.scopes.subAgentId),
217952
218167
  drizzleOrm.eq(subAgentTeamAgentRelations.id, params.relationId)
217953
218168
  )
217954
- );
217955
- return (result.rowsAffected || 0) > 0;
218169
+ ).returning();
218170
+ return result.length > 0;
217956
218171
  };
217957
218172
  var deleteSubAgentTeamAgentRelationsBySubAgent = (db) => async (params) => {
217958
218173
  const result = await db.delete(subAgentTeamAgentRelations).where(
@@ -217962,8 +218177,8 @@ var deleteSubAgentTeamAgentRelationsBySubAgent = (db) => async (params) => {
217962
218177
  drizzleOrm.eq(subAgentTeamAgentRelations.agentId, params.scopes.agentId),
217963
218178
  drizzleOrm.eq(subAgentTeamAgentRelations.subAgentId, params.scopes.subAgentId)
217964
218179
  )
217965
- );
217966
- return (result.rowsAffected || 0) > 0;
218180
+ ).returning();
218181
+ return result.length > 0;
217967
218182
  };
217968
218183
  var deleteSubAgentTeamAgentRelationsByAgent = (db) => async (params) => {
217969
218184
  const result = await db.delete(subAgentTeamAgentRelations).where(
@@ -217972,8 +218187,8 @@ var deleteSubAgentTeamAgentRelationsByAgent = (db) => async (params) => {
217972
218187
  drizzleOrm.eq(subAgentTeamAgentRelations.projectId, params.scopes.projectId),
217973
218188
  drizzleOrm.eq(subAgentTeamAgentRelations.agentId, params.scopes.agentId)
217974
218189
  )
217975
- );
217976
- return (result.rowsAffected || 0) > 0;
218190
+ ).returning();
218191
+ return result.length > 0;
217977
218192
  };
217978
218193
  var scryptAsync = util.promisify(crypto.scrypt);
217979
218194
  var logger5 = getLogger("api-key");
@@ -218205,6 +218420,18 @@ var detectAuthenticationRequired = async ({
218205
218420
  logger15?.debug({ error: error?.message }, "No MCP OAuth authentication requirement detected");
218206
218421
  return false;
218207
218422
  };
218423
+
218424
+ // src/utils/date.ts
218425
+ function normalizeDateString(dateString) {
218426
+ if (typeof dateString !== "string") {
218427
+ return dateString;
218428
+ }
218429
+ const pgTimestampPattern = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d{1,3})?$/;
218430
+ if (pgTimestampPattern.test(dateString)) {
218431
+ return dateString.replace(" ", "T") + "Z";
218432
+ }
218433
+ return dateString;
218434
+ }
218208
218435
  var ErrorCode = zodOpenapi.z.enum([
218209
218436
  "bad_request",
218210
218437
  "unauthorized",
@@ -218542,15 +218769,15 @@ var McpClient = class {
218542
218769
  this.transport = new streamableHttp_js.StreamableHTTPClientTransport(new URL(urlString), {
218543
218770
  requestInit: mergedRequestInit,
218544
218771
  reconnectionOptions: {
218545
- maxRetries: 3,
218546
- maxReconnectionDelay: 3e4,
218547
- initialReconnectionDelay: 1e3,
218548
- reconnectionDelayGrowFactor: 1.5,
218772
+ maxRetries: MCP_TOOL_MAX_RETRIES,
218773
+ maxReconnectionDelay: MCP_TOOL_MAX_RECONNECTION_DELAY_MS,
218774
+ initialReconnectionDelay: MCP_TOOL_INITIAL_RECONNECTION_DELAY_MS,
218775
+ reconnectionDelayGrowFactor: MCP_TOOL_RECONNECTION_DELAY_GROWTH_FACTOR,
218549
218776
  ...config.reconnectionOptions
218550
218777
  },
218551
218778
  sessionId: config.sessionId
218552
218779
  });
218553
- await this.client.connect(this.transport, { timeout: 3e3 });
218780
+ await this.client.connect(this.transport, { timeout: MCP_TOOL_CONNECTION_TIMEOUT_MS });
218554
218781
  }
218555
218782
  async disconnect() {
218556
218783
  if (!this.transport) {
@@ -218658,57 +218885,6 @@ var McpClient = class {
218658
218885
  return results;
218659
218886
  }
218660
218887
  };
218661
- var loadEnvironmentFiles = () => {
218662
- const environmentFiles = [];
218663
- const currentEnv = path__default.default.resolve(process.cwd(), ".env");
218664
- if (fs__default.default.existsSync(currentEnv)) {
218665
- environmentFiles.push(currentEnv);
218666
- }
218667
- const rootEnv = findUp.findUpSync(".env", { cwd: path__default.default.dirname(process.cwd()) });
218668
- if (rootEnv) {
218669
- if (rootEnv !== currentEnv) {
218670
- environmentFiles.push(rootEnv);
218671
- }
218672
- }
218673
- const userConfigPath = path__default.default.join(os__default.default.homedir(), ".inkeep", "config");
218674
- if (fs__default.default.existsSync(userConfigPath)) {
218675
- dotenv__default.default.config({ path: userConfigPath, override: true, quiet: true });
218676
- }
218677
- if (environmentFiles.length > 0) {
218678
- dotenv__default.default.config({
218679
- path: environmentFiles,
218680
- override: false,
218681
- quiet: true
218682
- });
218683
- dotenvExpand.expand({ processEnv: process.env });
218684
- }
218685
- };
218686
- loadEnvironmentFiles();
218687
- var envSchema = zod.z.object({
218688
- ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
218689
- DB_FILE_NAME: zod.z.string().optional(),
218690
- TURSO_DATABASE_URL: zod.z.string().optional(),
218691
- TURSO_AUTH_TOKEN: zod.z.string().optional(),
218692
- INKEEP_AGENTS_JWT_SIGNING_SECRET: zod.z.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional()
218693
- });
218694
- var parseEnv = () => {
218695
- try {
218696
- const parsedEnv = envSchema.parse(process.env);
218697
- return parsedEnv;
218698
- } catch (error) {
218699
- if (error instanceof zod.z.ZodError) {
218700
- const missingVars = error.issues.map((issue) => issue.path.join("."));
218701
- throw new Error(
218702
- `\u274C Invalid environment variables: ${missingVars.join(", ")}
218703
- ${error.message}`
218704
- );
218705
- }
218706
- throw error;
218707
- }
218708
- };
218709
- var env = parseEnv();
218710
-
218711
- // src/utils/service-token-auth.ts
218712
218888
  var logger6 = getLogger("service-token-auth");
218713
218889
  function getJwtSecret() {
218714
218890
  const secret = env.INKEEP_AGENTS_JWT_SIGNING_SECRET;
@@ -219177,8 +219353,8 @@ var dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry) => {
219177
219353
  availableTools: [],
219178
219354
  capabilities: capabilities || void 0,
219179
219355
  credentialReferenceId: credentialReferenceId || void 0,
219180
- createdAt: new Date(createdAt),
219181
- updatedAt: new Date(dbResult.updatedAt),
219356
+ createdAt: new Date(normalizeDateString(createdAt)),
219357
+ updatedAt: new Date(normalizeDateString(dbResult.updatedAt)),
219182
219358
  lastError: null,
219183
219359
  headers: headers2 || void 0,
219184
219360
  imageUrl: imageUrl || void 0
@@ -219211,7 +219387,7 @@ var dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry) => {
219211
219387
  } else if (credentialStore.type === CredentialStoreType.keychain) {
219212
219388
  const oauthTokens = JSON.parse(credentialDataString);
219213
219389
  if (oauthTokens.expires_at) {
219214
- expiresAt = new Date(oauthTokens.expires_at);
219390
+ expiresAt = new Date(normalizeDateString(oauthTokens.expires_at));
219215
219391
  }
219216
219392
  }
219217
219393
  }
@@ -219248,7 +219424,7 @@ var dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry) => {
219248
219424
  availableTools,
219249
219425
  capabilities: capabilities || void 0,
219250
219426
  credentialReferenceId: credentialReferenceId || void 0,
219251
- createdAt: new Date(createdAt),
219427
+ createdAt: new Date(normalizeDateString(createdAt)),
219252
219428
  updatedAt: new Date(now),
219253
219429
  expiresAt,
219254
219430
  lastError: lastErrorComputed,
@@ -219810,8 +219986,8 @@ var getFullAgentDefinition = (db) => async ({
219810
219986
  description: agent.description,
219811
219987
  defaultSubAgentId: agent.defaultSubAgentId,
219812
219988
  subAgents: agentsObject,
219813
- createdAt: agent.createdAt && !Number.isNaN(new Date(agent.createdAt).getTime()) ? new Date(agent.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
219814
- updatedAt: agent.updatedAt && !Number.isNaN(new Date(agent.updatedAt).getTime()) ? new Date(agent.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
219989
+ createdAt: agent.createdAt && !Number.isNaN(new Date(agent.createdAt).getTime()) ? new Date(agent.createdAt) : /* @__PURE__ */ new Date(),
219990
+ updatedAt: agent.updatedAt && !Number.isNaN(new Date(agent.updatedAt).getTime()) ? new Date(agent.updatedAt) : /* @__PURE__ */ new Date()
219815
219991
  };
219816
219992
  if (Object.keys(externalAgentsObject).length > 0) {
219817
219993
  result.externalAgents = externalAgentsObject;
@@ -220220,8 +220396,8 @@ var deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
220220
220396
  drizzleOrm.eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
220221
220397
  drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
220222
220398
  )
220223
- );
220224
- return (result.rowsAffected || 0) > 0;
220399
+ ).returning();
220400
+ return result.length > 0;
220225
220401
  };
220226
220402
  var getAgentsUsingArtifactComponent = (db) => async (params) => {
220227
220403
  return await db.select({
@@ -220591,8 +220767,8 @@ var deleteAgentDataComponentRelationByAgent = (db) => async (params) => {
220591
220767
  drizzleOrm.eq(subAgentDataComponents.agentId, params.scopes.agentId),
220592
220768
  drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId)
220593
220769
  )
220594
- );
220595
- return (result.rowsAffected || 0) > 0;
220770
+ ).returning();
220771
+ return result.length > 0;
220596
220772
  };
220597
220773
  var getAgentsUsingDataComponent = (db) => async (params) => {
220598
220774
  return await db.select({
@@ -221676,8 +221852,8 @@ var updateFullAgentServerSide = (db, logger15 = defaultLogger) => async (scopes,
221676
221852
  drizzleOrm.eq(subAgentToolRelations.agentId, finalAgentId),
221677
221853
  drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgentId)
221678
221854
  )
221679
- );
221680
- deletedCount = result.rowsAffected || 0;
221855
+ ).returning();
221856
+ deletedCount = result.length;
221681
221857
  } else {
221682
221858
  const result = await db.delete(subAgentToolRelations).where(
221683
221859
  drizzleOrm.and(
@@ -221687,8 +221863,8 @@ var updateFullAgentServerSide = (db, logger15 = defaultLogger) => async (scopes,
221687
221863
  drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgentId),
221688
221864
  drizzleOrm.not(drizzleOrm.inArray(subAgentToolRelations.id, Array.from(incomingRelationshipIds)))
221689
221865
  )
221690
- );
221691
- deletedCount = result.rowsAffected || 0;
221866
+ ).returning();
221867
+ deletedCount = result.length;
221692
221868
  }
221693
221869
  if (deletedCount > 0) {
221694
221870
  logger15.info({ subAgentId, deletedCount }, "Deleted orphaned agent-tool relations");
@@ -222146,6 +222322,7 @@ var deleteApiKey = (db) => async (params) => {
222146
222322
  id: params.id
222147
222323
  });
222148
222324
  if (!existingKey) {
222325
+ console.error("API key not found", { params });
222149
222326
  return false;
222150
222327
  }
222151
222328
  await db.delete(apiKeys).where(
@@ -222276,8 +222453,8 @@ var clearConversationCache = (db) => async (params) => {
222276
222453
  drizzleOrm.eq(contextCache.projectId, params.scopes.projectId),
222277
222454
  drizzleOrm.eq(contextCache.conversationId, params.conversationId)
222278
222455
  )
222279
- );
222280
- return result.rowsAffected || 0;
222456
+ ).returning();
222457
+ return result.length;
222281
222458
  };
222282
222459
  var clearContextConfigCache = (db) => async (params) => {
222283
222460
  const result = await db.delete(contextCache).where(
@@ -222286,8 +222463,8 @@ var clearContextConfigCache = (db) => async (params) => {
222286
222463
  drizzleOrm.eq(contextCache.projectId, params.scopes.projectId),
222287
222464
  drizzleOrm.eq(contextCache.contextConfigId, params.contextConfigId)
222288
222465
  )
222289
- );
222290
- return result.rowsAffected || 0;
222466
+ ).returning();
222467
+ return result.length;
222291
222468
  };
222292
222469
  var cleanupTenantCache = (db) => async (params) => {
222293
222470
  const result = await db.delete(contextCache).where(
@@ -222295,8 +222472,8 @@ var cleanupTenantCache = (db) => async (params) => {
222295
222472
  drizzleOrm.eq(contextCache.tenantId, params.scopes.tenantId),
222296
222473
  drizzleOrm.eq(contextCache.projectId, params.scopes.projectId)
222297
222474
  )
222298
- );
222299
- return result.rowsAffected || 0;
222475
+ ).returning();
222476
+ return result.length;
222300
222477
  };
222301
222478
  var invalidateHeadersCache = (db) => async (params) => {
222302
222479
  const result = await db.delete(contextCache).where(
@@ -222307,8 +222484,8 @@ var invalidateHeadersCache = (db) => async (params) => {
222307
222484
  drizzleOrm.eq(contextCache.contextConfigId, params.contextConfigId),
222308
222485
  drizzleOrm.eq(contextCache.contextVariableKey, "headers")
222309
222486
  )
222310
- );
222311
- return result.rowsAffected || 0;
222487
+ ).returning();
222488
+ return result.length;
222312
222489
  };
222313
222490
  var invalidateInvocationDefinitionsCache = (db) => async (params) => {
222314
222491
  let totalRowsAffected = 0;
@@ -222321,8 +222498,8 @@ var invalidateInvocationDefinitionsCache = (db) => async (params) => {
222321
222498
  drizzleOrm.eq(contextCache.contextConfigId, params.contextConfigId),
222322
222499
  drizzleOrm.eq(contextCache.contextVariableKey, definitionId)
222323
222500
  )
222324
- );
222325
- totalRowsAffected += result.rowsAffected || 0;
222501
+ ).returning();
222502
+ totalRowsAffected += result.length;
222326
222503
  }
222327
222504
  return totalRowsAffected;
222328
222505
  };
@@ -222741,7 +222918,7 @@ var addLedgerArtifacts = (db) => async (params) => {
222741
222918
  return;
222742
222919
  } catch (error) {
222743
222920
  lastError = error;
222744
- const isRetryable = error.code === "SQLITE_BUSY" || error.code === "SQLITE_LOCKED" || error.message?.includes("database is locked") || error.message?.includes("busy") || error.message?.includes("timeout");
222921
+ const isRetryable = error.cause.code === "40P01" || error.cause.code === "40001" || error.cause.code === "55P03" || error.message?.includes("database is locked") || error.message?.includes("busy") || error.message?.includes("timeout") || error.message?.includes("deadlock") || error.message?.includes("serialization failure");
222745
222922
  if (!isRetryable || attempt === maxRetries) {
222746
222923
  await tryFallbackInsert(db, rows);
222747
222924
  return;
@@ -223159,9 +223336,7 @@ var createFullProjectServerSide = (db, logger15 = defaultLogger2) => async (scop
223159
223336
  description: typed.description || "",
223160
223337
  models: typed.models,
223161
223338
  stopWhen: typed.stopWhen,
223162
- tenantId,
223163
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
223164
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
223339
+ tenantId
223165
223340
  };
223166
223341
  logger15.info({ projectId: typed.id }, "Creating project metadata");
223167
223342
  await createProject(db)(projectPayload);
@@ -226579,6 +226754,9 @@ exports.A2AMessageMetadataSchema = A2AMessageMetadataSchema;
226579
226754
  exports.ACTIVITY_NAMES = ACTIVITY_NAMES;
226580
226755
  exports.ACTIVITY_STATUS = ACTIVITY_STATUS;
226581
226756
  exports.ACTIVITY_TYPES = ACTIVITY_TYPES;
226757
+ exports.AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT = AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT;
226758
+ exports.AGENT_EXECUTION_TRANSFER_COUNT_MAX = AGENT_EXECUTION_TRANSFER_COUNT_MAX;
226759
+ exports.AGENT_EXECUTION_TRANSFER_COUNT_MIN = AGENT_EXECUTION_TRANSFER_COUNT_MIN;
226582
226760
  exports.AGENT_IDS = AGENT_IDS;
226583
226761
  exports.AGGREGATE_OPERATORS = AGGREGATE_OPERATORS;
226584
226762
  exports.AI_OPERATIONS = AI_OPERATIONS;
@@ -226612,6 +226790,9 @@ exports.ArtifactComponentListResponse = ArtifactComponentListResponse;
226612
226790
  exports.ArtifactComponentResponse = ArtifactComponentResponse;
226613
226791
  exports.ArtifactComponentSelectSchema = ArtifactComponentSelectSchema;
226614
226792
  exports.ArtifactComponentUpdateSchema = ArtifactComponentUpdateSchema;
226793
+ exports.CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT = CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT;
226794
+ exports.CONVERSATION_HISTORY_DEFAULT_LIMIT = CONVERSATION_HISTORY_DEFAULT_LIMIT;
226795
+ exports.CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT = CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT;
226615
226796
  exports.CanUseItemSchema = CanUseItemSchema;
226616
226797
  exports.ComponentAssociationSchema = ComponentAssociationSchema;
226617
226798
  exports.ContextCache = ContextCache;
@@ -226728,6 +226909,11 @@ exports.MAX_ID_LENGTH = MAX_ID_LENGTH;
226728
226909
  exports.MCPServerType = MCPServerType;
226729
226910
  exports.MCPToolConfigSchema = MCPToolConfigSchema;
226730
226911
  exports.MCPTransportType = MCPTransportType;
226912
+ exports.MCP_TOOL_CONNECTION_TIMEOUT_MS = MCP_TOOL_CONNECTION_TIMEOUT_MS;
226913
+ exports.MCP_TOOL_INITIAL_RECONNECTION_DELAY_MS = MCP_TOOL_INITIAL_RECONNECTION_DELAY_MS;
226914
+ exports.MCP_TOOL_MAX_RECONNECTION_DELAY_MS = MCP_TOOL_MAX_RECONNECTION_DELAY_MS;
226915
+ exports.MCP_TOOL_MAX_RETRIES = MCP_TOOL_MAX_RETRIES;
226916
+ exports.MCP_TOOL_RECONNECTION_DELAY_GROWTH_FACTOR = MCP_TOOL_RECONNECTION_DELAY_GROWTH_FACTOR;
226731
226917
  exports.MIN_ID_LENGTH = MIN_ID_LENGTH;
226732
226918
  exports.McpClient = McpClient;
226733
226919
  exports.McpToolDefinitionSchema = McpToolDefinitionSchema;
@@ -226771,6 +226957,11 @@ exports.RelatedAgentInfoSchema = RelatedAgentInfoSchema;
226771
226957
  exports.RemovedResponseSchema = RemovedResponseSchema;
226772
226958
  exports.SPAN_KEYS = SPAN_KEYS;
226773
226959
  exports.SPAN_NAMES = SPAN_NAMES;
226960
+ exports.STATUS_UPDATE_MAX_INTERVAL_SECONDS = STATUS_UPDATE_MAX_INTERVAL_SECONDS;
226961
+ exports.STATUS_UPDATE_MAX_NUM_EVENTS = STATUS_UPDATE_MAX_NUM_EVENTS;
226962
+ exports.SUB_AGENT_TURN_GENERATION_STEPS_DEFAULT = SUB_AGENT_TURN_GENERATION_STEPS_DEFAULT;
226963
+ exports.SUB_AGENT_TURN_GENERATION_STEPS_MAX = SUB_AGENT_TURN_GENERATION_STEPS_MAX;
226964
+ exports.SUB_AGENT_TURN_GENERATION_STEPS_MIN = SUB_AGENT_TURN_GENERATION_STEPS_MIN;
226774
226965
  exports.SingleResponseSchema = SingleResponseSchema;
226775
226966
  exports.StatusComponentSchema = StatusComponentSchema;
226776
226967
  exports.StatusUpdateSchema = StatusUpdateSchema;
@@ -226873,6 +227064,8 @@ exports.ToolUpdateSchema = ToolUpdateSchema;
226873
227064
  exports.TransferDataSchema = TransferDataSchema;
226874
227065
  exports.UNKNOWN_VALUE = UNKNOWN_VALUE;
226875
227066
  exports.URL_SAFE_ID_PATTERN = URL_SAFE_ID_PATTERN;
227067
+ exports.VALIDATION_AGENT_PROMPT_MAX_CHARS = VALIDATION_AGENT_PROMPT_MAX_CHARS;
227068
+ exports.VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS = VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS;
226876
227069
  exports.VALID_RELATION_TYPES = VALID_RELATION_TYPES;
226877
227070
  exports.addFunctionToolToSubAgent = addFunctionToolToSubAgent;
226878
227071
  exports.addLedgerArtifacts = addLedgerArtifacts;
@@ -226933,7 +227126,6 @@ exports.createExternalAgent = createExternalAgent;
226933
227126
  exports.createFullAgentServerSide = createFullAgentServerSide;
226934
227127
  exports.createFullProjectServerSide = createFullProjectServerSide;
226935
227128
  exports.createFunctionTool = createFunctionTool;
226936
- exports.createInMemoryDatabaseClient = createInMemoryDatabaseClient;
226937
227129
  exports.createKeyChainStore = createKeyChainStore;
226938
227130
  exports.createMessage = createMessage;
226939
227131
  exports.createNangoCredentialStore = createNangoCredentialStore;
@@ -226986,6 +227178,7 @@ exports.determineContextTrigger = determineContextTrigger;
226986
227178
  exports.errorResponseSchema = errorResponseSchema;
226987
227179
  exports.errorSchemaFactory = errorSchemaFactory;
226988
227180
  exports.exchangeMcpAuthorizationCode = exchangeMcpAuthorizationCode;
227181
+ exports.executionLimitsSharedDefaults = executionLimitsSharedDefaults;
226989
227182
  exports.externalAgentExists = externalAgentExists;
226990
227183
  exports.externalAgentUrlExists = externalAgentUrlExists;
226991
227184
  exports.externalAgents = externalAgents;
@@ -227128,6 +227321,7 @@ exports.loggerFactory = loggerFactory;
227128
227321
  exports.maskApiKey = maskApiKey;
227129
227322
  exports.messages = messages;
227130
227323
  exports.messagesRelations = messagesRelations;
227324
+ exports.normalizeDateString = normalizeDateString;
227131
227325
  exports.preview = preview;
227132
227326
  exports.problemDetailsSchema = problemDetailsSchema;
227133
227327
  exports.projectExists = projectExists;
@@ -227139,6 +227333,7 @@ exports.removeArtifactComponentFromAgent = removeArtifactComponentFromAgent;
227139
227333
  exports.removeDataComponentFromAgent = removeDataComponentFromAgent;
227140
227334
  exports.removeToolFromAgent = removeToolFromAgent;
227141
227335
  exports.resourceIdSchema = resourceIdSchema;
227336
+ exports.schemaValidationDefaults = schemaValidationDefaults;
227142
227337
  exports.setActiveAgentForConversation = setActiveAgentForConversation;
227143
227338
  exports.setActiveAgentForThread = setActiveAgentForThread;
227144
227339
  exports.setCacheEntry = setCacheEntry;