@inkeep/agents-core 0.0.0-dev-20250911195722 → 0.0.0-dev-20250911212652

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -23,37 +23,13 @@ var ai = require('ai');
23
23
  var exitHook = require('exit-hook');
24
24
  var tsPattern = require('ts-pattern');
25
25
  var zod = require('zod');
26
- var fs = require('fs');
27
- var path = require('path');
28
- var dotenv = require('dotenv');
29
26
  var node = require('@nangohq/node');
30
27
 
31
28
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
32
29
 
33
- function _interopNamespace(e) {
34
- if (e && e.__esModule) return e;
35
- var n = Object.create(null);
36
- if (e) {
37
- Object.keys(e).forEach(function (k) {
38
- if (k !== 'default') {
39
- var d = Object.getOwnPropertyDescriptor(e, k);
40
- Object.defineProperty(n, k, d.get ? d : {
41
- enumerable: true,
42
- get: function () { return e[k]; }
43
- });
44
- }
45
- });
46
- }
47
- n.default = e;
48
- return Object.freeze(n);
49
- }
50
-
51
30
  var jmespath__default = /*#__PURE__*/_interopDefault(jmespath);
52
31
  var crypto__default = /*#__PURE__*/_interopDefault(crypto);
53
32
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
54
- var fs__default = /*#__PURE__*/_interopDefault(fs);
55
- var path__default = /*#__PURE__*/_interopDefault(path);
56
- var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
57
33
 
58
34
  var __defProp = Object.defineProperty;
59
35
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -99,8 +75,8 @@ var LoggerFactory = class {
99
75
  /**
100
76
  * Configure the logger factory
101
77
  */
102
- configure(config2) {
103
- this.config = config2;
78
+ configure(config) {
79
+ this.config = config;
104
80
  this.loggers.clear();
105
81
  }
106
82
  /**
@@ -108,7 +84,11 @@ var LoggerFactory = class {
108
84
  */
109
85
  getLogger(name) {
110
86
  if (this.loggers.has(name)) {
111
- return this.loggers.get(name);
87
+ const logger12 = this.loggers.get(name);
88
+ if (!logger12) {
89
+ throw new Error(`Logger '${name}' not found in cache`);
90
+ }
91
+ return logger12;
112
92
  }
113
93
  let logger11;
114
94
  if (this.config.loggerFactory) {
@@ -133,8 +113,8 @@ var loggerFactory = new LoggerFactory();
133
113
  function getLogger(name) {
134
114
  return loggerFactory.getLogger(name);
135
115
  }
136
- function configureLogging(config2) {
137
- loggerFactory.configure(config2);
116
+ function configureLogging(config) {
117
+ loggerFactory.configure(config);
138
118
  }
139
119
 
140
120
  // src/db/schema.ts
@@ -1836,8 +1816,8 @@ var _TemplateEngine = class _TemplateEngine {
1836
1816
  * Process variable substitutions {{variable.path}} using JMESPath
1837
1817
  */
1838
1818
  static processVariables(template, context, options) {
1839
- return template.replace(/\{\{([^}]+)\}\}/g, (match2, path2) => {
1840
- const trimmedPath = path2.trim();
1819
+ return template.replace(/\{\{([^}]+)\}\}/g, (match2, path) => {
1820
+ const trimmedPath = path.trim();
1841
1821
  try {
1842
1822
  if (trimmedPath.startsWith("$")) {
1843
1823
  return _TemplateEngine.processBuiltinVariable(trimmedPath);
@@ -2197,14 +2177,14 @@ var CredentialStuffer = class {
2197
2177
  return baseConfig;
2198
2178
  }
2199
2179
  };
2200
- function createDatabaseClient(config2) {
2180
+ function createDatabaseClient(config) {
2201
2181
  const client$1 = client.createClient({
2202
- url: config2.url,
2203
- authToken: config2.authToken
2182
+ url: config.url,
2183
+ authToken: config.authToken
2204
2184
  });
2205
2185
  return libsql.drizzle(client$1, {
2206
2186
  schema: schema_exports,
2207
- logger: config2.logger
2187
+ logger: config.logger
2208
2188
  });
2209
2189
  }
2210
2190
  function createInMemoryDatabaseClient() {
@@ -2786,6 +2766,9 @@ var upsertAgent = (db) => async (params) => {
2786
2766
  stopWhen: params.data.stopWhen
2787
2767
  }
2788
2768
  });
2769
+ if (!updated) {
2770
+ throw new Error("Failed to update agent - no rows affected");
2771
+ }
2789
2772
  return updated;
2790
2773
  } else {
2791
2774
  return await createAgent(db)(params.data);
@@ -3072,6 +3055,9 @@ var upsertExternalAgent = (db) => async (params) => {
3072
3055
  headers: params.data.headers
3073
3056
  }
3074
3057
  });
3058
+ if (!updated) {
3059
+ throw new Error("Failed to update external agent - no rows affected");
3060
+ }
3075
3061
  return updated;
3076
3062
  } else {
3077
3063
  return await createExternalAgent(db)(params.data);
@@ -3238,14 +3224,14 @@ var deleteAgentGraph = (db) => async (params) => {
3238
3224
  ).returning();
3239
3225
  return result.length > 0;
3240
3226
  };
3241
- var fetchComponentRelationships = (db) => async (scopes, agentIds, config2) => {
3227
+ var fetchComponentRelationships = (db) => async (scopes, agentIds, config) => {
3242
3228
  const componentsObject = {};
3243
3229
  if (agentIds.length > 0) {
3244
- const results = await db.select(config2.selectFields).from(config2.relationTable).innerJoin(config2.componentTable, drizzleOrm.eq(config2.relationIdField, config2.componentIdField)).where(
3230
+ const results = await db.select(config.selectFields).from(config.relationTable).innerJoin(config.componentTable, drizzleOrm.eq(config.relationIdField, config.componentIdField)).where(
3245
3231
  drizzleOrm.and(
3246
- drizzleOrm.eq(config2.relationTable.tenantId, scopes.tenantId),
3247
- drizzleOrm.eq(config2.relationTable.projectId, scopes.projectId),
3248
- drizzleOrm.inArray(config2.relationTable.agentId, agentIds)
3232
+ drizzleOrm.eq(config.relationTable.tenantId, scopes.tenantId),
3233
+ drizzleOrm.eq(config.relationTable.projectId, scopes.projectId),
3234
+ drizzleOrm.inArray(config.relationTable.agentId, agentIds)
3249
3235
  )
3250
3236
  );
3251
3237
  for (const component of results) {
@@ -4566,6 +4552,9 @@ var upsertCredentialReference = (db) => async (params) => {
4566
4552
  retrievalParams: params.data.retrievalParams
4567
4553
  }
4568
4554
  });
4555
+ if (!updated) {
4556
+ throw new Error("Failed to update credential reference - no rows affected");
4557
+ }
4569
4558
  return updated;
4570
4559
  } else {
4571
4560
  return await createCredentialReference(db)(params.data);
@@ -6626,8 +6615,8 @@ var tryWellKnownEndpoints = async (baseUrl, logger11) => {
6626
6615
  return null;
6627
6616
  };
6628
6617
  var checkForOAuthEndpoints = async (serverUrl, logger11) => {
6629
- const config2 = await discoverOAuthEndpoints(serverUrl, logger11);
6630
- return config2 !== null;
6618
+ const config = await discoverOAuthEndpoints(serverUrl, logger11);
6619
+ return config !== null;
6631
6620
  };
6632
6621
  var discoverOAuthEndpoints = async (serverUrl, logger11) => {
6633
6622
  try {
@@ -7007,7 +6996,7 @@ var McpClient = class {
7007
6996
  }
7008
6997
  async connect() {
7009
6998
  if (this.connected) return;
7010
- await tsPattern.match(this.serverConfig).with({ type: MCPTransportType.streamableHttp }, (config2) => this.connectHttp(config2)).with({ type: MCPTransportType.sse }, (config2) => this.connectSSE(config2)).exhaustive();
6999
+ await tsPattern.match(this.serverConfig).with({ type: MCPTransportType.streamableHttp }, (config) => this.connectHttp(config)).with({ type: MCPTransportType.sse }, (config) => this.connectSSE(config)).exhaustive();
7011
7000
  this.connected = true;
7012
7001
  const close = this.client.onclose;
7013
7002
  this.client.onclose = () => {
@@ -7019,25 +7008,25 @@ var McpClient = class {
7019
7008
  exitHook.asyncExitHook(() => this.disconnect(), { wait: 5e3 });
7020
7009
  process.on("SIGTERM", () => exitHook.gracefulExit());
7021
7010
  }
7022
- async connectSSE(config2) {
7023
- const url = typeof config2.url === "string" ? config2.url : config2.url.toString();
7011
+ async connectSSE(config) {
7012
+ const url = typeof config.url === "string" ? config.url : config.url.toString();
7024
7013
  this.transport = new sse_js.SSEClientTransport(new URL(url), {
7025
- eventSourceInit: config2.eventSourceInit,
7014
+ eventSourceInit: config.eventSourceInit,
7026
7015
  requestInit: {
7027
- headers: config2.headers || {}
7016
+ headers: config.headers || {}
7028
7017
  }
7029
7018
  });
7030
7019
  await this.client.connect(this.transport, {
7031
- timeout: config2.timeout ?? this.timeout
7020
+ timeout: config.timeout ?? this.timeout
7032
7021
  });
7033
7022
  }
7034
- async connectHttp(config2) {
7035
- const { url, requestInit } = config2;
7023
+ async connectHttp(config) {
7024
+ const { url, requestInit } = config;
7036
7025
  const mergedRequestInit = {
7037
7026
  ...requestInit,
7038
7027
  headers: {
7039
7028
  ...requestInit?.headers || {},
7040
- ...config2.headers || {}
7029
+ ...config.headers || {}
7041
7030
  }
7042
7031
  };
7043
7032
  const urlObj = new URL(url);
@@ -7048,9 +7037,9 @@ var McpClient = class {
7048
7037
  maxReconnectionDelay: 3e4,
7049
7038
  initialReconnectionDelay: 1e3,
7050
7039
  reconnectionDelayGrowFactor: 1.5,
7051
- ...config2.reconnectionOptions
7040
+ ...config.reconnectionOptions
7052
7041
  },
7053
- sessionId: config2.sessionId
7042
+ sessionId: config.sessionId
7054
7043
  });
7055
7044
  await this.client.connect(this.transport, { timeout: 3e3 });
7056
7045
  }
@@ -7154,52 +7143,7 @@ var McpClient = class {
7154
7143
  return results;
7155
7144
  }
7156
7145
  };
7157
- dotenv__namespace.config({ quiet: true });
7158
- var environmentSchema = zod.z.enum(["development", "pentest", "production", "test"]);
7159
- var criticalEnv = zod.z.object({
7160
- ENVIRONMENT: environmentSchema
7161
- }).parse(process.env);
7162
- var loadEnvFile = () => {
7163
- const envPath = path__default.default.resolve(process.cwd(), `.env.${criticalEnv.ENVIRONMENT}.nonsecret`);
7164
- if (fs__default.default.existsSync(envPath)) {
7165
- const envConfig = dotenv__namespace.parse(fs__default.default.readFileSync(envPath));
7166
- for (const k in envConfig) {
7167
- if (!(k in process.env)) {
7168
- process.env[k] = envConfig[k];
7169
- }
7170
- }
7171
- }
7172
- };
7173
- loadEnvFile();
7174
- var envSchema = zod.z.object({
7175
- ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
7176
- DB_FILE_NAME: zod.z.string().default("file:../../local.db"),
7177
- OTEL_TRACES_FORCE_FLUSH_ENABLED: zod.z.stringbool().optional()
7178
- });
7179
- var parseEnv = () => {
7180
- try {
7181
- const parsedEnv = envSchema.parse(process.env);
7182
- return parsedEnv;
7183
- } catch (error) {
7184
- if (error instanceof zod.z.ZodError) {
7185
- const missingVars = error.issues.map((issue) => issue.path.join("."));
7186
- throw new Error(
7187
- `\u274C Invalid environment variables: ${missingVars.join(", ")}
7188
- ${error.message}`
7189
- );
7190
- }
7191
- throw error;
7192
- }
7193
- };
7194
- var env = parseEnv();
7195
-
7196
- // src/utils/tracer.ts
7197
7146
  var logger4 = getLogger("tracer");
7198
- var FORCE_FLUSH_ENVIRONMENTS = ["development"];
7199
- var BASE = "inkeep-chat";
7200
- var SERVICE_NAME = "inkeep-chat";
7201
- var SERVICE_VERSION = "1.0.0";
7202
- var createSpanName = (suffix) => `${BASE}.${suffix}`;
7203
7147
  var createNoOpSpan = () => ({
7204
7148
  setAttributes: () => ({}),
7205
7149
  recordException: () => ({}),
@@ -7228,8 +7172,7 @@ var noopTracer = {
7228
7172
  return createNoOpSpan();
7229
7173
  }
7230
7174
  };
7231
- var globalTracerInstance = null;
7232
- function handleSpanError(span, error, logger11, logMessage) {
7175
+ function setSpanWithError(span, error, logger11, logMessage) {
7233
7176
  const errorMessage = error instanceof Error ? error.message : String(error);
7234
7177
  span.recordException(error);
7235
7178
  span.setStatus({
@@ -7240,45 +7183,21 @@ function handleSpanError(span, error, logger11, logMessage) {
7240
7183
  logger11.error({ error: errorMessage }, logMessage);
7241
7184
  }
7242
7185
  }
7243
- function getGlobalTracer() {
7244
- if (!globalTracerInstance) {
7245
- try {
7246
- globalTracerInstance = api.trace.getTracer(SERVICE_NAME, SERVICE_VERSION);
7247
- } catch (error) {
7248
- logger4.debug(
7249
- { error: error instanceof Error ? error.message : "Unknown error" },
7250
- "OpenTelemetry tracer not available, using no-op tracer"
7251
- );
7252
- globalTracerInstance = noopTracer;
7253
- }
7254
- }
7255
- return globalTracerInstance;
7256
- }
7257
- async function forceFlushTracer() {
7258
- const isOtelTracesForceFlushEnabled = env.OTEL_TRACES_FORCE_FLUSH_ENABLED;
7259
- const isForceFlushEnvironment = env.ENVIRONMENT && FORCE_FLUSH_ENVIRONMENTS.includes(env.ENVIRONMENT);
7260
- const shouldForceFlush = isOtelTracesForceFlushEnabled === true || isOtelTracesForceFlushEnabled == null && isForceFlushEnvironment;
7261
- if (!shouldForceFlush) {
7262
- return;
7263
- }
7186
+ function getTracer(serviceName, serviceVersion) {
7264
7187
  try {
7265
- const tracerProvider = api.trace.getTracerProvider();
7266
- if (tracerProvider && "forceFlush" in tracerProvider && typeof tracerProvider.forceFlush === "function") {
7267
- await tracerProvider.forceFlush();
7268
- logger4.debug(
7269
- { message: "Tracer provider force flush completed" },
7270
- "Tracer provider force flush completed"
7271
- );
7272
- } else {
7273
- logger4.debug(
7274
- { message: "Tracer provider does not support force flush or is not available" },
7275
- "Tracer provider does not support force flush or is not available"
7276
- );
7277
- }
7278
- } catch (error) {
7279
- logger4.warn({ error }, "Failed to force flush tracer");
7188
+ return api.trace.getTracer(serviceName, serviceVersion);
7189
+ } catch (_error) {
7190
+ logger4.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
7191
+ return noopTracer;
7280
7192
  }
7281
7193
  }
7194
+
7195
+ // package.json
7196
+ var package_default = {
7197
+ version: "0.0.0-dev-20250911212652"};
7198
+
7199
+ // src/utils/tracer.ts
7200
+ var tracer = getTracer("agents-core", package_default.version);
7282
7201
  var logger5 = getLogger("context-cache");
7283
7202
  var ContextCache = class {
7284
7203
  constructor(tenantId, projectId, dbClient) {
@@ -7474,7 +7393,6 @@ var ContextCache = class {
7474
7393
 
7475
7394
  // src/context/ContextResolver.ts
7476
7395
  var logger6 = getLogger("context-resolver");
7477
- var tracer = getGlobalTracer();
7478
7396
  var ContextResolver = class {
7479
7397
  constructor(tenantId, projectId, dbClient, credentialStoreRegistry) {
7480
7398
  __publicField(this, "fetcher");
@@ -7507,7 +7425,7 @@ var ContextResolver = class {
7507
7425
  "Starting context resolution"
7508
7426
  );
7509
7427
  return tracer.startActiveSpan(
7510
- createSpanName("context.resolve"),
7428
+ "context.resolve",
7511
7429
  {
7512
7430
  attributes: {
7513
7431
  "context.config_id": contextConfig2.id,
@@ -7659,7 +7577,7 @@ var ContextResolver = class {
7659
7577
  return result;
7660
7578
  } catch (error) {
7661
7579
  const durationMs = Date.now() - startTime;
7662
- handleSpanError(parentSpan, error);
7580
+ setSpanWithError(parentSpan, error);
7663
7581
  logger6.error(
7664
7582
  {
7665
7583
  contextConfigId: contextConfig2.id,
@@ -7680,7 +7598,7 @@ var ContextResolver = class {
7680
7598
  */
7681
7599
  async resolveSingleFetchDefinition(contextConfig2, definition, templateKey, options, requestHash, result) {
7682
7600
  return tracer.startActiveSpan(
7683
- createSpanName("context-resolver.resolve_single_fetch_definition"),
7601
+ "context-resolver.resolve_single_fetch_definition",
7684
7602
  {
7685
7603
  attributes: {
7686
7604
  "context.definition_id": definition.id,
@@ -7765,7 +7683,7 @@ var ContextResolver = class {
7765
7683
  "Context variable resolved and cached"
7766
7684
  );
7767
7685
  } catch (error) {
7768
- handleSpanError(parentSpan, error);
7686
+ setSpanWithError(parentSpan, error);
7769
7687
  throw error;
7770
7688
  } finally {
7771
7689
  parentSpan.end();
@@ -7960,7 +7878,15 @@ async function fetchExistingRequestContext({
7960
7878
  "No request context found in cache. Please provide requestContext in request body."
7961
7879
  );
7962
7880
  }
7963
- async function validateRequestContext(tenantId, projectId, graphId, conversationId, parsedRequest, dbClient, credentialStores, legacyRequestContext) {
7881
+ async function validateRequestContext({
7882
+ tenantId,
7883
+ projectId,
7884
+ graphId,
7885
+ conversationId,
7886
+ parsedRequest,
7887
+ dbClient,
7888
+ credentialStores
7889
+ }) {
7964
7890
  try {
7965
7891
  const agentGraph2 = await getAgentGraphWithDefaultAgent(dbClient)({
7966
7892
  scopes: { tenantId, projectId },
@@ -8003,10 +7929,7 @@ async function validateRequestContext(tenantId, projectId, graphId, conversation
8003
7929
  }
8004
7930
  try {
8005
7931
  const schema = contextConfig2.requestContextSchema;
8006
- logger7.debug(
8007
- { contextConfigId: contextConfig2.id },
8008
- "Using headers schema validation"
8009
- );
7932
+ logger7.debug({ contextConfigId: contextConfig2.id }, "Using headers schema validation");
8010
7933
  const httpRequest = parsedRequest;
8011
7934
  const validationResult = await validateHttpRequestHeaders(schema, httpRequest);
8012
7935
  if (validationResult.valid) {
@@ -8089,14 +8012,15 @@ function contextValidationMiddleware(dbClient) {
8089
8012
  const parsedRequest = {
8090
8013
  headers
8091
8014
  };
8092
- const validationResult = await validateRequestContext(
8015
+ const validationResult = await validateRequestContext({
8093
8016
  tenantId,
8094
8017
  projectId,
8095
8018
  graphId,
8096
8019
  conversationId,
8097
8020
  parsedRequest,
8098
8021
  dbClient,
8099
- credentialStores);
8022
+ credentialStores
8023
+ });
8100
8024
  if (!validationResult.valid) {
8101
8025
  logger7.warn(
8102
8026
  {
@@ -8163,13 +8087,11 @@ var ContextFetcher = class {
8163
8087
  __publicField(this, "tenantId");
8164
8088
  __publicField(this, "projectId");
8165
8089
  __publicField(this, "defaultTimeout");
8166
- __publicField(this, "credentialStoreRegistry");
8167
8090
  __publicField(this, "credentialStuffer");
8168
8091
  __publicField(this, "dbClient");
8169
8092
  this.tenantId = tenantId;
8170
8093
  this.projectId = projectId;
8171
8094
  this.defaultTimeout = defaultTimeout;
8172
- this.credentialStoreRegistry = credentialStoreRegistry;
8173
8095
  if (credentialStoreRegistry) {
8174
8096
  this.credentialStuffer = new CredentialStuffer(credentialStoreRegistry);
8175
8097
  }
@@ -8356,21 +8278,21 @@ var ContextFetcher = class {
8356
8278
  /**
8357
8279
  * Perform HTTP request
8358
8280
  */
8359
- async performRequest(config2) {
8281
+ async performRequest(config) {
8360
8282
  const startTime = Date.now();
8361
8283
  try {
8362
8284
  logger8.debug(
8363
8285
  {
8364
- url: config2.url,
8365
- method: config2.method
8286
+ url: config.url,
8287
+ method: config.method
8366
8288
  },
8367
8289
  "Performing HTTP request"
8368
8290
  );
8369
- const response = await fetch(config2.url, {
8370
- method: config2.method,
8371
- headers: config2.headers,
8372
- body: config2.body ? JSON.stringify(config2.body) : void 0,
8373
- signal: AbortSignal.timeout(config2.timeout || this.defaultTimeout)
8291
+ const response = await fetch(config.url, {
8292
+ method: config.method,
8293
+ headers: config.headers,
8294
+ body: config.body ? JSON.stringify(config.body) : void 0,
8295
+ signal: AbortSignal.timeout(config.timeout || this.defaultTimeout)
8374
8296
  });
8375
8297
  if (!response.ok) {
8376
8298
  const errorText = await response.text();
@@ -8390,7 +8312,7 @@ var ContextFetcher = class {
8390
8312
  }
8391
8313
  return {
8392
8314
  data,
8393
- source: config2.url,
8315
+ source: config.url,
8394
8316
  durationMs
8395
8317
  };
8396
8318
  } catch (error) {
@@ -8398,7 +8320,7 @@ var ContextFetcher = class {
8398
8320
  const requestError = error instanceof Error ? error : new Error("Unknown error");
8399
8321
  logger8.warn(
8400
8322
  {
8401
- url: config2.url,
8323
+ url: config.url,
8402
8324
  error: requestError.message,
8403
8325
  durationMs
8404
8326
  },
@@ -8486,7 +8408,6 @@ var ContextFetcher = class {
8486
8408
  }
8487
8409
  };
8488
8410
  var logger9 = getLogger("context");
8489
- var tracer2 = getGlobalTracer();
8490
8411
  async function determineContextTrigger(tenantId, projectId, conversationId, dbClient) {
8491
8412
  const conversation = await getConversation(dbClient)({
8492
8413
  scopes: { tenantId, projectId },
@@ -8517,8 +8438,8 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
8517
8438
  }
8518
8439
  }
8519
8440
  async function handleContextResolution(tenantId, projectId, conversationId, graphId, requestContext, dbClient, credentialStores) {
8520
- return tracer2.startActiveSpan(
8521
- createSpanName("context.handle_context_resolution"),
8441
+ return tracer.startActiveSpan(
8442
+ "context.handle_context_resolution",
8522
8443
  {
8523
8444
  attributes: {
8524
8445
  "context.request_context_keys": Object.keys(requestContext)
@@ -8593,7 +8514,6 @@ async function handleContextResolution(tenantId, projectId, conversationId, grap
8593
8514
  } else {
8594
8515
  parentSpan.setStatus({ code: api.SpanStatusCode.OK });
8595
8516
  }
8596
- await forceFlushTracer();
8597
8517
  logger9.info(
8598
8518
  {
8599
8519
  conversationId,
@@ -8611,15 +8531,11 @@ async function handleContextResolution(tenantId, projectId, conversationId, grap
8611
8531
  return resolvedContext;
8612
8532
  } catch (error) {
8613
8533
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
8614
- parentSpan.recordException(error);
8615
8534
  parentSpan.setAttributes({
8616
8535
  "context.final_status": "failed",
8617
8536
  "context.error_message": errorMessage
8618
8537
  });
8619
- parentSpan.setStatus({
8620
- code: api.SpanStatusCode.ERROR,
8621
- message: errorMessage
8622
- });
8538
+ setSpanWithError(parentSpan, error);
8623
8539
  logger9.error(
8624
8540
  {
8625
8541
  error: errorMessage,
@@ -8633,7 +8549,6 @@ async function handleContextResolution(tenantId, projectId, conversationId, grap
8633
8549
  },
8634
8550
  "Failed to resolve context, proceeding without context resolution"
8635
8551
  );
8636
- await forceFlushTracer();
8637
8552
  return null;
8638
8553
  } finally {
8639
8554
  parentSpan.end();
@@ -8983,13 +8898,13 @@ function isSupportedAuthMode(mode) {
8983
8898
  return SUPPORTED_AUTH_MODES.includes(mode);
8984
8899
  }
8985
8900
  var NangoCredentialStore = class {
8986
- constructor(id, config2) {
8901
+ constructor(id, config) {
8987
8902
  __publicField(this, "id");
8988
8903
  __publicField(this, "type", CredentialStoreType.nango);
8989
8904
  __publicField(this, "nangoConfig");
8990
8905
  __publicField(this, "nangoClient");
8991
8906
  this.id = id;
8992
- this.nangoConfig = config2;
8907
+ this.nangoConfig = config;
8993
8908
  this.nangoClient = new node.Nango({
8994
8909
  secretKey: this.nangoConfig.secretKey,
8995
8910
  host: this.nangoConfig.apiUrl
@@ -9216,8 +9131,8 @@ var NangoCredentialStore = class {
9216
9131
  }
9217
9132
  }
9218
9133
  };
9219
- function createNangoCredentialStore(id, config2) {
9220
- const nangoSecretKey = config2?.secretKey || process.env.NANGO_SECRET_KEY;
9134
+ function createNangoCredentialStore(id, config) {
9135
+ const nangoSecretKey = config?.secretKey || process.env.NANGO_SECRET_KEY;
9221
9136
  if (!nangoSecretKey || nangoSecretKey === "your_nango_secret_key" || nangoSecretKey.includes("mock")) {
9222
9137
  throw new Error(
9223
9138
  "NANGO_SECRET_KEY environment variable is required and must be a real Nango secret key (not mock/placeholder)"
@@ -9225,7 +9140,7 @@ function createNangoCredentialStore(id, config2) {
9225
9140
  }
9226
9141
  return new NangoCredentialStore(id, {
9227
9142
  apiUrl: "https://api.nango.dev",
9228
- ...config2,
9143
+ ...config,
9229
9144
  secretKey: nangoSecretKey
9230
9145
  });
9231
9146
  }
@@ -9315,7 +9230,6 @@ exports.ArtifactComponentApiUpdateSchema = ArtifactComponentApiUpdateSchema;
9315
9230
  exports.ArtifactComponentInsertSchema = ArtifactComponentInsertSchema;
9316
9231
  exports.ArtifactComponentSelectSchema = ArtifactComponentSelectSchema;
9317
9232
  exports.ArtifactComponentUpdateSchema = ArtifactComponentUpdateSchema;
9318
- exports.BASE = BASE;
9319
9233
  exports.ConsoleLogger = ConsoleLogger;
9320
9234
  exports.ContextCache = ContextCache;
9321
9235
  exports.ContextCacheApiInsertSchema = ContextCacheApiInsertSchema;
@@ -9412,8 +9326,6 @@ exports.ProjectModelSchema = ProjectModelSchema;
9412
9326
  exports.ProjectSelectSchema = ProjectSelectSchema;
9413
9327
  exports.ProjectUpdateSchema = ProjectUpdateSchema;
9414
9328
  exports.RemovedResponseSchema = RemovedResponseSchema;
9415
- exports.SERVICE_NAME = SERVICE_NAME;
9416
- exports.SERVICE_VERSION = SERVICE_VERSION;
9417
9329
  exports.SingleResponseSchema = SingleResponseSchema;
9418
9330
  exports.StatusComponentSchema = StatusComponentSchema;
9419
9331
  exports.StatusUpdateSchema = StatusUpdateSchema;
@@ -9513,7 +9425,6 @@ exports.createMessage = createMessage;
9513
9425
  exports.createNangoCredentialStore = createNangoCredentialStore;
9514
9426
  exports.createOrGetConversation = createOrGetConversation;
9515
9427
  exports.createProject = createProject;
9516
- exports.createSpanName = createSpanName;
9517
9428
  exports.createTask = createTask;
9518
9429
  exports.createTool = createTool;
9519
9430
  exports.createValidatedDataAccess = createValidatedDataAccess;
@@ -9554,7 +9465,6 @@ exports.externalAgentsRelations = externalAgentsRelations;
9554
9465
  exports.extractPublicId = extractPublicId;
9555
9466
  exports.fetchComponentRelationships = fetchComponentRelationships;
9556
9467
  exports.fetchDefinition = fetchDefinition;
9557
- exports.forceFlushTracer = forceFlushTracer;
9558
9468
  exports.generateAndCreateApiKey = generateAndCreateApiKey;
9559
9469
  exports.generateApiKey = generateApiKey;
9560
9470
  exports.generateIdFromName = generateIdFromName;
@@ -9600,7 +9510,6 @@ exports.getExternalAgentByUrl = getExternalAgentByUrl;
9600
9510
  exports.getExternalAgentRelations = getExternalAgentRelations;
9601
9511
  exports.getFullGraph = getFullGraph;
9602
9512
  exports.getFullGraphDefinition = getFullGraphDefinition;
9603
- exports.getGlobalTracer = getGlobalTracer;
9604
9513
  exports.getGraphAgentInfos = getGraphAgentInfos;
9605
9514
  exports.getHealthyToolsForAgent = getHealthyToolsForAgent;
9606
9515
  exports.getLedgerArtifacts = getLedgerArtifacts;
@@ -9617,12 +9526,12 @@ exports.getTask = getTask;
9617
9526
  exports.getToolById = getToolById;
9618
9527
  exports.getToolsByStatus = getToolsByStatus;
9619
9528
  exports.getToolsForAgent = getToolsForAgent;
9529
+ exports.getTracer = getTracer;
9620
9530
  exports.getVisibleMessages = getVisibleMessages;
9621
9531
  exports.graphHasArtifactComponents = graphHasArtifactComponents;
9622
9532
  exports.handleApiError = handleApiError;
9623
9533
  exports.handleContextConfigChange = handleContextConfigChange;
9624
9534
  exports.handleContextResolution = handleContextResolution;
9625
- exports.handleSpanError = handleSpanError;
9626
9535
  exports.hasApiKey = hasApiKey;
9627
9536
  exports.hasContextConfig = hasContextConfig;
9628
9537
  exports.hasCredentialReference = hasCredentialReference;
@@ -9683,6 +9592,7 @@ exports.resourceIdSchema = resourceIdSchema;
9683
9592
  exports.setActiveAgentForConversation = setActiveAgentForConversation;
9684
9593
  exports.setActiveAgentForThread = setActiveAgentForThread;
9685
9594
  exports.setCacheEntry = setCacheEntry;
9595
+ exports.setSpanWithError = setSpanWithError;
9686
9596
  exports.taskRelations = taskRelations;
9687
9597
  exports.taskRelationsRelations = taskRelationsRelations;
9688
9598
  exports.tasks = tasks;