@inkeep/agents-manage-api 0.39.4 → 0.40.0

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 (123) hide show
  1. package/dist/create-app.d.ts +21 -0
  2. package/dist/create-app.js +144 -0
  3. package/dist/data/agentFull.d.ts +15 -0
  4. package/dist/data/agentFull.js +84 -0
  5. package/dist/data/conversations.d.ts +77 -0
  6. package/dist/data/conversations.js +152 -0
  7. package/dist/data/db/dbClient.d.ts +6 -0
  8. package/dist/data/db/dbClient.js +17 -0
  9. package/dist/env.d.ts +61 -0
  10. package/dist/env.js +55 -0
  11. package/dist/factory.d.ts +17 -2
  12. package/dist/factory.js +35 -2
  13. package/dist/index.d.ts +119 -22
  14. package/dist/index.js +8 -5
  15. package/dist/initialization.d.ts +6 -0
  16. package/dist/initialization.js +79 -0
  17. package/dist/logger.d.ts +2 -0
  18. package/dist/logger.js +3 -0
  19. package/dist/middleware/auth.d.ts +24 -0
  20. package/dist/middleware/auth.js +55 -0
  21. package/dist/middleware/error-handler.d.ts +12 -0
  22. package/dist/middleware/error-handler.js +88 -0
  23. package/dist/middleware/require-permission.d.ts +19 -0
  24. package/dist/middleware/require-permission.js +80 -0
  25. package/dist/middleware/session-auth.d.ts +6 -0
  26. package/dist/middleware/session-auth.js +26 -0
  27. package/dist/middleware/tenant-access.d.ts +12 -0
  28. package/dist/middleware/tenant-access.js +54 -0
  29. package/dist/openapi.d.ts +7 -0
  30. package/dist/openapi.js +157 -0
  31. package/dist/routes/agent.d.ts +9 -0
  32. package/dist/routes/agent.js +244 -0
  33. package/dist/routes/agentFull.d.ts +9 -0
  34. package/dist/routes/agentFull.js +188 -0
  35. package/dist/routes/agentToolRelations.d.ts +9 -0
  36. package/dist/routes/agentToolRelations.js +284 -0
  37. package/dist/routes/apiKeys.d.ts +9 -0
  38. package/dist/routes/apiKeys.js +217 -0
  39. package/dist/routes/artifactComponents.d.ts +9 -0
  40. package/dist/routes/artifactComponents.js +204 -0
  41. package/dist/routes/cliAuth.d.ts +9 -0
  42. package/dist/routes/cliAuth.js +60 -0
  43. package/dist/routes/contextConfigs.d.ts +9 -0
  44. package/dist/routes/contextConfigs.js +175 -0
  45. package/dist/routes/conversations.d.ts +7 -0
  46. package/dist/routes/conversations.js +59 -0
  47. package/dist/routes/credentialStores.d.ts +9 -0
  48. package/dist/routes/credentialStores.js +81 -0
  49. package/dist/routes/credentials.d.ts +9 -0
  50. package/dist/routes/credentials.js +204 -0
  51. package/dist/routes/dataComponents.d.ts +9 -0
  52. package/dist/routes/dataComponents.js +188 -0
  53. package/dist/routes/externalAgents.d.ts +9 -0
  54. package/dist/routes/externalAgents.js +195 -0
  55. package/dist/routes/functionTools.d.ts +9 -0
  56. package/dist/routes/functionTools.js +252 -0
  57. package/dist/routes/functions.d.ts +9 -0
  58. package/dist/routes/functions.js +281 -0
  59. package/dist/routes/index.d.ts +7 -0
  60. package/dist/routes/index.js +54 -0
  61. package/dist/routes/invitations.d.ts +9 -0
  62. package/dist/routes/invitations.js +41 -0
  63. package/dist/routes/mcp.d.ts +7 -0
  64. package/dist/routes/mcp.js +45 -0
  65. package/dist/routes/mcpCatalog.d.ts +13 -0
  66. package/dist/routes/mcpCatalog.js +454 -0
  67. package/dist/routes/oauth.d.ts +10 -0
  68. package/dist/routes/oauth.js +314 -0
  69. package/dist/routes/playgroundToken.d.ts +9 -0
  70. package/dist/routes/playgroundToken.js +108 -0
  71. package/dist/routes/projectFull.d.ts +9 -0
  72. package/dist/routes/projectFull.js +193 -0
  73. package/dist/routes/projects.d.ts +9 -0
  74. package/dist/routes/projects.js +188 -0
  75. package/dist/routes/shared.d.ts +93 -0
  76. package/dist/routes/shared.js +44 -0
  77. package/dist/routes/signoz.d.ts +10 -0
  78. package/dist/routes/signoz.js +155 -0
  79. package/dist/routes/subAgentArtifactComponents.d.ts +9 -0
  80. package/dist/routes/subAgentArtifactComponents.js +198 -0
  81. package/dist/routes/subAgentDataComponents.d.ts +9 -0
  82. package/dist/routes/subAgentDataComponents.js +197 -0
  83. package/dist/routes/subAgentExternalAgentRelations.d.ts +9 -0
  84. package/dist/routes/subAgentExternalAgentRelations.js +213 -0
  85. package/dist/routes/subAgentRelations.d.ts +9 -0
  86. package/dist/routes/subAgentRelations.js +259 -0
  87. package/dist/routes/subAgentTeamAgentRelations.d.ts +9 -0
  88. package/dist/routes/subAgentTeamAgentRelations.js +213 -0
  89. package/dist/routes/subAgentToolRelations.d.ts +9 -0
  90. package/dist/routes/subAgentToolRelations.js +284 -0
  91. package/dist/routes/subAgents.d.ts +9 -0
  92. package/dist/routes/subAgents.js +210 -0
  93. package/dist/routes/thirdPartyMCPServers.d.ts +14 -0
  94. package/dist/routes/thirdPartyMCPServers.js +72 -0
  95. package/dist/routes/tools.d.ts +9 -0
  96. package/dist/routes/tools.js +256 -0
  97. package/dist/routes/userOrganizations.d.ts +9 -0
  98. package/dist/routes/userOrganizations.js +58 -0
  99. package/dist/sso-helpers.d.ts +20 -0
  100. package/dist/sso-helpers.js +51 -0
  101. package/dist/types/app.d.ts +47 -0
  102. package/dist/types/app.js +1 -0
  103. package/dist/utils/cors.d.ts +33 -0
  104. package/dist/utils/cors.js +98 -0
  105. package/dist/utils/oauth-service.d.ts +71 -0
  106. package/dist/utils/oauth-service.js +106 -0
  107. package/dist/utils/signoz-helpers.d.ts +9 -0
  108. package/dist/utils/signoz-helpers.js +33 -0
  109. package/dist/utils/temp-api-keys.d.ts +17 -0
  110. package/dist/utils/temp-api-keys.js +26 -0
  111. package/package.json +6 -13
  112. package/dist/chunk-VBDAOXYI.js +0 -832
  113. package/dist/chunk-VBDAOXYI.js.map +0 -1
  114. package/dist/factory2.d.ts +0 -41
  115. package/dist/factory2.d.ts.map +0 -1
  116. package/dist/factory2.js +0 -37085
  117. package/dist/factory2.js.map +0 -1
  118. package/dist/index.d.ts.map +0 -1
  119. package/dist/index.js.map +0 -1
  120. package/dist/nodefs.js +0 -27
  121. package/dist/nodefs.js.map +0 -1
  122. package/dist/opfs-ahp.js +0 -368
  123. package/dist/opfs-ahp.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ import { BaseAppVariables } from "../types/app.js";
2
+ import { OpenAPIHono } from "@hono/zod-openapi";
3
+
4
+ //#region src/routes/subAgentDataComponents.d.ts
5
+ declare const app: OpenAPIHono<{
6
+ Variables: BaseAppVariables;
7
+ }, {}, "/">;
8
+ //#endregion
9
+ export { app as default };
@@ -0,0 +1,197 @@
1
+ import dbClient_default from "../data/db/dbClient.js";
2
+ import { requirePermission } from "../middleware/require-permission.js";
3
+ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
4
+ import { ComponentAssociationListResponse, DataComponentArrayResponse, ErrorResponseSchema, ExistsResponseSchema, RemovedResponseSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentResponse, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentParamsSchema, associateDataComponentWithAgent, commonGetErrorResponses, createApiError, getAgentsUsingDataComponent, getDataComponent, getDataComponentsForAgent, getSubAgentById, isDataComponentAssociatedWithAgent, removeDataComponentFromAgent } from "@inkeep/agents-core";
5
+
6
+ //#region src/routes/subAgentDataComponents.ts
7
+ const app = new OpenAPIHono();
8
+ app.use("/", async (c, next) => {
9
+ if (c.req.method === "POST") return requirePermission({ sub_agent: ["create"] })(c, next);
10
+ return next();
11
+ });
12
+ app.use("/agent/:subAgentId/component/:dataComponentId", async (c, next) => {
13
+ if (c.req.method === "DELETE") return requirePermission({ sub_agent: ["delete"] })(c, next);
14
+ return next();
15
+ });
16
+ app.openapi(createRoute({
17
+ method: "get",
18
+ path: "/agent/{subAgentId}",
19
+ summary: "Get Data Components for Agent",
20
+ operationId: "get-data-components-for-agent",
21
+ tags: ["Agent Data Component Relations"],
22
+ request: { params: TenantProjectAgentSubAgentParamsSchema },
23
+ responses: {
24
+ 200: {
25
+ description: "Data components retrieved successfully",
26
+ content: { "application/json": { schema: DataComponentArrayResponse } }
27
+ },
28
+ ...commonGetErrorResponses
29
+ }
30
+ }), async (c) => {
31
+ const { tenantId, projectId, agentId, subAgentId } = c.req.valid("param");
32
+ const dataComponents = await getDataComponentsForAgent(dbClient_default)({ scopes: {
33
+ tenantId,
34
+ projectId,
35
+ agentId,
36
+ subAgentId
37
+ } });
38
+ return c.json({ data: dataComponents });
39
+ });
40
+ app.openapi(createRoute({
41
+ method: "get",
42
+ path: "/component/{dataComponentId}/agents",
43
+ summary: "Get Agents Using Data Component",
44
+ operationId: "get-agents-using-data-component",
45
+ tags: ["Agent Data Component Relations"],
46
+ request: { params: TenantProjectAgentParamsSchema.extend({ dataComponentId: z.string() }) },
47
+ responses: {
48
+ 200: {
49
+ description: "Agents retrieved successfully",
50
+ content: { "application/json": { schema: ComponentAssociationListResponse } }
51
+ },
52
+ ...commonGetErrorResponses
53
+ }
54
+ }), async (c) => {
55
+ const { tenantId, projectId, dataComponentId } = c.req.valid("param");
56
+ const agents = await getAgentsUsingDataComponent(dbClient_default)({
57
+ scopes: {
58
+ tenantId,
59
+ projectId
60
+ },
61
+ dataComponentId
62
+ });
63
+ return c.json({ data: agents });
64
+ });
65
+ app.openapi(createRoute({
66
+ method: "post",
67
+ path: "/",
68
+ summary: "Associate Data Component with Agent",
69
+ operationId: "associate-data-component-with-agent",
70
+ tags: ["Agent Data Component Relations"],
71
+ request: {
72
+ params: TenantProjectAgentParamsSchema,
73
+ body: { content: { "application/json": { schema: SubAgentDataComponentApiInsertSchema } } }
74
+ },
75
+ responses: {
76
+ 201: {
77
+ description: "Agent data component association created successfully",
78
+ content: { "application/json": { schema: SubAgentDataComponentResponse } }
79
+ },
80
+ 409: {
81
+ description: "Association already exists",
82
+ content: { "application/json": { schema: ErrorResponseSchema } }
83
+ },
84
+ ...commonGetErrorResponses
85
+ }
86
+ }), async (c) => {
87
+ const { tenantId, projectId, agentId } = c.req.valid("param");
88
+ const { subAgentId, dataComponentId } = c.req.valid("json");
89
+ const [agent, dataComponent] = await Promise.all([getSubAgentById(dbClient_default)({
90
+ scopes: {
91
+ tenantId,
92
+ projectId,
93
+ agentId
94
+ },
95
+ subAgentId
96
+ }), getDataComponent(dbClient_default)({
97
+ scopes: {
98
+ tenantId,
99
+ projectId
100
+ },
101
+ dataComponentId
102
+ })]);
103
+ if (!agent) throw createApiError({
104
+ code: "not_found",
105
+ message: `Agent with id '${subAgentId}' not found`
106
+ });
107
+ if (!dataComponent) throw createApiError({
108
+ code: "not_found",
109
+ message: `Data component with id '${dataComponentId}' not found`
110
+ });
111
+ if (await isDataComponentAssociatedWithAgent(dbClient_default)({
112
+ scopes: {
113
+ tenantId,
114
+ projectId,
115
+ agentId,
116
+ subAgentId
117
+ },
118
+ dataComponentId
119
+ })) throw createApiError({
120
+ code: "conflict",
121
+ message: "Agent data component association already exists"
122
+ });
123
+ const association = await associateDataComponentWithAgent(dbClient_default)({
124
+ scopes: {
125
+ tenantId,
126
+ projectId,
127
+ agentId,
128
+ subAgentId
129
+ },
130
+ dataComponentId
131
+ });
132
+ return c.json({ data: association }, 201);
133
+ });
134
+ app.openapi(createRoute({
135
+ method: "delete",
136
+ path: "/agent/{subAgentId}/component/{dataComponentId}",
137
+ summary: "Remove Data Component from Agent",
138
+ operationId: "remove-data-component-from-agent",
139
+ tags: ["Agent Data Component Relations"],
140
+ request: { params: TenantProjectAgentSubAgentParamsSchema.extend({ dataComponentId: z.string() }) },
141
+ responses: {
142
+ 200: {
143
+ description: "Association removed successfully",
144
+ content: { "application/json": { schema: RemovedResponseSchema } }
145
+ },
146
+ ...commonGetErrorResponses
147
+ }
148
+ }), async (c) => {
149
+ const { tenantId, projectId, agentId, subAgentId, dataComponentId } = c.req.valid("param");
150
+ if (!await removeDataComponentFromAgent(dbClient_default)({
151
+ scopes: {
152
+ tenantId,
153
+ projectId,
154
+ agentId,
155
+ subAgentId
156
+ },
157
+ dataComponentId
158
+ })) throw createApiError({
159
+ code: "not_found",
160
+ message: "Agent data component association not found"
161
+ });
162
+ return c.json({
163
+ message: "Association removed successfully",
164
+ removed: true
165
+ });
166
+ });
167
+ app.openapi(createRoute({
168
+ method: "get",
169
+ path: "/agent/{subAgentId}/component/{dataComponentId}/exists",
170
+ summary: "Check if Data Component is Associated with Agent",
171
+ operationId: "check-data-component-agent-association",
172
+ tags: ["Agent Data Component Relations"],
173
+ request: { params: TenantProjectAgentSubAgentParamsSchema.extend({ dataComponentId: z.string() }) },
174
+ responses: {
175
+ 200: {
176
+ description: "Association status retrieved successfully",
177
+ content: { "application/json": { schema: ExistsResponseSchema } }
178
+ },
179
+ ...commonGetErrorResponses
180
+ }
181
+ }), async (c) => {
182
+ const { tenantId, projectId, agentId, subAgentId, dataComponentId } = c.req.valid("param");
183
+ const exists = await isDataComponentAssociatedWithAgent(dbClient_default)({
184
+ scopes: {
185
+ tenantId,
186
+ projectId,
187
+ agentId,
188
+ subAgentId
189
+ },
190
+ dataComponentId
191
+ });
192
+ return c.json({ exists });
193
+ });
194
+ var subAgentDataComponents_default = app;
195
+
196
+ //#endregion
197
+ export { subAgentDataComponents_default as default };
@@ -0,0 +1,9 @@
1
+ import { BaseAppVariables } from "../types/app.js";
2
+ import { OpenAPIHono } from "@hono/zod-openapi";
3
+
4
+ //#region src/routes/subAgentExternalAgentRelations.d.ts
5
+ declare const app: OpenAPIHono<{
6
+ Variables: BaseAppVariables;
7
+ }, {}, "/">;
8
+ //#endregion
9
+ export { app as default };
@@ -0,0 +1,213 @@
1
+ import dbClient_default from "../data/db/dbClient.js";
2
+ import { requirePermission } from "../middleware/require-permission.js";
3
+ import { speakeasyOffsetLimitPagination } from "./shared.js";
4
+ import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
5
+ import { ErrorResponseSchema, PaginationQueryParamsSchema, SubAgentExternalAgentRelationApiInsertSchema, SubAgentExternalAgentRelationApiUpdateSchema, SubAgentExternalAgentRelationListResponse, SubAgentExternalAgentRelationResponse, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, commonGetErrorResponses, createApiError, createSubAgentExternalAgentRelation, deleteSubAgentExternalAgentRelation, getSubAgentExternalAgentRelationById, listSubAgentExternalAgentRelations, updateSubAgentExternalAgentRelation } from "@inkeep/agents-core";
6
+ import { nanoid } from "nanoid";
7
+
8
+ //#region src/routes/subAgentExternalAgentRelations.ts
9
+ const app = new OpenAPIHono();
10
+ app.use("/", async (c, next) => {
11
+ if (c.req.method === "POST") return requirePermission({ sub_agent: ["create"] })(c, next);
12
+ return next();
13
+ });
14
+ app.use("/:id", async (c, next) => {
15
+ if (c.req.method === "PUT") return requirePermission({ sub_agent: ["update"] })(c, next);
16
+ if (c.req.method === "DELETE") return requirePermission({ sub_agent: ["delete"] })(c, next);
17
+ return next();
18
+ });
19
+ app.openapi(createRoute({
20
+ method: "get",
21
+ path: "/",
22
+ summary: "List Sub Agent External Agent Relations",
23
+ operationId: "list-sub-agent-external-agent-relations",
24
+ tags: ["Sub Agent External Agent Relations"],
25
+ request: {
26
+ params: TenantProjectAgentSubAgentParamsSchema,
27
+ query: PaginationQueryParamsSchema
28
+ },
29
+ responses: {
30
+ 200: {
31
+ description: "List of sub agent external agent relations retrieved successfully",
32
+ content: { "application/json": { schema: SubAgentExternalAgentRelationListResponse } }
33
+ },
34
+ ...commonGetErrorResponses
35
+ },
36
+ ...speakeasyOffsetLimitPagination
37
+ }), async (c) => {
38
+ const { tenantId, projectId, agentId, subAgentId } = c.req.valid("param");
39
+ const { page = 1, limit = 10 } = c.req.valid("query");
40
+ const pageNum = Number(page);
41
+ const limitNum = Math.min(Number(limit), 100);
42
+ try {
43
+ const result = await listSubAgentExternalAgentRelations(dbClient_default)({
44
+ scopes: {
45
+ tenantId,
46
+ projectId,
47
+ agentId,
48
+ subAgentId
49
+ },
50
+ pagination: {
51
+ page: pageNum,
52
+ limit: limitNum
53
+ }
54
+ });
55
+ return c.json(result);
56
+ } catch (_error) {
57
+ throw createApiError({
58
+ code: "internal_server_error",
59
+ message: "Failed to retrieve sub agent external agent relations"
60
+ });
61
+ }
62
+ });
63
+ app.openapi(createRoute({
64
+ method: "get",
65
+ path: "/{id}",
66
+ summary: "Get Sub Agent External Agent Relation",
67
+ operationId: "get-sub-agent-external-agent-relation-by-id",
68
+ tags: ["Sub Agent External Agent Relations"],
69
+ request: { params: TenantProjectAgentSubAgentIdParamsSchema },
70
+ responses: {
71
+ 200: {
72
+ description: "Sub Agent external agent relation found",
73
+ content: { "application/json": { schema: SubAgentExternalAgentRelationResponse } }
74
+ },
75
+ ...commonGetErrorResponses
76
+ }
77
+ }), async (c) => {
78
+ const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
79
+ const relation = await getSubAgentExternalAgentRelationById(dbClient_default)({
80
+ scopes: {
81
+ tenantId,
82
+ projectId,
83
+ agentId,
84
+ subAgentId
85
+ },
86
+ relationId: id
87
+ });
88
+ if (!relation) throw createApiError({
89
+ code: "not_found",
90
+ message: "Sub Agent External Agent Relation not found"
91
+ });
92
+ return c.json({ data: relation });
93
+ });
94
+ app.openapi(createRoute({
95
+ method: "post",
96
+ path: "/",
97
+ summary: "Create Sub Agent External Agent Relation",
98
+ operationId: "create-sub-agent-external-agent-relation",
99
+ tags: ["Sub Agent External Agent Relations"],
100
+ request: {
101
+ params: TenantProjectAgentSubAgentParamsSchema,
102
+ body: { content: { "application/json": { schema: SubAgentExternalAgentRelationApiInsertSchema } } }
103
+ },
104
+ responses: {
105
+ 201: {
106
+ description: "Sub Agent External Agent Relation created successfully",
107
+ content: { "application/json": { schema: SubAgentExternalAgentRelationResponse } }
108
+ },
109
+ ...commonGetErrorResponses
110
+ }
111
+ }), async (c) => {
112
+ const { tenantId, projectId, agentId, subAgentId } = c.req.valid("param");
113
+ const body = await c.req.valid("json");
114
+ if ((await listSubAgentExternalAgentRelations(dbClient_default)({
115
+ scopes: {
116
+ tenantId,
117
+ projectId,
118
+ agentId,
119
+ subAgentId
120
+ },
121
+ pagination: {
122
+ page: 1,
123
+ limit: 1e3
124
+ }
125
+ })).data.some((relation$1) => relation$1.externalAgentId === body.externalAgentId && relation$1.subAgentId === subAgentId)) throw createApiError({
126
+ code: "unprocessable_entity",
127
+ message: `A relation between this sub-agent and external agent already exists`
128
+ });
129
+ const relation = await createSubAgentExternalAgentRelation(dbClient_default)({
130
+ scopes: {
131
+ tenantId,
132
+ projectId,
133
+ agentId,
134
+ subAgentId
135
+ },
136
+ relationId: nanoid(),
137
+ data: {
138
+ externalAgentId: body.externalAgentId,
139
+ headers: body.headers || null
140
+ }
141
+ });
142
+ return c.json({ data: relation }, 201);
143
+ });
144
+ app.openapi(createRoute({
145
+ method: "put",
146
+ path: "/{id}",
147
+ summary: "Update Sub Agent External Agent Relation",
148
+ operationId: "update-sub-agent-external-agent-relation",
149
+ tags: ["Sub Agent External Agent Relations"],
150
+ request: {
151
+ params: TenantProjectAgentSubAgentIdParamsSchema,
152
+ body: { content: { "application/json": { schema: SubAgentExternalAgentRelationApiUpdateSchema } } }
153
+ },
154
+ responses: {
155
+ 200: {
156
+ description: "Sub Agent external agent relation updated successfully",
157
+ content: { "application/json": { schema: SubAgentExternalAgentRelationResponse } }
158
+ },
159
+ ...commonGetErrorResponses
160
+ }
161
+ }), async (c) => {
162
+ const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
163
+ const body = await c.req.valid("json");
164
+ const updatedRelation = await updateSubAgentExternalAgentRelation(dbClient_default)({
165
+ scopes: {
166
+ tenantId,
167
+ projectId,
168
+ agentId,
169
+ subAgentId
170
+ },
171
+ relationId: id,
172
+ data: body
173
+ });
174
+ if (!updatedRelation) throw createApiError({
175
+ code: "not_found",
176
+ message: "Sub Agent External Agent Relation not found"
177
+ });
178
+ return c.json({ data: updatedRelation });
179
+ });
180
+ app.openapi(createRoute({
181
+ method: "delete",
182
+ path: "/{id}",
183
+ summary: "Delete Sub Agent External Agent Relation",
184
+ operationId: "delete-sub-agent-external-agent-relation",
185
+ tags: ["Sub Agent External Agent Relations"],
186
+ request: { params: TenantProjectAgentSubAgentIdParamsSchema },
187
+ responses: {
188
+ 204: { description: "Sub Agent External Agent Relation deleted successfully" },
189
+ 404: {
190
+ description: "Sub Agent External Agent Relation not found",
191
+ content: { "application/json": { schema: ErrorResponseSchema } }
192
+ }
193
+ }
194
+ }), async (c) => {
195
+ const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
196
+ if (!await deleteSubAgentExternalAgentRelation(dbClient_default)({
197
+ scopes: {
198
+ tenantId,
199
+ projectId,
200
+ agentId,
201
+ subAgentId
202
+ },
203
+ relationId: id
204
+ })) throw createApiError({
205
+ code: "not_found",
206
+ message: "Sub Agent External Agent Relation not found"
207
+ });
208
+ return c.body(null, 204);
209
+ });
210
+ var subAgentExternalAgentRelations_default = app;
211
+
212
+ //#endregion
213
+ export { subAgentExternalAgentRelations_default as default };
@@ -0,0 +1,9 @@
1
+ import { BaseAppVariables } from "../types/app.js";
2
+ import { OpenAPIHono } from "@hono/zod-openapi";
3
+
4
+ //#region src/routes/subAgentRelations.d.ts
5
+ declare const app: OpenAPIHono<{
6
+ Variables: BaseAppVariables;
7
+ }, {}, "/">;
8
+ //#endregion
9
+ export { app as default };
@@ -0,0 +1,259 @@
1
+ import dbClient_default from "../data/db/dbClient.js";
2
+ import { requirePermission } from "../middleware/require-permission.js";
3
+ import { speakeasyOffsetLimitPagination } from "./shared.js";
4
+ import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
5
+ import { ErrorResponseSchema, PaginationQueryParamsSchema, SubAgentRelationApiInsertSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationListResponse, SubAgentRelationQuerySchema, SubAgentRelationResponse, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, commonGetErrorResponses, createApiError, createSubAgentRelation, deleteSubAgentRelation, generateId, getAgentRelationById, getAgentRelationsBySource, getSubAgentRelationsByTarget, listAgentRelations, updateAgentRelation, validateSubAgent } from "@inkeep/agents-core";
6
+
7
+ //#region src/routes/subAgentRelations.ts
8
+ const app = new OpenAPIHono();
9
+ app.use("/", async (c, next) => {
10
+ if (c.req.method === "POST") return requirePermission({ sub_agent: ["create"] })(c, next);
11
+ return next();
12
+ });
13
+ app.use("/:id", async (c, next) => {
14
+ if (c.req.method === "PUT") return requirePermission({ sub_agent: ["update"] })(c, next);
15
+ if (c.req.method === "DELETE") return requirePermission({ sub_agent: ["delete"] })(c, next);
16
+ return next();
17
+ });
18
+ app.openapi(createRoute({
19
+ method: "get",
20
+ path: "/",
21
+ summary: "List Sub Agent Relations",
22
+ operationId: "list-sub-agent-relations",
23
+ tags: ["Sub Agent Relations"],
24
+ request: {
25
+ params: TenantProjectAgentParamsSchema,
26
+ query: PaginationQueryParamsSchema.merge(SubAgentRelationQuerySchema)
27
+ },
28
+ responses: {
29
+ 200: {
30
+ description: "List of sub agent relations retrieved successfully",
31
+ content: { "application/json": { schema: SubAgentRelationListResponse } }
32
+ },
33
+ ...commonGetErrorResponses
34
+ },
35
+ ...speakeasyOffsetLimitPagination
36
+ }), async (c) => {
37
+ const { tenantId, projectId, agentId } = c.req.valid("param");
38
+ const { page = 1, limit = 10, sourceSubAgentId, targetSubAgentId } = c.req.valid("query");
39
+ const pageNum = Number(page);
40
+ const limitNum = Math.min(Number(limit), 100);
41
+ try {
42
+ let result;
43
+ if (sourceSubAgentId) {
44
+ const rawResult = await getAgentRelationsBySource(dbClient_default)({
45
+ scopes: {
46
+ tenantId,
47
+ projectId,
48
+ agentId
49
+ },
50
+ sourceSubAgentId,
51
+ pagination: {
52
+ page: pageNum,
53
+ limit: limitNum
54
+ }
55
+ });
56
+ result = {
57
+ ...rawResult,
58
+ data: rawResult.data
59
+ };
60
+ } else if (targetSubAgentId) {
61
+ const rawResult = await getSubAgentRelationsByTarget(dbClient_default)({
62
+ scopes: {
63
+ tenantId,
64
+ projectId,
65
+ agentId
66
+ },
67
+ targetSubAgentId,
68
+ pagination: {
69
+ page: pageNum,
70
+ limit: limitNum
71
+ }
72
+ });
73
+ result = {
74
+ ...rawResult,
75
+ data: rawResult.data
76
+ };
77
+ } else {
78
+ const rawResult = await listAgentRelations(dbClient_default)({
79
+ scopes: {
80
+ tenantId,
81
+ projectId,
82
+ agentId
83
+ },
84
+ pagination: {
85
+ page: pageNum,
86
+ limit: limitNum
87
+ }
88
+ });
89
+ result = {
90
+ ...rawResult,
91
+ data: rawResult.data
92
+ };
93
+ }
94
+ return c.json(result);
95
+ } catch (_error) {
96
+ throw createApiError({
97
+ code: "internal_server_error",
98
+ message: "Failed to retrieve sub agent relations"
99
+ });
100
+ }
101
+ });
102
+ app.openapi(createRoute({
103
+ method: "get",
104
+ path: "/{id}",
105
+ summary: "Get Sub Agent Relation",
106
+ operationId: "get-sub-agent-relation-by-id",
107
+ tags: ["Sub Agent Relations"],
108
+ request: { params: TenantProjectAgentIdParamsSchema },
109
+ responses: {
110
+ 200: {
111
+ description: "Sub Agent relation found",
112
+ content: { "application/json": { schema: SubAgentRelationResponse } }
113
+ },
114
+ ...commonGetErrorResponses
115
+ }
116
+ }), async (c) => {
117
+ const { tenantId, projectId, agentId, id } = c.req.valid("param");
118
+ const agentRelation = await getAgentRelationById(dbClient_default)({
119
+ scopes: {
120
+ tenantId,
121
+ projectId,
122
+ agentId
123
+ },
124
+ relationId: id
125
+ });
126
+ if (!agentRelation) throw createApiError({
127
+ code: "not_found",
128
+ message: "Sub Agent Relation not found"
129
+ });
130
+ return c.json({ data: agentRelation });
131
+ });
132
+ app.openapi(createRoute({
133
+ method: "post",
134
+ path: "/",
135
+ summary: "Create Sub Agent Relation",
136
+ operationId: "create-sub-agent-relation",
137
+ tags: ["Sub Agent Relations"],
138
+ request: {
139
+ params: TenantProjectAgentParamsSchema,
140
+ body: { content: { "application/json": { schema: SubAgentRelationApiInsertSchema } } }
141
+ },
142
+ responses: {
143
+ 201: {
144
+ description: "Sub Agent Relation created successfully",
145
+ content: { "application/json": { schema: SubAgentRelationResponse } }
146
+ },
147
+ ...commonGetErrorResponses
148
+ }
149
+ }), async (c) => {
150
+ const { tenantId, projectId, agentId } = c.req.valid("param");
151
+ const body = await c.req.valid("json");
152
+ if (body.targetSubAgentId) {
153
+ if (!await validateSubAgent(dbClient_default)({ scopes: {
154
+ tenantId,
155
+ projectId,
156
+ agentId,
157
+ subAgentId: body.targetSubAgentId
158
+ } })) throw createApiError({
159
+ code: "bad_request",
160
+ message: `Sub agent with ID ${body.targetSubAgentId} not found`
161
+ });
162
+ }
163
+ if ((await listAgentRelations(dbClient_default)({
164
+ scopes: {
165
+ tenantId,
166
+ projectId,
167
+ agentId
168
+ },
169
+ pagination: {
170
+ page: 1,
171
+ limit: 1e3
172
+ }
173
+ })).data.some((relation) => {
174
+ if (relation.agentId !== agentId || relation.sourceSubAgentId !== body.sourceSubAgentId) return false;
175
+ return relation.targetSubAgentId === body.targetSubAgentId;
176
+ })) throw createApiError({
177
+ code: "unprocessable_entity",
178
+ message: `A relation between these agents in this agent already exists`
179
+ });
180
+ const relationData = {
181
+ agentId,
182
+ tenantId,
183
+ id: generateId(),
184
+ projectId,
185
+ sourceSubAgentId: body.sourceSubAgentId,
186
+ targetSubAgentId: body.targetSubAgentId,
187
+ relationType: body.relationType
188
+ };
189
+ const agentRelation = await createSubAgentRelation(dbClient_default)({ ...relationData });
190
+ return c.json({ data: agentRelation }, 201);
191
+ });
192
+ app.openapi(createRoute({
193
+ method: "put",
194
+ path: "/{id}",
195
+ summary: "Update Sub Agent Relation",
196
+ operationId: "update-sub-agent-relation",
197
+ tags: ["Sub Agent Relations"],
198
+ request: {
199
+ params: TenantProjectAgentIdParamsSchema,
200
+ body: { content: { "application/json": { schema: SubAgentRelationApiUpdateSchema } } }
201
+ },
202
+ responses: {
203
+ 200: {
204
+ description: "Sub Agent relation updated successfully",
205
+ content: { "application/json": { schema: SubAgentRelationResponse } }
206
+ },
207
+ ...commonGetErrorResponses
208
+ }
209
+ }), async (c) => {
210
+ const { tenantId, projectId, agentId, id } = c.req.valid("param");
211
+ const body = await c.req.valid("json");
212
+ const updatedAgentRelation = await updateAgentRelation(dbClient_default)({
213
+ scopes: {
214
+ tenantId,
215
+ projectId,
216
+ agentId
217
+ },
218
+ relationId: id,
219
+ data: body
220
+ });
221
+ if (!updatedAgentRelation) throw createApiError({
222
+ code: "not_found",
223
+ message: "Sub Agent Relation not found"
224
+ });
225
+ return c.json({ data: updatedAgentRelation });
226
+ });
227
+ app.openapi(createRoute({
228
+ method: "delete",
229
+ path: "/{id}",
230
+ summary: "Delete Sub Agent Relation",
231
+ operationId: "delete-sub-agent-relation",
232
+ tags: ["Sub Agent Relations"],
233
+ request: { params: TenantProjectAgentIdParamsSchema },
234
+ responses: {
235
+ 204: { description: "Sub Agent Relation deleted successfully" },
236
+ 404: {
237
+ description: "Sub Agent Relation not found",
238
+ content: { "application/json": { schema: ErrorResponseSchema } }
239
+ }
240
+ }
241
+ }), async (c) => {
242
+ const { tenantId, projectId, agentId, id } = c.req.valid("param");
243
+ if (!await deleteSubAgentRelation(dbClient_default)({
244
+ scopes: {
245
+ tenantId,
246
+ projectId,
247
+ agentId
248
+ },
249
+ relationId: id
250
+ })) throw createApiError({
251
+ code: "not_found",
252
+ message: "Sub Agent Relation not found"
253
+ });
254
+ return c.body(null, 204);
255
+ });
256
+ var subAgentRelations_default = app;
257
+
258
+ //#endregion
259
+ export { subAgentRelations_default as default };