@inkeep/agents-manage-api 0.36.1 → 0.37.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.
- package/dist/{chunk-NMRIX6IG.js → chunk-6E4QM6FE.js} +217 -68
- package/dist/factory.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { F, u, R, x, T, h, U, L, or, C, Vr, ce, ur, P } from './chunk-SBJLXGYG.js';
|
|
2
|
-
import { loadEnvironmentFiles, getLogger, createDatabaseClient, commonGetErrorResponses, AgentListResponse, PaginationQueryParamsSchema, TenantProjectParamsSchema, listAgents, AgentResponse, TenantProjectIdParamsSchema, getAgentById, createApiError, RelatedAgentInfoListResponse, TenantProjectAgentSubAgentParamsSchema, getAgentSubAgentInfos, AgentWithinContextOfProjectResponse, TenantProjectAgentParamsSchema, getFullAgentDefinition, AgentApiInsertSchema, createAgent, generateId, AgentApiUpdateSchema, updateAgent, ErrorResponseSchema, deleteAgent, AgentWithinContextOfProjectSchema, createFullAgentServerSide, getFullAgent, updateFullAgentServerSide, deleteFullAgent, ApiKeyListResponse, listApiKeysPaginated, ApiKeyResponse, getApiKeyById, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, generateApiKey, createApiKey, ApiKeyApiUpdateSchema, updateApiKey, deleteApiKey, ArtifactComponentListResponse, listArtifactComponentsPaginated, ArtifactComponentResponse, getArtifactComponentById, ArtifactComponentApiInsertSchema, validatePropsAsJsonSchema, createArtifactComponent, ArtifactComponentApiUpdateSchema, updateArtifactComponent, deleteArtifactComponent, ContextConfigListResponse, listContextConfigsPaginated, ContextConfigResponse, TenantProjectAgentIdParamsSchema, getContextConfigById, ContextConfigApiInsertSchema, createContextConfig, commonUpdateErrorResponses, ContextConfigApiUpdateSchema, updateContextConfig, commonDeleteErrorResponses, deleteContextConfig, CredentialStoreListResponseSchema, CreateCredentialInStoreResponseSchema, CreateCredentialInStoreRequestSchema, CredentialReferenceListResponse, listCredentialReferencesPaginated, ListResponseSchema, CredentialReferenceApiSelectSchema, CredentialReferenceResponse, getCredentialReferenceWithResources, CredentialReferenceApiInsertSchema, createCredentialReference, CredentialReferenceApiUpdateSchema, updateCredentialReference, getCredentialReferenceById, getCredentialStoreLookupKeyFromRetrievalParams, deleteCredentialReference, DataComponentListResponse, listDataComponentsPaginated, DataComponentResponse, getDataComponent, DataComponentApiInsertSchema, createDataComponent, DataComponentApiUpdateSchema, updateDataComponent, deleteDataComponent, ExternalAgentListResponse, listExternalAgentsPaginated, ExternalAgentResponse, getExternalAgent, ExternalAgentApiInsertSchema, createExternalAgent, ExternalAgentApiUpdateSchema, updateExternalAgent, deleteExternalAgent, FunctionListResponse, listFunctions, FunctionResponse, getFunction, FunctionApiInsertSchema, upsertFunction, FunctionApiUpdateSchema, deleteFunction, FunctionToolListResponse, listFunctionTools, FunctionToolResponse, getFunctionToolById, FunctionToolApiInsertSchema, createFunctionTool, FunctionToolApiUpdateSchema, updateFunctionTool, deleteFunctionTool, MCPCatalogListResponse, fetchComposioServers, MCPTransportType, ProjectListResponse, TenantParamsSchema, listProjectsPaginated, ProjectResponse, TenantIdParamsSchema, getProject, ProjectApiInsertSchema, createProject, ProjectApiUpdateSchema, updateProject, deleteProject, ArtifactComponentArrayResponse, getArtifactComponentsForAgent, ComponentAssociationListResponse, getAgentsUsingArtifactComponent, SubAgentArtifactComponentResponse, SubAgentArtifactComponentApiInsertSchema, getSubAgentById, isArtifactComponentAssociatedWithAgent, associateArtifactComponentWithAgent, RemovedResponseSchema, removeArtifactComponentFromAgent, ExistsResponseSchema, DataComponentArrayResponse, getDataComponentsForAgent, getAgentsUsingDataComponent, SubAgentDataComponentResponse, SubAgentDataComponentApiInsertSchema, isDataComponentAssociatedWithAgent, associateDataComponentWithAgent, removeDataComponentFromAgent, SubAgentExternalAgentRelationListResponse, listSubAgentExternalAgentRelations, SubAgentExternalAgentRelationResponse, TenantProjectAgentSubAgentIdParamsSchema, getSubAgentExternalAgentRelationById, SubAgentExternalAgentRelationApiInsertSchema, createSubAgentExternalAgentRelation, SubAgentExternalAgentRelationApiUpdateSchema, updateSubAgentExternalAgentRelation, deleteSubAgentExternalAgentRelation, SubAgentRelationListResponse, SubAgentRelationQuerySchema, getAgentRelationsBySource, getSubAgentRelationsByTarget, listAgentRelations, SubAgentRelationResponse, getAgentRelationById, SubAgentRelationApiInsertSchema, validateSubAgent, createSubAgentRelation, SubAgentRelationApiUpdateSchema, updateAgentRelation, deleteSubAgentRelation, SubAgentListResponse, listSubAgentsPaginated, SubAgentResponse, SubAgentApiInsertSchema, createSubAgent, SubAgentApiUpdateSchema, updateSubAgent, deleteSubAgent, SubAgentTeamAgentRelationListResponse, listSubAgentTeamAgentRelations, SubAgentTeamAgentRelationResponse, getSubAgentTeamAgentRelationById, SubAgentTeamAgentRelationApiInsertSchema, createSubAgentTeamAgentRelation, SubAgentTeamAgentRelationApiUpdateSchema, updateSubAgentTeamAgentRelation, deleteSubAgentTeamAgentRelation, SubAgentToolRelationListResponse, getAgentToolRelationByAgent, getAgentToolRelationByTool, listAgentToolRelations, SubAgentToolRelationResponse, getAgentToolRelationById, getAgentsForTool, SubAgentToolRelationApiInsertSchema, createAgentToolRelation, SubAgentToolRelationApiUpdateSchema, updateAgentToolRelation, deleteAgentToolRelation, ThirdPartyMCPServerResponse, fetchSingleComposioServer, McpToolListResponse, ToolStatusSchema, listTools, dbResultToMcpTool, McpToolResponse, getToolById, ToolApiInsertSchema, createTool, ToolApiUpdateSchema, updateTool, deleteTool, getPendingInvitationsByEmail, OAuthLoginQuerySchema, OAuthCallbackQuerySchema, CredentialStoreType, FullProjectDefinitionResponse, FullProjectDefinitionSchema, createFullProjectServerSide, getFullProject, updateFullProjectServerSide, deleteFullProject, getUserOrganizations, addUserToOrganization, initiateMcpOAuthFlow, exchangeMcpAuthorizationCode, handleApiError, organization, getUserByEmail, member, createDefaultCredentialStores, CredentialStoreRegistry } from '@inkeep/agents-core';
|
|
2
|
+
import { loadEnvironmentFiles, getLogger, createDatabaseClient, commonGetErrorResponses, AgentListResponse, PaginationQueryParamsSchema, TenantProjectParamsSchema, listAgents, AgentResponse, TenantProjectIdParamsSchema, getAgentById, createApiError, RelatedAgentInfoListResponse, TenantProjectAgentSubAgentParamsSchema, getAgentSubAgentInfos, AgentWithinContextOfProjectResponse, TenantProjectAgentParamsSchema, getFullAgentDefinition, AgentApiInsertSchema, createAgent, generateId, AgentApiUpdateSchema, updateAgent, ErrorResponseSchema, deleteAgent, AgentWithinContextOfProjectSchema, createFullAgentServerSide, getFullAgent, updateFullAgentServerSide, deleteFullAgent, ApiKeyListResponse, listApiKeysPaginated, ApiKeyResponse, getApiKeyById, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, generateApiKey, createApiKey, ApiKeyApiUpdateSchema, updateApiKey, deleteApiKey, ArtifactComponentListResponse, listArtifactComponentsPaginated, ArtifactComponentResponse, getArtifactComponentById, ArtifactComponentApiInsertSchema, validatePropsAsJsonSchema, createArtifactComponent, ArtifactComponentApiUpdateSchema, updateArtifactComponent, deleteArtifactComponent, ContextConfigListResponse, listContextConfigsPaginated, ContextConfigResponse, TenantProjectAgentIdParamsSchema, getContextConfigById, ContextConfigApiInsertSchema, createContextConfig, commonUpdateErrorResponses, ContextConfigApiUpdateSchema, updateContextConfig, commonDeleteErrorResponses, deleteContextConfig, CredentialStoreListResponseSchema, CreateCredentialInStoreResponseSchema, CreateCredentialInStoreRequestSchema, CredentialReferenceListResponse, listCredentialReferencesPaginated, ListResponseSchema, CredentialReferenceApiSelectSchema, CredentialReferenceResponse, getCredentialReferenceWithResources, CredentialReferenceApiInsertSchema, createCredentialReference, CredentialReferenceApiUpdateSchema, updateCredentialReference, getCredentialReferenceById, getCredentialStoreLookupKeyFromRetrievalParams, deleteCredentialReference, DataComponentListResponse, listDataComponentsPaginated, DataComponentResponse, getDataComponent, DataComponentApiInsertSchema, createDataComponent, DataComponentApiUpdateSchema, updateDataComponent, deleteDataComponent, ExternalAgentListResponse, listExternalAgentsPaginated, ExternalAgentResponse, getExternalAgent, ExternalAgentApiInsertSchema, createExternalAgent, ExternalAgentApiUpdateSchema, updateExternalAgent, deleteExternalAgent, FunctionListResponse, listFunctions, FunctionResponse, getFunction, FunctionApiInsertSchema, upsertFunction, FunctionApiUpdateSchema, deleteFunction, FunctionToolListResponse, listFunctionTools, FunctionToolResponse, getFunctionToolById, FunctionToolApiInsertSchema, createFunctionTool, FunctionToolApiUpdateSchema, updateFunctionTool, deleteFunctionTool, MCPCatalogListResponse, fetchComposioServers, MCPTransportType, ProjectListResponse, TenantParamsSchema, listProjectsPaginated, ProjectResponse, TenantIdParamsSchema, getProject, ProjectApiInsertSchema, createProject, ProjectApiUpdateSchema, updateProject, deleteProject, ArtifactComponentArrayResponse, getArtifactComponentsForAgent, ComponentAssociationListResponse, getAgentsUsingArtifactComponent, SubAgentArtifactComponentResponse, SubAgentArtifactComponentApiInsertSchema, getSubAgentById, isArtifactComponentAssociatedWithAgent, associateArtifactComponentWithAgent, RemovedResponseSchema, removeArtifactComponentFromAgent, ExistsResponseSchema, DataComponentArrayResponse, getDataComponentsForAgent, getAgentsUsingDataComponent, SubAgentDataComponentResponse, SubAgentDataComponentApiInsertSchema, isDataComponentAssociatedWithAgent, associateDataComponentWithAgent, removeDataComponentFromAgent, SubAgentExternalAgentRelationListResponse, listSubAgentExternalAgentRelations, SubAgentExternalAgentRelationResponse, TenantProjectAgentSubAgentIdParamsSchema, getSubAgentExternalAgentRelationById, SubAgentExternalAgentRelationApiInsertSchema, createSubAgentExternalAgentRelation, SubAgentExternalAgentRelationApiUpdateSchema, updateSubAgentExternalAgentRelation, deleteSubAgentExternalAgentRelation, SubAgentRelationListResponse, SubAgentRelationQuerySchema, getAgentRelationsBySource, getSubAgentRelationsByTarget, listAgentRelations, SubAgentRelationResponse, getAgentRelationById, SubAgentRelationApiInsertSchema, validateSubAgent, createSubAgentRelation, SubAgentRelationApiUpdateSchema, updateAgentRelation, deleteSubAgentRelation, SubAgentListResponse, listSubAgentsPaginated, SubAgentResponse, SubAgentApiInsertSchema, createSubAgent, SubAgentApiUpdateSchema, updateSubAgent, deleteSubAgent, SubAgentTeamAgentRelationListResponse, listSubAgentTeamAgentRelations, SubAgentTeamAgentRelationResponse, getSubAgentTeamAgentRelationById, SubAgentTeamAgentRelationApiInsertSchema, createSubAgentTeamAgentRelation, SubAgentTeamAgentRelationApiUpdateSchema, updateSubAgentTeamAgentRelation, deleteSubAgentTeamAgentRelation, SubAgentToolRelationListResponse, getAgentToolRelationByAgent, getAgentToolRelationByTool, listAgentToolRelations, SubAgentToolRelationResponse, getAgentToolRelationById, getAgentsForTool, SubAgentToolRelationApiInsertSchema, createAgentToolRelation, SubAgentToolRelationApiUpdateSchema, updateAgentToolRelation, deleteAgentToolRelation, ThirdPartyMCPServerResponse, fetchSingleComposioServer, McpToolListResponse, ToolStatusSchema, listTools, dbResultToMcpTool, McpToolResponse, getToolById, ToolApiInsertSchema, createTool, ToolApiUpdateSchema, updateTool, deleteTool, getPendingInvitationsByEmail, OAuthLoginQuerySchema, OAuthCallbackQuerySchema, CredentialStoreType, projectExists, signTempToken, FullProjectDefinitionResponse, FullProjectDefinitionSchema, createFullProjectServerSide, getFullProject, updateFullProjectServerSide, deleteFullProject, getUserOrganizations, addUserToOrganization, initiateMcpOAuthFlow, exchangeMcpAuthorizationCode, handleApiError, organization, getUserByEmail, member, createDefaultCredentialStores, CredentialStoreRegistry } from '@inkeep/agents-core';
|
|
3
3
|
import { createAuth } from '@inkeep/agents-core/auth';
|
|
4
4
|
import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
|
|
5
5
|
import { Hono } from 'hono';
|
|
@@ -36,7 +36,8 @@ var envSchema = z.object({
|
|
|
36
36
|
INKEEP_AGENTS_MANAGE_UI_PASSWORD: z.string().optional().refine((val) => !val || val.length >= 8, {
|
|
37
37
|
message: "Password must be at least 8 characters"
|
|
38
38
|
}),
|
|
39
|
-
DISABLE_AUTH: z.string().optional().default("false").transform((val) => val === "true")
|
|
39
|
+
DISABLE_AUTH: z.string().optional().default("false").transform((val) => val === "true"),
|
|
40
|
+
INKEEP_AGENTS_TEMP_JWT_PRIVATE_KEY: z.string().optional()
|
|
40
41
|
});
|
|
41
42
|
var parseEnv = () => {
|
|
42
43
|
try {
|
|
@@ -80,8 +81,9 @@ var sessionAuth = () => createMiddleware(async (c, next) => {
|
|
|
80
81
|
try {
|
|
81
82
|
const user = c.get("user");
|
|
82
83
|
if (!user) {
|
|
83
|
-
throw
|
|
84
|
-
|
|
84
|
+
throw createApiError({
|
|
85
|
+
code: "unauthorized",
|
|
86
|
+
message: "Please log in to access this resource"
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
c.set("userId", user.id);
|
|
@@ -91,7 +93,8 @@ var sessionAuth = () => createMiddleware(async (c, next) => {
|
|
|
91
93
|
if (error instanceof HTTPException) {
|
|
92
94
|
throw error;
|
|
93
95
|
}
|
|
94
|
-
throw
|
|
96
|
+
throw createApiError({
|
|
97
|
+
code: "unauthorized",
|
|
95
98
|
message: "Authentication failed"
|
|
96
99
|
});
|
|
97
100
|
}
|
|
@@ -5165,22 +5168,23 @@ var requireTenantAccess = () => createMiddleware(async (c, next) => {
|
|
|
5165
5168
|
const userId = c.get("userId");
|
|
5166
5169
|
const tenantId = c.req.param("tenantId");
|
|
5167
5170
|
if (!userId) {
|
|
5168
|
-
throw
|
|
5169
|
-
|
|
5171
|
+
throw createApiError({
|
|
5172
|
+
code: "unauthorized",
|
|
5173
|
+
message: "User ID not found"
|
|
5170
5174
|
});
|
|
5171
5175
|
}
|
|
5172
5176
|
if (!tenantId) {
|
|
5173
|
-
throw
|
|
5174
|
-
|
|
5177
|
+
throw createApiError({
|
|
5178
|
+
code: "bad_request",
|
|
5179
|
+
message: "Organization ID is required"
|
|
5175
5180
|
});
|
|
5176
5181
|
}
|
|
5177
5182
|
try {
|
|
5178
5183
|
const userOrganizations = await getUserOrganizations(dbClient_default)(userId);
|
|
5179
|
-
const organizationAccess = userOrganizations.find(
|
|
5180
|
-
(org) => org.organizationId === tenantId
|
|
5181
|
-
);
|
|
5184
|
+
const organizationAccess = userOrganizations.find((org) => org.organizationId === tenantId);
|
|
5182
5185
|
if (!organizationAccess) {
|
|
5183
|
-
throw
|
|
5186
|
+
throw createApiError({
|
|
5187
|
+
code: "forbidden",
|
|
5184
5188
|
message: "Access denied to this organization"
|
|
5185
5189
|
});
|
|
5186
5190
|
}
|
|
@@ -5191,16 +5195,17 @@ var requireTenantAccess = () => createMiddleware(async (c, next) => {
|
|
|
5191
5195
|
if (error instanceof HTTPException) {
|
|
5192
5196
|
throw error;
|
|
5193
5197
|
}
|
|
5194
|
-
throw
|
|
5198
|
+
throw createApiError({
|
|
5199
|
+
code: "internal_server_error",
|
|
5195
5200
|
message: "Failed to verify organization access"
|
|
5196
5201
|
});
|
|
5197
5202
|
}
|
|
5198
5203
|
});
|
|
5199
|
-
function setupOpenAPIRoutes(
|
|
5200
|
-
|
|
5204
|
+
function setupOpenAPIRoutes(app27) {
|
|
5205
|
+
app27.get("/openapi.json", (c) => {
|
|
5201
5206
|
try {
|
|
5202
5207
|
const serverUrl = process.env.VERCEL_ENV === "production" && process.env.VERCEL_PROJECT_PRODUCTION_URL ? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}` : process.env.VERCEL_ENV === "preview" && process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : env.INKEEP_AGENTS_MANAGE_API_URL;
|
|
5203
|
-
const document2 =
|
|
5208
|
+
const document2 = app27.getOpenAPIDocument({
|
|
5204
5209
|
openapi: "3.0.0",
|
|
5205
5210
|
info: {
|
|
5206
5211
|
title: "Inkeep Agents Manage API",
|
|
@@ -5308,6 +5313,30 @@ function setupOpenAPIRoutes(app26) {
|
|
|
5308
5313
|
}
|
|
5309
5314
|
]
|
|
5310
5315
|
});
|
|
5316
|
+
document2.components = {
|
|
5317
|
+
...document2.components,
|
|
5318
|
+
securitySchemes: {
|
|
5319
|
+
...document2.components?.securitySchemes || {},
|
|
5320
|
+
cookieAuth: {
|
|
5321
|
+
type: "apiKey",
|
|
5322
|
+
in: "cookie",
|
|
5323
|
+
name: "better-auth.session_token",
|
|
5324
|
+
description: 'Session-based authentication using HTTP-only cookies. Cookies are automatically sent by browsers. For server-side requests, include cookies with names starting with "better-auth." in the Cookie header.'
|
|
5325
|
+
},
|
|
5326
|
+
bearerAuth: {
|
|
5327
|
+
type: "http",
|
|
5328
|
+
scheme: "bearer",
|
|
5329
|
+
bearerFormat: "Token",
|
|
5330
|
+
description: 'Bearer token authentication. Use this for API clients and service-to-service communication. Set the Authorization header to "Bearer <token>".'
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
};
|
|
5334
|
+
document2.security = [
|
|
5335
|
+
{
|
|
5336
|
+
cookieAuth: [],
|
|
5337
|
+
bearerAuth: []
|
|
5338
|
+
}
|
|
5339
|
+
];
|
|
5311
5340
|
return c.json(document2);
|
|
5312
5341
|
} catch (error) {
|
|
5313
5342
|
console.error("OpenAPI document generation failed:", error);
|
|
@@ -5315,7 +5344,7 @@ function setupOpenAPIRoutes(app26) {
|
|
|
5315
5344
|
return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
|
|
5316
5345
|
}
|
|
5317
5346
|
});
|
|
5318
|
-
|
|
5347
|
+
app27.get(
|
|
5319
5348
|
"/docs",
|
|
5320
5349
|
swaggerUI({
|
|
5321
5350
|
url: "/openapi.json",
|
|
@@ -11295,15 +11324,118 @@ app24.openapi(
|
|
|
11295
11324
|
}
|
|
11296
11325
|
);
|
|
11297
11326
|
var oauth_default = app24;
|
|
11298
|
-
var logger8 = getLogger("
|
|
11327
|
+
var logger8 = getLogger("playgroundToken");
|
|
11299
11328
|
var app25 = new OpenAPIHono();
|
|
11300
|
-
app25.use("/
|
|
11329
|
+
app25.use("/", requirePermission({ agent: ["create"] }));
|
|
11330
|
+
var PlaygroundTokenRequestSchema = z$1.object({
|
|
11331
|
+
projectId: z$1.string(),
|
|
11332
|
+
agentId: z$1.string()
|
|
11333
|
+
});
|
|
11334
|
+
var PlaygroundTokenResponseSchema = z$1.object({
|
|
11335
|
+
apiKey: z$1.string().describe("Temporary API key for playground use"),
|
|
11336
|
+
expiresAt: z$1.string().describe("ISO 8601 timestamp when the key expires")
|
|
11337
|
+
});
|
|
11338
|
+
app25.openapi(
|
|
11339
|
+
createRoute({
|
|
11340
|
+
method: "post",
|
|
11341
|
+
path: "/",
|
|
11342
|
+
summary: "Generate temporary API key for playground",
|
|
11343
|
+
operationId: "create-playground-token",
|
|
11344
|
+
tags: ["Playground"],
|
|
11345
|
+
description: "Generates a short-lived API key (1 hour expiry) for authenticated users to access the run-api from the playground",
|
|
11346
|
+
security: [{ cookieAuth: [] }],
|
|
11347
|
+
request: {
|
|
11348
|
+
body: {
|
|
11349
|
+
content: {
|
|
11350
|
+
"application/json": {
|
|
11351
|
+
schema: PlaygroundTokenRequestSchema
|
|
11352
|
+
}
|
|
11353
|
+
}
|
|
11354
|
+
}
|
|
11355
|
+
},
|
|
11356
|
+
responses: {
|
|
11357
|
+
200: {
|
|
11358
|
+
description: "Temporary API key generated successfully",
|
|
11359
|
+
content: {
|
|
11360
|
+
"application/json": {
|
|
11361
|
+
schema: PlaygroundTokenResponseSchema
|
|
11362
|
+
}
|
|
11363
|
+
}
|
|
11364
|
+
},
|
|
11365
|
+
401: {
|
|
11366
|
+
description: "Unauthorized - session required",
|
|
11367
|
+
content: {
|
|
11368
|
+
"application/json": {
|
|
11369
|
+
schema: ErrorResponseSchema
|
|
11370
|
+
}
|
|
11371
|
+
}
|
|
11372
|
+
}
|
|
11373
|
+
}
|
|
11374
|
+
}),
|
|
11375
|
+
async (c) => {
|
|
11376
|
+
const userId = c.get("userId");
|
|
11377
|
+
const tenantId = c.get("tenantId");
|
|
11378
|
+
const { projectId, agentId } = c.req.valid("json");
|
|
11379
|
+
logger8.info(
|
|
11380
|
+
{ userId, tenantId, projectId, agentId },
|
|
11381
|
+
"Generating temporary JWT token for playground"
|
|
11382
|
+
);
|
|
11383
|
+
const projectExistsCheck = await projectExists(dbClient_default)({ tenantId, projectId });
|
|
11384
|
+
if (!projectExistsCheck) {
|
|
11385
|
+
logger8.warn({ userId, tenantId, projectId }, "Project not found or access denied");
|
|
11386
|
+
throw createApiError({
|
|
11387
|
+
code: "not_found",
|
|
11388
|
+
message: "Project not found"
|
|
11389
|
+
});
|
|
11390
|
+
}
|
|
11391
|
+
const agent = await getAgentById(dbClient_default)({ scopes: { tenantId, projectId, agentId } });
|
|
11392
|
+
if (!agent) {
|
|
11393
|
+
logger8.warn({ userId, tenantId, projectId, agentId }, "Agent not found or access denied");
|
|
11394
|
+
throw createApiError({
|
|
11395
|
+
code: "not_found",
|
|
11396
|
+
message: "Agent not found"
|
|
11397
|
+
});
|
|
11398
|
+
}
|
|
11399
|
+
if (!env.INKEEP_AGENTS_TEMP_JWT_PRIVATE_KEY) {
|
|
11400
|
+
throw createApiError({
|
|
11401
|
+
code: "internal_server_error",
|
|
11402
|
+
message: "Temporary token signing not configured"
|
|
11403
|
+
});
|
|
11404
|
+
}
|
|
11405
|
+
const privateKeyPem = Buffer.from(env.INKEEP_AGENTS_TEMP_JWT_PRIVATE_KEY, "base64").toString(
|
|
11406
|
+
"utf-8"
|
|
11407
|
+
);
|
|
11408
|
+
const result = await signTempToken(
|
|
11409
|
+
privateKeyPem,
|
|
11410
|
+
{
|
|
11411
|
+
tenantId,
|
|
11412
|
+
projectId,
|
|
11413
|
+
agentId,
|
|
11414
|
+
type: "temporary",
|
|
11415
|
+
initiatedBy: { type: "user", id: userId }
|
|
11416
|
+
},
|
|
11417
|
+
userId
|
|
11418
|
+
);
|
|
11419
|
+
logger8.info({ userId, expiresAt: result.expiresAt }, "Temporary JWT token generated");
|
|
11420
|
+
return c.json(
|
|
11421
|
+
{
|
|
11422
|
+
apiKey: result.token,
|
|
11423
|
+
expiresAt: result.expiresAt
|
|
11424
|
+
},
|
|
11425
|
+
200
|
|
11426
|
+
);
|
|
11427
|
+
}
|
|
11428
|
+
);
|
|
11429
|
+
var playgroundToken_default = app25;
|
|
11430
|
+
var logger9 = getLogger("projectFull");
|
|
11431
|
+
var app26 = new OpenAPIHono();
|
|
11432
|
+
app26.use("/project-full", async (c, next) => {
|
|
11301
11433
|
if (c.req.method === "POST") {
|
|
11302
11434
|
return requirePermission({ project: ["create"] })(c, next);
|
|
11303
11435
|
}
|
|
11304
11436
|
return next();
|
|
11305
11437
|
});
|
|
11306
|
-
|
|
11438
|
+
app26.use("/project-full/:projectId", async (c, next) => {
|
|
11307
11439
|
if (c.req.method === "PUT") {
|
|
11308
11440
|
return requirePermission({ project: ["update"] })(c, next);
|
|
11309
11441
|
}
|
|
@@ -11312,7 +11444,7 @@ app25.use("/project-full/:projectId", async (c, next) => {
|
|
|
11312
11444
|
}
|
|
11313
11445
|
return next();
|
|
11314
11446
|
});
|
|
11315
|
-
|
|
11447
|
+
app26.openapi(
|
|
11316
11448
|
createRoute({
|
|
11317
11449
|
method: "post",
|
|
11318
11450
|
path: "/project-full",
|
|
@@ -11355,13 +11487,13 @@ app25.openapi(
|
|
|
11355
11487
|
const projectData = c.req.valid("json");
|
|
11356
11488
|
const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
|
|
11357
11489
|
try {
|
|
11358
|
-
const createdProject = await createFullProjectServerSide(dbClient_default,
|
|
11490
|
+
const createdProject = await createFullProjectServerSide(dbClient_default, logger9)(
|
|
11359
11491
|
{ tenantId, projectId: validatedProjectData.id },
|
|
11360
11492
|
validatedProjectData
|
|
11361
11493
|
);
|
|
11362
11494
|
return c.json({ data: createdProject }, 201);
|
|
11363
11495
|
} catch (error) {
|
|
11364
|
-
|
|
11496
|
+
logger9.error({ error }, "Error creating project");
|
|
11365
11497
|
if (error?.cause?.code === "23505") {
|
|
11366
11498
|
throw createApiError({
|
|
11367
11499
|
code: "conflict",
|
|
@@ -11372,7 +11504,7 @@ app25.openapi(
|
|
|
11372
11504
|
}
|
|
11373
11505
|
}
|
|
11374
11506
|
);
|
|
11375
|
-
|
|
11507
|
+
app26.openapi(
|
|
11376
11508
|
createRoute({
|
|
11377
11509
|
method: "get",
|
|
11378
11510
|
path: "/project-full/{projectId}",
|
|
@@ -11400,7 +11532,7 @@ app25.openapi(
|
|
|
11400
11532
|
try {
|
|
11401
11533
|
const project = await getFullProject(
|
|
11402
11534
|
dbClient_default,
|
|
11403
|
-
|
|
11535
|
+
logger9
|
|
11404
11536
|
)({
|
|
11405
11537
|
scopes: { tenantId, projectId }
|
|
11406
11538
|
});
|
|
@@ -11425,7 +11557,7 @@ app25.openapi(
|
|
|
11425
11557
|
}
|
|
11426
11558
|
}
|
|
11427
11559
|
);
|
|
11428
|
-
|
|
11560
|
+
app26.openapi(
|
|
11429
11561
|
createRoute({
|
|
11430
11562
|
method: "put",
|
|
11431
11563
|
path: "/project-full/{projectId}",
|
|
@@ -11476,15 +11608,15 @@ app25.openapi(
|
|
|
11476
11608
|
}
|
|
11477
11609
|
const existingProject = await getFullProject(
|
|
11478
11610
|
dbClient_default,
|
|
11479
|
-
|
|
11611
|
+
logger9
|
|
11480
11612
|
)({
|
|
11481
11613
|
scopes: { tenantId, projectId }
|
|
11482
11614
|
});
|
|
11483
11615
|
const isCreate = !existingProject;
|
|
11484
|
-
const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default,
|
|
11616
|
+
const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default, logger9)(
|
|
11485
11617
|
{ tenantId, projectId },
|
|
11486
11618
|
validatedProjectData
|
|
11487
|
-
) : await updateFullProjectServerSide(dbClient_default,
|
|
11619
|
+
) : await updateFullProjectServerSide(dbClient_default, logger9)(
|
|
11488
11620
|
{ tenantId, projectId },
|
|
11489
11621
|
validatedProjectData
|
|
11490
11622
|
);
|
|
@@ -11509,7 +11641,7 @@ app25.openapi(
|
|
|
11509
11641
|
}
|
|
11510
11642
|
}
|
|
11511
11643
|
);
|
|
11512
|
-
|
|
11644
|
+
app26.openapi(
|
|
11513
11645
|
createRoute({
|
|
11514
11646
|
method: "delete",
|
|
11515
11647
|
path: "/project-full/{projectId}",
|
|
@@ -11532,7 +11664,7 @@ app25.openapi(
|
|
|
11532
11664
|
try {
|
|
11533
11665
|
const deleted = await deleteFullProject(
|
|
11534
11666
|
dbClient_default,
|
|
11535
|
-
|
|
11667
|
+
logger9
|
|
11536
11668
|
)({
|
|
11537
11669
|
scopes: { tenantId, projectId }
|
|
11538
11670
|
});
|
|
@@ -11557,7 +11689,7 @@ app25.openapi(
|
|
|
11557
11689
|
}
|
|
11558
11690
|
}
|
|
11559
11691
|
);
|
|
11560
|
-
var projectFull_default =
|
|
11692
|
+
var projectFull_default = app26;
|
|
11561
11693
|
var userOrganizationsRoutes = new OpenAPIHono();
|
|
11562
11694
|
userOrganizationsRoutes.openapi(
|
|
11563
11695
|
createRoute({
|
|
@@ -11632,8 +11764,8 @@ userOrganizationsRoutes.openapi(
|
|
|
11632
11764
|
var userOrganizations_default = userOrganizationsRoutes;
|
|
11633
11765
|
|
|
11634
11766
|
// src/app.ts
|
|
11635
|
-
var
|
|
11636
|
-
|
|
11767
|
+
var logger10 = getLogger("agents-manage-api");
|
|
11768
|
+
logger10.info({ logger: logger10.getTransports() }, "Logger initialized");
|
|
11637
11769
|
function isOriginAllowed(origin) {
|
|
11638
11770
|
if (!origin) return false;
|
|
11639
11771
|
try {
|
|
@@ -11652,15 +11784,15 @@ function isOriginAllowed(origin) {
|
|
|
11652
11784
|
}
|
|
11653
11785
|
}
|
|
11654
11786
|
function createManagementHono(serverConfig, credentialStores, auth) {
|
|
11655
|
-
const
|
|
11656
|
-
|
|
11657
|
-
|
|
11787
|
+
const app27 = new OpenAPIHono();
|
|
11788
|
+
app27.use("*", requestId());
|
|
11789
|
+
app27.use("*", async (c, next) => {
|
|
11658
11790
|
c.set("serverConfig", serverConfig);
|
|
11659
11791
|
c.set("credentialStores", credentialStores);
|
|
11660
11792
|
c.set("auth", auth);
|
|
11661
11793
|
return next();
|
|
11662
11794
|
});
|
|
11663
|
-
|
|
11795
|
+
app27.use(
|
|
11664
11796
|
pinoLogger({
|
|
11665
11797
|
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
11666
11798
|
http: {
|
|
@@ -11673,7 +11805,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11673
11805
|
}
|
|
11674
11806
|
})
|
|
11675
11807
|
);
|
|
11676
|
-
|
|
11808
|
+
app27.onError(async (err2, c) => {
|
|
11677
11809
|
const isExpectedError = err2 instanceof HTTPException;
|
|
11678
11810
|
const status = isExpectedError ? err2.status : 500;
|
|
11679
11811
|
const requestId2 = c.get("requestId") || "unknown";
|
|
@@ -11706,7 +11838,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11706
11838
|
if (!isExpectedError) {
|
|
11707
11839
|
const errorMessage = err2 instanceof Error ? err2.message : String(err2);
|
|
11708
11840
|
const errorStack = err2 instanceof Error ? err2.stack : void 0;
|
|
11709
|
-
|
|
11841
|
+
logger10.error(
|
|
11710
11842
|
{
|
|
11711
11843
|
error: err2,
|
|
11712
11844
|
message: errorMessage,
|
|
@@ -11717,7 +11849,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11717
11849
|
"Unexpected server error occurred"
|
|
11718
11850
|
);
|
|
11719
11851
|
} else {
|
|
11720
|
-
|
|
11852
|
+
logger10.error(
|
|
11721
11853
|
{
|
|
11722
11854
|
error: err2,
|
|
11723
11855
|
path: c.req.path,
|
|
@@ -11743,7 +11875,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11743
11875
|
return c.body(JSON.stringify(responseBody));
|
|
11744
11876
|
});
|
|
11745
11877
|
if (auth) {
|
|
11746
|
-
|
|
11878
|
+
app27.use(
|
|
11747
11879
|
"/api/auth/*",
|
|
11748
11880
|
cors({
|
|
11749
11881
|
origin: (origin) => {
|
|
@@ -11756,14 +11888,30 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11756
11888
|
credentials: true
|
|
11757
11889
|
})
|
|
11758
11890
|
);
|
|
11759
|
-
|
|
11891
|
+
app27.on(["POST", "GET"], "/api/auth/*", (c) => {
|
|
11760
11892
|
return auth.handler(c.req.raw);
|
|
11761
11893
|
});
|
|
11762
11894
|
}
|
|
11763
|
-
|
|
11895
|
+
app27.use(
|
|
11896
|
+
"/tenants/*/playground/token",
|
|
11897
|
+
cors({
|
|
11898
|
+
origin: (origin) => {
|
|
11899
|
+
return isOriginAllowed(origin) ? origin : null;
|
|
11900
|
+
},
|
|
11901
|
+
allowHeaders: ["content-type", "Content-Type", "authorization", "Authorization"],
|
|
11902
|
+
allowMethods: ["POST", "OPTIONS"],
|
|
11903
|
+
exposeHeaders: ["Content-Length"],
|
|
11904
|
+
maxAge: 600,
|
|
11905
|
+
credentials: true
|
|
11906
|
+
})
|
|
11907
|
+
);
|
|
11908
|
+
app27.use("*", async (c, next) => {
|
|
11764
11909
|
if (auth && c.req.path.startsWith("/api/auth/")) {
|
|
11765
11910
|
return next();
|
|
11766
11911
|
}
|
|
11912
|
+
if (c.req.path.includes("/playground/token")) {
|
|
11913
|
+
return next();
|
|
11914
|
+
}
|
|
11767
11915
|
return cors({
|
|
11768
11916
|
origin: (origin) => {
|
|
11769
11917
|
return isOriginAllowed(origin) ? origin : null;
|
|
@@ -11775,7 +11923,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11775
11923
|
credentials: true
|
|
11776
11924
|
})(c, next);
|
|
11777
11925
|
});
|
|
11778
|
-
|
|
11926
|
+
app27.use("*", async (c, next) => {
|
|
11779
11927
|
if (env.DISABLE_AUTH || !auth) {
|
|
11780
11928
|
c.set("user", null);
|
|
11781
11929
|
c.set("session", null);
|
|
@@ -11793,7 +11941,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11793
11941
|
c.set("session", session.session);
|
|
11794
11942
|
await next();
|
|
11795
11943
|
});
|
|
11796
|
-
|
|
11944
|
+
app27.openapi(
|
|
11797
11945
|
createRoute({
|
|
11798
11946
|
method: "get",
|
|
11799
11947
|
path: "/health",
|
|
@@ -11810,7 +11958,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11810
11958
|
return c.body(null, 204);
|
|
11811
11959
|
}
|
|
11812
11960
|
);
|
|
11813
|
-
|
|
11961
|
+
app27.use("/tenants/*", async (c, next) => {
|
|
11814
11962
|
const isTestEnvironment = process.env.ENVIRONMENT === "test";
|
|
11815
11963
|
if (env.DISABLE_AUTH || isTestEnvironment) {
|
|
11816
11964
|
await next();
|
|
@@ -11824,19 +11972,20 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
11824
11972
|
});
|
|
11825
11973
|
const isTestEnv = process.env.ENVIRONMENT === "test";
|
|
11826
11974
|
if (!env.DISABLE_AUTH && !isTestEnv) {
|
|
11827
|
-
|
|
11828
|
-
}
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11975
|
+
app27.use("/tenants/:tenantId/*", requireTenantAccess());
|
|
11976
|
+
}
|
|
11977
|
+
app27.route("/api/users/:userId/organizations", userOrganizations_default);
|
|
11978
|
+
app27.route("/api/invitations", invitations_default);
|
|
11979
|
+
app27.route("/tenants/:tenantId", routes_default);
|
|
11980
|
+
app27.route("/tenants/:tenantId/playground/token", playgroundToken_default);
|
|
11981
|
+
app27.route("/tenants/:tenantId", projectFull_default);
|
|
11982
|
+
app27.route("/oauth", oauth_default);
|
|
11983
|
+
setupOpenAPIRoutes(app27);
|
|
11835
11984
|
const baseApp = new Hono();
|
|
11836
|
-
baseApp.route("/",
|
|
11985
|
+
baseApp.route("/", app27);
|
|
11837
11986
|
return baseApp;
|
|
11838
11987
|
}
|
|
11839
|
-
var
|
|
11988
|
+
var logger11 = getLogger("initialization");
|
|
11840
11989
|
async function initializeDefaultUser(authInstance) {
|
|
11841
11990
|
const { INKEEP_AGENTS_MANAGE_UI_USERNAME, INKEEP_AGENTS_MANAGE_UI_PASSWORD, DISABLE_AUTH } = env;
|
|
11842
11991
|
const hasCredentials = INKEEP_AGENTS_MANAGE_UI_USERNAME && INKEEP_AGENTS_MANAGE_UI_PASSWORD;
|
|
@@ -11851,23 +12000,23 @@ async function initializeDefaultUser(authInstance) {
|
|
|
11851
12000
|
logo: null,
|
|
11852
12001
|
metadata: null
|
|
11853
12002
|
});
|
|
11854
|
-
|
|
12003
|
+
logger11.info({ organizationId: orgId }, "Created default organization");
|
|
11855
12004
|
} else {
|
|
11856
|
-
|
|
12005
|
+
logger11.info({ organizationId: orgId }, "Organization already exists");
|
|
11857
12006
|
}
|
|
11858
12007
|
if (!hasCredentials || DISABLE_AUTH || !authInstance) {
|
|
11859
|
-
|
|
12008
|
+
logger11.info({ hasCredentials: false }, "Skipping default user creation");
|
|
11860
12009
|
return;
|
|
11861
12010
|
}
|
|
11862
12011
|
try {
|
|
11863
12012
|
let user = await getUserByEmail(dbClient_default)(INKEEP_AGENTS_MANAGE_UI_USERNAME);
|
|
11864
12013
|
if (user) {
|
|
11865
|
-
|
|
12014
|
+
logger11.info(
|
|
11866
12015
|
{ email: INKEEP_AGENTS_MANAGE_UI_USERNAME, userId: user.id },
|
|
11867
12016
|
"Default user already exists"
|
|
11868
12017
|
);
|
|
11869
12018
|
} else {
|
|
11870
|
-
|
|
12019
|
+
logger11.info(
|
|
11871
12020
|
{ email: INKEEP_AGENTS_MANAGE_UI_USERNAME },
|
|
11872
12021
|
"Creating default user with Better Auth..."
|
|
11873
12022
|
);
|
|
@@ -11886,7 +12035,7 @@ async function initializeDefaultUser(authInstance) {
|
|
|
11886
12035
|
if (!user) {
|
|
11887
12036
|
throw new Error("User was created but could not be retrieved from database");
|
|
11888
12037
|
}
|
|
11889
|
-
|
|
12038
|
+
logger11.info(
|
|
11890
12039
|
{
|
|
11891
12040
|
email: user.email,
|
|
11892
12041
|
id: user.id
|
|
@@ -11903,14 +12052,14 @@ async function initializeDefaultUser(authInstance) {
|
|
|
11903
12052
|
role: "owner",
|
|
11904
12053
|
createdAt: /* @__PURE__ */ new Date()
|
|
11905
12054
|
});
|
|
11906
|
-
|
|
12055
|
+
logger11.info({ userId: user.id, organizationId: orgId }, "Added user as organization owner");
|
|
11907
12056
|
} else {
|
|
11908
|
-
|
|
12057
|
+
logger11.info(
|
|
11909
12058
|
{ userId: user.id, organizationId: orgId },
|
|
11910
12059
|
"User already a member of organization"
|
|
11911
12060
|
);
|
|
11912
12061
|
}
|
|
11913
|
-
|
|
12062
|
+
logger11.info(
|
|
11914
12063
|
{
|
|
11915
12064
|
organizationId: orgId,
|
|
11916
12065
|
organizationSlug: env.TENANT_ID,
|
|
@@ -11920,7 +12069,7 @@ async function initializeDefaultUser(authInstance) {
|
|
|
11920
12069
|
"\u2705 Initialization complete - login with these credentials"
|
|
11921
12070
|
);
|
|
11922
12071
|
} catch (error) {
|
|
11923
|
-
|
|
12072
|
+
logger11.error(
|
|
11924
12073
|
{ error, email: INKEEP_AGENTS_MANAGE_UI_USERNAME },
|
|
11925
12074
|
"\u274C Failed to create default user"
|
|
11926
12075
|
);
|
package/dist/factory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-
|
|
1
|
+
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-6E4QM6FE.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createAuth0Provider, createManagementHono, env, initializeDefaultUser, dbClient_default } from './chunk-
|
|
2
|
-
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-
|
|
1
|
+
import { createAuth0Provider, createManagementHono, env, initializeDefaultUser, dbClient_default } from './chunk-6E4QM6FE.js';
|
|
2
|
+
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-6E4QM6FE.js';
|
|
3
3
|
import { createDefaultCredentialStores, CredentialStoreRegistry } from '@inkeep/agents-core';
|
|
4
4
|
import { createAuth } from '@inkeep/agents-core/auth';
|
|
5
5
|
export { Hono } from 'hono';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-manage-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Agents Manage API for Inkeep Agent Framework - handles CRUD operations and OAuth",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"drizzle-orm": "^0.44.4",
|
|
28
28
|
"hono": "^4.10.4",
|
|
29
29
|
"hono-pino": "^0.10.1",
|
|
30
|
+
"jose": "^6.1.0",
|
|
30
31
|
"nanoid": "^5.1.5",
|
|
31
32
|
"openid-client": "^6.6.4",
|
|
32
33
|
"pino": "^9.7.0",
|
|
33
34
|
"zod": "^4.1.11",
|
|
34
|
-
"@inkeep/agents-core": "^0.
|
|
35
|
+
"@inkeep/agents-core": "^0.37.0"
|
|
35
36
|
},
|
|
36
37
|
"optionalDependencies": {
|
|
37
38
|
"keytar": "^7.9.0"
|