@inkeep/agents-api 0.0.0-dev-20260206001412 → 0.0.0-dev-20260206015755

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 (31) hide show
  1. package/dist/.well-known/workflow/v1/manifest.debug.json +5 -5
  2. package/dist/.well-known/workflow/v1/step.cjs +14 -1
  3. package/dist/createApp.js +3 -1
  4. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  5. package/dist/domains/evals/routes/index.d.ts +2 -2
  6. package/dist/domains/evals/services/EvaluationService.js +2 -1
  7. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  8. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  9. package/dist/domains/manage/routes/index.d.ts +2 -2
  10. package/dist/domains/manage/routes/invitations.d.ts +2 -2
  11. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  12. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  13. package/dist/domains/manage/routes/userOrganizations.d.ts +2 -2
  14. package/dist/domains/mcp/routes/mcp.d.ts +2 -2
  15. package/dist/domains/run/a2a/client.d.ts +2 -0
  16. package/dist/domains/run/a2a/client.js +7 -5
  17. package/dist/domains/run/agents/relationTools.js +3 -1
  18. package/dist/domains/run/handlers/executionHandler.js +12 -8
  19. package/dist/factory.d.ts +262 -262
  20. package/dist/index.d.ts +261 -261
  21. package/dist/middleware/evalsAuth.d.ts +2 -2
  22. package/dist/middleware/manageAuth.d.ts +2 -2
  23. package/dist/middleware/projectAccess.d.ts +2 -2
  24. package/dist/middleware/projectConfig.d.ts +3 -3
  25. package/dist/middleware/requirePermission.d.ts +2 -2
  26. package/dist/middleware/sessionAuth.d.ts +3 -3
  27. package/dist/middleware/tenantAccess.d.ts +2 -2
  28. package/dist/middleware/tracing.d.ts +3 -3
  29. package/dist/utils/in-process-fetch.d.ts +22 -0
  30. package/dist/utils/in-process-fetch.js +32 -0
  31. package/package.json +5 -5
@@ -41,15 +41,15 @@
41
41
  }
42
42
  },
43
43
  "workflows": {
44
- "src/domains/evals/workflow/functions/evaluateConversation.ts": {
45
- "_evaluateConversationWorkflow": {
46
- "workflowId": "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//_evaluateConversationWorkflow"
47
- }
48
- },
49
44
  "src/domains/evals/workflow/functions/runDatasetItem.ts": {
50
45
  "_runDatasetItemWorkflow": {
51
46
  "workflowId": "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//_runDatasetItemWorkflow"
52
47
  }
48
+ },
49
+ "src/domains/evals/workflow/functions/evaluateConversation.ts": {
50
+ "_evaluateConversationWorkflow": {
51
+ "workflowId": "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//_evaluateConversationWorkflow"
52
+ }
53
53
  }
54
54
  }
55
55
  }
@@ -228857,6 +228857,19 @@ var runDbClient = createAgentsRunDatabaseClient({
228857
228857
  });
228858
228858
  var runDbClient_default = runDbClient;
228859
228859
 
228860
+ // src/utils/in-process-fetch.ts
228861
+ var _appFetch;
228862
+ function getInProcessFetch() {
228863
+ if (!_appFetch) {
228864
+ if (process.env.ENVIRONMENT === "test") {
228865
+ return fetch;
228866
+ }
228867
+ throw new Error("[in-process-fetch] App fetch not registered. Call registerAppFetch() during app initialization before handling requests.");
228868
+ }
228869
+ return _appFetch;
228870
+ }
228871
+ __name(getInProcessFetch, "getInProcessFetch");
228872
+
228860
228873
  // src/domains/evals/services/EvaluationService.ts
228861
228874
  var logger21 = getLogger("EvaluationService");
228862
228875
  var EvaluationService = class {
@@ -228951,7 +228964,7 @@ var EvaluationService = class {
228951
228964
  datasetRunId,
228952
228965
  conversationId
228953
228966
  }, "Running dataset item through chat API");
228954
- const response = await fetch(chatUrl, {
228967
+ const response = await getInProcessFetch()(chatUrl, {
228955
228968
  method: "POST",
228956
228969
  headers: headers2,
228957
228970
  body: JSON.stringify(chatPayload)
package/dist/createApp.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getLogger as getLogger$1 } from "./logger.js";
2
2
  import { env } from "./env.js";
3
+ import { getInProcessFetch, registerAppFetch } from "./utils/in-process-fetch.js";
3
4
  import { evalRoutes } from "./domains/evals/index.js";
4
5
  import { workflowRoutes } from "./domains/evals/workflow/routes.js";
5
6
  import { sessionAuth, sessionContext } from "./middleware/sessionAuth.js";
@@ -181,7 +182,7 @@ function createAgentsHono(config) {
181
182
  headers: new Headers(c.req.raw.headers),
182
183
  body: bodyBuffer
183
184
  });
184
- return fetch(forwardedRequest);
185
+ return getInProcessFetch()(forwardedRequest);
185
186
  });
186
187
  app.route("/evals", evalRoutes);
187
188
  app.route("/work-apps/github", githubRoutes);
@@ -193,6 +194,7 @@ function createAgentsHono(config) {
193
194
  });
194
195
  const base = new Hono();
195
196
  base.route("/", app);
197
+ registerAppFetch(base.request.bind(base));
196
198
  return base;
197
199
  }
198
200
 
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono15 from "hono";
2
+ import * as hono11 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/datasetTriggers.d.ts
5
- declare const app: OpenAPIHono<hono15.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono11.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono16 from "hono";
2
+ import * as hono13 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono16.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono13.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -3,6 +3,7 @@ import { env } from "../../../env.js";
3
3
  import manageDbClient_default from "../../../data/db/manageDbClient.js";
4
4
  import manageDbPool_default from "../../../data/db/manageDbPool.js";
5
5
  import runDbClient_default from "../../../data/db/runDbClient.js";
6
+ import { getInProcessFetch } from "../../../utils/in-process-fetch.js";
6
7
  import { ModelFactory, createEvaluationResult, createEvaluationRun, filterConversationsForJob, generateId, getConversationHistory, getEvaluationJobConfigById, getEvaluationJobConfigEvaluatorRelations, getEvaluatorById, getFullAgent, getProjectScopedRef, resolveRef, updateEvaluationResult, withRef } from "@inkeep/agents-core";
7
8
  import { generateObject, generateText } from "ai";
8
9
  import { z } from "zod";
@@ -86,7 +87,7 @@ var EvaluationService = class {
86
87
  datasetRunId,
87
88
  conversationId
88
89
  }, "Running dataset item through chat API");
89
- const response = await fetch(chatUrl, {
90
+ const response = await getInProcessFetch()(chatUrl, {
90
91
  method: "POST",
91
92
  headers: headers$1,
92
93
  body: JSON.stringify(chatPayload)
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types12 from "hono/types";
2
+ import * as hono_types5 from "hono/types";
3
3
 
4
4
  //#region src/domains/evals/workflow/routes.d.ts
5
- declare const workflowRoutes: Hono<hono_types12.BlankEnv, hono_types12.BlankSchema, "/">;
5
+ declare const workflowRoutes: Hono<hono_types5.BlankEnv, hono_types5.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { workflowRoutes };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono7 from "hono";
2
+ import * as hono16 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/conversations.d.ts
5
- declare const app: OpenAPIHono<hono7.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono16.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono14 from "hono";
2
+ import * as hono18 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono14.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono18.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,10 +1,10 @@
1
1
  import { ManageAppVariables } from "../../../types/app.js";
2
2
  import { Hono } from "hono";
3
- import * as hono_types1 from "hono/types";
3
+ import * as hono_types12 from "hono/types";
4
4
 
5
5
  //#region src/domains/manage/routes/invitations.d.ts
6
6
  declare const invitationsRoutes: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types1.BlankSchema, "/">;
8
+ }, hono_types12.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { invitationsRoutes as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types2 from "hono/types";
2
+ import * as hono_types9 from "hono/types";
3
3
 
4
4
  //#region src/domains/manage/routes/mcp.d.ts
5
- declare const app: Hono<hono_types2.BlankEnv, hono_types2.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types9.BlankEnv, hono_types9.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,10 +1,10 @@
1
1
  import { ManageAppVariables } from "../../../types/app.js";
2
2
  import { Hono } from "hono";
3
- import * as hono_types7 from "hono/types";
3
+ import * as hono_types11 from "hono/types";
4
4
 
5
5
  //#region src/domains/manage/routes/signoz.d.ts
6
6
  declare const app: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types7.BlankSchema, "/">;
8
+ }, hono_types11.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { app as default };
@@ -1,10 +1,10 @@
1
1
  import { ManageAppVariables } from "../../../types/app.js";
2
2
  import { Hono } from "hono";
3
- import * as hono_types6 from "hono/types";
3
+ import * as hono_types13 from "hono/types";
4
4
 
5
5
  //#region src/domains/manage/routes/userOrganizations.d.ts
6
6
  declare const userOrganizationsRoutes: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types6.BlankSchema, "/">;
8
+ }, hono_types13.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { userOrganizationsRoutes as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types8 from "hono/types";
2
+ import * as hono_types7 from "hono/types";
3
3
 
4
4
  //#region src/domains/mcp/routes/mcp.d.ts
5
- declare const app: Hono<hono_types8.BlankEnv, hono_types8.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types7.BlankEnv, hono_types7.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -20,6 +20,7 @@ interface A2AClientOptions {
20
20
  retryConfig?: RetryConfig;
21
21
  ref?: ResolvedRef;
22
22
  headers?: Record<string, string>;
23
+ fetchFn?: typeof fetch;
23
24
  }
24
25
  /**
25
26
  * A2AClient is a TypeScript HTTP client for interacting with A2A-compliant agents.
@@ -64,6 +65,7 @@ declare class A2AClient {
64
65
  private requestIdCounter;
65
66
  private serviceEndpointUrl?;
66
67
  private options;
68
+ private fetchFn;
67
69
  /**
68
70
  * Constructs an A2AClient instance.
69
71
  * It initiates fetching the agent card from the provided agent baseUrl.
@@ -82,6 +82,7 @@ var A2AClient = class {
82
82
  requestIdCounter = 1;
83
83
  serviceEndpointUrl;
84
84
  options;
85
+ fetchFn;
85
86
  /**
86
87
  * Constructs an A2AClient instance.
87
88
  * It initiates fetching the agent card from the provided agent baseUrl.
@@ -92,6 +93,7 @@ var A2AClient = class {
92
93
  */
93
94
  constructor(agentBaseUrl, options) {
94
95
  this.agentBaseUrl = agentBaseUrl.replace(/\/$/, "");
96
+ this.fetchFn = options?.fetchFn ?? fetch;
95
97
  this.options = {
96
98
  retryConfig: {
97
99
  strategy: "backoff",
@@ -117,7 +119,7 @@ var A2AClient = class {
117
119
  agentBaseUrl: this.agentBaseUrl
118
120
  }, "agentCardUrl");
119
121
  try {
120
- const response = await fetch(url.toString(), { headers: {
122
+ const response = await this.fetchFn(url.toString(), { headers: {
121
123
  Accept: "application/json",
122
124
  ...this.options.headers || {}
123
125
  } });
@@ -144,7 +146,7 @@ var A2AClient = class {
144
146
  const agentCardUrl = `${agentBaseUrl.replace(/\/$/, "")}/.well-known/agent.json`;
145
147
  const url = new URL(agentCardUrl);
146
148
  if (this.options.ref) url.searchParams.set("ref", this.options.ref.name);
147
- const response = await fetch(url.toString(), { headers: {
149
+ const response = await this.fetchFn(url.toString(), { headers: {
148
150
  Accept: "application/json",
149
151
  ...this.options.headers || {}
150
152
  } });
@@ -284,7 +286,7 @@ var A2AClient = class {
284
286
  id: requestId
285
287
  };
286
288
  const httpResponse = await this.retry(async () => {
287
- return fetch(endpoint, {
289
+ return this.fetchFn(endpoint, {
288
290
  method: "POST",
289
291
  headers: {
290
292
  "Content-Type": "application/json",
@@ -347,7 +349,7 @@ var A2AClient = class {
347
349
  params,
348
350
  id: clientRequestId
349
351
  };
350
- const response = await fetch(endpoint, {
352
+ const response = await this.fetchFn(endpoint, {
351
353
  method: "POST",
352
354
  headers: {
353
355
  "Content-Type": "application/json",
@@ -422,7 +424,7 @@ var A2AClient = class {
422
424
  params,
423
425
  id: clientRequestId
424
426
  };
425
- const response = await fetch(endpoint, {
427
+ const response = await this.fetchFn(endpoint, {
426
428
  method: "POST",
427
429
  headers: {
428
430
  "Content-Type": "application/json",
@@ -1,6 +1,7 @@
1
1
  import { getLogger as getLogger$1 } from "../../../logger.js";
2
2
  import manageDbPool_default from "../../../data/db/manageDbPool.js";
3
3
  import runDbClient_default from "../../../data/db/runDbClient.js";
4
+ import { getInProcessFetch } from "../../../utils/in-process-fetch.js";
4
5
  import { DELEGATION_TOOL_BACKOFF_EXPONENT, DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS, DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS, DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS } from "../constants/execution-limits/index.js";
5
6
  import { toolSessionManager } from "./ToolSessionManager.js";
6
7
  import { saveA2AMessageResponse } from "../data/conversations.js";
@@ -206,7 +207,8 @@ function createDelegateToAgentTool({ delegateConfig, callingAgentId, executionCo
206
207
  exponent: DELEGATION_TOOL_BACKOFF_EXPONENT,
207
208
  maxElapsedTime: DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS
208
209
  }
209
- }
210
+ },
211
+ ...isInternal || isTeam ? { fetchFn: getInProcessFetch() } : {}
210
212
  });
211
213
  const messageToSend = {
212
214
  role: "agent",
@@ -1,5 +1,6 @@
1
1
  import { getLogger as getLogger$1 } from "../../../logger.js";
2
2
  import runDbClient_default from "../../../data/db/runDbClient.js";
3
+ import { getInProcessFetch } from "../../../utils/in-process-fetch.js";
3
4
  import { AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS } from "../constants/execution-limits/index.js";
4
5
  import { tracer } from "../utils/tracer.js";
5
6
  import { registerStreamHelper, unregisterStreamHelper } from "../utils/stream-registry.js";
@@ -164,14 +165,17 @@ var ExecutionHandler = class {
164
165
  currentAgentId = activeAgent.activeSubAgentId;
165
166
  logger.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
166
167
  }
167
- const a2aClient = new A2AClient(`${baseUrl}/run/agents`, { headers: {
168
- Authorization: `Bearer ${apiKey}`,
169
- "x-inkeep-tenant-id": tenantId,
170
- "x-inkeep-project-id": projectId,
171
- "x-inkeep-agent-id": agentId,
172
- "x-inkeep-sub-agent-id": currentAgentId,
173
- ...forwardedHeaders || {}
174
- } });
168
+ const a2aClient = new A2AClient(`${baseUrl}/run/agents`, {
169
+ headers: {
170
+ Authorization: `Bearer ${apiKey}`,
171
+ "x-inkeep-tenant-id": tenantId,
172
+ "x-inkeep-project-id": projectId,
173
+ "x-inkeep-agent-id": agentId,
174
+ "x-inkeep-sub-agent-id": currentAgentId,
175
+ ...forwardedHeaders || {}
176
+ },
177
+ fetchFn: getInProcessFetch()
178
+ });
175
179
  let messageResponse = null;
176
180
  const messageMetadata = {
177
181
  stream_request_id: requestId,