@inkeep/agents-api 0.0.0-dev-20260212200928 → 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,23 +1,18 @@
1
1
  {
2
2
  "version": "1.0.0",
3
3
  "steps": {
4
- "src/domains/evals/workflow/functions/evaluateConversation.ts": {
5
- "executeEvaluatorStep": {
6
- "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//executeEvaluatorStep"
4
+ "src/domains/evals/workflow/functions/runDatasetItem.ts": {
5
+ "callChatApiStep": {
6
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//callChatApiStep"
7
7
  },
8
- "getConversationStep": {
9
- "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//getConversationStep"
8
+ "createRelationStep": {
9
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//createRelationStep"
10
10
  },
11
- "getEvaluatorsStep": {
12
- "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//getEvaluatorsStep"
11
+ "executeEvaluatorStep": {
12
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//executeEvaluatorStep"
13
13
  },
14
14
  "logStep": {
15
- "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//logStep"
16
- }
17
- },
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/stdlib.js": {
19
- "fetch": {
20
- "stepId": "step//workflow@4.1.0-beta.54//fetch"
15
+ "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//logStep"
21
16
  }
22
17
  },
23
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": {
@@ -31,18 +26,18 @@
31
26
  "stepId": "__builtin_response_text"
32
27
  }
33
28
  },
34
- "src/domains/evals/workflow/functions/runDatasetItem.ts": {
35
- "callChatApiStep": {
36
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//callChatApiStep"
29
+ "src/domains/evals/workflow/functions/evaluateConversation.ts": {
30
+ "executeEvaluatorStep": {
31
+ "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//executeEvaluatorStep"
37
32
  },
38
- "createRelationStep": {
39
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//createRelationStep"
33
+ "getConversationStep": {
34
+ "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//getConversationStep"
40
35
  },
41
- "executeEvaluatorStep": {
42
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//executeEvaluatorStep"
36
+ "getEvaluatorsStep": {
37
+ "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//getEvaluatorsStep"
43
38
  },
44
39
  "logStep": {
45
- "stepId": "step//./src/domains/evals/workflow/functions/runDatasetItem//logStep"
40
+ "stepId": "step//./src/domains/evals/workflow/functions/evaluateConversation//logStep"
46
41
  }
47
42
  },
48
43
  "src/domains/run/workflow/steps/scheduledTriggerSteps.ts": {
@@ -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_types0 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_types0.BlankEnv, hono_types0.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 hono17 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<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 { Hono } from "hono";
2
- import * as hono_types8 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_types8.BlankEnv, hono_types8.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 hono14 from "hono";
2
+ import * as hono13 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/availableAgents.d.ts
5
- declare const app: OpenAPIHono<hono14.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono13.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 hono15 from "hono";
2
+ import * as hono14 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/conversations.d.ts
5
- declare const app: OpenAPIHono<hono15.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono14.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 hono15 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<hono15.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_types3 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_types3.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_types5 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_types5.BlankEnv, hono_types5.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/passwordResetLinks.d.ts
6
6
  declare const passwordResetLinksRoutes: Hono<{
7
7
  Variables: ManageAppVariables;
8
- }, hono_types7.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_types4 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_types4.BlankSchema, "/">;
8
+ }, hono_types7.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { app as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types10 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_types10.BlankEnv, hono_types10.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };