@inkeep/agents-api 0.0.0-dev-20260122092303 → 0.0.0-dev-20260122101439

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.
@@ -1,6 +1,6 @@
1
- import * as _inkeep_agents_core0 from "@inkeep/agents-core";
1
+ import * as _inkeep_agents_core2 from "@inkeep/agents-core";
2
2
 
3
3
  //#region src/data/db/runDbClient.d.ts
4
- declare const runDbClient: _inkeep_agents_core0.AgentsRunDatabaseClient;
4
+ declare const runDbClient: _inkeep_agents_core2.AgentsRunDatabaseClient;
5
5
  //#endregion
6
6
  export { runDbClient as default };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono9 from "hono";
2
+ import * as hono10 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/datasetTriggers.d.ts
5
- declare const app: OpenAPIHono<hono9.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono10.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 hono10 from "hono";
2
+ import * as hono11 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono10.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono11.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types6 from "hono/types";
2
+ import * as hono_types3 from "hono/types";
3
3
 
4
4
  //#region src/domains/evals/workflow/routes.d.ts
5
- declare const workflowRoutes: Hono<hono_types6.BlankEnv, hono_types6.BlankSchema, "/">;
5
+ declare const workflowRoutes: Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { workflowRoutes };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono17 from "hono";
2
+ import * as hono12 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/conversations.d.ts
5
- declare const app: OpenAPIHono<hono17.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono12.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 hono18 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/evals/evaluationResults.d.ts
5
- declare const app: OpenAPIHono<hono16.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono18.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 hono18 from "hono";
2
+ import * as hono14 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono18.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono14.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types3 from "hono/types";
2
+ import * as hono_types5 from "hono/types";
3
3
 
4
4
  //#region src/domains/manage/routes/mcp.d.ts
5
- declare const app: Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types5.BlankEnv, hono_types5.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_types5 from "hono/types";
3
+ import * as hono_types7 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_types5.BlankSchema, "/">;
8
+ }, hono_types7.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { app as default };
@@ -1,6 +1,6 @@
1
1
  import { AgentConfig, DelegateRelation } from "./Agent.js";
2
2
  import { InternalRelation } from "../utils/project.js";
3
- import * as _inkeep_agents_core1 from "@inkeep/agents-core";
3
+ import * as _inkeep_agents_core0 from "@inkeep/agents-core";
4
4
  import { CredentialStoreRegistry, FullExecutionContext } from "@inkeep/agents-core";
5
5
  import * as ai0 from "ai";
6
6
 
@@ -44,7 +44,7 @@ declare function createDelegateToAgentTool({
44
44
  message: string;
45
45
  }, {
46
46
  toolCallId: any;
47
- result: _inkeep_agents_core1.Message | _inkeep_agents_core1.Task;
47
+ result: _inkeep_agents_core0.Message | _inkeep_agents_core0.Task;
48
48
  }>;
49
49
  /**
50
50
  * Parameters for building a transfer relation config
@@ -5,7 +5,7 @@ import runDbClient_default from "../../../data/db/runDbClient.js";
5
5
  import { createSSEStreamHelper } from "../utils/stream-helpers.js";
6
6
  import { ExecutionHandler } from "../handlers/executionHandler.js";
7
7
  import { JsonTransformer, createMessage, createOrGetConversation, createTriggerInvocation, generateId, getConversationId, getFullProjectWithRelationIds, getTriggerById, interpolateTemplate, setActiveAgentForConversation, updateTriggerInvocationStatus, verifySigningSecret, verifyTriggerAuth, withRef } from "@inkeep/agents-core";
8
- import { trace } from "@opentelemetry/api";
8
+ import { SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  import Ajv from "ajv";
10
10
 
11
11
  //#region src/domains/run/services/TriggerService.ts
@@ -250,98 +250,15 @@ async function dispatchExecution(params) {
250
250
  */
251
251
  async function executeAgentAsync(params) {
252
252
  const { tenantId, projectId, agentId, triggerId, invocationId, conversationId, userMessage, messageParts, resolvedRef } = params;
253
- logger.info({
254
- tenantId,
255
- projectId,
256
- agentId,
257
- triggerId,
258
- invocationId,
259
- conversationId
260
- }, "Starting async trigger execution");
261
- try {
262
- const project = await withRef(manageDbPool_default, resolvedRef, async (db) => {
263
- return await getFullProjectWithRelationIds(db)({ scopes: {
264
- tenantId,
265
- projectId
266
- } });
267
- });
268
- if (!project) throw new Error(`Project ${projectId} not found`);
269
- const agent = project.agents?.[agentId];
270
- if (!agent) throw new Error(`Agent ${agentId} not found in project`);
271
- const defaultSubAgentId = agent.defaultSubAgentId;
272
- if (!defaultSubAgentId) throw new Error(`Agent ${agentId} has no default sub-agent configured`);
273
- await createOrGetConversation(runDbClient_default)({
274
- id: conversationId,
275
- tenantId,
276
- projectId,
277
- agentId,
278
- activeSubAgentId: defaultSubAgentId,
279
- ref: resolvedRef
280
- });
281
- await setActiveAgentForConversation(runDbClient_default)({
282
- scopes: {
283
- tenantId,
284
- projectId
285
- },
286
- conversationId,
287
- subAgentId: defaultSubAgentId,
288
- agentId,
289
- ref: resolvedRef
290
- });
291
- await createMessage(runDbClient_default)({
292
- id: generateId(),
293
- tenantId,
294
- projectId,
295
- conversationId,
296
- role: "user",
297
- content: {
298
- text: userMessage,
299
- parts: messageParts
300
- },
301
- metadata: { a2a_metadata: {
302
- triggerId,
303
- invocationId
304
- } }
305
- });
306
- const executionContext = {
307
- tenantId,
308
- projectId,
309
- agentId,
310
- baseUrl: env.INKEEP_AGENTS_API_URL || "http://localhost:3002",
311
- apiKey: env.INKEEP_AGENTS_RUN_API_BYPASS_SECRET || "",
312
- apiKeyId: "trigger-invocation",
313
- resolvedRef,
314
- project,
315
- metadata: { initiatedBy: {
316
- type: "api_key",
317
- id: triggerId
318
- } }
319
- };
320
- const requestId = `trigger-${invocationId}`;
321
- const noOpStreamHelper = createSSEStreamHelper({
322
- writeSSE: async () => {},
323
- sleep: async () => {}
324
- }, requestId, Math.floor(Date.now() / 1e3));
325
- await new ExecutionHandler().execute({
326
- executionContext,
327
- conversationId,
328
- userMessage,
329
- messageParts,
330
- initialAgentId: agentId,
331
- requestId,
332
- sseHelper: noOpStreamHelper,
333
- emitOperations: false
334
- });
335
- await updateTriggerInvocationStatus(runDbClient_default)({
336
- scopes: {
337
- tenantId,
338
- projectId,
339
- agentId
340
- },
341
- triggerId,
342
- invocationId,
343
- data: { status: "success" }
344
- });
253
+ return trace.getTracer("trigger-service").startActiveSpan("trigger.execute_async", { attributes: {
254
+ "tenant.id": tenantId,
255
+ "project.id": projectId,
256
+ "agent.id": agentId,
257
+ "trigger.id": triggerId,
258
+ "trigger.invocation.id": invocationId,
259
+ "conversation.id": conversationId,
260
+ "invocation.type": "trigger"
261
+ } }, async (span) => {
345
262
  logger.info({
346
263
  tenantId,
347
264
  projectId,
@@ -349,20 +266,81 @@ async function executeAgentAsync(params) {
349
266
  triggerId,
350
267
  invocationId,
351
268
  conversationId
352
- }, "Async trigger execution completed successfully");
353
- } catch (error) {
354
- const errorMessage = error instanceof Error ? error.message : String(error);
355
- const errorStack = error instanceof Error ? error.stack : void 0;
356
- logger.error({
357
- err: errorMessage,
358
- errorStack,
359
- tenantId,
360
- projectId,
361
- agentId,
362
- triggerId,
363
- invocationId
364
- }, "Async trigger execution failed");
269
+ }, "Starting async trigger execution");
365
270
  try {
271
+ const project = await withRef(manageDbPool_default, resolvedRef, async (db) => {
272
+ return await getFullProjectWithRelationIds(db)({ scopes: {
273
+ tenantId,
274
+ projectId
275
+ } });
276
+ });
277
+ if (!project) throw new Error(`Project ${projectId} not found`);
278
+ const agent = project.agents?.[agentId];
279
+ if (!agent) throw new Error(`Agent ${agentId} not found in project`);
280
+ const defaultSubAgentId = agent.defaultSubAgentId;
281
+ if (!defaultSubAgentId) throw new Error(`Agent ${agentId} has no default sub-agent configured`);
282
+ await createOrGetConversation(runDbClient_default)({
283
+ id: conversationId,
284
+ tenantId,
285
+ projectId,
286
+ agentId,
287
+ activeSubAgentId: defaultSubAgentId,
288
+ ref: resolvedRef
289
+ });
290
+ await setActiveAgentForConversation(runDbClient_default)({
291
+ scopes: {
292
+ tenantId,
293
+ projectId
294
+ },
295
+ conversationId,
296
+ subAgentId: defaultSubAgentId,
297
+ agentId,
298
+ ref: resolvedRef
299
+ });
300
+ await createMessage(runDbClient_default)({
301
+ id: generateId(),
302
+ tenantId,
303
+ projectId,
304
+ conversationId,
305
+ role: "user",
306
+ content: {
307
+ text: userMessage,
308
+ parts: messageParts
309
+ },
310
+ metadata: { a2a_metadata: {
311
+ triggerId,
312
+ invocationId
313
+ } }
314
+ });
315
+ const executionContext = {
316
+ tenantId,
317
+ projectId,
318
+ agentId,
319
+ baseUrl: env.INKEEP_AGENTS_API_URL || "http://localhost:3002",
320
+ apiKey: env.INKEEP_AGENTS_RUN_API_BYPASS_SECRET || "",
321
+ apiKeyId: "trigger-invocation",
322
+ resolvedRef,
323
+ project,
324
+ metadata: { initiatedBy: {
325
+ type: "api_key",
326
+ id: triggerId
327
+ } }
328
+ };
329
+ const requestId = `trigger-${invocationId}`;
330
+ const noOpStreamHelper = createSSEStreamHelper({
331
+ writeSSE: async () => {},
332
+ sleep: async () => {}
333
+ }, requestId, Math.floor(Date.now() / 1e3));
334
+ await new ExecutionHandler().execute({
335
+ executionContext,
336
+ conversationId,
337
+ userMessage,
338
+ messageParts,
339
+ initialAgentId: agentId,
340
+ requestId,
341
+ sseHelper: noOpStreamHelper,
342
+ emitOperations: false
343
+ });
366
344
  await updateTriggerInvocationStatus(runDbClient_default)({
367
345
  scopes: {
368
346
  tenantId,
@@ -371,20 +349,60 @@ async function executeAgentAsync(params) {
371
349
  },
372
350
  triggerId,
373
351
  invocationId,
374
- data: {
375
- status: "failed",
376
- errorMessage
377
- }
352
+ data: { status: "success" }
353
+ });
354
+ span.setStatus({ code: SpanStatusCode.OK });
355
+ logger.info({
356
+ tenantId,
357
+ projectId,
358
+ agentId,
359
+ triggerId,
360
+ invocationId,
361
+ conversationId
362
+ }, "Async trigger execution completed successfully");
363
+ } catch (error) {
364
+ const errorMessage = error instanceof Error ? error.message : String(error);
365
+ const errorStack = error instanceof Error ? error.stack : void 0;
366
+ span.setStatus({
367
+ code: SpanStatusCode.ERROR,
368
+ message: errorMessage
378
369
  });
379
- } catch (updateError) {
380
- const updateErrorMessage = updateError instanceof Error ? updateError.message : String(updateError);
370
+ span.recordException(error instanceof Error ? error : new Error(errorMessage));
381
371
  logger.error({
382
- err: updateErrorMessage,
372
+ err: errorMessage,
373
+ errorStack,
374
+ tenantId,
375
+ projectId,
376
+ agentId,
377
+ triggerId,
383
378
  invocationId
384
- }, "Failed to update invocation status to failed");
379
+ }, "Async trigger execution failed");
380
+ try {
381
+ await updateTriggerInvocationStatus(runDbClient_default)({
382
+ scopes: {
383
+ tenantId,
384
+ projectId,
385
+ agentId
386
+ },
387
+ triggerId,
388
+ invocationId,
389
+ data: {
390
+ status: "failed",
391
+ errorMessage
392
+ }
393
+ });
394
+ } catch (updateError) {
395
+ const updateErrorMessage = updateError instanceof Error ? updateError.message : String(updateError);
396
+ logger.error({
397
+ err: updateErrorMessage,
398
+ invocationId
399
+ }, "Failed to update invocation status to failed");
400
+ }
401
+ throw error;
402
+ } finally {
403
+ span.end();
385
404
  }
386
- throw error;
387
- }
405
+ });
388
406
  }
389
407
 
390
408
  //#endregion
package/dist/env.d.ts CHANGED
@@ -14,11 +14,11 @@ declare const envSchema: z.ZodObject<{
14
14
  pentest: "pentest";
15
15
  }>>;
16
16
  LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
17
- error: "error";
18
17
  trace: "trace";
19
18
  debug: "debug";
20
19
  info: "info";
21
20
  warn: "warn";
21
+ error: "error";
22
22
  }>>;
23
23
  INKEEP_AGENTS_MANAGE_DATABASE_URL: z.ZodString;
24
24
  INKEEP_AGENTS_RUN_DATABASE_URL: z.ZodString;
@@ -53,7 +53,7 @@ declare const envSchema: z.ZodObject<{
53
53
  declare const env: {
54
54
  NODE_ENV: "development" | "production" | "test";
55
55
  ENVIRONMENT: "development" | "production" | "test" | "pentest";
56
- LOG_LEVEL: "error" | "trace" | "debug" | "info" | "warn";
56
+ LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error";
57
57
  INKEEP_AGENTS_MANAGE_DATABASE_URL: string;
58
58
  INKEEP_AGENTS_RUN_DATABASE_URL: string;
59
59
  INKEEP_AGENTS_API_URL: string;