@inkeep/agents-api 0.0.0-dev-20260212210717 → 0.0.0-dev-20260212211616

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,20 @@
1
1
  {
2
2
  "version": "1.0.0",
3
3
  "steps": {
4
+ "src/domains/evals/workflow/functions/runDatasetItem.ts": {
5
+ "callChatApiStep": {
6
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//callChatApiStep"
7
+ },
8
+ "createRelationStep": {
9
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//createRelationStep"
10
+ },
11
+ "executeEvaluatorStep": {
12
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//executeEvaluatorStep"
13
+ },
14
+ "logStep": {
15
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//logStep"
16
+ }
17
+ },
4
18
  "node_modules/.pnpm/workflow@4.1.0-beta.54_@aws-sdk+client-sts@3.970.0_@nestjs+common@11.1.13_reflect-metad_f85281f2580d7065fc514e637f5f5e1f/node_modules/workflow/dist/internal/builtins.js": {
5
19
  "__builtin_response_array_buffer": {
6
20
  "stepId": "__builtin_response_array_buffer"
@@ -12,11 +26,6 @@
12
26
  "stepId": "__builtin_response_text"
13
27
  }
14
28
  },
15
- "node_modules/.pnpm/workflow@4.1.0-beta.54_@aws-sdk+client-sts@3.970.0_@nestjs+common@11.1.13_reflect-metad_f85281f2580d7065fc514e637f5f5e1f/node_modules/workflow/dist/stdlib.js": {
16
- "fetch": {
17
- "stepId": "step//workflow@4.1.0-beta.54//fetch"
18
- }
19
- },
20
29
  "src/domains/evals/workflow/functions/evaluateConversation.ts": {
21
30
  "executeEvaluatorStep": {
22
31
  "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//executeEvaluatorStep"
@@ -31,20 +40,6 @@
31
40
  "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//logStep"
32
41
  }
33
42
  },
34
- "src/domains/evals/workflow/functions/runDatasetItem.ts": {
35
- "callChatApiStep": {
36
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//callChatApiStep"
37
- },
38
- "createRelationStep": {
39
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//createRelationStep"
40
- },
41
- "executeEvaluatorStep": {
42
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//executeEvaluatorStep"
43
- },
44
- "logStep": {
45
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//logStep"
46
- }
47
- },
48
43
  "src/domains/run/workflow/steps/scheduledTriggerSteps.ts": {
49
44
  "addConversationIdStep": {
50
45
  "stepId": "step//./src/domains/run/workflow/steps/scheduledTriggerSteps//addConversationIdStep"
@@ -88,21 +83,26 @@
88
83
  "markRunningStep": {
89
84
  "stepId": "step//./src/domains/run/workflow/steps/scheduledTriggerSteps//markRunningStep"
90
85
  }
86
+ },
87
+ "node_modules/.pnpm/workflow@4.1.0-beta.54_@aws-sdk+client-sts@3.970.0_@nestjs+common@11.1.13_reflect-metad_f85281f2580d7065fc514e637f5f5e1f/node_modules/workflow/dist/stdlib.js": {
88
+ "fetch": {
89
+ "stepId": "step//workflow@4.1.0-beta.54//fetch"
90
+ }
91
91
  }
92
92
  },
93
93
  "workflows": {
94
- "src/domains/evals/workflow/functions/evaluateConversation.ts": {
95
- "_evaluateConversationWorkflow": {
96
- "workflowId": "workflow//./src/domains/evals/workflow/functions/evaluateConversation//_evaluateConversationWorkflow",
94
+ "src/domains/evals/workflow/functions/runDatasetItem.ts": {
95
+ "_runDatasetItemWorkflow": {
96
+ "workflowId": "workflow//./src/domains/evals/workflow/functions/runDatasetItem//_runDatasetItemWorkflow",
97
97
  "graph": {
98
98
  "nodes": [],
99
99
  "edges": []
100
100
  }
101
101
  }
102
102
  },
103
- "src/domains/evals/workflow/functions/runDatasetItem.ts": {
104
- "_runDatasetItemWorkflow": {
105
- "workflowId": "workflow//./src/domains/evals/workflow/functions/runDatasetItem//_runDatasetItemWorkflow",
103
+ "src/domains/evals/workflow/functions/evaluateConversation.ts": {
104
+ "_evaluateConversationWorkflow": {
105
+ "workflowId": "workflow//./src/domains/evals/workflow/functions/evaluateConversation//_evaluateConversationWorkflow",
106
106
  "graph": {
107
107
  "nodes": [],
108
108
  "edges": []
@@ -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_types12 from "hono/types";
4
+ import * as hono_types13 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_types12.BlankEnv, hono_types12.BlankSchema, "/">;
8
+ declare function createAgentsHono(config: AppConfig): Hono<hono_types13.BlankEnv, hono_types13.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { createAgentsHono, isWebhookRoute };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono9 from "hono";
2
+ import * as hono16 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<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 hono8 from "hono";
2
+ import * as hono12 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono8.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono12.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types0 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_types0.BlankEnv, hono_types0.BlankSchema, "/">;
5
+ declare const workflowRoutes: Hono<hono_types5.BlankEnv, hono_types5.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { workflowRoutes };
@@ -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_types8 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_types6.BlankSchema, "/">;
8
+ }, hono_types8.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { invitationsRoutes as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types4 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_types4.BlankEnv, hono_types4.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_types3 from "hono/types";
3
+ import * as hono_types11 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_types3.BlankSchema, "/">;
8
+ }, hono_types11.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { passwordResetLinksRoutes as default };
@@ -5,7 +5,7 @@ import { requireProjectPermission } from "../../../middleware/projectAccess.js";
5
5
  import { onTriggerCreated, onTriggerDeleted, onTriggerUpdated } from "../../run/services/ScheduledTriggerService.js";
6
6
  import { requirePermission } from "../../../middleware/requirePermission.js";
7
7
  import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
8
- import { ErrorResponseSchema, FullProjectDefinitionSchema, FullProjectSelectResponse, FullProjectSelectWithRelationIdsResponse, TenantParamsSchema, TenantProjectParamsSchema, cascadeDeleteByProject, checkoutBranch, commonGetErrorResponses, createApiError, createFullProjectServerSide, createProjectMetadataAndBranch, deleteFullProject, deleteProjectWithBranch, doltCheckout, getFullProject, getFullProjectWithRelationIds, getProjectMainBranchName, getProjectMetadata, listScheduledTriggers, updateFullProjectServerSide } from "@inkeep/agents-core";
8
+ import { ErrorResponseSchema, FullProjectDefinitionSchema, FullProjectSelectResponse, FullProjectSelectWithRelationIdsResponse, TenantParamsSchema, TenantProjectParamsSchema, cascadeDeleteByProject, checkoutBranch, commonGetErrorResponses, createApiError, createFullProjectServerSide, createProjectMetadataAndBranch, deleteFullProject, deleteProjectWithBranch, doltCheckout, getFullProject, getFullProjectWithRelationIds, getProjectMainBranchName, getProjectMetadata, listScheduledTriggers, removeProjectFromSpiceDb, syncProjectToSpiceDb, updateFullProjectServerSide } from "@inkeep/agents-core";
9
9
 
10
10
  //#region src/domains/manage/routes/projectFull.ts
11
11
  const logger = getLogger$1("projectFull");
@@ -65,33 +65,47 @@ app.openapi(createRoute({
65
65
  const projectData = c.req.valid("json");
66
66
  const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
67
67
  try {
68
- await createProjectMetadataAndBranch(runDbClient_default, configDb)({
69
- tenantId,
70
- projectId: validatedProjectData.id,
71
- createdBy: userId
72
- });
73
- logger.info({
74
- tenantId,
75
- projectId: validatedProjectData.id
76
- }, "Created project with branch, now populating config");
77
- const projectMainBranch = getProjectMainBranchName(tenantId, validatedProjectData.id);
78
- await checkoutBranch(configDb)({
79
- branchName: projectMainBranch,
80
- autoCommitPending: true
81
- });
82
- const newResolvedRef = {
83
- type: "branch",
84
- name: projectMainBranch,
85
- hash: ""
86
- };
87
- c.set("resolvedRef", newResolvedRef);
88
- logger.debug({ projectMainBranch }, "Checked out project branch for config writes");
89
- const createdProject = await createFullProjectServerSide(configDb)({
90
- scopes: {
91
- tenantId,
92
- projectId: validatedProjectData.id
93
- },
94
- projectData: validatedProjectData
68
+ const createdProject = await runDbClient_default.transaction(async (runTx) => {
69
+ return await configDb.transaction(async (configTx) => {
70
+ await createProjectMetadataAndBranch(runTx, configTx)({
71
+ tenantId,
72
+ projectId: validatedProjectData.id,
73
+ createdBy: userId
74
+ });
75
+ logger.info({
76
+ tenantId,
77
+ projectId: validatedProjectData.id
78
+ }, "Created project with branch, now populating config");
79
+ const projectMainBranch = getProjectMainBranchName(tenantId, validatedProjectData.id);
80
+ await checkoutBranch(configTx)({
81
+ branchName: projectMainBranch,
82
+ autoCommitPending: true
83
+ });
84
+ const newResolvedRef = {
85
+ type: "branch",
86
+ name: projectMainBranch,
87
+ hash: ""
88
+ };
89
+ c.set("resolvedRef", newResolvedRef);
90
+ logger.debug({ projectMainBranch }, "Checked out project branch for config writes");
91
+ const project = await createFullProjectServerSide(configTx)({
92
+ scopes: {
93
+ tenantId,
94
+ projectId: validatedProjectData.id
95
+ },
96
+ projectData: validatedProjectData
97
+ });
98
+ if (userId) await syncProjectToSpiceDb({
99
+ tenantId,
100
+ projectId: validatedProjectData.id,
101
+ creatorUserId: userId
102
+ });
103
+ else logger.warn({
104
+ tenantId,
105
+ projectId: validatedProjectData.id
106
+ }, "Skipping SpiceDB sync — no userId available");
107
+ return project;
108
+ });
95
109
  });
96
110
  return c.json({ data: createdProject }, 201);
97
111
  } catch (error) {
@@ -100,6 +114,19 @@ app.openapi(createRoute({
100
114
  code: "conflict",
101
115
  message: `Project with ID '${projectData.id}' already exists`
102
116
  });
117
+ const isGrpcError = error?.metadata !== void 0 && typeof error?.code === "number";
118
+ if (error?.message?.includes("SpiceDB") || isGrpcError) {
119
+ logger.error({
120
+ error,
121
+ tenantId,
122
+ projectId: validatedProjectData.id,
123
+ userId
124
+ }, "Failed to sync project to SpiceDB — database transactions rolled back");
125
+ throw createApiError({
126
+ code: "internal_server_error",
127
+ message: "Failed to set up project authorization. No changes were made to the database."
128
+ });
129
+ }
103
130
  throw error;
104
131
  }
105
132
  });
@@ -212,29 +239,13 @@ app.openapi(createRoute({
212
239
  const projectData = c.req.valid("json");
213
240
  const configDb = c.get("db");
214
241
  const userId = c.get("userId");
242
+ const isCreate = c.get("isProjectCreate") ?? false;
215
243
  try {
216
244
  const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
217
245
  if (projectId !== validatedProjectData.id) throw createApiError({
218
246
  code: "bad_request",
219
247
  message: `Project ID mismatch: expected ${projectId}, got ${validatedProjectData.id}`
220
248
  });
221
- const isCreate = c.get("isProjectCreate") ?? false;
222
- if (isCreate) {
223
- await createProjectMetadataAndBranch(runDbClient_default, configDb)({
224
- tenantId,
225
- projectId,
226
- createdBy: userId
227
- });
228
- logger.info({
229
- tenantId,
230
- projectId
231
- }, "Created project with branch for PUT (upsert)");
232
- const projectMainBranch = getProjectMainBranchName(tenantId, projectId);
233
- await checkoutBranch(configDb)({
234
- branchName: projectMainBranch,
235
- autoCommitPending: true
236
- });
237
- }
238
249
  const existingTriggersByAgent = /* @__PURE__ */ new Map();
239
250
  if (!isCreate) {
240
251
  const agents = Object.keys(validatedProjectData.agents || {});
@@ -247,12 +258,40 @@ app.openapi(createRoute({
247
258
  existingTriggersByAgent.set(agentId, existingTriggers);
248
259
  }
249
260
  }
250
- const updatedProject = isCreate ? await createFullProjectServerSide(configDb)({
251
- scopes: {
252
- tenantId,
253
- projectId
254
- },
255
- projectData: validatedProjectData
261
+ const updatedProject = isCreate ? await runDbClient_default.transaction(async (runTx) => {
262
+ return await configDb.transaction(async (configTx) => {
263
+ await createProjectMetadataAndBranch(runTx, configTx)({
264
+ tenantId,
265
+ projectId,
266
+ createdBy: userId
267
+ });
268
+ logger.info({
269
+ tenantId,
270
+ projectId
271
+ }, "Created project with branch for PUT (upsert)");
272
+ const projectMainBranch = getProjectMainBranchName(tenantId, projectId);
273
+ await checkoutBranch(configTx)({
274
+ branchName: projectMainBranch,
275
+ autoCommitPending: true
276
+ });
277
+ const project = await createFullProjectServerSide(configTx)({
278
+ scopes: {
279
+ tenantId,
280
+ projectId
281
+ },
282
+ projectData: validatedProjectData
283
+ });
284
+ if (userId) await syncProjectToSpiceDb({
285
+ tenantId,
286
+ projectId,
287
+ creatorUserId: userId
288
+ });
289
+ else logger.warn({
290
+ tenantId,
291
+ projectId
292
+ }, "Skipping SpiceDB sync — no userId available");
293
+ return project;
294
+ });
256
295
  }) : await updateFullProjectServerSide(configDb)({
257
296
  scopes: {
258
297
  tenantId,
@@ -356,6 +395,21 @@ app.openapi(createRoute({
356
395
  code: "bad_request",
357
396
  message: error.message
358
397
  });
398
+ if (isCreate) {
399
+ const isGrpcError = error?.metadata !== void 0 && typeof error?.code === "number";
400
+ if (error?.message?.includes("SpiceDB") || isGrpcError) {
401
+ logger.error({
402
+ error,
403
+ tenantId,
404
+ projectId,
405
+ userId
406
+ }, "Failed to sync project to SpiceDB — database transactions rolled back");
407
+ throw createApiError({
408
+ code: "internal_server_error",
409
+ message: "Failed to set up project authorization. No changes were made to the database."
410
+ });
411
+ }
412
+ }
359
413
  throw createApiError({
360
414
  code: "internal_server_error",
361
415
  message: error instanceof Error ? error.message : "Failed to update project"
@@ -407,6 +461,22 @@ app.openapi(createRoute({
407
461
  code: "not_found",
408
462
  message: "Project not found"
409
463
  });
464
+ try {
465
+ await removeProjectFromSpiceDb({
466
+ tenantId,
467
+ projectId
468
+ });
469
+ logger.info({
470
+ tenantId,
471
+ projectId
472
+ }, "Removed project from SpiceDB");
473
+ } catch (error) {
474
+ logger.warn({
475
+ error,
476
+ tenantId,
477
+ projectId
478
+ }, "Failed to remove project from SpiceDB - orphaned auth relationships may remain");
479
+ }
410
480
  return c.body(null, 204);
411
481
  } catch (error) {
412
482
  if (error instanceof Error && error.message.includes("not found")) throw createApiError({
@@ -1,10 +1,10 @@
1
1
  import { ManageAppVariables } from "../../../types/app.js";
2
2
  import { Hono } from "hono";
3
- import * as hono_types14 from "hono/types";
3
+ import * as hono_types12 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_types14.BlankSchema, "/">;
8
+ }, hono_types12.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { usersRoutes as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types1 from "hono/types";
2
+ import * as hono_types3 from "hono/types";
3
3
 
4
4
  //#region src/domains/mcp/routes/mcp.d.ts
5
- declare const app: Hono<hono_types1.BlankEnv, hono_types1.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -105,7 +105,7 @@ declare function createInvocationIdempotentStep(params: {
105
105
  projectId: string;
106
106
  tenantId: string;
107
107
  id: string;
108
- status: "completed" | "pending" | "failed" | "running" | "cancelled";
108
+ status: "pending" | "completed" | "failed" | "running" | "cancelled";
109
109
  resolvedPayload?: Record<string, unknown> | null | undefined;
110
110
  };
111
111
  alreadyExists: boolean;
@@ -145,7 +145,7 @@ declare function markRunningStep(params: {
145
145
  projectId: string;
146
146
  tenantId: string;
147
147
  id: string;
148
- status: "completed" | "pending" | "failed" | "running" | "cancelled";
148
+ status: "pending" | "completed" | "failed" | "running" | "cancelled";
149
149
  resolvedPayload?: Record<string, unknown> | null | undefined;
150
150
  }>;
151
151
  /**
@@ -172,7 +172,7 @@ declare function addConversationIdStep(params: {
172
172
  projectId: string;
173
173
  tenantId: string;
174
174
  id: string;
175
- status: "completed" | "pending" | "failed" | "running" | "cancelled";
175
+ status: "pending" | "completed" | "failed" | "running" | "cancelled";
176
176
  resolvedPayload?: Record<string, unknown> | null | undefined;
177
177
  } | undefined>;
178
178
  /**
@@ -197,7 +197,7 @@ declare function markCompletedStep(params: {
197
197
  projectId: string;
198
198
  tenantId: string;
199
199
  id: string;
200
- status: "completed" | "pending" | "failed" | "running" | "cancelled";
200
+ status: "pending" | "completed" | "failed" | "running" | "cancelled";
201
201
  resolvedPayload?: Record<string, unknown> | null | undefined;
202
202
  } | undefined>;
203
203
  /**
@@ -222,7 +222,7 @@ declare function markFailedStep(params: {
222
222
  projectId: string;
223
223
  tenantId: string;
224
224
  id: string;
225
- status: "completed" | "pending" | "failed" | "running" | "cancelled";
225
+ status: "pending" | "completed" | "failed" | "running" | "cancelled";
226
226
  resolvedPayload?: Record<string, unknown> | null | undefined;
227
227
  } | undefined>;
228
228
  /**
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;
@@ -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: "error" | "trace" | "debug" | "info" | "warn";
62
+ LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error";
63
63
  INKEEP_AGENTS_MANAGE_DATABASE_URL: string;
64
64
  INKEEP_AGENTS_RUN_DATABASE_URL: string;
65
65
  INKEEP_AGENTS_API_URL: string;