@inkeep/agents-core 0.0.0-dev-20251008194140 → 0.0.0-dev-20251008200151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{chunk-AHSEMW6N.js → chunk-5ZHSPLXI.js} +1 -2
  2. package/dist/{chunk-FMCAYVO7.js → chunk-BNXFEUNP.js} +105 -2
  3. package/dist/{chunk-FLKAMXLV.js → chunk-PR7XWHED.js} +1 -1
  4. package/dist/chunk-R2EERZSW.js +223 -0
  5. package/dist/client-exports.cjs +110 -9
  6. package/dist/client-exports.d.cts +14 -11
  7. package/dist/client-exports.d.ts +14 -11
  8. package/dist/client-exports.js +4 -10
  9. package/dist/db/schema.cjs +1 -2
  10. package/dist/db/schema.d.cts +2 -2
  11. package/dist/db/schema.d.ts +2 -2
  12. package/dist/db/schema.js +1 -1
  13. package/dist/index.cjs +549 -371
  14. package/dist/index.d.cts +262 -265
  15. package/dist/index.d.ts +262 -265
  16. package/dist/index.js +41 -188
  17. package/dist/props-validation-BMR1qNiy.d.cts +15 -0
  18. package/dist/props-validation-BMR1qNiy.d.ts +15 -0
  19. package/dist/{schema-D0E2bG9V.d.ts → schema-BYR5XAeI.d.ts} +3 -22
  20. package/dist/{schema-CTBfyt-o.d.cts → schema-Cn2ZkYOh.d.cts} +3 -22
  21. package/dist/types/index.d.cts +2 -2
  22. package/dist/types/index.d.ts +2 -2
  23. package/dist/{utility-BMAHFZX6.d.cts → utility-6UlHR5nQ.d.cts} +191 -216
  24. package/dist/{utility-BMAHFZX6.d.ts → utility-6UlHR5nQ.d.ts} +191 -216
  25. package/dist/utils/schema-conversion.cjs +236 -0
  26. package/dist/utils/schema-conversion.d.cts +26 -0
  27. package/dist/utils/schema-conversion.d.ts +26 -0
  28. package/dist/utils/schema-conversion.js +1 -0
  29. package/dist/validation/index.cjs +109 -2
  30. package/dist/validation/index.d.cts +3 -2
  31. package/dist/validation/index.d.ts +3 -2
  32. package/dist/validation/index.js +2 -2
  33. package/drizzle/0002_bumpy_romulus.sql +3 -0
  34. package/drizzle/meta/0002_snapshot.json +2428 -0
  35. package/drizzle/meta/_journal.json +7 -0
  36. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -13,6 +13,7 @@ var libsql = require('drizzle-orm/libsql');
13
13
  var nanoid = require('nanoid');
14
14
  var crypto = require('crypto');
15
15
  var util = require('util');
16
+ var Ajv = require('ajv');
16
17
  var httpException = require('hono/http-exception');
17
18
  var index_js = require('@modelcontextprotocol/sdk/client/index.js');
18
19
  var sse_js = require('@modelcontextprotocol/sdk/client/sse.js');
@@ -23,7 +24,6 @@ var ai = require('ai');
23
24
  var exitHook = require('exit-hook');
24
25
  var tsPattern = require('ts-pattern');
25
26
  var api = require('@opentelemetry/api');
26
- var Ajv = require('ajv');
27
27
  var node = require('@nangohq/node');
28
28
  var fs = require('fs');
29
29
  var os = require('os');
@@ -191,22 +191,22 @@ var LoggerFactory = class {
191
191
  */
192
192
  getLogger(name) {
193
193
  if (this.loggers.has(name)) {
194
- const logger13 = this.loggers.get(name);
195
- if (!logger13) {
194
+ const logger14 = this.loggers.get(name);
195
+ if (!logger14) {
196
196
  throw new Error(`Logger '${name}' not found in cache`);
197
197
  }
198
- return logger13;
198
+ return logger14;
199
199
  }
200
- let logger12;
200
+ let logger13;
201
201
  if (this.config.loggerFactory) {
202
- logger12 = this.config.loggerFactory(name);
202
+ logger13 = this.config.loggerFactory(name);
203
203
  } else if (this.config.defaultLogger) {
204
- logger12 = this.config.defaultLogger;
204
+ logger13 = this.config.defaultLogger;
205
205
  } else {
206
- logger12 = new PinoLogger(name, this.config.pinoConfig);
206
+ logger13 = new PinoLogger(name, this.config.pinoConfig);
207
207
  }
208
- this.loggers.set(name, logger12);
209
- return logger12;
208
+ this.loggers.set(name, logger13);
209
+ return logger13;
210
210
  }
211
211
  /**
212
212
  * Reset factory to default state
@@ -220,6 +220,64 @@ var loggerFactory = new LoggerFactory();
220
220
  function getLogger(name) {
221
221
  return loggerFactory.getLogger(name);
222
222
  }
223
+ var logger = getLogger("schema-conversion");
224
+ function convertZodToJsonSchema(zodSchema) {
225
+ try {
226
+ const jsonSchema = zod.z.toJSONSchema(zodSchema);
227
+ if (jsonSchema.$schema) {
228
+ delete jsonSchema.$schema;
229
+ }
230
+ return jsonSchema;
231
+ } catch (error) {
232
+ logger.error(
233
+ {
234
+ error: error instanceof Error ? error.message : "Unknown error",
235
+ stack: error instanceof Error ? error.stack : void 0
236
+ },
237
+ "Failed to convert Zod schema to JSON Schema"
238
+ );
239
+ throw new Error("Failed to convert Zod schema to JSON Schema");
240
+ }
241
+ }
242
+ var preview = (schema) => {
243
+ schema._def.inPreview = true;
244
+ return schema;
245
+ };
246
+ function convertZodToJsonSchemaWithPreview(zodSchema) {
247
+ const jsonSchema = convertZodToJsonSchema(zodSchema);
248
+ if (zodSchema instanceof zod.z.ZodObject && jsonSchema.properties) {
249
+ const shape = zodSchema.shape;
250
+ for (const [key, fieldSchema] of Object.entries(shape)) {
251
+ if (fieldSchema?._def?.inPreview === true) {
252
+ jsonSchema.properties[key].inPreview = true;
253
+ }
254
+ }
255
+ }
256
+ return jsonSchema;
257
+ }
258
+ function isZodSchema(value) {
259
+ return value?._def?.type === "object";
260
+ }
261
+ function extractPreviewFields(schema) {
262
+ const previewFields = [];
263
+ if (schema instanceof zod.z.ZodObject) {
264
+ const shape = schema.shape;
265
+ for (const [key, fieldSchema] of Object.entries(shape)) {
266
+ if (fieldSchema?._def?.inPreview === true) {
267
+ previewFields.push(key);
268
+ }
269
+ }
270
+ return previewFields;
271
+ }
272
+ if (schema?.type === "object" && schema.properties) {
273
+ for (const [key, prop] of Object.entries(schema.properties)) {
274
+ if (prop.inPreview === true) {
275
+ previewFields.push(key);
276
+ }
277
+ }
278
+ }
279
+ return previewFields;
280
+ }
223
281
 
224
282
  // src/db/schema.ts
225
283
  var schema_exports = {};
@@ -544,8 +602,7 @@ var artifactComponents = sqliteCore.sqliteTable(
544
602
  {
545
603
  ...projectScoped,
546
604
  ...uiProperties,
547
- summaryProps: sqliteCore.blob("summary_props", { mode: "json" }).$type(),
548
- fullProps: sqliteCore.blob("full_props", { mode: "json" }).$type(),
605
+ props: sqliteCore.blob("props", { mode: "json" }).$type(),
549
606
  ...timestamps
550
607
  },
551
608
  (table) => [
@@ -1704,7 +1761,7 @@ var PaginationQueryParamsSchema = zodOpenapi.z.object({
1704
1761
  });
1705
1762
 
1706
1763
  // src/context/ContextConfig.ts
1707
- var logger = getLogger("context-config");
1764
+ var logger2 = getLogger("context-config");
1708
1765
  var RequestContextSchemaBuilder = class {
1709
1766
  constructor(options) {
1710
1767
  __publicField(this, "schema");
@@ -1721,19 +1778,6 @@ var RequestContextSchemaBuilder = class {
1721
1778
  return convertZodToJsonSchema(this.schema);
1722
1779
  }
1723
1780
  };
1724
- function convertZodToJsonSchema(zodSchema) {
1725
- try {
1726
- return zod.z.toJSONSchema(zodSchema, { target: "draft-7" });
1727
- } catch (error) {
1728
- logger.error(
1729
- {
1730
- error: error instanceof Error ? error.message : "Unknown error"
1731
- },
1732
- "Failed to convert Zod schema to JSON Schema"
1733
- );
1734
- throw new Error("Failed to convert Zod schema to JSON Schema");
1735
- }
1736
- }
1737
1781
  var ContextConfigBuilder = class {
1738
1782
  constructor(options) {
1739
1783
  __publicField(this, "config");
@@ -1748,7 +1792,7 @@ var ContextConfigBuilder = class {
1748
1792
  let requestContextSchema2;
1749
1793
  if (options.requestContextSchema) {
1750
1794
  const actualSchema = options.requestContextSchema instanceof RequestContextSchemaBuilder ? options.requestContextSchema.getSchema() : options.requestContextSchema;
1751
- logger.info(
1795
+ logger2.info(
1752
1796
  {
1753
1797
  requestContextSchema: options.requestContextSchema
1754
1798
  },
@@ -1766,7 +1810,7 @@ var ContextConfigBuilder = class {
1766
1810
  responseSchema: convertZodToJsonSchema(definition.responseSchema),
1767
1811
  credentialReferenceId
1768
1812
  };
1769
- logger.debug(
1813
+ logger2.debug(
1770
1814
  {
1771
1815
  contextVariableKey: key,
1772
1816
  originalSchema: definition.responseSchema,
@@ -1785,7 +1829,7 @@ var ContextConfigBuilder = class {
1785
1829
  requestContextSchema: requestContextSchema2,
1786
1830
  contextVariables: processedContextVariables
1787
1831
  };
1788
- logger.info(
1832
+ logger2.info(
1789
1833
  {
1790
1834
  contextConfigId: this.config.id,
1791
1835
  tenantId: this.tenantId
@@ -1805,7 +1849,7 @@ var ContextConfigBuilder = class {
1805
1849
  this.config.tenantId = tenantId;
1806
1850
  this.config.projectId = projectId;
1807
1851
  this.config.graphId = graphId;
1808
- logger.info(
1852
+ logger2.info(
1809
1853
  {
1810
1854
  contextConfigId: this.config.id,
1811
1855
  tenantId: this.tenantId,
@@ -1901,14 +1945,14 @@ var ContextConfigBuilder = class {
1901
1945
  }
1902
1946
  try {
1903
1947
  await this.upsertContextConfig();
1904
- logger.info(
1948
+ logger2.info(
1905
1949
  {
1906
1950
  contextConfigId: this.getId()
1907
1951
  },
1908
1952
  "Context config initialized successfully"
1909
1953
  );
1910
1954
  } catch (error) {
1911
- logger.error(
1955
+ logger2.error(
1912
1956
  {
1913
1957
  contextConfigId: this.getId(),
1914
1958
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1939,7 +1983,7 @@ var ContextConfigBuilder = class {
1939
1983
  }
1940
1984
  );
1941
1985
  if (updateResponse.ok) {
1942
- logger.info(
1986
+ logger2.info(
1943
1987
  {
1944
1988
  contextConfigId: this.getId()
1945
1989
  },
@@ -1948,7 +1992,7 @@ var ContextConfigBuilder = class {
1948
1992
  return;
1949
1993
  }
1950
1994
  if (updateResponse.status === 404) {
1951
- logger.info(
1995
+ logger2.info(
1952
1996
  {
1953
1997
  contextConfigId: this.getId()
1954
1998
  },
@@ -1970,7 +2014,7 @@ var ContextConfigBuilder = class {
1970
2014
  `Failed to create context config (${createResponse.status}): ${errorData2.message || errorData2.error || "Unknown error"}`
1971
2015
  );
1972
2016
  }
1973
- logger.info(
2017
+ logger2.info(
1974
2018
  {
1975
2019
  contextConfigId: this.getId()
1976
2020
  },
@@ -2028,7 +2072,7 @@ function fetchDefinition(options) {
2028
2072
  credentialReferenceId: options.credentialReference?.id
2029
2073
  };
2030
2074
  }
2031
- var logger2 = getLogger("template-engine");
2075
+ var logger3 = getLogger("template-engine");
2032
2076
  var _TemplateEngine = class _TemplateEngine {
2033
2077
  /**
2034
2078
  * Render a template string with context data using JMESPath
@@ -2043,7 +2087,7 @@ var _TemplateEngine = class _TemplateEngine {
2043
2087
  }
2044
2088
  return rendered;
2045
2089
  } catch (error) {
2046
- logger2.error(
2090
+ logger3.error(
2047
2091
  {
2048
2092
  template: template.substring(0, 100) + (template.length > 100 ? "..." : ""),
2049
2093
  contextKeys: Object.keys(context),
@@ -2073,7 +2117,7 @@ var _TemplateEngine = class _TemplateEngine {
2073
2117
  return match2;
2074
2118
  }
2075
2119
  if (trimmedPath.startsWith("requestContext.")) {
2076
- logger2.warn(
2120
+ logger3.warn(
2077
2121
  {
2078
2122
  variable: trimmedPath,
2079
2123
  availableKeys: Object.keys(context),
@@ -2083,7 +2127,7 @@ var _TemplateEngine = class _TemplateEngine {
2083
2127
  "RequestContext template variable debugging"
2084
2128
  );
2085
2129
  } else {
2086
- logger2.warn(
2130
+ logger3.warn(
2087
2131
  {
2088
2132
  variable: trimmedPath,
2089
2133
  availableKeys: Object.keys(context)
@@ -2102,7 +2146,7 @@ var _TemplateEngine = class _TemplateEngine {
2102
2146
  if (options.strict) {
2103
2147
  throw new Error(`Failed to resolve template variable '${trimmedPath}': ${errorMessage}`);
2104
2148
  }
2105
- logger2.error(
2149
+ logger3.error(
2106
2150
  {
2107
2151
  variable: trimmedPath,
2108
2152
  error: errorMessage
@@ -2131,7 +2175,7 @@ var _TemplateEngine = class _TemplateEngine {
2131
2175
  const envVar = variable.substring(5);
2132
2176
  return process.env[envVar] || "";
2133
2177
  }
2134
- logger2.warn(
2178
+ logger3.warn(
2135
2179
  {
2136
2180
  variable
2137
2181
  },
@@ -2247,11 +2291,11 @@ function getCredentialStoreLookupKeyFromRetrievalParams({
2247
2291
 
2248
2292
  // src/credential-stuffer/CredentialStuffer.ts
2249
2293
  var CredentialStuffer = class {
2250
- constructor(credentialStoreRegistry, contextResolver, logger12) {
2294
+ constructor(credentialStoreRegistry, contextResolver, logger13) {
2251
2295
  this.credentialStoreRegistry = credentialStoreRegistry;
2252
2296
  this.contextResolver = contextResolver;
2253
2297
  __publicField(this, "logger");
2254
- this.logger = logger12 || getLogger("credential-stuffer");
2298
+ this.logger = logger13 || getLogger("credential-stuffer");
2255
2299
  }
2256
2300
  /**
2257
2301
  * Retrieve credentials from credential store registry
@@ -3763,8 +3807,7 @@ var getFullGraphDefinition = (db) => async ({
3763
3807
  id: artifactComponents.id,
3764
3808
  name: artifactComponents.name,
3765
3809
  description: artifactComponents.description,
3766
- summaryProps: artifactComponents.summaryProps,
3767
- fullProps: artifactComponents.fullProps
3810
+ props: artifactComponents.props
3768
3811
  }
3769
3812
  });
3770
3813
  } catch (error) {
@@ -3874,7 +3917,7 @@ var upsertAgentGraph = (db) => async (params) => {
3874
3917
  }
3875
3918
  };
3876
3919
  var scryptAsync = util.promisify(crypto.scrypt);
3877
- var logger3 = getLogger("api-key");
3920
+ var logger4 = getLogger("api-key");
3878
3921
  var API_KEY_LENGTH = 32;
3879
3922
  var SALT_LENGTH = 32;
3880
3923
  var KEY_LENGTH = 64;
@@ -3911,7 +3954,7 @@ async function validateApiKey(key, storedHash) {
3911
3954
  const hashedBuffer = await scryptAsync(key, salt, KEY_LENGTH);
3912
3955
  return crypto.timingSafeEqual(storedHashBuffer, hashedBuffer);
3913
3956
  } catch (error) {
3914
- logger3.error({ error }, "Error validating API key");
3957
+ logger4.error({ error }, "Error validating API key");
3915
3958
  return false;
3916
3959
  }
3917
3960
  }
@@ -4112,6 +4155,110 @@ var validateAndGetApiKey = async (key, db) => {
4112
4155
  });
4113
4156
  return apiKey;
4114
4157
  };
4158
+ function validatePropsAsJsonSchema(props) {
4159
+ if (!props || typeof props === "object" && Object.keys(props).length === 0) {
4160
+ return {
4161
+ isValid: true,
4162
+ errors: []
4163
+ };
4164
+ }
4165
+ if (typeof props !== "object" || Array.isArray(props)) {
4166
+ return {
4167
+ isValid: false,
4168
+ errors: [
4169
+ {
4170
+ field: "props",
4171
+ message: "Props must be a valid JSON Schema object",
4172
+ value: props
4173
+ }
4174
+ ]
4175
+ };
4176
+ }
4177
+ if (!props.type) {
4178
+ return {
4179
+ isValid: false,
4180
+ errors: [
4181
+ {
4182
+ field: "props.type",
4183
+ message: 'JSON Schema must have a "type" field'
4184
+ }
4185
+ ]
4186
+ };
4187
+ }
4188
+ if (props.type !== "object") {
4189
+ return {
4190
+ isValid: false,
4191
+ errors: [
4192
+ {
4193
+ field: "props.type",
4194
+ message: 'JSON Schema type must be "object" for component props',
4195
+ value: props.type
4196
+ }
4197
+ ]
4198
+ };
4199
+ }
4200
+ if (!props.properties || typeof props.properties !== "object") {
4201
+ return {
4202
+ isValid: false,
4203
+ errors: [
4204
+ {
4205
+ field: "props.properties",
4206
+ message: 'JSON Schema must have a "properties" object'
4207
+ }
4208
+ ]
4209
+ };
4210
+ }
4211
+ if (props.required !== void 0 && !Array.isArray(props.required)) {
4212
+ return {
4213
+ isValid: false,
4214
+ errors: [
4215
+ {
4216
+ field: "props.required",
4217
+ message: 'If present, "required" must be an array'
4218
+ }
4219
+ ]
4220
+ };
4221
+ }
4222
+ try {
4223
+ const schemaToValidate = { ...props };
4224
+ delete schemaToValidate.$schema;
4225
+ const schemaValidator = new Ajv__default.default({
4226
+ strict: false,
4227
+ // Allow unknown keywords like inPreview
4228
+ validateSchema: true,
4229
+ // Validate the schema itself
4230
+ addUsedSchema: false
4231
+ // Don't add schemas to the instance
4232
+ });
4233
+ const isValid = schemaValidator.validateSchema(schemaToValidate);
4234
+ if (!isValid) {
4235
+ const errors = schemaValidator.errors || [];
4236
+ return {
4237
+ isValid: false,
4238
+ errors: errors.map((error) => ({
4239
+ field: `props${error.instancePath || ""}`,
4240
+ message: error.message || "Invalid schema"
4241
+ }))
4242
+ };
4243
+ }
4244
+ return {
4245
+ isValid: true,
4246
+ errors: []
4247
+ };
4248
+ } catch (error) {
4249
+ return {
4250
+ isValid: false,
4251
+ errors: [
4252
+ {
4253
+ field: "props",
4254
+ message: `Schema validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
4255
+ }
4256
+ ]
4257
+ };
4258
+ }
4259
+ }
4260
+
4261
+ // src/data-access/artifactComponents.ts
4115
4262
  var getArtifactComponentById = (db) => async (params) => {
4116
4263
  return await db.query.artifactComponents.findFirst({
4117
4264
  where: drizzleOrm.and(
@@ -4150,6 +4297,13 @@ var listArtifactComponentsPaginated = (db) => async (params) => {
4150
4297
  };
4151
4298
  };
4152
4299
  var createArtifactComponent = (db) => async (params) => {
4300
+ if (params.props !== null && params.props !== void 0) {
4301
+ const propsValidation = validatePropsAsJsonSchema(params.props);
4302
+ if (!propsValidation.isValid) {
4303
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
4304
+ throw new Error(`Invalid props schema: ${errorMessages}`);
4305
+ }
4306
+ }
4153
4307
  const now = (/* @__PURE__ */ new Date()).toISOString();
4154
4308
  const [artifactComponent] = await db.insert(artifactComponents).values({
4155
4309
  ...params,
@@ -4159,6 +4313,13 @@ var createArtifactComponent = (db) => async (params) => {
4159
4313
  return artifactComponent;
4160
4314
  };
4161
4315
  var updateArtifactComponent = (db) => async (params) => {
4316
+ if (params.data.props !== void 0 && params.data.props !== null) {
4317
+ const propsValidation = validatePropsAsJsonSchema(params.data.props);
4318
+ if (!propsValidation.isValid) {
4319
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
4320
+ throw new Error(`Invalid props schema: ${errorMessages}`);
4321
+ }
4322
+ }
4162
4323
  const now = (/* @__PURE__ */ new Date()).toISOString();
4163
4324
  const [updated] = await db.update(artifactComponents).set({
4164
4325
  ...params.data,
@@ -4194,8 +4355,7 @@ var getArtifactComponentsForAgent = (db) => async (params) => {
4194
4355
  projectId: artifactComponents.projectId,
4195
4356
  name: artifactComponents.name,
4196
4357
  description: artifactComponents.description,
4197
- summaryProps: artifactComponents.summaryProps,
4198
- fullProps: artifactComponents.fullProps,
4358
+ props: artifactComponents.props,
4199
4359
  createdAt: artifactComponents.createdAt,
4200
4360
  updatedAt: artifactComponents.updatedAt
4201
4361
  }).from(artifactComponents).innerJoin(
@@ -4342,8 +4502,7 @@ var upsertArtifactComponent = (db) => async (params) => {
4342
4502
  data: {
4343
4503
  name: params.data.name,
4344
4504
  description: params.data.description,
4345
- summaryProps: params.data.summaryProps,
4346
- fullProps: params.data.fullProps
4505
+ props: params.data.props
4347
4506
  }
4348
4507
  });
4349
4508
  } else {
@@ -4898,10 +5057,24 @@ var listDataComponentsPaginated = (db) => async (params) => {
4898
5057
  };
4899
5058
  };
4900
5059
  var createDataComponent = (db) => async (params) => {
5060
+ if (params.props) {
5061
+ const propsValidation = validatePropsAsJsonSchema(params.props);
5062
+ if (!propsValidation.isValid) {
5063
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
5064
+ throw new Error(`Invalid props schema: ${errorMessages}`);
5065
+ }
5066
+ }
4901
5067
  const dataComponent = await db.insert(dataComponents).values(params).returning();
4902
5068
  return dataComponent[0];
4903
5069
  };
4904
5070
  var updateDataComponent = (db) => async (params) => {
5071
+ if (params.data.props !== void 0 && params.data.props !== null) {
5072
+ const propsValidation = validatePropsAsJsonSchema(params.data.props);
5073
+ if (!propsValidation.isValid) {
5074
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
5075
+ throw new Error(`Invalid props schema: ${errorMessages}`);
5076
+ }
5077
+ }
4905
5078
  const now = (/* @__PURE__ */ new Date()).toISOString();
4906
5079
  await db.update(dataComponents).set({
4907
5080
  ...params.data,
@@ -5169,7 +5342,7 @@ var buildOAuthConfig = (metadata) => ({
5169
5342
  registrationUrl: metadata.registration_endpoint,
5170
5343
  supportsDynamicRegistration: !!metadata.registration_endpoint
5171
5344
  });
5172
- var tryWellKnownEndpoints = async (baseUrl, logger12) => {
5345
+ var tryWellKnownEndpoints = async (baseUrl, logger13) => {
5173
5346
  const wellKnownUrls = getWellKnownUrls(baseUrl);
5174
5347
  for (const wellKnownUrl of wellKnownUrls) {
5175
5348
  try {
@@ -5177,21 +5350,21 @@ var tryWellKnownEndpoints = async (baseUrl, logger12) => {
5177
5350
  if (response.ok) {
5178
5351
  const metadata = await response.json();
5179
5352
  if (validateOAuthMetadata(metadata)) {
5180
- logger12?.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
5353
+ logger13?.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
5181
5354
  return buildOAuthConfig(metadata);
5182
5355
  }
5183
5356
  }
5184
5357
  } catch (error) {
5185
- logger12?.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
5358
+ logger13?.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
5186
5359
  }
5187
5360
  }
5188
5361
  return null;
5189
5362
  };
5190
- var checkForOAuthEndpoints = async (serverUrl, logger12) => {
5191
- const config = await discoverOAuthEndpoints(serverUrl, logger12);
5363
+ var checkForOAuthEndpoints = async (serverUrl, logger13) => {
5364
+ const config = await discoverOAuthEndpoints(serverUrl, logger13);
5192
5365
  return config !== null;
5193
5366
  };
5194
- var discoverOAuthEndpoints = async (serverUrl, logger12) => {
5367
+ var discoverOAuthEndpoints = async (serverUrl, logger13) => {
5195
5368
  try {
5196
5369
  const response = await fetch(serverUrl, {
5197
5370
  method: "POST",
@@ -5207,7 +5380,7 @@ var discoverOAuthEndpoints = async (serverUrl, logger12) => {
5207
5380
  if (metadataResponse.ok) {
5208
5381
  const metadata = await metadataResponse.json();
5209
5382
  if (metadata.authorization_servers?.length > 0) {
5210
- return await tryWellKnownEndpoints(metadata.authorization_servers[0], logger12);
5383
+ return await tryWellKnownEndpoints(metadata.authorization_servers[0], logger13);
5211
5384
  }
5212
5385
  }
5213
5386
  }
@@ -5217,25 +5390,25 @@ var discoverOAuthEndpoints = async (serverUrl, logger12) => {
5217
5390
  }
5218
5391
  const url = new URL(serverUrl);
5219
5392
  const baseUrl = `${url.protocol}//${url.host}`;
5220
- return await tryWellKnownEndpoints(baseUrl, logger12);
5393
+ return await tryWellKnownEndpoints(baseUrl, logger13);
5221
5394
  };
5222
5395
  var detectAuthenticationRequired = async ({
5223
5396
  serverUrl,
5224
5397
  toolId,
5225
5398
  error,
5226
- logger: logger12
5399
+ logger: logger13
5227
5400
  }) => {
5228
5401
  try {
5229
- const hasOAuthEndpoints = await checkForOAuthEndpoints(serverUrl, logger12);
5402
+ const hasOAuthEndpoints = await checkForOAuthEndpoints(serverUrl, logger13);
5230
5403
  if (hasOAuthEndpoints) {
5231
- logger12?.info(
5404
+ logger13?.info(
5232
5405
  { toolId, serverUrl },
5233
5406
  "OAuth 2.1/PKCE support confirmed via endpoint discovery"
5234
5407
  );
5235
5408
  return true;
5236
5409
  }
5237
5410
  } catch (discoveryError) {
5238
- logger12?.debug({ toolId, discoveryError }, "OAuth endpoint discovery failed");
5411
+ logger13?.debug({ toolId, discoveryError }, "OAuth endpoint discovery failed");
5239
5412
  }
5240
5413
  try {
5241
5414
  const response = await fetch(serverUrl, {
@@ -5254,13 +5427,13 @@ var detectAuthenticationRequired = async ({
5254
5427
  const authLower = wwwAuth.toLowerCase();
5255
5428
  const hasActiveOAuthFlow = authLower.includes("authorization_uri") || authLower.includes("as_uri=") || authLower.includes("bearer") && (authLower.includes("scope=") || authLower.includes("error_uri="));
5256
5429
  if (hasActiveOAuthFlow) {
5257
- logger12?.info(
5430
+ logger13?.info(
5258
5431
  { toolId, wwwAuth },
5259
5432
  "Active OAuth flow detected via WWW-Authenticate parameters"
5260
5433
  );
5261
5434
  return true;
5262
5435
  } else {
5263
- logger12?.debug(
5436
+ logger13?.debug(
5264
5437
  { toolId, wwwAuth },
5265
5438
  "Bearer authentication detected - likely simple token auth, not OAuth"
5266
5439
  );
@@ -5268,9 +5441,9 @@ var detectAuthenticationRequired = async ({
5268
5441
  }
5269
5442
  }
5270
5443
  } catch (fetchError) {
5271
- logger12?.debug({ toolId, fetchError }, "Direct fetch authentication check failed");
5444
+ logger13?.debug({ toolId, fetchError }, "Direct fetch authentication check failed");
5272
5445
  }
5273
- logger12?.debug(
5446
+ logger13?.debug(
5274
5447
  { toolId, error: error.message },
5275
5448
  "No OAuth 2.1/PKCE authentication requirement detected"
5276
5449
  );
@@ -5724,7 +5897,7 @@ var McpClient = class {
5724
5897
  return results;
5725
5898
  }
5726
5899
  };
5727
- var logger4 = getLogger("tracer");
5900
+ var logger5 = getLogger("tracer");
5728
5901
  var createNoOpSpan = () => ({
5729
5902
  setAttributes: () => ({}),
5730
5903
  recordException: () => ({}),
@@ -5753,27 +5926,27 @@ var noopTracer = {
5753
5926
  return createNoOpSpan();
5754
5927
  }
5755
5928
  };
5756
- function setSpanWithError(span, error, logger12, logMessage) {
5929
+ function setSpanWithError(span, error, logger13, logMessage) {
5757
5930
  span.recordException(error);
5758
5931
  span.setStatus({
5759
5932
  code: api.SpanStatusCode.ERROR,
5760
5933
  message: error.message
5761
5934
  });
5762
- if (logger12 && logMessage) {
5763
- logger12.error({ error: error.message }, logMessage);
5935
+ if (logger13 && logMessage) {
5936
+ logger13.error({ error: error.message }, logMessage);
5764
5937
  }
5765
5938
  }
5766
5939
  function getTracer(serviceName, serviceVersion) {
5767
5940
  try {
5768
5941
  return api.trace.getTracer(serviceName, serviceVersion);
5769
5942
  } catch (_error) {
5770
- logger4.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
5943
+ logger5.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
5771
5944
  return noopTracer;
5772
5945
  }
5773
5946
  }
5774
5947
 
5775
5948
  // src/data-access/tools.ts
5776
- var logger5 = getLogger("tools");
5949
+ var logger6 = getLogger("tools");
5777
5950
  function extractInputSchema(toolDef) {
5778
5951
  if (toolDef.inputSchema) {
5779
5952
  return toolDef.inputSchema;
@@ -5867,7 +6040,7 @@ var discoverToolsFromServer = async (tool2, dbClient, credentialStoreRegistry) =
5867
6040
  );
5868
6041
  return toolDefinitions;
5869
6042
  } catch (error) {
5870
- logger5.error({ toolId: tool2.id, error }, "Tool discovery failed");
6043
+ logger6.error({ toolId: tool2.id, error }, "Tool discovery failed");
5871
6044
  throw error;
5872
6045
  }
5873
6046
  };
@@ -5885,7 +6058,7 @@ var dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry) => {
5885
6058
  serverUrl: dbResult.config.mcp.server.url,
5886
6059
  toolId: dbResult.id,
5887
6060
  error,
5888
- logger: logger5
6061
+ logger: logger6
5889
6062
  });
5890
6063
  status = toolNeedsAuth ? "needs_auth" : "unhealthy";
5891
6064
  lastErrorComputed = toolNeedsAuth ? "Authentication required - OAuth login needed" : error instanceof Error ? error.message : "Tool discovery failed";
@@ -6048,18 +6221,18 @@ var defaultLogger = {
6048
6221
  error: () => {
6049
6222
  }
6050
6223
  };
6051
- async function applyExecutionLimitsInheritance(db, logger12, scopes, graphData) {
6224
+ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData) {
6052
6225
  const { tenantId, projectId } = scopes;
6053
6226
  try {
6054
6227
  const project = await db.query.projects.findFirst({
6055
6228
  where: drizzleOrm.and(drizzleOrm.eq(projects.tenantId, tenantId), drizzleOrm.eq(projects.id, projectId))
6056
6229
  });
6057
6230
  if (!project?.stopWhen) {
6058
- logger12.info({ projectId }, "No project stopWhen configuration found");
6231
+ logger13.info({ projectId }, "No project stopWhen configuration found");
6059
6232
  return;
6060
6233
  }
6061
6234
  const projectStopWhen = project.stopWhen;
6062
- logger12.info(
6235
+ logger13.info(
6063
6236
  {
6064
6237
  projectId,
6065
6238
  projectStopWhen
@@ -6071,7 +6244,7 @@ async function applyExecutionLimitsInheritance(db, logger12, scopes, graphData)
6071
6244
  }
6072
6245
  if (graphData.stopWhen.transferCountIs === void 0 && projectStopWhen?.transferCountIs !== void 0) {
6073
6246
  graphData.stopWhen.transferCountIs = projectStopWhen.transferCountIs;
6074
- logger12.info(
6247
+ logger13.info(
6075
6248
  {
6076
6249
  graphId: graphData.id,
6077
6250
  inheritedValue: projectStopWhen.transferCountIs
@@ -6081,7 +6254,7 @@ async function applyExecutionLimitsInheritance(db, logger12, scopes, graphData)
6081
6254
  }
6082
6255
  if (graphData.stopWhen.transferCountIs === void 0) {
6083
6256
  graphData.stopWhen.transferCountIs = 10;
6084
- logger12.info(
6257
+ logger13.info(
6085
6258
  {
6086
6259
  graphId: graphData.id,
6087
6260
  defaultValue: 10
@@ -6090,7 +6263,7 @@ async function applyExecutionLimitsInheritance(db, logger12, scopes, graphData)
6090
6263
  );
6091
6264
  }
6092
6265
  if (projectStopWhen?.stepCountIs !== void 0) {
6093
- logger12.info(
6266
+ logger13.info(
6094
6267
  {
6095
6268
  projectId,
6096
6269
  stepCountIs: projectStopWhen.stepCountIs
@@ -6105,7 +6278,7 @@ async function applyExecutionLimitsInheritance(db, logger12, scopes, graphData)
6105
6278
  }
6106
6279
  if (agent.stopWhen.stepCountIs === void 0) {
6107
6280
  agent.stopWhen.stepCountIs = projectStopWhen.stepCountIs;
6108
- logger12.info(
6281
+ logger13.info(
6109
6282
  {
6110
6283
  agentId,
6111
6284
  inheritedValue: projectStopWhen.stepCountIs
@@ -6117,7 +6290,7 @@ async function applyExecutionLimitsInheritance(db, logger12, scopes, graphData)
6117
6290
  }
6118
6291
  }
6119
6292
  } catch (error) {
6120
- logger12.error(
6293
+ logger13.error(
6121
6294
  {
6122
6295
  projectId,
6123
6296
  error: error instanceof Error ? error.message : "Unknown error"
@@ -6126,21 +6299,21 @@ async function applyExecutionLimitsInheritance(db, logger12, scopes, graphData)
6126
6299
  );
6127
6300
  }
6128
6301
  }
6129
- var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes, graphData) => {
6302
+ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes, graphData) => {
6130
6303
  const { tenantId, projectId } = scopes;
6131
6304
  const typed = validateAndTypeGraphData(graphData);
6132
6305
  validateGraphStructure(typed);
6133
- await applyExecutionLimitsInheritance(db, logger12, { tenantId, projectId }, typed);
6306
+ await applyExecutionLimitsInheritance(db, logger13, { tenantId, projectId }, typed);
6134
6307
  try {
6135
- logger12.info(
6308
+ logger13.info(
6136
6309
  {},
6137
6310
  "CredentialReferences are project-scoped - skipping credential reference creation in graph"
6138
6311
  );
6139
- logger12.info({}, "Tools are project-scoped - skipping tool creation in graph");
6312
+ logger13.info({}, "Tools are project-scoped - skipping tool creation in graph");
6140
6313
  let finalGraphId;
6141
6314
  try {
6142
6315
  const graphId = typed.id || nanoid.nanoid();
6143
- logger12.info({ graphId }, "Creating agent graph metadata");
6316
+ logger13.info({ graphId }, "Creating agent graph metadata");
6144
6317
  const agentGraph2 = await upsertAgentGraph(db)({
6145
6318
  data: {
6146
6319
  id: graphId,
@@ -6158,15 +6331,15 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6158
6331
  }
6159
6332
  });
6160
6333
  finalGraphId = agentGraph2.id;
6161
- logger12.info({ graphId: finalGraphId }, "Agent graph metadata created successfully");
6334
+ logger13.info({ graphId: finalGraphId }, "Agent graph metadata created successfully");
6162
6335
  } catch (error) {
6163
- logger12.error({ graphId: typed.id, error }, "Failed to create/update graph metadata");
6336
+ logger13.error({ graphId: typed.id, error }, "Failed to create/update graph metadata");
6164
6337
  throw error;
6165
6338
  }
6166
6339
  let contextConfigId;
6167
6340
  if (typed.contextConfig) {
6168
6341
  try {
6169
- logger12.info({ contextConfigId: typed.contextConfig.id }, "Processing context config");
6342
+ logger13.info({ contextConfigId: typed.contextConfig.id }, "Processing context config");
6170
6343
  const contextConfig2 = await upsertContextConfig(db)({
6171
6344
  data: {
6172
6345
  ...typed.contextConfig,
@@ -6176,9 +6349,9 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6176
6349
  }
6177
6350
  });
6178
6351
  contextConfigId = contextConfig2.id;
6179
- logger12.info({ contextConfigId }, "Context config processed successfully");
6352
+ logger13.info({ contextConfigId }, "Context config processed successfully");
6180
6353
  } catch (error) {
6181
- logger12.error(
6354
+ logger13.error(
6182
6355
  { contextConfigId: typed.contextConfig.id, error },
6183
6356
  "Failed to create/update context config"
6184
6357
  );
@@ -6187,7 +6360,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6187
6360
  }
6188
6361
  if (contextConfigId) {
6189
6362
  try {
6190
- logger12.info(
6363
+ logger13.info(
6191
6364
  { graphId: finalGraphId, contextConfigId },
6192
6365
  "Updating graph with contextConfigId"
6193
6366
  );
@@ -6206,30 +6379,30 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6206
6379
  stopWhen: typed.stopWhen
6207
6380
  }
6208
6381
  });
6209
- logger12.info(
6382
+ logger13.info(
6210
6383
  { graphId: finalGraphId, contextConfigId },
6211
6384
  "Graph updated with contextConfigId successfully"
6212
6385
  );
6213
6386
  } catch (error) {
6214
- logger12.error(
6387
+ logger13.error(
6215
6388
  { graphId: finalGraphId, contextConfigId, error },
6216
6389
  "Failed to update graph with contextConfigId"
6217
6390
  );
6218
6391
  throw error;
6219
6392
  }
6220
6393
  }
6221
- logger12.info(
6394
+ logger13.info(
6222
6395
  {},
6223
6396
  "DataComponents are project-scoped - skipping dataComponent creation in graph"
6224
6397
  );
6225
- logger12.info(
6398
+ logger13.info(
6226
6399
  {},
6227
6400
  "ArtifactComponents are project-scoped - skipping artifactComponent creation in graph"
6228
6401
  );
6229
6402
  const internalAgentPromises = Object.entries(typed.agents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([agentId, agentData]) => {
6230
6403
  const internalAgent = agentData;
6231
6404
  try {
6232
- logger12.info({ agentId }, "Processing internal agent");
6405
+ logger13.info({ agentId }, "Processing internal agent");
6233
6406
  await upsertAgent(db)({
6234
6407
  data: {
6235
6408
  id: agentId,
@@ -6244,9 +6417,9 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6244
6417
  stopWhen: internalAgent.stopWhen
6245
6418
  }
6246
6419
  });
6247
- logger12.info({ agentId }, "Internal agent processed successfully");
6420
+ logger13.info({ agentId }, "Internal agent processed successfully");
6248
6421
  } catch (error) {
6249
- logger12.error({ agentId, error }, "Failed to create/update internal agent");
6422
+ logger13.error({ agentId, error }, "Failed to create/update internal agent");
6250
6423
  throw error;
6251
6424
  }
6252
6425
  });
@@ -6254,11 +6427,11 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6254
6427
  const internalAgentCount = Object.entries(typed.agents).filter(
6255
6428
  ([_, agentData]) => isInternalAgent(agentData)
6256
6429
  ).length;
6257
- logger12.info({ internalAgentCount }, "All internal agents created/updated successfully");
6430
+ logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
6258
6431
  const externalAgentPromises = Object.entries(typed.agents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([agentId, agentData]) => {
6259
6432
  const externalAgent = agentData;
6260
6433
  try {
6261
- logger12.info({ agentId }, "Processing external agent");
6434
+ logger13.info({ agentId }, "Processing external agent");
6262
6435
  await upsertExternalAgent(db)({
6263
6436
  data: {
6264
6437
  id: agentId,
@@ -6272,9 +6445,9 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6272
6445
  headers: externalAgent.headers || void 0
6273
6446
  }
6274
6447
  });
6275
- logger12.info({ agentId }, "External agent processed successfully");
6448
+ logger13.info({ agentId }, "External agent processed successfully");
6276
6449
  } catch (error) {
6277
- logger12.error({ agentId, error }, "Failed to create/update external agent");
6450
+ logger13.error({ agentId, error }, "Failed to create/update external agent");
6278
6451
  throw error;
6279
6452
  }
6280
6453
  });
@@ -6282,10 +6455,10 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6282
6455
  const externalAgentCount = Object.entries(typed.agents).filter(
6283
6456
  ([_, agentData]) => isExternalAgent(agentData)
6284
6457
  ).length;
6285
- logger12.info({ externalAgentCount }, "All external agents created/updated successfully");
6458
+ logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
6286
6459
  if (contextConfigId) {
6287
6460
  try {
6288
- logger12.info(
6461
+ logger13.info(
6289
6462
  { graphId: finalGraphId, contextConfigId },
6290
6463
  "Updating graph with context config"
6291
6464
  );
@@ -6293,9 +6466,9 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6293
6466
  scopes: { tenantId, projectId, graphId: finalGraphId },
6294
6467
  data: { contextConfigId }
6295
6468
  });
6296
- logger12.info({ graphId: finalGraphId }, "Graph updated with context config");
6469
+ logger13.info({ graphId: finalGraphId }, "Graph updated with context config");
6297
6470
  } catch (error) {
6298
- logger12.error(
6471
+ logger13.error(
6299
6472
  { graphId: finalGraphId, error },
6300
6473
  "Failed to update graph with context config"
6301
6474
  );
@@ -6310,7 +6483,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6310
6483
  (async () => {
6311
6484
  try {
6312
6485
  const { toolId, toolSelection, headers, agentToolRelationId } = canUseItem;
6313
- logger12.info({ agentId, toolId }, "Processing agent-tool relation");
6486
+ logger13.info({ agentId, toolId }, "Processing agent-tool relation");
6314
6487
  await upsertAgentToolRelation(db)({
6315
6488
  scopes: { tenantId, projectId, graphId: finalGraphId },
6316
6489
  agentId,
@@ -6319,9 +6492,9 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6319
6492
  headers: headers || void 0,
6320
6493
  relationId: agentToolRelationId
6321
6494
  });
6322
- logger12.info({ agentId, toolId }, "Agent-tool relation processed successfully");
6495
+ logger13.info({ agentId, toolId }, "Agent-tool relation processed successfully");
6323
6496
  } catch (error) {
6324
- logger12.error(
6497
+ logger13.error(
6325
6498
  { agentId, toolId: canUseItem.toolId, error },
6326
6499
  "Failed to create agent-tool relation"
6327
6500
  );
@@ -6332,7 +6505,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6332
6505
  }
6333
6506
  }
6334
6507
  await Promise.all(agentToolPromises);
6335
- logger12.info(
6508
+ logger13.info(
6336
6509
  { agentToolCount: Object.keys(typed.agents).length },
6337
6510
  "All agent-tool relations created"
6338
6511
  );
@@ -6343,7 +6516,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6343
6516
  agentDataComponentPromises.push(
6344
6517
  (async () => {
6345
6518
  try {
6346
- logger12.info(
6519
+ logger13.info(
6347
6520
  { agentId, dataComponentId },
6348
6521
  "Processing agent-data component relation"
6349
6522
  );
@@ -6351,12 +6524,12 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6351
6524
  scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
6352
6525
  dataComponentId
6353
6526
  });
6354
- logger12.info(
6527
+ logger13.info(
6355
6528
  { agentId, dataComponentId },
6356
6529
  "Agent-data component relation processed successfully"
6357
6530
  );
6358
6531
  } catch (error) {
6359
- logger12.error(
6532
+ logger13.error(
6360
6533
  { agentId, dataComponentId, error },
6361
6534
  "Failed to create agent-data component relation"
6362
6535
  );
@@ -6367,7 +6540,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6367
6540
  }
6368
6541
  }
6369
6542
  await Promise.all(agentDataComponentPromises);
6370
- logger12.info({}, "All agent-data component relations created");
6543
+ logger13.info({}, "All agent-data component relations created");
6371
6544
  const agentArtifactComponentPromises = [];
6372
6545
  for (const [agentId, agentData] of Object.entries(typed.agents)) {
6373
6546
  if (isInternalAgent(agentData) && agentData.artifactComponents) {
@@ -6375,7 +6548,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6375
6548
  agentArtifactComponentPromises.push(
6376
6549
  (async () => {
6377
6550
  try {
6378
- logger12.info(
6551
+ logger13.info(
6379
6552
  { agentId, artifactComponentId },
6380
6553
  "Processing agent-artifact component relation"
6381
6554
  );
@@ -6383,12 +6556,12 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6383
6556
  scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
6384
6557
  artifactComponentId
6385
6558
  });
6386
- logger12.info(
6559
+ logger13.info(
6387
6560
  { agentId, artifactComponentId },
6388
6561
  "Agent-artifact component relation processed successfully"
6389
6562
  );
6390
6563
  } catch (error) {
6391
- logger12.error(
6564
+ logger13.error(
6392
6565
  { agentId, artifactComponentId, error },
6393
6566
  "Failed to create agent-artifact component relation"
6394
6567
  );
@@ -6399,7 +6572,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6399
6572
  }
6400
6573
  }
6401
6574
  await Promise.all(agentArtifactComponentPromises);
6402
- logger12.info({}, "All agent-artifact component relations created");
6575
+ logger13.info({}, "All agent-artifact component relations created");
6403
6576
  const agentRelationPromises = [];
6404
6577
  for (const [agentId, agentData] of Object.entries(typed.agents)) {
6405
6578
  if (isInternalAgent(agentData) && agentData.canTransferTo) {
@@ -6407,7 +6580,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6407
6580
  agentRelationPromises.push(
6408
6581
  (async () => {
6409
6582
  try {
6410
- logger12.info(
6583
+ logger13.info(
6411
6584
  { agentId, targetAgentId, type: "transfer" },
6412
6585
  "Processing agent transfer relation"
6413
6586
  );
@@ -6420,12 +6593,12 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6420
6593
  targetAgentId,
6421
6594
  relationType: "transfer"
6422
6595
  });
6423
- logger12.info(
6596
+ logger13.info(
6424
6597
  { agentId, targetAgentId, type: "transfer" },
6425
6598
  "Agent transfer relation processed successfully"
6426
6599
  );
6427
6600
  } catch (error) {
6428
- logger12.error(
6601
+ logger13.error(
6429
6602
  { agentId, targetAgentId, type: "transfer", error },
6430
6603
  "Failed to create transfer relation"
6431
6604
  );
@@ -6441,7 +6614,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6441
6614
  agentRelationPromises.push(
6442
6615
  (async () => {
6443
6616
  try {
6444
- logger12.info(
6617
+ logger13.info(
6445
6618
  { agentId, targetAgentId, type: "delegate" },
6446
6619
  "Processing agent delegation relation"
6447
6620
  );
@@ -6455,12 +6628,12 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6455
6628
  externalAgentId: isTargetExternal ? targetAgentId : void 0,
6456
6629
  relationType: "delegate"
6457
6630
  });
6458
- logger12.info(
6631
+ logger13.info(
6459
6632
  { agentId, targetAgentId, type: "delegate" },
6460
6633
  "Agent delegation relation processed successfully"
6461
6634
  );
6462
6635
  } catch (error) {
6463
- logger12.error(
6636
+ logger13.error(
6464
6637
  { agentId, targetAgentId, type: "delegate", error },
6465
6638
  "Failed to create delegation relation"
6466
6639
  );
@@ -6471,7 +6644,7 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6471
6644
  }
6472
6645
  }
6473
6646
  await Promise.all(agentRelationPromises);
6474
- logger12.info(
6647
+ logger13.info(
6475
6648
  { agentRelationCount: agentRelationPromises.length },
6476
6649
  "All agent relations created"
6477
6650
  );
@@ -6481,21 +6654,21 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6481
6654
  if (!createdGraph) {
6482
6655
  throw new Error("Failed to retrieve created graph");
6483
6656
  }
6484
- logger12.info({ tenantId, graphId: finalGraphId }, "Full graph created successfully");
6657
+ logger13.info({ tenantId, graphId: finalGraphId }, "Full graph created successfully");
6485
6658
  return createdGraph;
6486
6659
  } catch (error) {
6487
6660
  const errorGraphId = typed.id || "unknown";
6488
- logger12.error({ tenantId, graphId: errorGraphId, error }, "Failed to create full graph");
6661
+ logger13.error({ tenantId, graphId: errorGraphId, error }, "Failed to create full graph");
6489
6662
  throw error;
6490
6663
  }
6491
6664
  };
6492
- var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes, graphData) => {
6665
+ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes, graphData) => {
6493
6666
  const { tenantId, projectId } = scopes;
6494
6667
  const typedGraphDefinition = validateAndTypeGraphData(graphData);
6495
6668
  if (!typedGraphDefinition.id) {
6496
6669
  throw new Error("Graph ID is required");
6497
6670
  }
6498
- logger12.info(
6671
+ logger13.info(
6499
6672
  {
6500
6673
  tenantId,
6501
6674
  graphId: typedGraphDefinition.id,
@@ -6506,7 +6679,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6506
6679
  validateGraphStructure(typedGraphDefinition);
6507
6680
  await applyExecutionLimitsInheritance(
6508
6681
  db,
6509
- logger12,
6682
+ logger13,
6510
6683
  { tenantId, projectId },
6511
6684
  typedGraphDefinition
6512
6685
  );
@@ -6515,22 +6688,22 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6515
6688
  scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
6516
6689
  });
6517
6690
  if (!existingGraph) {
6518
- logger12.info(
6691
+ logger13.info(
6519
6692
  { graphId: typedGraphDefinition.id },
6520
6693
  "Graph does not exist, creating new graph"
6521
6694
  );
6522
6695
  return createFullGraphServerSide(db)(scopes, graphData);
6523
6696
  }
6524
6697
  const existingGraphModels = existingGraph.models;
6525
- logger12.info(
6698
+ logger13.info(
6526
6699
  {},
6527
6700
  "CredentialReferences are project-scoped - skipping credential reference update in graph"
6528
6701
  );
6529
- logger12.info({}, "Tools are project-scoped - skipping tool creation in graph update");
6702
+ logger13.info({}, "Tools are project-scoped - skipping tool creation in graph update");
6530
6703
  let finalGraphId;
6531
6704
  try {
6532
6705
  const graphId = typedGraphDefinition.id || nanoid.nanoid();
6533
- logger12.info({ graphId }, "Getting/creating agent graph metadata");
6706
+ logger13.info({ graphId }, "Getting/creating agent graph metadata");
6534
6707
  const agentGraph2 = await upsertAgentGraph(db)({
6535
6708
  data: {
6536
6709
  id: graphId,
@@ -6548,9 +6721,9 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6548
6721
  }
6549
6722
  });
6550
6723
  finalGraphId = agentGraph2.id;
6551
- logger12.info({ graphId: finalGraphId }, "Agent graph metadata ready");
6724
+ logger13.info({ graphId: finalGraphId }, "Agent graph metadata ready");
6552
6725
  } catch (error) {
6553
- logger12.error(
6726
+ logger13.error(
6554
6727
  { graphId: typedGraphDefinition.id, error },
6555
6728
  "Failed to get/update graph metadata"
6556
6729
  );
@@ -6558,7 +6731,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6558
6731
  }
6559
6732
  let contextConfigId;
6560
6733
  if (typedGraphDefinition.contextConfig) {
6561
- logger12.info(
6734
+ logger13.info(
6562
6735
  { contextConfigId: typedGraphDefinition.contextConfig?.id },
6563
6736
  " context config exists"
6564
6737
  );
@@ -6574,9 +6747,9 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6574
6747
  }
6575
6748
  });
6576
6749
  contextConfigId = contextConfig2.id;
6577
- logger12.info({ contextConfigId }, "Context config processed successfully");
6750
+ logger13.info({ contextConfigId }, "Context config processed successfully");
6578
6751
  } catch (error) {
6579
- logger12.error(
6752
+ logger13.error(
6580
6753
  { contextConfigId: typedGraphDefinition.contextConfig.id, error },
6581
6754
  "Failed to create/update context config"
6582
6755
  );
@@ -6585,7 +6758,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6585
6758
  }
6586
6759
  if (contextConfigId) {
6587
6760
  try {
6588
- logger12.info(
6761
+ logger13.info(
6589
6762
  { graphId: finalGraphId, contextConfigId },
6590
6763
  "Updating graph with contextConfigId"
6591
6764
  );
@@ -6604,20 +6777,20 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6604
6777
  stopWhen: typedGraphDefinition.stopWhen
6605
6778
  }
6606
6779
  });
6607
- logger12.info(
6780
+ logger13.info(
6608
6781
  { graphId: finalGraphId, contextConfigId },
6609
6782
  "Graph updated with contextConfigId successfully"
6610
6783
  );
6611
6784
  } catch (error) {
6612
- logger12.error(
6785
+ logger13.error(
6613
6786
  { graphId: finalGraphId, contextConfigId, error },
6614
6787
  "Failed to update graph with contextConfigId"
6615
6788
  );
6616
6789
  throw error;
6617
6790
  }
6618
6791
  }
6619
- logger12.info({}, "DataComponents are project-scoped - skipping dataComponent update in graph");
6620
- logger12.info(
6792
+ logger13.info({}, "DataComponents are project-scoped - skipping dataComponent update in graph");
6793
+ logger13.info(
6621
6794
  {},
6622
6795
  "ArtifactComponents are project-scoped - skipping artifactComponent update in graph"
6623
6796
  );
@@ -6648,7 +6821,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6648
6821
  (graphModels[modelType].model !== existingGraphModels[modelType].model || // OR providerOptions changed
6649
6822
  JSON.stringify(graphModels[modelType].providerOptions) !== JSON.stringify(existingGraphModels[modelType].providerOptions))) {
6650
6823
  cascadedModels[modelType] = graphModels[modelType];
6651
- logger12.info(
6824
+ logger13.info(
6652
6825
  {
6653
6826
  agentId,
6654
6827
  modelType,
@@ -6663,7 +6836,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6663
6836
  finalModelSettings = cascadedModels;
6664
6837
  }
6665
6838
  try {
6666
- logger12.info({ agentId }, "Processing internal agent");
6839
+ logger13.info({ agentId }, "Processing internal agent");
6667
6840
  await upsertAgent(db)({
6668
6841
  data: {
6669
6842
  id: agentId,
@@ -6678,9 +6851,9 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6678
6851
  stopWhen: internalAgent.stopWhen
6679
6852
  }
6680
6853
  });
6681
- logger12.info({ agentId }, "Internal agent processed successfully");
6854
+ logger13.info({ agentId }, "Internal agent processed successfully");
6682
6855
  } catch (error) {
6683
- logger12.error({ agentId, error }, "Failed to create/update internal agent");
6856
+ logger13.error({ agentId, error }, "Failed to create/update internal agent");
6684
6857
  throw error;
6685
6858
  }
6686
6859
  });
@@ -6688,11 +6861,11 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6688
6861
  const internalAgentCount = Object.entries(typedGraphDefinition.agents).filter(
6689
6862
  ([_, agentData]) => isInternalAgent(agentData)
6690
6863
  ).length;
6691
- logger12.info({ internalAgentCount }, "All internal agents created/updated successfully");
6864
+ logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
6692
6865
  const externalAgentPromises = Object.entries(typedGraphDefinition.agents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([agentId, agentData]) => {
6693
6866
  const externalAgent = agentData;
6694
6867
  try {
6695
- logger12.info({ agentId }, "Processing external agent");
6868
+ logger13.info({ agentId }, "Processing external agent");
6696
6869
  await upsertExternalAgent(db)({
6697
6870
  data: {
6698
6871
  id: agentId,
@@ -6706,9 +6879,9 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6706
6879
  headers: externalAgent.headers || void 0
6707
6880
  }
6708
6881
  });
6709
- logger12.info({ agentId }, "External agent processed successfully");
6882
+ logger13.info({ agentId }, "External agent processed successfully");
6710
6883
  } catch (error) {
6711
- logger12.error({ agentId, error }, "Failed to create/update external agent");
6884
+ logger13.error({ agentId, error }, "Failed to create/update external agent");
6712
6885
  throw error;
6713
6886
  }
6714
6887
  });
@@ -6716,7 +6889,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6716
6889
  const externalAgentCount = Object.entries(typedGraphDefinition.agents).filter(
6717
6890
  ([_, agentData]) => isExternalAgent(agentData)
6718
6891
  ).length;
6719
- logger12.info({ externalAgentCount }, "All external agents created/updated successfully");
6892
+ logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
6720
6893
  const incomingAgentIds = new Set(Object.keys(typedGraphDefinition.agents));
6721
6894
  const existingInternalAgents = await listAgents(db)({
6722
6895
  scopes: { tenantId, projectId, graphId: finalGraphId }
@@ -6733,9 +6906,9 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6733
6906
  agentId: agent.id
6734
6907
  });
6735
6908
  deletedInternalCount++;
6736
- logger12.info({ agentId: agent.id }, "Deleted orphaned internal agent");
6909
+ logger13.info({ agentId: agent.id }, "Deleted orphaned internal agent");
6737
6910
  } catch (error) {
6738
- logger12.error({ agentId: agent.id, error }, "Failed to delete orphaned internal agent");
6911
+ logger13.error({ agentId: agent.id, error }, "Failed to delete orphaned internal agent");
6739
6912
  }
6740
6913
  }
6741
6914
  }
@@ -6748,14 +6921,14 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6748
6921
  agentId: agent.id
6749
6922
  });
6750
6923
  deletedExternalCount++;
6751
- logger12.info({ agentId: agent.id }, "Deleted orphaned external agent");
6924
+ logger13.info({ agentId: agent.id }, "Deleted orphaned external agent");
6752
6925
  } catch (error) {
6753
- logger12.error({ agentId: agent.id, error }, "Failed to delete orphaned external agent");
6926
+ logger13.error({ agentId: agent.id, error }, "Failed to delete orphaned external agent");
6754
6927
  }
6755
6928
  }
6756
6929
  }
6757
6930
  if (deletedInternalCount > 0 || deletedExternalCount > 0) {
6758
- logger12.info(
6931
+ logger13.info(
6759
6932
  {
6760
6933
  deletedInternalCount,
6761
6934
  deletedExternalCount,
@@ -6777,7 +6950,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6777
6950
  stopWhen: typedGraphDefinition.stopWhen
6778
6951
  }
6779
6952
  });
6780
- logger12.info({ graphId: typedGraphDefinition.id }, "Graph metadata updated");
6953
+ logger13.info({ graphId: typedGraphDefinition.id }, "Graph metadata updated");
6781
6954
  const incomingRelationshipIds = /* @__PURE__ */ new Set();
6782
6955
  for (const [_agentId, agentData] of Object.entries(typedGraphDefinition.agents)) {
6783
6956
  if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
@@ -6814,10 +6987,10 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6814
6987
  deletedCount = result.rowsAffected || 0;
6815
6988
  }
6816
6989
  if (deletedCount > 0) {
6817
- logger12.info({ agentId, deletedCount }, "Deleted orphaned agent-tool relations");
6990
+ logger13.info({ agentId, deletedCount }, "Deleted orphaned agent-tool relations");
6818
6991
  }
6819
6992
  } catch (error) {
6820
- logger12.error({ agentId, error }, "Failed to delete orphaned agent-tool relations");
6993
+ logger13.error({ agentId, error }, "Failed to delete orphaned agent-tool relations");
6821
6994
  }
6822
6995
  }
6823
6996
  const agentToolPromises = [];
@@ -6836,12 +7009,12 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6836
7009
  headers: headers || void 0,
6837
7010
  relationId: agentToolRelationId
6838
7011
  });
6839
- logger12.info(
7012
+ logger13.info(
6840
7013
  { agentId, toolId, relationId: agentToolRelationId },
6841
7014
  "Agent-tool relation upserted"
6842
7015
  );
6843
7016
  } catch (error) {
6844
- logger12.error(
7017
+ logger13.error(
6845
7018
  {
6846
7019
  agentId,
6847
7020
  toolId: canUseItem.toolId,
@@ -6857,7 +7030,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6857
7030
  }
6858
7031
  }
6859
7032
  await Promise.all(agentToolPromises);
6860
- logger12.info(
7033
+ logger13.info(
6861
7034
  { agentToolPromisesCount: agentToolPromises.length },
6862
7035
  "All agent-tool relations updated"
6863
7036
  );
@@ -6877,9 +7050,9 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6877
7050
  scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
6878
7051
  dataComponentId
6879
7052
  });
6880
- logger12.info({ agentId, dataComponentId }, "Agent-dataComponent relation created");
7053
+ logger13.info({ agentId, dataComponentId }, "Agent-dataComponent relation created");
6881
7054
  } catch (error) {
6882
- logger12.error(
7055
+ logger13.error(
6883
7056
  { agentId, dataComponentId, error },
6884
7057
  "Failed to create agent-dataComponent relation"
6885
7058
  );
@@ -6890,7 +7063,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6890
7063
  }
6891
7064
  }
6892
7065
  await Promise.all(agentDataComponentPromises);
6893
- logger12.info(
7066
+ logger13.info(
6894
7067
  { agentDataComponentPromisesCount: agentDataComponentPromises.length },
6895
7068
  "All agent-dataComponent relations updated"
6896
7069
  );
@@ -6910,12 +7083,12 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6910
7083
  scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
6911
7084
  artifactComponentId
6912
7085
  });
6913
- logger12.info(
7086
+ logger13.info(
6914
7087
  { agentId, artifactComponentId },
6915
7088
  "Agent-artifactComponent relation created"
6916
7089
  );
6917
7090
  } catch (error) {
6918
- logger12.error(
7091
+ logger13.error(
6919
7092
  { agentId, artifactComponentId, error },
6920
7093
  "Failed to create agent-artifactComponent relation"
6921
7094
  );
@@ -6926,7 +7099,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6926
7099
  }
6927
7100
  }
6928
7101
  await Promise.all(agentArtifactComponentPromises);
6929
- logger12.info(
7102
+ logger13.info(
6930
7103
  { agentArtifactComponentPromisesCount: agentArtifactComponentPromises.length },
6931
7104
  "All agent-artifactComponent relations updated"
6932
7105
  );
@@ -6955,12 +7128,12 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6955
7128
  projectId,
6956
7129
  ...relationData
6957
7130
  });
6958
- logger12.info(
7131
+ logger13.info(
6959
7132
  { agentId, targetAgentId, isTargetExternal },
6960
7133
  "Transfer relation created"
6961
7134
  );
6962
7135
  } catch (error) {
6963
- logger12.error(
7136
+ logger13.error(
6964
7137
  { agentId, targetAgentId, error },
6965
7138
  "Failed to create transfer relation"
6966
7139
  );
@@ -6989,9 +7162,9 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6989
7162
  projectId,
6990
7163
  ...relationData
6991
7164
  });
6992
- logger12.info({ agentId, targetAgentId }, "Delegation relation created");
7165
+ logger13.info({ agentId, targetAgentId }, "Delegation relation created");
6993
7166
  } catch (error) {
6994
- logger12.error(
7167
+ logger13.error(
6995
7168
  { agentId, targetAgentId, error },
6996
7169
  "Failed to create delegation relation"
6997
7170
  );
@@ -7002,7 +7175,7 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
7002
7175
  }
7003
7176
  }
7004
7177
  await Promise.all(agentRelationPromises);
7005
- logger12.info(
7178
+ logger13.info(
7006
7179
  { agentRelationPromisesCount: agentRelationPromises.length },
7007
7180
  "All agent relations updated"
7008
7181
  );
@@ -7012,26 +7185,26 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
7012
7185
  if (!updatedGraph) {
7013
7186
  throw new Error("Failed to retrieve updated graph");
7014
7187
  }
7015
- logger12.info({ graphId: typedGraphDefinition.id }, "Full graph updated successfully");
7188
+ logger13.info({ graphId: typedGraphDefinition.id }, "Full graph updated successfully");
7016
7189
  return updatedGraph;
7017
7190
  } catch (error) {
7018
- logger12.error({ graphId: typedGraphDefinition.id, error }, "Failed to update full graph");
7191
+ logger13.error({ graphId: typedGraphDefinition.id, error }, "Failed to update full graph");
7019
7192
  throw error;
7020
7193
  }
7021
7194
  };
7022
- var getFullGraph = (db, logger12 = defaultLogger) => async (params) => {
7195
+ var getFullGraph = (db, logger13 = defaultLogger) => async (params) => {
7023
7196
  const { scopes } = params;
7024
7197
  const { tenantId, projectId } = scopes;
7025
- logger12.info({ tenantId, graphId: scopes.graphId }, "Retrieving full graph definition");
7198
+ logger13.info({ tenantId, graphId: scopes.graphId }, "Retrieving full graph definition");
7026
7199
  try {
7027
7200
  const graph = await getFullGraphDefinition(db)({
7028
7201
  scopes: { tenantId, projectId, graphId: scopes.graphId }
7029
7202
  });
7030
7203
  if (!graph) {
7031
- logger12.info({ tenantId, graphId: scopes.graphId }, "Graph not found");
7204
+ logger13.info({ tenantId, graphId: scopes.graphId }, "Graph not found");
7032
7205
  return null;
7033
7206
  }
7034
- logger12.info(
7207
+ logger13.info(
7035
7208
  {
7036
7209
  tenantId,
7037
7210
  graphId: scopes.graphId,
@@ -7041,7 +7214,7 @@ var getFullGraph = (db, logger12 = defaultLogger) => async (params) => {
7041
7214
  );
7042
7215
  return graph;
7043
7216
  } catch (error) {
7044
- logger12.error(
7217
+ logger13.error(
7045
7218
  {
7046
7219
  tenantId,
7047
7220
  graphId: scopes.graphId,
@@ -7052,21 +7225,21 @@ var getFullGraph = (db, logger12 = defaultLogger) => async (params) => {
7052
7225
  throw error;
7053
7226
  }
7054
7227
  };
7055
- var deleteFullGraph = (db, logger12 = defaultLogger) => async (params) => {
7228
+ var deleteFullGraph = (db, logger13 = defaultLogger) => async (params) => {
7056
7229
  const { tenantId, projectId, graphId } = params.scopes;
7057
- logger12.info({ tenantId, graphId }, "Deleting full graph and related entities");
7230
+ logger13.info({ tenantId, graphId }, "Deleting full graph and related entities");
7058
7231
  try {
7059
7232
  const graph = await getFullGraphDefinition(db)({
7060
7233
  scopes: { tenantId, projectId, graphId }
7061
7234
  });
7062
7235
  if (!graph) {
7063
- logger12.info({ tenantId, graphId }, "Graph not found for deletion");
7236
+ logger13.info({ tenantId, graphId }, "Graph not found for deletion");
7064
7237
  return false;
7065
7238
  }
7066
7239
  await deleteAgentRelationsByGraph(db)({
7067
7240
  scopes: { tenantId, projectId, graphId }
7068
7241
  });
7069
- logger12.info({ tenantId, graphId }, "Agent relations deleted");
7242
+ logger13.info({ tenantId, graphId }, "Agent relations deleted");
7070
7243
  const agentIds = Object.keys(graph.agents);
7071
7244
  if (agentIds.length > 0) {
7072
7245
  for (const agentId of agentIds) {
@@ -7074,7 +7247,7 @@ var deleteFullGraph = (db, logger12 = defaultLogger) => async (params) => {
7074
7247
  scopes: { tenantId, projectId, graphId, agentId }
7075
7248
  });
7076
7249
  }
7077
- logger12.info(
7250
+ logger13.info(
7078
7251
  { tenantId, graphId, agentCount: agentIds.length },
7079
7252
  "Agent-tool relations deleted"
7080
7253
  );
@@ -7082,11 +7255,11 @@ var deleteFullGraph = (db, logger12 = defaultLogger) => async (params) => {
7082
7255
  await deleteAgentGraph(db)({
7083
7256
  scopes: { tenantId, projectId, graphId }
7084
7257
  });
7085
- logger12.info({ tenantId, graphId }, "Graph metadata deleted");
7086
- logger12.info({ tenantId, graphId }, "Full graph deleted successfully");
7258
+ logger13.info({ tenantId, graphId }, "Graph metadata deleted");
7259
+ logger13.info({ tenantId, graphId }, "Full graph deleted successfully");
7087
7260
  return true;
7088
7261
  } catch (error) {
7089
- logger12.error(
7262
+ logger13.error(
7090
7263
  {
7091
7264
  tenantId,
7092
7265
  graphId,
@@ -7676,10 +7849,10 @@ var defaultLogger2 = getLogger("projectFull");
7676
7849
  function validateAndTypeProjectData(projectData) {
7677
7850
  return projectData;
7678
7851
  }
7679
- var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scopes, projectData) => {
7852
+ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scopes, projectData) => {
7680
7853
  const { tenantId } = scopes;
7681
7854
  const typed = validateAndTypeProjectData(projectData);
7682
- logger12.info(
7855
+ logger13.info(
7683
7856
  {
7684
7857
  tenantId,
7685
7858
  projectId: typed.id,
@@ -7698,11 +7871,11 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7698
7871
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7699
7872
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
7700
7873
  };
7701
- logger12.info({ projectId: typed.id }, "Creating project metadata");
7874
+ logger13.info({ projectId: typed.id }, "Creating project metadata");
7702
7875
  await createProject(db)(projectPayload);
7703
- logger12.info({ projectId: typed.id }, "Project metadata created successfully");
7876
+ logger13.info({ projectId: typed.id }, "Project metadata created successfully");
7704
7877
  if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
7705
- logger12.info(
7878
+ logger13.info(
7706
7879
  {
7707
7880
  projectId: typed.id,
7708
7881
  count: Object.keys(typed.credentialReferences).length
@@ -7712,7 +7885,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7712
7885
  const credentialPromises = Object.entries(typed.credentialReferences).map(
7713
7886
  async ([_credId, credData]) => {
7714
7887
  try {
7715
- logger12.info(
7888
+ logger13.info(
7716
7889
  { projectId: typed.id, credId: credData.id },
7717
7890
  "Creating credentialReference in project"
7718
7891
  );
@@ -7723,12 +7896,12 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7723
7896
  projectId: typed.id
7724
7897
  }
7725
7898
  });
7726
- logger12.info(
7899
+ logger13.info(
7727
7900
  { projectId: typed.id, credId: credData.id },
7728
7901
  "CredentialReference created successfully"
7729
7902
  );
7730
7903
  } catch (error) {
7731
- logger12.error(
7904
+ logger13.error(
7732
7905
  { projectId: typed.id, credId: credData.id, error },
7733
7906
  "Failed to create credentialReference in project"
7734
7907
  );
@@ -7737,7 +7910,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7737
7910
  }
7738
7911
  );
7739
7912
  await Promise.all(credentialPromises);
7740
- logger12.info(
7913
+ logger13.info(
7741
7914
  {
7742
7915
  projectId: typed.id,
7743
7916
  count: Object.keys(typed.credentialReferences).length
@@ -7746,7 +7919,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7746
7919
  );
7747
7920
  }
7748
7921
  if (typed.tools && Object.keys(typed.tools).length > 0) {
7749
- logger12.info(
7922
+ logger13.info(
7750
7923
  {
7751
7924
  projectId: typed.id,
7752
7925
  toolCount: Object.keys(typed.tools).length
@@ -7755,7 +7928,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7755
7928
  );
7756
7929
  const toolPromises = Object.entries(typed.tools).map(async ([toolId, toolData]) => {
7757
7930
  try {
7758
- logger12.info({ projectId: typed.id, toolId }, "Creating tool in project");
7931
+ logger13.info({ projectId: typed.id, toolId }, "Creating tool in project");
7759
7932
  await upsertTool(db)({
7760
7933
  data: {
7761
7934
  tenantId,
@@ -7763,9 +7936,9 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7763
7936
  ...toolData
7764
7937
  }
7765
7938
  });
7766
- logger12.info({ projectId: typed.id, toolId }, "Tool created successfully");
7939
+ logger13.info({ projectId: typed.id, toolId }, "Tool created successfully");
7767
7940
  } catch (error) {
7768
- logger12.error(
7941
+ logger13.error(
7769
7942
  { projectId: typed.id, toolId, error },
7770
7943
  "Failed to create tool in project"
7771
7944
  );
@@ -7773,7 +7946,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7773
7946
  }
7774
7947
  });
7775
7948
  await Promise.all(toolPromises);
7776
- logger12.info(
7949
+ logger13.info(
7777
7950
  {
7778
7951
  projectId: typed.id,
7779
7952
  toolCount: Object.keys(typed.tools).length
@@ -7782,7 +7955,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7782
7955
  );
7783
7956
  }
7784
7957
  if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
7785
- logger12.info(
7958
+ logger13.info(
7786
7959
  {
7787
7960
  projectId: typed.id,
7788
7961
  count: Object.keys(typed.dataComponents).length
@@ -7792,7 +7965,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7792
7965
  const dataComponentPromises = Object.entries(typed.dataComponents).map(
7793
7966
  async ([componentId, componentData]) => {
7794
7967
  try {
7795
- logger12.info(
7968
+ logger13.info(
7796
7969
  { projectId: typed.id, componentId },
7797
7970
  "Creating dataComponent in project"
7798
7971
  );
@@ -7803,12 +7976,12 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7803
7976
  projectId: typed.id
7804
7977
  }
7805
7978
  });
7806
- logger12.info(
7979
+ logger13.info(
7807
7980
  { projectId: typed.id, componentId },
7808
7981
  "DataComponent created successfully"
7809
7982
  );
7810
7983
  } catch (error) {
7811
- logger12.error(
7984
+ logger13.error(
7812
7985
  { projectId: typed.id, componentId, error },
7813
7986
  "Failed to create dataComponent in project"
7814
7987
  );
@@ -7817,7 +7990,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7817
7990
  }
7818
7991
  );
7819
7992
  await Promise.all(dataComponentPromises);
7820
- logger12.info(
7993
+ logger13.info(
7821
7994
  {
7822
7995
  projectId: typed.id,
7823
7996
  count: Object.keys(typed.dataComponents).length
@@ -7826,7 +7999,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7826
7999
  );
7827
8000
  }
7828
8001
  if (typed.artifactComponents && Object.keys(typed.artifactComponents).length > 0) {
7829
- logger12.info(
8002
+ logger13.info(
7830
8003
  {
7831
8004
  projectId: typed.id,
7832
8005
  count: Object.keys(typed.artifactComponents).length
@@ -7836,7 +8009,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7836
8009
  const artifactComponentPromises = Object.entries(typed.artifactComponents).map(
7837
8010
  async ([componentId, componentData]) => {
7838
8011
  try {
7839
- logger12.info(
8012
+ logger13.info(
7840
8013
  { projectId: typed.id, componentId },
7841
8014
  "Creating artifactComponent in project"
7842
8015
  );
@@ -7847,12 +8020,12 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7847
8020
  projectId: typed.id
7848
8021
  }
7849
8022
  });
7850
- logger12.info(
8023
+ logger13.info(
7851
8024
  { projectId: typed.id, componentId },
7852
8025
  "ArtifactComponent created successfully"
7853
8026
  );
7854
8027
  } catch (error) {
7855
- logger12.error(
8028
+ logger13.error(
7856
8029
  { projectId: typed.id, componentId, error },
7857
8030
  "Failed to create artifactComponent in project"
7858
8031
  );
@@ -7861,7 +8034,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7861
8034
  }
7862
8035
  );
7863
8036
  await Promise.all(artifactComponentPromises);
7864
- logger12.info(
8037
+ logger13.info(
7865
8038
  {
7866
8039
  projectId: typed.id,
7867
8040
  count: Object.keys(typed.artifactComponents).length
@@ -7870,7 +8043,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7870
8043
  );
7871
8044
  }
7872
8045
  if (typed.graphs && Object.keys(typed.graphs).length > 0) {
7873
- logger12.info(
8046
+ logger13.info(
7874
8047
  {
7875
8048
  projectId: typed.id,
7876
8049
  graphCount: Object.keys(typed.graphs).length
@@ -7879,7 +8052,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7879
8052
  );
7880
8053
  const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
7881
8054
  try {
7882
- logger12.info({ projectId: typed.id, graphId }, "Creating graph in project");
8055
+ logger13.info({ projectId: typed.id, graphId }, "Creating graph in project");
7883
8056
  const graphDataWithProjectResources = {
7884
8057
  ...graphData,
7885
8058
  tools: typed.tools || {},
@@ -7889,13 +8062,13 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7889
8062
  credentialReferences: typed.credentialReferences || {},
7890
8063
  statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
7891
8064
  };
7892
- await createFullGraphServerSide(db, logger12)(
8065
+ await createFullGraphServerSide(db, logger13)(
7893
8066
  { tenantId, projectId: typed.id },
7894
8067
  graphDataWithProjectResources
7895
8068
  );
7896
- logger12.info({ projectId: typed.id, graphId }, "Graph created successfully in project");
8069
+ logger13.info({ projectId: typed.id, graphId }, "Graph created successfully in project");
7897
8070
  } catch (error) {
7898
- logger12.error(
8071
+ logger13.error(
7899
8072
  { projectId: typed.id, graphId, error },
7900
8073
  "Failed to create graph in project"
7901
8074
  );
@@ -7903,7 +8076,7 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7903
8076
  }
7904
8077
  });
7905
8078
  await Promise.all(graphPromises);
7906
- logger12.info(
8079
+ logger13.info(
7907
8080
  {
7908
8081
  projectId: typed.id,
7909
8082
  graphCount: Object.keys(typed.graphs).length
@@ -7911,15 +8084,15 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7911
8084
  "All project graphs created successfully"
7912
8085
  );
7913
8086
  }
7914
- logger12.info({ projectId: typed.id }, "Full project created successfully");
8087
+ logger13.info({ projectId: typed.id }, "Full project created successfully");
7915
8088
  return await getFullProject(
7916
8089
  db,
7917
- logger12
8090
+ logger13
7918
8091
  )({
7919
8092
  scopes: { tenantId, projectId: typed.id }
7920
8093
  });
7921
8094
  } catch (error) {
7922
- logger12.error(
8095
+ logger13.error(
7923
8096
  {
7924
8097
  tenantId,
7925
8098
  projectId: typed.id,
@@ -7930,13 +8103,13 @@ var createFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7930
8103
  throw error;
7931
8104
  }
7932
8105
  };
7933
- var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scopes, projectData) => {
8106
+ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scopes, projectData) => {
7934
8107
  const { tenantId } = scopes;
7935
8108
  const typed = validateAndTypeProjectData(projectData);
7936
8109
  if (!typed.id) {
7937
8110
  throw new Error("Project ID is required");
7938
8111
  }
7939
- logger12.info(
8112
+ logger13.info(
7940
8113
  {
7941
8114
  tenantId,
7942
8115
  projectId: typed.id,
@@ -7949,8 +8122,8 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7949
8122
  scopes: { tenantId, projectId: typed.id }
7950
8123
  });
7951
8124
  if (!existingProject) {
7952
- logger12.info({ projectId: typed.id }, "Project not found, creating new project");
7953
- return await createFullProjectServerSide(db, logger12)(
8125
+ logger13.info({ projectId: typed.id }, "Project not found, creating new project");
8126
+ return await createFullProjectServerSide(db, logger13)(
7954
8127
  { tenantId, projectId: typed.id },
7955
8128
  projectData
7956
8129
  );
@@ -7961,14 +8134,14 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7961
8134
  models: typed.models,
7962
8135
  stopWhen: typed.stopWhen
7963
8136
  };
7964
- logger12.info({ projectId: typed.id }, "Updating project metadata");
8137
+ logger13.info({ projectId: typed.id }, "Updating project metadata");
7965
8138
  await updateProject(db)({
7966
8139
  scopes: { tenantId, projectId: typed.id },
7967
8140
  data: projectUpdatePayload
7968
8141
  });
7969
- logger12.info({ projectId: typed.id }, "Project metadata updated successfully");
8142
+ logger13.info({ projectId: typed.id }, "Project metadata updated successfully");
7970
8143
  if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
7971
- logger12.info(
8144
+ logger13.info(
7972
8145
  {
7973
8146
  projectId: typed.id,
7974
8147
  count: Object.keys(typed.credentialReferences).length
@@ -7978,7 +8151,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7978
8151
  const credentialPromises = Object.entries(typed.credentialReferences).map(
7979
8152
  async ([_credId, credData]) => {
7980
8153
  try {
7981
- logger12.info(
8154
+ logger13.info(
7982
8155
  { projectId: typed.id, credId: credData.id },
7983
8156
  "Updating credentialReference in project"
7984
8157
  );
@@ -7989,12 +8162,12 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
7989
8162
  projectId: typed.id
7990
8163
  }
7991
8164
  });
7992
- logger12.info(
8165
+ logger13.info(
7993
8166
  { projectId: typed.id, credId: credData.id },
7994
8167
  "CredentialReference updated successfully"
7995
8168
  );
7996
8169
  } catch (error) {
7997
- logger12.error(
8170
+ logger13.error(
7998
8171
  { projectId: typed.id, credId: credData.id, error },
7999
8172
  "Failed to update credentialReference in project"
8000
8173
  );
@@ -8003,7 +8176,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8003
8176
  }
8004
8177
  );
8005
8178
  await Promise.all(credentialPromises);
8006
- logger12.info(
8179
+ logger13.info(
8007
8180
  {
8008
8181
  projectId: typed.id,
8009
8182
  count: Object.keys(typed.credentialReferences).length
@@ -8012,7 +8185,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8012
8185
  );
8013
8186
  }
8014
8187
  if (typed.tools && Object.keys(typed.tools).length > 0) {
8015
- logger12.info(
8188
+ logger13.info(
8016
8189
  {
8017
8190
  projectId: typed.id,
8018
8191
  toolCount: Object.keys(typed.tools).length
@@ -8021,7 +8194,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8021
8194
  );
8022
8195
  const toolPromises = Object.entries(typed.tools).map(async ([toolId, toolData]) => {
8023
8196
  try {
8024
- logger12.info({ projectId: typed.id, toolId }, "Updating tool in project");
8197
+ logger13.info({ projectId: typed.id, toolId }, "Updating tool in project");
8025
8198
  await upsertTool(db)({
8026
8199
  data: {
8027
8200
  tenantId,
@@ -8029,9 +8202,9 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8029
8202
  ...toolData
8030
8203
  }
8031
8204
  });
8032
- logger12.info({ projectId: typed.id, toolId }, "Tool updated successfully");
8205
+ logger13.info({ projectId: typed.id, toolId }, "Tool updated successfully");
8033
8206
  } catch (error) {
8034
- logger12.error(
8207
+ logger13.error(
8035
8208
  { projectId: typed.id, toolId, error },
8036
8209
  "Failed to update tool in project"
8037
8210
  );
@@ -8039,7 +8212,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8039
8212
  }
8040
8213
  });
8041
8214
  await Promise.all(toolPromises);
8042
- logger12.info(
8215
+ logger13.info(
8043
8216
  {
8044
8217
  projectId: typed.id,
8045
8218
  toolCount: Object.keys(typed.tools).length
@@ -8048,7 +8221,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8048
8221
  );
8049
8222
  }
8050
8223
  if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
8051
- logger12.info(
8224
+ logger13.info(
8052
8225
  {
8053
8226
  projectId: typed.id,
8054
8227
  count: Object.keys(typed.dataComponents).length
@@ -8058,7 +8231,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8058
8231
  const dataComponentPromises = Object.entries(typed.dataComponents).map(
8059
8232
  async ([componentId, componentData]) => {
8060
8233
  try {
8061
- logger12.info(
8234
+ logger13.info(
8062
8235
  { projectId: typed.id, componentId },
8063
8236
  "Updating dataComponent in project"
8064
8237
  );
@@ -8069,12 +8242,12 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8069
8242
  projectId: typed.id
8070
8243
  }
8071
8244
  });
8072
- logger12.info(
8245
+ logger13.info(
8073
8246
  { projectId: typed.id, componentId },
8074
8247
  "DataComponent updated successfully"
8075
8248
  );
8076
8249
  } catch (error) {
8077
- logger12.error(
8250
+ logger13.error(
8078
8251
  { projectId: typed.id, componentId, error },
8079
8252
  "Failed to update dataComponent in project"
8080
8253
  );
@@ -8083,7 +8256,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8083
8256
  }
8084
8257
  );
8085
8258
  await Promise.all(dataComponentPromises);
8086
- logger12.info(
8259
+ logger13.info(
8087
8260
  {
8088
8261
  projectId: typed.id,
8089
8262
  count: Object.keys(typed.dataComponents).length
@@ -8092,7 +8265,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8092
8265
  );
8093
8266
  }
8094
8267
  if (typed.artifactComponents && Object.keys(typed.artifactComponents).length > 0) {
8095
- logger12.info(
8268
+ logger13.info(
8096
8269
  {
8097
8270
  projectId: typed.id,
8098
8271
  count: Object.keys(typed.artifactComponents).length
@@ -8102,7 +8275,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8102
8275
  const artifactComponentPromises = Object.entries(typed.artifactComponents).map(
8103
8276
  async ([componentId, componentData]) => {
8104
8277
  try {
8105
- logger12.info(
8278
+ logger13.info(
8106
8279
  { projectId: typed.id, componentId },
8107
8280
  "Updating artifactComponent in project"
8108
8281
  );
@@ -8113,12 +8286,12 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8113
8286
  projectId: typed.id
8114
8287
  }
8115
8288
  });
8116
- logger12.info(
8289
+ logger13.info(
8117
8290
  { projectId: typed.id, componentId },
8118
8291
  "ArtifactComponent updated successfully"
8119
8292
  );
8120
8293
  } catch (error) {
8121
- logger12.error(
8294
+ logger13.error(
8122
8295
  { projectId: typed.id, componentId, error },
8123
8296
  "Failed to update artifactComponent in project"
8124
8297
  );
@@ -8127,7 +8300,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8127
8300
  }
8128
8301
  );
8129
8302
  await Promise.all(artifactComponentPromises);
8130
- logger12.info(
8303
+ logger13.info(
8131
8304
  {
8132
8305
  projectId: typed.id,
8133
8306
  count: Object.keys(typed.artifactComponents).length
@@ -8145,14 +8318,14 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8145
8318
  try {
8146
8319
  await deleteFullGraph(
8147
8320
  db,
8148
- logger12
8321
+ logger13
8149
8322
  )({
8150
8323
  scopes: { tenantId, projectId: typed.id, graphId: graph.id }
8151
8324
  });
8152
8325
  deletedGraphCount++;
8153
- logger12.info({ graphId: graph.id }, "Deleted orphaned graph from project");
8326
+ logger13.info({ graphId: graph.id }, "Deleted orphaned graph from project");
8154
8327
  } catch (error) {
8155
- logger12.error(
8328
+ logger13.error(
8156
8329
  { graphId: graph.id, error },
8157
8330
  "Failed to delete orphaned graph from project"
8158
8331
  );
@@ -8160,7 +8333,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8160
8333
  }
8161
8334
  }
8162
8335
  if (deletedGraphCount > 0) {
8163
- logger12.info(
8336
+ logger13.info(
8164
8337
  {
8165
8338
  deletedGraphCount,
8166
8339
  projectId: typed.id
@@ -8169,7 +8342,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8169
8342
  );
8170
8343
  }
8171
8344
  if (typed.graphs && Object.keys(typed.graphs).length > 0) {
8172
- logger12.info(
8345
+ logger13.info(
8173
8346
  {
8174
8347
  projectId: typed.id,
8175
8348
  graphCount: Object.keys(typed.graphs).length
@@ -8178,7 +8351,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8178
8351
  );
8179
8352
  const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
8180
8353
  try {
8181
- logger12.info({ projectId: typed.id, graphId }, "Updating graph in project");
8354
+ logger13.info({ projectId: typed.id, graphId }, "Updating graph in project");
8182
8355
  const graphDataWithProjectResources = {
8183
8356
  ...graphData,
8184
8357
  tools: typed.tools || {},
@@ -8188,13 +8361,13 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8188
8361
  credentialReferences: typed.credentialReferences || {},
8189
8362
  statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
8190
8363
  };
8191
- await updateFullGraphServerSide(db, logger12)(
8364
+ await updateFullGraphServerSide(db, logger13)(
8192
8365
  { tenantId, projectId: typed.id },
8193
8366
  graphDataWithProjectResources
8194
8367
  );
8195
- logger12.info({ projectId: typed.id, graphId }, "Graph updated successfully in project");
8368
+ logger13.info({ projectId: typed.id, graphId }, "Graph updated successfully in project");
8196
8369
  } catch (error) {
8197
- logger12.error(
8370
+ logger13.error(
8198
8371
  { projectId: typed.id, graphId, error },
8199
8372
  "Failed to update graph in project"
8200
8373
  );
@@ -8202,7 +8375,7 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8202
8375
  }
8203
8376
  });
8204
8377
  await Promise.all(graphPromises);
8205
- logger12.info(
8378
+ logger13.info(
8206
8379
  {
8207
8380
  projectId: typed.id,
8208
8381
  graphCount: Object.keys(typed.graphs).length
@@ -8210,15 +8383,15 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8210
8383
  "All project graphs updated successfully"
8211
8384
  );
8212
8385
  }
8213
- logger12.info({ projectId: typed.id }, "Full project updated successfully");
8386
+ logger13.info({ projectId: typed.id }, "Full project updated successfully");
8214
8387
  return await getFullProject(
8215
8388
  db,
8216
- logger12
8389
+ logger13
8217
8390
  )({
8218
8391
  scopes: { tenantId, projectId: typed.id }
8219
8392
  });
8220
8393
  } catch (error) {
8221
- logger12.error(
8394
+ logger13.error(
8222
8395
  {
8223
8396
  tenantId,
8224
8397
  projectId: typed.id,
@@ -8229,23 +8402,23 @@ var updateFullProjectServerSide = (db, logger12 = defaultLogger2) => async (scop
8229
8402
  throw error;
8230
8403
  }
8231
8404
  };
8232
- var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8405
+ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
8233
8406
  const { scopes } = params;
8234
8407
  const { tenantId, projectId } = scopes;
8235
- logger12.info({ tenantId, projectId }, "Retrieving full project definition");
8408
+ logger13.info({ tenantId, projectId }, "Retrieving full project definition");
8236
8409
  try {
8237
8410
  const project = await getProject(db)({
8238
8411
  scopes: { tenantId, projectId }
8239
8412
  });
8240
8413
  if (!project) {
8241
- logger12.info({ tenantId, projectId }, "Project not found");
8414
+ logger13.info({ tenantId, projectId }, "Project not found");
8242
8415
  return null;
8243
8416
  }
8244
- logger12.info({ tenantId, projectId }, "Project metadata retrieved");
8417
+ logger13.info({ tenantId, projectId }, "Project metadata retrieved");
8245
8418
  const graphList = await listAgentGraphs(db)({
8246
8419
  scopes: { tenantId, projectId }
8247
8420
  });
8248
- logger12.info(
8421
+ logger13.info(
8249
8422
  {
8250
8423
  tenantId,
8251
8424
  projectId,
@@ -8273,12 +8446,12 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8273
8446
  // status, lastHealthCheck, availableTools, activeTools, lastToolsSync are all runtime
8274
8447
  };
8275
8448
  }
8276
- logger12.info(
8449
+ logger13.info(
8277
8450
  { tenantId, projectId, toolCount: Object.keys(projectTools).length },
8278
8451
  "Tools retrieved for project"
8279
8452
  );
8280
8453
  } catch (error) {
8281
- logger12.warn({ tenantId, projectId, error }, "Failed to retrieve tools for project");
8454
+ logger13.warn({ tenantId, projectId, error }, "Failed to retrieve tools for project");
8282
8455
  }
8283
8456
  const projectDataComponents = {};
8284
8457
  try {
@@ -8293,12 +8466,12 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8293
8466
  props: component.props
8294
8467
  };
8295
8468
  }
8296
- logger12.info(
8469
+ logger13.info(
8297
8470
  { tenantId, projectId, count: Object.keys(projectDataComponents).length },
8298
8471
  "DataComponents retrieved for project"
8299
8472
  );
8300
8473
  } catch (error) {
8301
- logger12.warn(
8474
+ logger13.warn(
8302
8475
  { tenantId, projectId, error },
8303
8476
  "Failed to retrieve dataComponents for project"
8304
8477
  );
@@ -8313,16 +8486,15 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8313
8486
  id: component.id,
8314
8487
  name: component.name,
8315
8488
  description: component.description,
8316
- summaryProps: component.summaryProps,
8317
- fullProps: component.fullProps
8489
+ props: component.props
8318
8490
  };
8319
8491
  }
8320
- logger12.info(
8492
+ logger13.info(
8321
8493
  { tenantId, projectId, count: Object.keys(projectArtifactComponents).length },
8322
8494
  "ArtifactComponents retrieved for project"
8323
8495
  );
8324
8496
  } catch (error) {
8325
- logger12.warn(
8497
+ logger13.warn(
8326
8498
  { tenantId, projectId, error },
8327
8499
  "Failed to retrieve artifactComponents for project"
8328
8500
  );
@@ -8340,12 +8512,12 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8340
8512
  retrievalParams: credential.retrievalParams
8341
8513
  };
8342
8514
  }
8343
- logger12.info(
8515
+ logger13.info(
8344
8516
  { tenantId, projectId, count: Object.keys(projectCredentialReferences).length },
8345
8517
  "CredentialReferences retrieved for project"
8346
8518
  );
8347
8519
  } catch (error) {
8348
- logger12.warn(
8520
+ logger13.warn(
8349
8521
  { tenantId, projectId, error },
8350
8522
  "Failed to retrieve credentialReferences for project"
8351
8523
  );
@@ -8354,7 +8526,7 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8354
8526
  if (graphList.length > 0) {
8355
8527
  const graphPromises = graphList.map(async (graph) => {
8356
8528
  try {
8357
- logger12.info(
8529
+ logger13.info(
8358
8530
  { tenantId, projectId, graphId: graph.id },
8359
8531
  "Retrieving full graph definition"
8360
8532
  );
@@ -8363,15 +8535,15 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8363
8535
  });
8364
8536
  if (fullGraph) {
8365
8537
  graphs[graph.id] = fullGraph;
8366
- logger12.info(
8538
+ logger13.info(
8367
8539
  { tenantId, projectId, graphId: graph.id },
8368
8540
  "Full graph definition retrieved"
8369
8541
  );
8370
8542
  } else {
8371
- logger12.warn({ tenantId, projectId, graphId: graph.id }, "Graph definition not found");
8543
+ logger13.warn({ tenantId, projectId, graphId: graph.id }, "Graph definition not found");
8372
8544
  }
8373
8545
  } catch (error) {
8374
- logger12.error(
8546
+ logger13.error(
8375
8547
  { tenantId, projectId, graphId: graph.id, error },
8376
8548
  "Failed to retrieve full graph definition"
8377
8549
  );
@@ -8398,7 +8570,7 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8398
8570
  createdAt: project.createdAt,
8399
8571
  updatedAt: project.updatedAt
8400
8572
  };
8401
- logger12.info(
8573
+ logger13.info(
8402
8574
  {
8403
8575
  tenantId,
8404
8576
  projectId,
@@ -8408,7 +8580,7 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8408
8580
  );
8409
8581
  return fullProjectDefinition;
8410
8582
  } catch (error) {
8411
- logger12.error(
8583
+ logger13.error(
8412
8584
  {
8413
8585
  tenantId,
8414
8586
  projectId,
@@ -8419,23 +8591,23 @@ var getFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8419
8591
  throw error;
8420
8592
  }
8421
8593
  };
8422
- var deleteFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8594
+ var deleteFullProject = (db, logger13 = defaultLogger2) => async (params) => {
8423
8595
  const { scopes } = params;
8424
8596
  const { tenantId, projectId } = scopes;
8425
- logger12.info({ tenantId, projectId }, "Deleting full project and related entities");
8597
+ logger13.info({ tenantId, projectId }, "Deleting full project and related entities");
8426
8598
  try {
8427
8599
  const project = await getFullProject(
8428
8600
  db,
8429
- logger12
8601
+ logger13
8430
8602
  )({
8431
8603
  scopes: { tenantId, projectId }
8432
8604
  });
8433
8605
  if (!project) {
8434
- logger12.info({ tenantId, projectId }, "Project not found for deletion");
8606
+ logger13.info({ tenantId, projectId }, "Project not found for deletion");
8435
8607
  return false;
8436
8608
  }
8437
8609
  if (project.graphs && Object.keys(project.graphs).length > 0) {
8438
- logger12.info(
8610
+ logger13.info(
8439
8611
  {
8440
8612
  tenantId,
8441
8613
  projectId,
@@ -8445,19 +8617,19 @@ var deleteFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8445
8617
  );
8446
8618
  const graphPromises = Object.keys(project.graphs).map(async (graphId) => {
8447
8619
  try {
8448
- logger12.info({ tenantId, projectId, graphId }, "Deleting graph from project");
8620
+ logger13.info({ tenantId, projectId, graphId }, "Deleting graph from project");
8449
8621
  await deleteFullGraph(
8450
8622
  db,
8451
- logger12
8623
+ logger13
8452
8624
  )({
8453
8625
  scopes: { tenantId, projectId, graphId }
8454
8626
  });
8455
- logger12.info(
8627
+ logger13.info(
8456
8628
  { tenantId, projectId, graphId },
8457
8629
  "Graph deleted successfully from project"
8458
8630
  );
8459
8631
  } catch (error) {
8460
- logger12.error(
8632
+ logger13.error(
8461
8633
  { tenantId, projectId, graphId, error },
8462
8634
  "Failed to delete graph from project"
8463
8635
  );
@@ -8465,7 +8637,7 @@ var deleteFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8465
8637
  }
8466
8638
  });
8467
8639
  await Promise.all(graphPromises);
8468
- logger12.info(
8640
+ logger13.info(
8469
8641
  {
8470
8642
  tenantId,
8471
8643
  projectId,
@@ -8478,13 +8650,13 @@ var deleteFullProject = (db, logger12 = defaultLogger2) => async (params) => {
8478
8650
  scopes: { tenantId, projectId }
8479
8651
  });
8480
8652
  if (!deleted) {
8481
- logger12.warn({ tenantId, projectId }, "Project deletion returned false");
8653
+ logger13.warn({ tenantId, projectId }, "Project deletion returned false");
8482
8654
  return false;
8483
8655
  }
8484
- logger12.info({ tenantId, projectId }, "Full project deleted successfully");
8656
+ logger13.info({ tenantId, projectId }, "Full project deleted successfully");
8485
8657
  return true;
8486
8658
  } catch (error) {
8487
- logger12.error(
8659
+ logger13.error(
8488
8660
  {
8489
8661
  tenantId,
8490
8662
  projectId,
@@ -8562,7 +8734,7 @@ var createValidatedDataAccess = (db, dataAccessFunctions) => {
8562
8734
 
8563
8735
  // src/utils/tracer.ts
8564
8736
  var tracer = getTracer("agents-core");
8565
- var logger6 = getLogger("context-cache");
8737
+ var logger7 = getLogger("context-cache");
8566
8738
  var ContextCache = class {
8567
8739
  constructor(tenantId, projectId, dbClient) {
8568
8740
  __publicField(this, "tenantId");
@@ -8571,7 +8743,7 @@ var ContextCache = class {
8571
8743
  this.tenantId = tenantId;
8572
8744
  this.projectId = projectId;
8573
8745
  this.dbClient = dbClient;
8574
- logger6.info(
8746
+ logger7.info(
8575
8747
  {
8576
8748
  tenantId: this.tenantId
8577
8749
  },
@@ -8606,7 +8778,7 @@ var ContextCache = class {
8606
8778
  tenantId: this.tenantId
8607
8779
  };
8608
8780
  } catch (error) {
8609
- logger6.error(
8781
+ logger7.error(
8610
8782
  {
8611
8783
  conversationId,
8612
8784
  contextConfigId,
@@ -8640,7 +8812,7 @@ var ContextCache = class {
8640
8812
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8641
8813
  };
8642
8814
  await setCacheEntry(this.dbClient)(cacheData);
8643
- logger6.debug(
8815
+ logger7.debug(
8644
8816
  {
8645
8817
  conversationId: entry.conversationId,
8646
8818
  contextConfigId: entry.contextConfigId,
@@ -8649,7 +8821,7 @@ var ContextCache = class {
8649
8821
  "Cache entry set successfully"
8650
8822
  );
8651
8823
  } catch (error) {
8652
- logger6.error(
8824
+ logger7.error(
8653
8825
  {
8654
8826
  conversationId: entry.conversationId,
8655
8827
  contextConfigId: entry.contextConfigId,
@@ -8669,7 +8841,7 @@ var ContextCache = class {
8669
8841
  scopes: { tenantId, projectId },
8670
8842
  conversationId
8671
8843
  });
8672
- logger6.info(
8844
+ logger7.info(
8673
8845
  {
8674
8846
  conversationId,
8675
8847
  rowsCleared: result
@@ -8677,7 +8849,7 @@ var ContextCache = class {
8677
8849
  "Conversation cache cleared successfully"
8678
8850
  );
8679
8851
  } catch (error) {
8680
- logger6.error(
8852
+ logger7.error(
8681
8853
  {
8682
8854
  conversationId,
8683
8855
  error: error instanceof Error ? error.message : "Unknown error"
@@ -8696,7 +8868,7 @@ var ContextCache = class {
8696
8868
  scopes: { tenantId, projectId },
8697
8869
  contextConfigId
8698
8870
  });
8699
- logger6.info(
8871
+ logger7.info(
8700
8872
  {
8701
8873
  contextConfigId,
8702
8874
  rowsCleared: result
@@ -8704,7 +8876,7 @@ var ContextCache = class {
8704
8876
  "Context config cache cleared successfully"
8705
8877
  );
8706
8878
  } catch (error) {
8707
- logger6.error(
8879
+ logger7.error(
8708
8880
  {
8709
8881
  contextConfigId,
8710
8882
  error: error instanceof Error ? error.message : "Unknown error"
@@ -8722,14 +8894,14 @@ var ContextCache = class {
8722
8894
  const result = await cleanupTenantCache(this.dbClient)({
8723
8895
  scopes: { tenantId: this.tenantId, projectId: this.projectId }
8724
8896
  });
8725
- logger6.info(
8897
+ logger7.info(
8726
8898
  {
8727
8899
  rowsCleared: result
8728
8900
  },
8729
8901
  "Cache cleanup completed"
8730
8902
  );
8731
8903
  } catch (error) {
8732
- logger6.error(
8904
+ logger7.error(
8733
8905
  {
8734
8906
  error: error instanceof Error ? error.message : "Unknown error"
8735
8907
  },
@@ -8756,7 +8928,7 @@ var ContextCache = class {
8756
8928
  };
8757
8929
 
8758
8930
  // src/context/ContextResolver.ts
8759
- var logger7 = getLogger("context-resolver");
8931
+ var logger8 = getLogger("context-resolver");
8760
8932
  var ContextResolver = class {
8761
8933
  constructor(tenantId, projectId, dbClient, credentialStoreRegistry) {
8762
8934
  __publicField(this, "fetcher");
@@ -8767,7 +8939,7 @@ var ContextResolver = class {
8767
8939
  this.projectId = projectId;
8768
8940
  this.fetcher = new ContextFetcher(tenantId, projectId, dbClient, credentialStoreRegistry);
8769
8941
  this.cache = new ContextCache(tenantId, projectId, dbClient);
8770
- logger7.info(
8942
+ logger8.info(
8771
8943
  {
8772
8944
  tenantId: this.tenantId,
8773
8945
  hasCredentialSupport: !!credentialStoreRegistry
@@ -8780,7 +8952,7 @@ var ContextResolver = class {
8780
8952
  */
8781
8953
  async resolve(contextConfig2, options) {
8782
8954
  const startTime = Date.now();
8783
- logger7.info(
8955
+ logger8.info(
8784
8956
  {
8785
8957
  contextConfigId: contextConfig2.id,
8786
8958
  triggerEvent: options.triggerEvent,
@@ -8820,7 +8992,7 @@ var ContextResolver = class {
8820
8992
  options.conversationId,
8821
8993
  contextConfig2.id
8822
8994
  );
8823
- logger7.info(
8995
+ logger8.info(
8824
8996
  {
8825
8997
  conversationId: options.conversationId,
8826
8998
  contextConfigId: contextConfig2.id
@@ -8834,7 +9006,7 @@ var ContextResolver = class {
8834
9006
  value: options.requestContext,
8835
9007
  tenantId: this.tenantId
8836
9008
  });
8837
- logger7.info(
9009
+ logger8.info(
8838
9010
  {
8839
9011
  conversationId: options.conversationId,
8840
9012
  contextConfigId: contextConfig2.id
@@ -8850,7 +9022,7 @@ var ContextResolver = class {
8850
9022
  const contextVariables = contextConfig2.contextVariables || {};
8851
9023
  const contextVariableEntries = Object.entries(contextVariables);
8852
9024
  if (contextVariableEntries.length === 0) {
8853
- logger7.info(
9025
+ logger8.info(
8854
9026
  {
8855
9027
  contextConfigId: contextConfig2.id
8856
9028
  },
@@ -8886,7 +9058,7 @@ var ContextResolver = class {
8886
9058
  result
8887
9059
  ).catch((error) => {
8888
9060
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
8889
- logger7.error(
9061
+ logger8.error(
8890
9062
  {
8891
9063
  contextConfigId: contextConfig2.id,
8892
9064
  definitionId: definition.id,
@@ -8901,7 +9073,7 @@ var ContextResolver = class {
8901
9073
  });
8902
9074
  if (definition.defaultValue !== void 0) {
8903
9075
  result.resolvedContext[templateKey] = definition.defaultValue;
8904
- logger7.info(
9076
+ logger8.info(
8905
9077
  {
8906
9078
  contextConfigId: contextConfig2.id,
8907
9079
  definitionId: definition.id,
@@ -8926,7 +9098,7 @@ var ContextResolver = class {
8926
9098
  } else {
8927
9099
  parentSpan.setStatus({ code: api.SpanStatusCode.OK });
8928
9100
  }
8929
- logger7.info(
9101
+ logger8.info(
8930
9102
  {
8931
9103
  contextConfigId: contextConfig2.id,
8932
9104
  resolvedKeys: Object.keys(result.resolvedContext),
@@ -8942,7 +9114,7 @@ var ContextResolver = class {
8942
9114
  } catch (error) {
8943
9115
  const durationMs = Date.now() - startTime;
8944
9116
  setSpanWithError(parentSpan, error instanceof Error ? error : new Error(String(error)));
8945
- logger7.error(
9117
+ logger8.error(
8946
9118
  {
8947
9119
  contextConfigId: contextConfig2.id,
8948
9120
  error: error instanceof Error ? error.message : String(error),
@@ -8970,7 +9142,7 @@ var ContextResolver = class {
8970
9142
  if (cachedEntry) {
8971
9143
  result.resolvedContext[templateKey] = cachedEntry.value;
8972
9144
  result.cacheHits.push(definition.id);
8973
- logger7.debug(
9145
+ logger8.debug(
8974
9146
  {
8975
9147
  definitionId: definition.id,
8976
9148
  templateKey,
@@ -8981,7 +9153,7 @@ var ContextResolver = class {
8981
9153
  return;
8982
9154
  }
8983
9155
  result.cacheMisses.push(definition.id);
8984
- logger7.debug(
9156
+ logger8.debug(
8985
9157
  {
8986
9158
  definitionId: definition.id,
8987
9159
  templateKey,
@@ -9038,7 +9210,7 @@ var ContextResolver = class {
9038
9210
  requestHash,
9039
9211
  tenantId: this.tenantId
9040
9212
  });
9041
- logger7.debug(
9213
+ logger8.debug(
9042
9214
  {
9043
9215
  definitionId: definition.id,
9044
9216
  templateKey,
@@ -9073,7 +9245,7 @@ var ContextResolver = class {
9073
9245
  */
9074
9246
  async clearCache(tenantId, projectId, conversationId) {
9075
9247
  await this.cache.clearConversation(tenantId, projectId, conversationId);
9076
- logger7.info(
9248
+ logger8.info(
9077
9249
  {
9078
9250
  conversationId
9079
9251
  },
@@ -9083,7 +9255,7 @@ var ContextResolver = class {
9083
9255
  };
9084
9256
 
9085
9257
  // src/middleware/contextValidation.ts
9086
- var logger8 = getLogger("context-validation");
9258
+ var logger9 = getLogger("context-validation");
9087
9259
  var ajv = new Ajv__default.default({ allErrors: true, strict: false });
9088
9260
  var HTTP_REQUEST_PARTS = ["headers"];
9089
9261
  var MAX_SCHEMA_CACHE_SIZE = 1e3;
@@ -9146,7 +9318,7 @@ function validationHelper(jsonSchema) {
9146
9318
  return getCachedValidator(jsonSchema);
9147
9319
  }
9148
9320
  function validateAgainstJsonSchema(jsonSchema, context) {
9149
- logger8.debug({ jsonSchema, context }, "Validating context against JSON Schema");
9321
+ logger9.debug({ jsonSchema, context }, "Validating context against JSON Schema");
9150
9322
  const validate = validationHelper(jsonSchema);
9151
9323
  return validate(context);
9152
9324
  }
@@ -9236,7 +9408,7 @@ async function validateHttpRequestHeaders(headersSchema, httpRequest) {
9236
9408
  validatedContext: filteredContext
9237
9409
  };
9238
9410
  } catch (error) {
9239
- logger8.error(
9411
+ logger9.error(
9240
9412
  { error: error instanceof Error ? error.message : "Unknown error" },
9241
9413
  "Failed to validate headers schema"
9242
9414
  );
@@ -9289,7 +9461,7 @@ async function validateRequestContext({
9289
9461
  scopes: { tenantId, projectId, graphId }
9290
9462
  });
9291
9463
  if (!agentGraph2?.contextConfigId) {
9292
- logger8.debug({ graphId }, "No context config found for graph, skipping validation");
9464
+ logger9.debug({ graphId }, "No context config found for graph, skipping validation");
9293
9465
  return {
9294
9466
  valid: true,
9295
9467
  errors: [],
@@ -9301,7 +9473,7 @@ async function validateRequestContext({
9301
9473
  id: agentGraph2.contextConfigId
9302
9474
  });
9303
9475
  if (!contextConfig2) {
9304
- logger8.warn({ contextConfigId: agentGraph2.contextConfigId }, "Context config not found");
9476
+ logger9.warn({ contextConfigId: agentGraph2.contextConfigId }, "Context config not found");
9305
9477
  return {
9306
9478
  valid: false,
9307
9479
  errors: [
@@ -9313,7 +9485,7 @@ async function validateRequestContext({
9313
9485
  };
9314
9486
  }
9315
9487
  if (!contextConfig2.requestContextSchema) {
9316
- logger8.debug(
9488
+ logger9.debug(
9317
9489
  { contextConfigId: contextConfig2.id },
9318
9490
  "No request context schema defined, accepting any context"
9319
9491
  );
@@ -9325,7 +9497,7 @@ async function validateRequestContext({
9325
9497
  }
9326
9498
  try {
9327
9499
  const schema = contextConfig2.requestContextSchema;
9328
- logger8.debug({ contextConfigId: contextConfig2.id }, "Using headers schema validation");
9500
+ logger9.debug({ contextConfigId: contextConfig2.id }, "Using headers schema validation");
9329
9501
  const httpRequest = parsedRequest;
9330
9502
  const validationResult = await validateHttpRequestHeaders(schema, httpRequest);
9331
9503
  if (validationResult.valid) {
@@ -9348,7 +9520,7 @@ async function validateRequestContext({
9348
9520
  return validationResult;
9349
9521
  }
9350
9522
  } catch (error) {
9351
- logger8.error(
9523
+ logger9.error(
9352
9524
  {
9353
9525
  contextConfigId: contextConfig2.id,
9354
9526
  error: error instanceof Error ? error.message : "Unknown error"
@@ -9366,7 +9538,7 @@ async function validateRequestContext({
9366
9538
  };
9367
9539
  }
9368
9540
  } catch (error) {
9369
- logger8.error(
9541
+ logger9.error(
9370
9542
  {
9371
9543
  tenantId,
9372
9544
  graphId,
@@ -9418,7 +9590,7 @@ function contextValidationMiddleware(dbClient) {
9418
9590
  credentialStores
9419
9591
  });
9420
9592
  if (!validationResult.valid) {
9421
- logger8.warn(
9593
+ logger9.warn(
9422
9594
  {
9423
9595
  tenantId,
9424
9596
  graphId,
@@ -9433,7 +9605,7 @@ function contextValidationMiddleware(dbClient) {
9433
9605
  });
9434
9606
  }
9435
9607
  c.set("validatedContext", validationResult.validatedContext);
9436
- logger8.debug(
9608
+ logger9.debug(
9437
9609
  {
9438
9610
  tenantId,
9439
9611
  graphId,
@@ -9443,7 +9615,7 @@ function contextValidationMiddleware(dbClient) {
9443
9615
  );
9444
9616
  return next();
9445
9617
  } catch (error) {
9446
- logger8.error(
9618
+ logger9.error(
9447
9619
  {
9448
9620
  error: error instanceof Error ? error.message : "Unknown error"
9449
9621
  },
@@ -9458,7 +9630,7 @@ function contextValidationMiddleware(dbClient) {
9458
9630
  }
9459
9631
 
9460
9632
  // src/context/ContextFetcher.ts
9461
- var logger9 = getLogger("context-fetcher");
9633
+ var logger10 = getLogger("context-fetcher");
9462
9634
  var checkGraphQLErrors = (data) => {
9463
9635
  if (data && typeof data === "object" && "errors" in data) {
9464
9636
  const errorObj = data;
@@ -9487,7 +9659,7 @@ var ContextFetcher = class {
9487
9659
  this.credentialStuffer = new CredentialStuffer(credentialStoreRegistry);
9488
9660
  }
9489
9661
  this.dbClient = dbClient;
9490
- logger9.info(
9662
+ logger10.info(
9491
9663
  {
9492
9664
  tenantId: this.tenantId,
9493
9665
  defaultTimeout: this.defaultTimeout,
@@ -9501,7 +9673,7 @@ var ContextFetcher = class {
9501
9673
  */
9502
9674
  async fetch(definition, context) {
9503
9675
  const startTime = Date.now();
9504
- logger9.info(
9676
+ logger10.info(
9505
9677
  {
9506
9678
  definitionId: definition.id,
9507
9679
  url: definition.fetchConfig.url
@@ -9515,7 +9687,7 @@ var ContextFetcher = class {
9515
9687
  definition.credentialReferenceId
9516
9688
  );
9517
9689
  const response = await this.performRequest(resolvedConfig);
9518
- logger9.info({ response }, "ContextFetcher Response");
9690
+ logger10.info({ response }, "ContextFetcher Response");
9519
9691
  let transformedData = response.data;
9520
9692
  if (definition.fetchConfig.transform) {
9521
9693
  transformedData = this.transformResponse(response.data, definition.fetchConfig.transform);
@@ -9528,7 +9700,7 @@ var ContextFetcher = class {
9528
9700
  );
9529
9701
  }
9530
9702
  const durationMs = Date.now() - startTime;
9531
- logger9.info(
9703
+ logger10.info(
9532
9704
  {
9533
9705
  definitionId: definition.id,
9534
9706
  source: response.source,
@@ -9540,7 +9712,7 @@ var ContextFetcher = class {
9540
9712
  } catch (error) {
9541
9713
  const durationMs = Date.now() - startTime;
9542
9714
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
9543
- logger9.error(
9715
+ logger10.error(
9544
9716
  {
9545
9717
  definitionId: definition.id,
9546
9718
  error: errorMessage,
@@ -9557,7 +9729,7 @@ var ContextFetcher = class {
9557
9729
  scopes: { tenantId: this.tenantId, projectId: this.projectId },
9558
9730
  id: credentialReferenceId
9559
9731
  });
9560
- logger9.info({ credentialReference }, "Credential reference");
9732
+ logger10.info({ credentialReference }, "Credential reference");
9561
9733
  if (!credentialReference || !this.credentialStuffer) {
9562
9734
  throw new Error(`Credential store not found for reference ID: ${credentialReferenceId}`);
9563
9735
  }
@@ -9575,7 +9747,7 @@ var ContextFetcher = class {
9575
9747
  );
9576
9748
  return credentialData;
9577
9749
  } catch (error) {
9578
- logger9.error(
9750
+ logger10.error(
9579
9751
  {
9580
9752
  credentialReferenceId,
9581
9753
  error: error instanceof Error ? error.message : "Unknown error"
@@ -9591,7 +9763,7 @@ var ContextFetcher = class {
9591
9763
  async resolveTemplateVariables(fetchConfig, context, credentialReferenceId) {
9592
9764
  const resolved = { ...fetchConfig };
9593
9765
  resolved.url = this.interpolateTemplate(fetchConfig.url, context);
9594
- logger9.info({ resolvedUrl: resolved.url }, "Resolved URL");
9766
+ logger10.info({ resolvedUrl: resolved.url }, "Resolved URL");
9595
9767
  if (fetchConfig.headers) {
9596
9768
  resolved.headers = {};
9597
9769
  for (const [key, value] of Object.entries(fetchConfig.headers)) {
@@ -9610,7 +9782,7 @@ var ContextFetcher = class {
9610
9782
  ...resolved.headers,
9611
9783
  ...credentialHeaders
9612
9784
  };
9613
- logger9.info(
9785
+ logger10.info(
9614
9786
  {
9615
9787
  credentialReferenceId
9616
9788
  },
@@ -9618,7 +9790,7 @@ var ContextFetcher = class {
9618
9790
  );
9619
9791
  }
9620
9792
  } catch (error) {
9621
- logger9.error(
9793
+ logger10.error(
9622
9794
  {
9623
9795
  credentialReferenceId,
9624
9796
  error: error instanceof Error ? error.message : "Unknown error"
@@ -9640,7 +9812,7 @@ var ContextFetcher = class {
9640
9812
  preserveUnresolved: true
9641
9813
  });
9642
9814
  } catch (error) {
9643
- logger9.error(
9815
+ logger10.error(
9644
9816
  {
9645
9817
  template,
9646
9818
  error: error instanceof Error ? error.message : "Unknown error"
@@ -9672,7 +9844,7 @@ var ContextFetcher = class {
9672
9844
  async performRequest(config) {
9673
9845
  const startTime = Date.now();
9674
9846
  try {
9675
- logger9.debug(
9847
+ logger10.debug(
9676
9848
  {
9677
9849
  url: config.url,
9678
9850
  method: config.method
@@ -9709,7 +9881,7 @@ var ContextFetcher = class {
9709
9881
  } catch (error) {
9710
9882
  const durationMs = Date.now() - startTime;
9711
9883
  const requestError = error instanceof Error ? error : new Error("Unknown error");
9712
- logger9.warn(
9884
+ logger10.warn(
9713
9885
  {
9714
9886
  url: config.url,
9715
9887
  error: requestError.message,
@@ -9728,7 +9900,7 @@ var ContextFetcher = class {
9728
9900
  const result = jmespath__default.default.search(data, transform);
9729
9901
  return result;
9730
9902
  } catch (error) {
9731
- logger9.error(
9903
+ logger10.error(
9732
9904
  {
9733
9905
  transform,
9734
9906
  error: error instanceof Error ? error.message : "Unknown error"
@@ -9747,7 +9919,7 @@ var ContextFetcher = class {
9747
9919
  if (!isValid) {
9748
9920
  throw new Error("Data does not match JSON Schema");
9749
9921
  }
9750
- logger9.debug(
9922
+ logger10.debug(
9751
9923
  {
9752
9924
  definitionId,
9753
9925
  dataType: typeof data,
@@ -9757,7 +9929,7 @@ var ContextFetcher = class {
9757
9929
  );
9758
9930
  } catch (error) {
9759
9931
  const errorMessage = error instanceof Error ? error.message : "Unknown validation error";
9760
- logger9.error(
9932
+ logger10.error(
9761
9933
  {
9762
9934
  definitionId,
9763
9935
  jsonSchema,
@@ -9798,7 +9970,7 @@ var ContextFetcher = class {
9798
9970
  };
9799
9971
  }
9800
9972
  };
9801
- var logger10 = getLogger("context");
9973
+ var logger11 = getLogger("context");
9802
9974
  async function determineContextTrigger(tenantId, projectId, conversationId, dbClient) {
9803
9975
  const conversation = await getConversation(dbClient)({
9804
9976
  scopes: { tenantId, projectId },
@@ -9818,7 +9990,7 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
9818
9990
  if (conversation.lastContextResolution) {
9819
9991
  const contextResolver = new ContextResolver(tenantId, projectId, dbClient, credentialStores);
9820
9992
  await contextResolver.clearCache(tenantId, projectId, conversationId);
9821
- logger10.info(
9993
+ logger11.info(
9822
9994
  {
9823
9995
  conversationId,
9824
9996
  graphId,
@@ -9852,7 +10024,7 @@ async function handleContextResolution({
9852
10024
  scopes: { tenantId, projectId, graphId }
9853
10025
  });
9854
10026
  if (!agentGraph2?.contextConfigId) {
9855
- logger10.debug({ graphId }, "No context config found for graph");
10027
+ logger11.debug({ graphId }, "No context config found for graph");
9856
10028
  return null;
9857
10029
  }
9858
10030
  await handleContextConfigChange(
@@ -9870,7 +10042,7 @@ async function handleContextResolution({
9870
10042
  id: agentGraph2.contextConfigId
9871
10043
  });
9872
10044
  if (!contextConfig2) {
9873
- logger10.warn(
10045
+ logger11.warn(
9874
10046
  { contextConfigId: agentGraph2.contextConfigId },
9875
10047
  "Context config not found, proceeding without context resolution"
9876
10048
  );
@@ -9912,7 +10084,7 @@ async function handleContextResolution({
9912
10084
  } else {
9913
10085
  parentSpan.setStatus({ code: api.SpanStatusCode.OK });
9914
10086
  }
9915
- logger10.info(
10087
+ logger11.info(
9916
10088
  {
9917
10089
  conversationId,
9918
10090
  graphId,
@@ -9934,7 +10106,7 @@ async function handleContextResolution({
9934
10106
  "context.error_message": errorMessage
9935
10107
  });
9936
10108
  setSpanWithError(parentSpan, error instanceof Error ? error : new Error(String(error)));
9937
- logger10.error(
10109
+ logger11.error(
9938
10110
  {
9939
10111
  error: errorMessage,
9940
10112
  contextConfigId: agentGraph2?.contextConfigId,
@@ -10275,7 +10447,7 @@ var InMemoryCredentialStore = class {
10275
10447
  return this.credentials.delete(key);
10276
10448
  }
10277
10449
  };
10278
- var logger11 = getLogger("nango-credential-store");
10450
+ var logger12 = getLogger("nango-credential-store");
10279
10451
  var CredentialKeySchema = zod.z.object({
10280
10452
  connectionId: zod.z.string().min(1, "connectionId must be a non-empty string"),
10281
10453
  providerConfigKey: zod.z.string().min(1, "providerConfigKey must be a non-empty string")
@@ -10415,7 +10587,7 @@ var NangoCredentialStore = class {
10415
10587
  if (error && typeof error === "object" && "status" in error && error.status === 404) {
10416
10588
  return null;
10417
10589
  }
10418
- logger11.error(
10590
+ logger12.error(
10419
10591
  { error: error instanceof Error ? error.message : "Unknown error", uniqueKey },
10420
10592
  `Failed to fetch integration ${uniqueKey}`
10421
10593
  );
@@ -10441,7 +10613,7 @@ var NangoCredentialStore = class {
10441
10613
  });
10442
10614
  const result = JSON.stringify(essential);
10443
10615
  if (result.length > 1024) {
10444
- logger11.error(
10616
+ logger12.error(
10445
10617
  {
10446
10618
  originalLength: tokenData.length,
10447
10619
  essentialLength: result.length,
@@ -10515,7 +10687,7 @@ var NangoCredentialStore = class {
10515
10687
  );
10516
10688
  }
10517
10689
  } catch (error) {
10518
- logger11.error(
10690
+ logger12.error(
10519
10691
  {
10520
10692
  error: error instanceof Error ? error.message : "Unknown error",
10521
10693
  name
@@ -10550,7 +10722,7 @@ var NangoCredentialStore = class {
10550
10722
  };
10551
10723
  return credentialData;
10552
10724
  } catch (error) {
10553
- logger11.error(
10725
+ logger12.error(
10554
10726
  {
10555
10727
  error: error instanceof Error ? error.message : "Unknown error",
10556
10728
  connectionId,
@@ -10571,7 +10743,7 @@ var NangoCredentialStore = class {
10571
10743
  try {
10572
10744
  parsedKey = JSON.parse(key);
10573
10745
  } catch (parseError) {
10574
- logger11.warn(
10746
+ logger12.warn(
10575
10747
  {
10576
10748
  storeId: this.id,
10577
10749
  key: key.substring(0, 50),
@@ -10584,7 +10756,7 @@ var NangoCredentialStore = class {
10584
10756
  }
10585
10757
  const validationResult = CredentialKeySchema.safeParse(parsedKey);
10586
10758
  if (!validationResult.success) {
10587
- logger11.warn(
10759
+ logger12.warn(
10588
10760
  {
10589
10761
  storeId: this.id,
10590
10762
  key: key.substring(0, 100),
@@ -10602,7 +10774,7 @@ var NangoCredentialStore = class {
10602
10774
  const credentialString = JSON.stringify(credentials);
10603
10775
  return credentialString;
10604
10776
  } catch (error) {
10605
- logger11.error(
10777
+ logger12.error(
10606
10778
  {
10607
10779
  storeId: this.id,
10608
10780
  key: key.substring(0, 100),
@@ -10631,7 +10803,7 @@ var NangoCredentialStore = class {
10631
10803
  const credentials = await this.get(key);
10632
10804
  return credentials !== null;
10633
10805
  } catch (error) {
10634
- logger11.error(
10806
+ logger12.error(
10635
10807
  {
10636
10808
  error: error instanceof Error ? error.message : "Unknown error",
10637
10809
  key
@@ -10650,7 +10822,7 @@ var NangoCredentialStore = class {
10650
10822
  try {
10651
10823
  parsedKey = JSON.parse(key);
10652
10824
  } catch (parseError) {
10653
- logger11.warn(
10825
+ logger12.warn(
10654
10826
  {
10655
10827
  storeId: this.id,
10656
10828
  key: key.substring(0, 50),
@@ -10663,7 +10835,7 @@ var NangoCredentialStore = class {
10663
10835
  }
10664
10836
  const validationResult = CredentialKeySchema.safeParse(parsedKey);
10665
10837
  if (!validationResult.success) {
10666
- logger11.warn(
10838
+ logger12.warn(
10667
10839
  {
10668
10840
  storeId: this.id,
10669
10841
  key: key.substring(0, 100),
@@ -10677,7 +10849,7 @@ var NangoCredentialStore = class {
10677
10849
  await this.nangoClient.deleteConnection(providerConfigKey, connectionId);
10678
10850
  return true;
10679
10851
  } catch (error) {
10680
- logger11.error(
10852
+ logger12.error(
10681
10853
  {
10682
10854
  storeId: this.id,
10683
10855
  key: key.substring(0, 100),
@@ -11016,6 +11188,8 @@ exports.contextConfigsRelations = contextConfigsRelations;
11016
11188
  exports.contextValidationMiddleware = contextValidationMiddleware;
11017
11189
  exports.conversations = conversations;
11018
11190
  exports.conversationsRelations = conversationsRelations;
11191
+ exports.convertZodToJsonSchema = convertZodToJsonSchema;
11192
+ exports.convertZodToJsonSchemaWithPreview = convertZodToJsonSchemaWithPreview;
11019
11193
  exports.countApiKeys = countApiKeys;
11020
11194
  exports.countArtifactComponents = countArtifactComponents;
11021
11195
  exports.countArtifactComponentsForAgent = countArtifactComponentsForAgent;
@@ -11089,6 +11263,7 @@ exports.externalAgentExists = externalAgentExists;
11089
11263
  exports.externalAgentUrlExists = externalAgentUrlExists;
11090
11264
  exports.externalAgents = externalAgents;
11091
11265
  exports.externalAgentsRelations = externalAgentsRelations;
11266
+ exports.extractPreviewFields = extractPreviewFields;
11092
11267
  exports.extractPublicId = extractPublicId;
11093
11268
  exports.fetchComponentRelationships = fetchComponentRelationships;
11094
11269
  exports.fetchDefinition = fetchDefinition;
@@ -11170,6 +11345,7 @@ exports.isExternalAgent = isExternalAgent;
11170
11345
  exports.isInternalAgent = isInternalAgent;
11171
11346
  exports.isValidHttpRequest = isValidHttpRequest;
11172
11347
  exports.isValidResourceId = isValidResourceId;
11348
+ exports.isZodSchema = isZodSchema;
11173
11349
  exports.ledgerArtifacts = ledgerArtifacts;
11174
11350
  exports.ledgerArtifactsRelations = ledgerArtifactsRelations;
11175
11351
  exports.listAgentGraphs = listAgentGraphs;
@@ -11201,6 +11377,7 @@ exports.loggerFactory = loggerFactory;
11201
11377
  exports.maskApiKey = maskApiKey;
11202
11378
  exports.messages = messages;
11203
11379
  exports.messagesRelations = messagesRelations;
11380
+ exports.preview = preview;
11204
11381
  exports.problemDetailsSchema = problemDetailsSchema;
11205
11382
  exports.projectExists = projectExists;
11206
11383
  exports.projectExistsInTable = projectExistsInTable;
@@ -11266,6 +11443,7 @@ exports.validateGraphStructure = validateGraphStructure;
11266
11443
  exports.validateHttpRequestHeaders = validateHttpRequestHeaders;
11267
11444
  exports.validateInternalAgent = validateInternalAgent;
11268
11445
  exports.validateProjectExists = validateProjectExists;
11446
+ exports.validatePropsAsJsonSchema = validatePropsAsJsonSchema;
11269
11447
  exports.validateRequestContext = validateRequestContext;
11270
11448
  exports.validateToolReferences = validateToolReferences;
11271
11449
  exports.validationHelper = validationHelper;