@inkeep/agents-run-api 0.0.0-dev-20251117174652 → 0.0.0-dev-20251117195744

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
@@ -8767,7 +8767,7 @@ var Agent = class {
8767
8767
  /**
8768
8768
  * Wraps a tool with streaming lifecycle tracking (start, complete, error) and AgentSession recording
8769
8769
  */
8770
- wrapToolWithStreaming(toolName, toolDefinition, streamRequestId, toolType) {
8770
+ wrapToolWithStreaming(toolName, toolDefinition, streamRequestId, toolType, relationshipId) {
8771
8771
  if (!toolDefinition || typeof toolDefinition !== "object" || !("execute" in toolDefinition)) {
8772
8772
  return toolDefinition;
8773
8773
  }
@@ -8793,7 +8793,8 @@ var Agent = class {
8793
8793
  agentSessionManager.recordEvent(streamRequestId, "tool_call", this.config.id, {
8794
8794
  toolName,
8795
8795
  input: args,
8796
- toolCallId
8796
+ toolCallId,
8797
+ relationshipId
8797
8798
  });
8798
8799
  }
8799
8800
  try {
@@ -8838,7 +8839,8 @@ var Agent = class {
8838
8839
  toolName,
8839
8840
  output: result,
8840
8841
  toolCallId,
8841
- duration
8842
+ duration,
8843
+ relationshipId
8842
8844
  });
8843
8845
  }
8844
8846
  return result;
@@ -8851,7 +8853,8 @@ var Agent = class {
8851
8853
  output: null,
8852
8854
  toolCallId,
8853
8855
  duration,
8854
- error: errorMessage
8856
+ error: errorMessage,
8857
+ relationshipId
8855
8858
  });
8856
8859
  }
8857
8860
  throw error;
@@ -8917,22 +8920,24 @@ var Agent = class {
8917
8920
  }) || [];
8918
8921
  const tools = await Promise.all(mcpTools.map((tool3) => this.getMcpTool(tool3)) || []) || [];
8919
8922
  if (!sessionId) {
8920
- const combinedTools = tools.reduce((acc, tool3) => {
8921
- return Object.assign(acc, tool3);
8922
- }, {});
8923
8923
  const wrappedTools2 = {};
8924
- for (const [toolName, toolDef] of Object.entries(combinedTools)) {
8925
- wrappedTools2[toolName] = this.wrapToolWithStreaming(
8926
- toolName,
8927
- toolDef,
8928
- streamRequestId,
8929
- "mcp"
8930
- );
8924
+ for (const [index, toolSet] of tools.entries()) {
8925
+ const relationshipId = mcpTools[index]?.relationshipId;
8926
+ for (const [toolName, toolDef] of Object.entries(toolSet)) {
8927
+ wrappedTools2[toolName] = this.wrapToolWithStreaming(
8928
+ toolName,
8929
+ toolDef,
8930
+ streamRequestId,
8931
+ "mcp",
8932
+ relationshipId
8933
+ );
8934
+ }
8931
8935
  }
8932
8936
  return wrappedTools2;
8933
8937
  }
8934
8938
  const wrappedTools = {};
8935
- for (const toolSet of tools) {
8939
+ for (const [index, toolSet] of tools.entries()) {
8940
+ const relationshipId = mcpTools[index]?.relationshipId;
8936
8941
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
8937
8942
  if (!isValidTool(originalTool)) {
8938
8943
  logger19.error({ toolName }, "Invalid MCP tool structure - missing required properties");
@@ -8945,7 +8950,7 @@ var Agent = class {
8945
8950
  logger19.debug({ toolName, toolCallId }, "MCP Tool Called");
8946
8951
  try {
8947
8952
  const rawResult = await originalTool.execute(args, { toolCallId });
8948
- if (rawResult && typeof rawResult === "object" && "isError" in rawResult && rawResult.isError) {
8953
+ if (rawResult && typeof rawResult === "object" && rawResult.isError) {
8949
8954
  const errorMessage = rawResult.content?.[0]?.text || "MCP tool returned an error";
8950
8955
  logger19.error(
8951
8956
  { toolName, toolCallId, errorMessage, rawResult },
@@ -8966,7 +8971,8 @@ var Agent = class {
8966
8971
  context: {
8967
8972
  toolName,
8968
8973
  toolCallId,
8969
- errorMessage
8974
+ errorMessage,
8975
+ relationshipId
8970
8976
  }
8971
8977
  });
8972
8978
  }
@@ -9005,7 +9011,8 @@ var Agent = class {
9005
9011
  toolName,
9006
9012
  sessionWrappedTool,
9007
9013
  streamRequestId,
9008
- "mcp"
9014
+ "mcp",
9015
+ relationshipId
9009
9016
  );
9010
9017
  }
9011
9018
  }
@@ -10677,7 +10684,12 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
10677
10684
  const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
10678
10685
  const toolsForAgentResult = await Promise.all(
10679
10686
  toolsForAgent.data.map(async (item) => {
10680
- const mcpTool = await agentsCore.dbResultToMcpTool(item.tool, dbClient_default, credentialStoreRegistry);
10687
+ const mcpTool = await agentsCore.dbResultToMcpTool(
10688
+ item.tool,
10689
+ dbClient_default,
10690
+ credentialStoreRegistry,
10691
+ item.id
10692
+ );
10681
10693
  if (item.selectedTools && item.selectedTools.length > 0) {
10682
10694
  const selectedToolsSet = new Set(item.selectedTools);
10683
10695
  mcpTool.availableTools = mcpTool.availableTools?.filter((tool3) => selectedToolsSet.has(tool3.name)) || [];
@@ -10759,7 +10771,8 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
10759
10771
  const mcpTool = await agentsCore.dbResultToMcpTool(
10760
10772
  item.tool,
10761
10773
  dbClient_default,
10762
- credentialStoreRegistry
10774
+ credentialStoreRegistry,
10775
+ item.id
10763
10776
  );
10764
10777
  if (item.selectedTools && item.selectedTools.length > 0) {
10765
10778
  const selectedToolsSet = new Set(item.selectedTools);
package/dist/index.js CHANGED
@@ -7075,7 +7075,7 @@ var Agent = class {
7075
7075
  /**
7076
7076
  * Wraps a tool with streaming lifecycle tracking (start, complete, error) and AgentSession recording
7077
7077
  */
7078
- wrapToolWithStreaming(toolName, toolDefinition, streamRequestId, toolType) {
7078
+ wrapToolWithStreaming(toolName, toolDefinition, streamRequestId, toolType, relationshipId) {
7079
7079
  if (!toolDefinition || typeof toolDefinition !== "object" || !("execute" in toolDefinition)) {
7080
7080
  return toolDefinition;
7081
7081
  }
@@ -7101,7 +7101,8 @@ var Agent = class {
7101
7101
  agentSessionManager.recordEvent(streamRequestId, "tool_call", this.config.id, {
7102
7102
  toolName,
7103
7103
  input: args,
7104
- toolCallId
7104
+ toolCallId,
7105
+ relationshipId
7105
7106
  });
7106
7107
  }
7107
7108
  try {
@@ -7146,7 +7147,8 @@ var Agent = class {
7146
7147
  toolName,
7147
7148
  output: result,
7148
7149
  toolCallId,
7149
- duration
7150
+ duration,
7151
+ relationshipId
7150
7152
  });
7151
7153
  }
7152
7154
  return result;
@@ -7159,7 +7161,8 @@ var Agent = class {
7159
7161
  output: null,
7160
7162
  toolCallId,
7161
7163
  duration,
7162
- error: errorMessage
7164
+ error: errorMessage,
7165
+ relationshipId
7163
7166
  });
7164
7167
  }
7165
7168
  throw error;
@@ -7225,22 +7228,24 @@ var Agent = class {
7225
7228
  }) || [];
7226
7229
  const tools = await Promise.all(mcpTools.map((tool3) => this.getMcpTool(tool3)) || []) || [];
7227
7230
  if (!sessionId) {
7228
- const combinedTools = tools.reduce((acc, tool3) => {
7229
- return Object.assign(acc, tool3);
7230
- }, {});
7231
7231
  const wrappedTools2 = {};
7232
- for (const [toolName, toolDef] of Object.entries(combinedTools)) {
7233
- wrappedTools2[toolName] = this.wrapToolWithStreaming(
7234
- toolName,
7235
- toolDef,
7236
- streamRequestId,
7237
- "mcp"
7238
- );
7232
+ for (const [index, toolSet] of tools.entries()) {
7233
+ const relationshipId = mcpTools[index]?.relationshipId;
7234
+ for (const [toolName, toolDef] of Object.entries(toolSet)) {
7235
+ wrappedTools2[toolName] = this.wrapToolWithStreaming(
7236
+ toolName,
7237
+ toolDef,
7238
+ streamRequestId,
7239
+ "mcp",
7240
+ relationshipId
7241
+ );
7242
+ }
7239
7243
  }
7240
7244
  return wrappedTools2;
7241
7245
  }
7242
7246
  const wrappedTools = {};
7243
- for (const toolSet of tools) {
7247
+ for (const [index, toolSet] of tools.entries()) {
7248
+ const relationshipId = mcpTools[index]?.relationshipId;
7244
7249
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
7245
7250
  if (!isValidTool(originalTool)) {
7246
7251
  logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
@@ -7253,7 +7258,7 @@ var Agent = class {
7253
7258
  logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
7254
7259
  try {
7255
7260
  const rawResult = await originalTool.execute(args, { toolCallId });
7256
- if (rawResult && typeof rawResult === "object" && "isError" in rawResult && rawResult.isError) {
7261
+ if (rawResult && typeof rawResult === "object" && rawResult.isError) {
7257
7262
  const errorMessage = rawResult.content?.[0]?.text || "MCP tool returned an error";
7258
7263
  logger15.error(
7259
7264
  { toolName, toolCallId, errorMessage, rawResult },
@@ -7274,7 +7279,8 @@ var Agent = class {
7274
7279
  context: {
7275
7280
  toolName,
7276
7281
  toolCallId,
7277
- errorMessage
7282
+ errorMessage,
7283
+ relationshipId
7278
7284
  }
7279
7285
  });
7280
7286
  }
@@ -7313,7 +7319,8 @@ var Agent = class {
7313
7319
  toolName,
7314
7320
  sessionWrappedTool,
7315
7321
  streamRequestId,
7316
- "mcp"
7322
+ "mcp",
7323
+ relationshipId
7317
7324
  );
7318
7325
  }
7319
7326
  }
@@ -8985,7 +8992,12 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8985
8992
  const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
8986
8993
  const toolsForAgentResult = await Promise.all(
8987
8994
  toolsForAgent.data.map(async (item) => {
8988
- const mcpTool = await dbResultToMcpTool(item.tool, dbClient_default, credentialStoreRegistry);
8995
+ const mcpTool = await dbResultToMcpTool(
8996
+ item.tool,
8997
+ dbClient_default,
8998
+ credentialStoreRegistry,
8999
+ item.id
9000
+ );
8989
9001
  if (item.selectedTools && item.selectedTools.length > 0) {
8990
9002
  const selectedToolsSet = new Set(item.selectedTools);
8991
9003
  mcpTool.availableTools = mcpTool.availableTools?.filter((tool3) => selectedToolsSet.has(tool3.name)) || [];
@@ -9067,7 +9079,8 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9067
9079
  const mcpTool = await dbResultToMcpTool(
9068
9080
  item.tool,
9069
9081
  dbClient_default,
9070
- credentialStoreRegistry
9082
+ credentialStoreRegistry,
9083
+ item.id
9071
9084
  );
9072
9085
  if (item.selectedTools && item.selectedTools.length > 0) {
9073
9086
  const selectedToolsSet = new Set(item.selectedTools);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-run-api",
3
- "version": "0.0.0-dev-20251117174652",
3
+ "version": "0.0.0-dev-20251117195744",
4
4
  "description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -53,7 +53,7 @@
53
53
  "traverse": "^0.6.11",
54
54
  "ts-pattern": "^5.7.1",
55
55
  "zod": "4.1.5",
56
- "@inkeep/agents-core": "^0.0.0-dev-20251117174652"
56
+ "@inkeep/agents-core": "^0.0.0-dev-20251117195744"
57
57
  },
58
58
  "optionalDependencies": {
59
59
  "keytar": "^7.9.0"