@inkeep/agents-api 0.0.0-dev-20260211172526 → 0.0.0-dev-20260211191741

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,10 +1,10 @@
1
1
  import { AppConfig } from "./types/app.js";
2
2
  import "./types/index.js";
3
3
  import { Hono } from "hono";
4
- import * as hono_types8 from "hono/types";
4
+ import * as hono_types0 from "hono/types";
5
5
 
6
6
  //#region src/createApp.d.ts
7
7
  declare const isWebhookRoute: (path: string) => boolean;
8
- declare function createAgentsHono(config: AppConfig): Hono<hono_types8.BlankEnv, hono_types8.BlankSchema, "/">;
8
+ declare function createAgentsHono(config: AppConfig): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { createAgentsHono, isWebhookRoute };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono4 from "hono";
2
+ import * as hono1 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/datasetTriggers.d.ts
5
- declare const app: OpenAPIHono<hono4.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono1.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 hono2 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono14.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono2.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/evals/workflow/routes.d.ts
5
- declare const workflowRoutes: Hono<hono_types3.BlankEnv, hono_types3.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 hono15 from "hono";
2
+ import * as hono5 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/availableAgents.d.ts
5
- declare const app: OpenAPIHono<hono15.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono5.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 hono17 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/conversations.d.ts
5
- declare const app: OpenAPIHono<hono16.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono17.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 hono17 from "hono";
2
+ import * as hono16 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono17.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono16.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_types12 from "hono/types";
3
+ import * as hono_types9 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_types12.BlankSchema, "/">;
8
+ }, hono_types9.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { invitationsRoutes 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/passwordResetLinks.d.ts
6
6
  declare const passwordResetLinksRoutes: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types1.BlankSchema, "/">;
8
+ }, hono_types12.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { passwordResetLinksRoutes as default };
@@ -1,10 +1,10 @@
1
1
  import { ManageAppVariables } from "../../../types/app.js";
2
2
  import { Hono } from "hono";
3
- import * as hono_types2 from "hono/types";
3
+ import * as hono_types14 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_types2.BlankSchema, "/">;
8
+ }, hono_types14.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_types7 from "hono/types";
3
+ import * as hono_types13 from "hono/types";
4
4
 
5
5
  //#region src/domains/manage/routes/users.d.ts
6
6
  declare const usersRoutes: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types7.BlankSchema, "/">;
8
+ }, hono_types13.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { usersRoutes as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types5 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_types5.BlankEnv, hono_types5.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types7.BlankEnv, hono_types7.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,4 +1,3 @@
1
- import { __require } from "../../../_virtual/rolldown_runtime.js";
2
1
  import { getLogger as getLogger$1 } from "../../../logger.js";
3
2
  import { env } from "../../../env.js";
4
3
  import manageDbPool_default from "../../../data/db/manageDbPool.js";
@@ -12,10 +11,19 @@ import { SpanStatusCode, context, propagation } from "@opentelemetry/api";
12
11
  import Ajv from "ajv";
13
12
 
14
13
  //#region src/domains/run/services/TriggerService.ts
15
- let waitUntil;
16
- if (process.env.VERCEL) try {
17
- ({waitUntil} = __require("@vercel/functions"));
18
- } catch {}
14
+ let _waitUntil;
15
+ let _waitUntilResolved = false;
16
+ async function getWaitUntil() {
17
+ if (_waitUntilResolved) return _waitUntil;
18
+ _waitUntilResolved = true;
19
+ if (!process.env.VERCEL) return void 0;
20
+ try {
21
+ _waitUntil = (await import("@vercel/functions")).waitUntil;
22
+ } catch (e) {
23
+ console.error("[TriggerService] Failed to import @vercel/functions:", e);
24
+ }
25
+ return _waitUntil;
26
+ }
19
27
  const logger = getLogger$1("TriggerService");
20
28
  const ajv = new Ajv({ allErrors: true });
21
29
  const credentialCache = /* @__PURE__ */ new Map();
@@ -320,7 +328,7 @@ async function dispatchExecution(params) {
320
328
  invocationId,
321
329
  conversationId
322
330
  }, "Trigger invocation created");
323
- const executionPromise = executeAgentAsync({
331
+ const safeExecutionPromise = executeAgentAsync({
324
332
  tenantId,
325
333
  projectId,
326
334
  agentId,
@@ -330,9 +338,7 @@ async function dispatchExecution(params) {
330
338
  userMessage: userMessageText,
331
339
  messageParts,
332
340
  resolvedRef
333
- });
334
- if (waitUntil) waitUntil(executionPromise);
335
- else executionPromise.catch((error) => {
341
+ }).catch(async (error) => {
336
342
  const errorMessage = error instanceof Error ? error.message : String(error);
337
343
  const errorStack = error instanceof Error ? error.stack : void 0;
338
344
  logger.error({
@@ -344,7 +350,45 @@ async function dispatchExecution(params) {
344
350
  triggerId,
345
351
  invocationId
346
352
  }, "Background trigger execution failed");
353
+ try {
354
+ await updateTriggerInvocationStatus(runDbClient_default)({
355
+ scopes: {
356
+ tenantId,
357
+ projectId,
358
+ agentId
359
+ },
360
+ triggerId,
361
+ invocationId,
362
+ data: {
363
+ status: "failed",
364
+ errorMessage
365
+ }
366
+ });
367
+ } catch (updateError) {
368
+ const updateErrorMessage = updateError instanceof Error ? updateError.message : String(updateError);
369
+ logger.error({
370
+ err: updateErrorMessage,
371
+ invocationId
372
+ }, "Failed to update invocation status to failed");
373
+ }
347
374
  });
375
+ const waitUntil = await getWaitUntil();
376
+ if (waitUntil) {
377
+ logger.info({
378
+ tenantId,
379
+ projectId,
380
+ agentId,
381
+ triggerId,
382
+ invocationId
383
+ }, "Calling waitUntil with execution promise");
384
+ waitUntil(safeExecutionPromise);
385
+ } else logger.warn({
386
+ tenantId,
387
+ projectId,
388
+ agentId,
389
+ triggerId,
390
+ invocationId
391
+ }, "waitUntil is NOT available — background execution will be abandoned on serverless");
348
392
  logger.info({
349
393
  tenantId,
350
394
  projectId,
@@ -364,20 +408,69 @@ async function dispatchExecution(params) {
364
408
  */
365
409
  async function executeAgentAsync(params) {
366
410
  const { tenantId, projectId, agentId, triggerId, invocationId, conversationId, userMessage, messageParts, resolvedRef } = params;
411
+ logger.info({
412
+ tenantId,
413
+ projectId,
414
+ agentId,
415
+ triggerId,
416
+ invocationId
417
+ }, "executeAgentAsync: started, loading project");
367
418
  const project = await withRef(manageDbPool_default, resolvedRef, async (db) => {
368
419
  return await getFullProjectWithRelationIds(db)({ scopes: {
369
420
  tenantId,
370
421
  projectId
371
422
  } });
372
423
  });
373
- if (!project) throw new Error(`Project ${projectId} not found`);
424
+ logger.info({
425
+ tenantId,
426
+ projectId,
427
+ agentId,
428
+ triggerId,
429
+ invocationId,
430
+ hasProject: !!project
431
+ }, "executeAgentAsync: project loaded");
432
+ if (!project) {
433
+ logger.error({
434
+ tenantId,
435
+ projectId,
436
+ agentId,
437
+ triggerId,
438
+ invocationId
439
+ }, "Project not found for trigger execution");
440
+ throw new Error(`Project ${projectId} not found`);
441
+ }
374
442
  const agent = project.agents?.[agentId];
375
- if (!agent) throw new Error(`Agent ${agentId} not found in project`);
443
+ if (!agent) {
444
+ logger.error({
445
+ tenantId,
446
+ projectId,
447
+ agentId,
448
+ triggerId,
449
+ invocationId
450
+ }, "Agent not found in project for trigger execution");
451
+ throw new Error(`Agent ${agentId} not found in project`);
452
+ }
376
453
  const defaultSubAgentId = agent.defaultSubAgentId;
377
- if (!defaultSubAgentId) throw new Error(`Agent ${agentId} has no default sub-agent configured`);
454
+ if (!defaultSubAgentId) {
455
+ logger.error({
456
+ tenantId,
457
+ projectId,
458
+ agentId,
459
+ triggerId,
460
+ invocationId
461
+ }, "Agent has no default sub-agent configured");
462
+ throw new Error(`Agent ${agentId} has no default sub-agent configured`);
463
+ }
378
464
  const agentName = agent.name;
379
465
  const baggage = propagation.createBaggage().setEntry("conversation.id", { value: conversationId }).setEntry("tenant.id", { value: tenantId }).setEntry("project.id", { value: projectId }).setEntry("agent.id", { value: agentId }).setEntry("agent.name", { value: agentName });
380
466
  const ctxWithBaggage = propagation.setBaggage(context.active(), baggage);
467
+ logger.info({
468
+ tenantId,
469
+ projectId,
470
+ agentId,
471
+ triggerId,
472
+ invocationId
473
+ }, "executeAgentAsync: starting tracer span");
381
474
  return tracer.startActiveSpan("trigger.execute_async", {
382
475
  root: true,
383
476
  attributes: {
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";
17
18
  trace: "trace";
18
19
  debug: "debug";
19
20
  info: "info";
20
21
  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;
@@ -59,7 +59,7 @@ declare const envSchema: z.ZodObject<{
59
59
  declare const env: {
60
60
  NODE_ENV: "development" | "production" | "test";
61
61
  ENVIRONMENT: "development" | "production" | "test" | "pentest";
62
- LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error";
62
+ LOG_LEVEL: "error" | "trace" | "debug" | "info" | "warn";
63
63
  INKEEP_AGENTS_MANAGE_DATABASE_URL: string;
64
64
  INKEEP_AGENTS_RUN_DATABASE_URL: string;
65
65
  INKEEP_AGENTS_API_URL: string;