@inkeep/agents-manage-api 0.36.0 → 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.
@@ -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';
@@ -22,6 +22,7 @@ var envSchema = z.object({
22
22
  NODE_ENV: z.enum(["development", "production", "test"]).optional(),
23
23
  ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional(),
24
24
  INKEEP_AGENTS_MANAGE_API_URL: z.string().optional().default("http://localhost:3002"),
25
+ INKEEP_AGENTS_MANAGE_UI_URL: z.string().optional().default("http://localhost:3000"),
25
26
  DATABASE_URL: z.string().optional(),
26
27
  LOG_LEVEL: z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
27
28
  NANGO_SERVER_URL: z.string().optional().default("https://api.nango.dev"),
@@ -35,7 +36,8 @@ var envSchema = z.object({
35
36
  INKEEP_AGENTS_MANAGE_UI_PASSWORD: z.string().optional().refine((val) => !val || val.length >= 8, {
36
37
  message: "Password must be at least 8 characters"
37
38
  }),
38
- 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()
39
41
  });
40
42
  var parseEnv = () => {
41
43
  try {
@@ -79,8 +81,9 @@ var sessionAuth = () => createMiddleware(async (c, next) => {
79
81
  try {
80
82
  const user = c.get("user");
81
83
  if (!user) {
82
- throw new HTTPException(401, {
83
- message: "Unauthorized - Please log in"
84
+ throw createApiError({
85
+ code: "unauthorized",
86
+ message: "Please log in to access this resource"
84
87
  });
85
88
  }
86
89
  c.set("userId", user.id);
@@ -90,7 +93,8 @@ var sessionAuth = () => createMiddleware(async (c, next) => {
90
93
  if (error instanceof HTTPException) {
91
94
  throw error;
92
95
  }
93
- throw new HTTPException(401, {
96
+ throw createApiError({
97
+ code: "unauthorized",
94
98
  message: "Authentication failed"
95
99
  });
96
100
  }
@@ -5164,22 +5168,23 @@ var requireTenantAccess = () => createMiddleware(async (c, next) => {
5164
5168
  const userId = c.get("userId");
5165
5169
  const tenantId = c.req.param("tenantId");
5166
5170
  if (!userId) {
5167
- throw new HTTPException(401, {
5168
- message: "Unauthorized - User ID not found"
5171
+ throw createApiError({
5172
+ code: "unauthorized",
5173
+ message: "User ID not found"
5169
5174
  });
5170
5175
  }
5171
5176
  if (!tenantId) {
5172
- throw new HTTPException(400, {
5173
- message: "Bad Request - Organization ID is required"
5177
+ throw createApiError({
5178
+ code: "bad_request",
5179
+ message: "Organization ID is required"
5174
5180
  });
5175
5181
  }
5176
5182
  try {
5177
5183
  const userOrganizations = await getUserOrganizations(dbClient_default)(userId);
5178
- const organizationAccess = userOrganizations.find(
5179
- (org) => org.organizationId === tenantId
5180
- );
5184
+ const organizationAccess = userOrganizations.find((org) => org.organizationId === tenantId);
5181
5185
  if (!organizationAccess) {
5182
- throw new HTTPException(403, {
5186
+ throw createApiError({
5187
+ code: "forbidden",
5183
5188
  message: "Access denied to this organization"
5184
5189
  });
5185
5190
  }
@@ -5190,16 +5195,17 @@ var requireTenantAccess = () => createMiddleware(async (c, next) => {
5190
5195
  if (error instanceof HTTPException) {
5191
5196
  throw error;
5192
5197
  }
5193
- throw new HTTPException(500, {
5198
+ throw createApiError({
5199
+ code: "internal_server_error",
5194
5200
  message: "Failed to verify organization access"
5195
5201
  });
5196
5202
  }
5197
5203
  });
5198
- function setupOpenAPIRoutes(app26) {
5199
- app26.get("/openapi.json", (c) => {
5204
+ function setupOpenAPIRoutes(app27) {
5205
+ app27.get("/openapi.json", (c) => {
5200
5206
  try {
5201
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;
5202
- const document2 = app26.getOpenAPIDocument({
5208
+ const document2 = app27.getOpenAPIDocument({
5203
5209
  openapi: "3.0.0",
5204
5210
  info: {
5205
5211
  title: "Inkeep Agents Manage API",
@@ -5307,6 +5313,30 @@ function setupOpenAPIRoutes(app26) {
5307
5313
  }
5308
5314
  ]
5309
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
+ ];
5310
5340
  return c.json(document2);
5311
5341
  } catch (error) {
5312
5342
  console.error("OpenAPI document generation failed:", error);
@@ -5314,7 +5344,7 @@ function setupOpenAPIRoutes(app26) {
5314
5344
  return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
5315
5345
  }
5316
5346
  });
5317
- app26.get(
5347
+ app27.get(
5318
5348
  "/docs",
5319
5349
  swaggerUI({
5320
5350
  url: "/openapi.json",
@@ -11294,15 +11324,118 @@ app24.openapi(
11294
11324
  }
11295
11325
  );
11296
11326
  var oauth_default = app24;
11297
- var logger8 = getLogger("projectFull");
11327
+ var logger8 = getLogger("playgroundToken");
11298
11328
  var app25 = new OpenAPIHono();
11299
- app25.use("/project-full", async (c, next) => {
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) => {
11300
11433
  if (c.req.method === "POST") {
11301
11434
  return requirePermission({ project: ["create"] })(c, next);
11302
11435
  }
11303
11436
  return next();
11304
11437
  });
11305
- app25.use("/project-full/:projectId", async (c, next) => {
11438
+ app26.use("/project-full/:projectId", async (c, next) => {
11306
11439
  if (c.req.method === "PUT") {
11307
11440
  return requirePermission({ project: ["update"] })(c, next);
11308
11441
  }
@@ -11311,7 +11444,7 @@ app25.use("/project-full/:projectId", async (c, next) => {
11311
11444
  }
11312
11445
  return next();
11313
11446
  });
11314
- app25.openapi(
11447
+ app26.openapi(
11315
11448
  createRoute({
11316
11449
  method: "post",
11317
11450
  path: "/project-full",
@@ -11354,13 +11487,13 @@ app25.openapi(
11354
11487
  const projectData = c.req.valid("json");
11355
11488
  const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
11356
11489
  try {
11357
- const createdProject = await createFullProjectServerSide(dbClient_default, logger8)(
11490
+ const createdProject = await createFullProjectServerSide(dbClient_default, logger9)(
11358
11491
  { tenantId, projectId: validatedProjectData.id },
11359
11492
  validatedProjectData
11360
11493
  );
11361
11494
  return c.json({ data: createdProject }, 201);
11362
11495
  } catch (error) {
11363
- logger8.error({ error }, "Error creating project");
11496
+ logger9.error({ error }, "Error creating project");
11364
11497
  if (error?.cause?.code === "23505") {
11365
11498
  throw createApiError({
11366
11499
  code: "conflict",
@@ -11371,7 +11504,7 @@ app25.openapi(
11371
11504
  }
11372
11505
  }
11373
11506
  );
11374
- app25.openapi(
11507
+ app26.openapi(
11375
11508
  createRoute({
11376
11509
  method: "get",
11377
11510
  path: "/project-full/{projectId}",
@@ -11399,7 +11532,7 @@ app25.openapi(
11399
11532
  try {
11400
11533
  const project = await getFullProject(
11401
11534
  dbClient_default,
11402
- logger8
11535
+ logger9
11403
11536
  )({
11404
11537
  scopes: { tenantId, projectId }
11405
11538
  });
@@ -11424,7 +11557,7 @@ app25.openapi(
11424
11557
  }
11425
11558
  }
11426
11559
  );
11427
- app25.openapi(
11560
+ app26.openapi(
11428
11561
  createRoute({
11429
11562
  method: "put",
11430
11563
  path: "/project-full/{projectId}",
@@ -11475,15 +11608,15 @@ app25.openapi(
11475
11608
  }
11476
11609
  const existingProject = await getFullProject(
11477
11610
  dbClient_default,
11478
- logger8
11611
+ logger9
11479
11612
  )({
11480
11613
  scopes: { tenantId, projectId }
11481
11614
  });
11482
11615
  const isCreate = !existingProject;
11483
- const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default, logger8)(
11616
+ const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default, logger9)(
11484
11617
  { tenantId, projectId },
11485
11618
  validatedProjectData
11486
- ) : await updateFullProjectServerSide(dbClient_default, logger8)(
11619
+ ) : await updateFullProjectServerSide(dbClient_default, logger9)(
11487
11620
  { tenantId, projectId },
11488
11621
  validatedProjectData
11489
11622
  );
@@ -11508,7 +11641,7 @@ app25.openapi(
11508
11641
  }
11509
11642
  }
11510
11643
  );
11511
- app25.openapi(
11644
+ app26.openapi(
11512
11645
  createRoute({
11513
11646
  method: "delete",
11514
11647
  path: "/project-full/{projectId}",
@@ -11531,7 +11664,7 @@ app25.openapi(
11531
11664
  try {
11532
11665
  const deleted = await deleteFullProject(
11533
11666
  dbClient_default,
11534
- logger8
11667
+ logger9
11535
11668
  )({
11536
11669
  scopes: { tenantId, projectId }
11537
11670
  });
@@ -11556,7 +11689,7 @@ app25.openapi(
11556
11689
  }
11557
11690
  }
11558
11691
  );
11559
- var projectFull_default = app25;
11692
+ var projectFull_default = app26;
11560
11693
  var userOrganizationsRoutes = new OpenAPIHono();
11561
11694
  userOrganizationsRoutes.openapi(
11562
11695
  createRoute({
@@ -11631,35 +11764,35 @@ userOrganizationsRoutes.openapi(
11631
11764
  var userOrganizations_default = userOrganizationsRoutes;
11632
11765
 
11633
11766
  // src/app.ts
11634
- var logger9 = getLogger("agents-manage-api");
11635
- logger9.info({ logger: logger9.getTransports() }, "Logger initialized");
11767
+ var logger10 = getLogger("agents-manage-api");
11768
+ logger10.info({ logger: logger10.getTransports() }, "Logger initialized");
11636
11769
  function isOriginAllowed(origin) {
11637
11770
  if (!origin) return false;
11638
11771
  try {
11639
11772
  const requestUrl = new URL(origin);
11640
11773
  const authUrl = new URL(env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002");
11774
+ const uiUrl = env.INKEEP_AGENTS_MANAGE_UI_URL ? new URL(env.INKEEP_AGENTS_MANAGE_UI_URL) : null;
11641
11775
  if (authUrl.hostname === "localhost" || authUrl.hostname === "127.0.0.1") {
11642
11776
  return requestUrl.hostname === "localhost" || requestUrl.hostname === "127.0.0.1";
11643
11777
  }
11644
- if (requestUrl.hostname.endsWith(".vercel.app")) {
11778
+ if (uiUrl && requestUrl.hostname === uiUrl.hostname) {
11645
11779
  return true;
11646
11780
  }
11647
- const baseDomain = authUrl.hostname.replace(/^api\./, "");
11648
- return requestUrl.hostname === baseDomain || requestUrl.hostname.endsWith(`.${baseDomain}`);
11781
+ return false;
11649
11782
  } catch {
11650
11783
  return false;
11651
11784
  }
11652
11785
  }
11653
11786
  function createManagementHono(serverConfig, credentialStores, auth) {
11654
- const app26 = new OpenAPIHono();
11655
- app26.use("*", requestId());
11656
- app26.use("*", async (c, next) => {
11787
+ const app27 = new OpenAPIHono();
11788
+ app27.use("*", requestId());
11789
+ app27.use("*", async (c, next) => {
11657
11790
  c.set("serverConfig", serverConfig);
11658
11791
  c.set("credentialStores", credentialStores);
11659
11792
  c.set("auth", auth);
11660
11793
  return next();
11661
11794
  });
11662
- app26.use(
11795
+ app27.use(
11663
11796
  pinoLogger({
11664
11797
  pino: getLogger("agents-manage-api").getPinoInstance(),
11665
11798
  http: {
@@ -11672,7 +11805,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11672
11805
  }
11673
11806
  })
11674
11807
  );
11675
- app26.onError(async (err2, c) => {
11808
+ app27.onError(async (err2, c) => {
11676
11809
  const isExpectedError = err2 instanceof HTTPException;
11677
11810
  const status = isExpectedError ? err2.status : 500;
11678
11811
  const requestId2 = c.get("requestId") || "unknown";
@@ -11705,7 +11838,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11705
11838
  if (!isExpectedError) {
11706
11839
  const errorMessage = err2 instanceof Error ? err2.message : String(err2);
11707
11840
  const errorStack = err2 instanceof Error ? err2.stack : void 0;
11708
- logger9.error(
11841
+ logger10.error(
11709
11842
  {
11710
11843
  error: err2,
11711
11844
  message: errorMessage,
@@ -11716,7 +11849,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11716
11849
  "Unexpected server error occurred"
11717
11850
  );
11718
11851
  } else {
11719
- logger9.error(
11852
+ logger10.error(
11720
11853
  {
11721
11854
  error: err2,
11722
11855
  path: c.req.path,
@@ -11742,7 +11875,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11742
11875
  return c.body(JSON.stringify(responseBody));
11743
11876
  });
11744
11877
  if (auth) {
11745
- app26.use(
11878
+ app27.use(
11746
11879
  "/api/auth/*",
11747
11880
  cors({
11748
11881
  origin: (origin) => {
@@ -11755,14 +11888,30 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11755
11888
  credentials: true
11756
11889
  })
11757
11890
  );
11758
- app26.on(["POST", "GET"], "/api/auth/*", (c) => {
11891
+ app27.on(["POST", "GET"], "/api/auth/*", (c) => {
11759
11892
  return auth.handler(c.req.raw);
11760
11893
  });
11761
11894
  }
11762
- app26.use("*", async (c, next) => {
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) => {
11763
11909
  if (auth && c.req.path.startsWith("/api/auth/")) {
11764
11910
  return next();
11765
11911
  }
11912
+ if (c.req.path.includes("/playground/token")) {
11913
+ return next();
11914
+ }
11766
11915
  return cors({
11767
11916
  origin: (origin) => {
11768
11917
  return isOriginAllowed(origin) ? origin : null;
@@ -11774,7 +11923,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11774
11923
  credentials: true
11775
11924
  })(c, next);
11776
11925
  });
11777
- app26.use("*", async (c, next) => {
11926
+ app27.use("*", async (c, next) => {
11778
11927
  if (env.DISABLE_AUTH || !auth) {
11779
11928
  c.set("user", null);
11780
11929
  c.set("session", null);
@@ -11792,7 +11941,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11792
11941
  c.set("session", session.session);
11793
11942
  await next();
11794
11943
  });
11795
- app26.openapi(
11944
+ app27.openapi(
11796
11945
  createRoute({
11797
11946
  method: "get",
11798
11947
  path: "/health",
@@ -11809,7 +11958,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11809
11958
  return c.body(null, 204);
11810
11959
  }
11811
11960
  );
11812
- app26.use("/tenants/*", async (c, next) => {
11961
+ app27.use("/tenants/*", async (c, next) => {
11813
11962
  const isTestEnvironment = process.env.ENVIRONMENT === "test";
11814
11963
  if (env.DISABLE_AUTH || isTestEnvironment) {
11815
11964
  await next();
@@ -11823,19 +11972,20 @@ function createManagementHono(serverConfig, credentialStores, auth) {
11823
11972
  });
11824
11973
  const isTestEnv = process.env.ENVIRONMENT === "test";
11825
11974
  if (!env.DISABLE_AUTH && !isTestEnv) {
11826
- app26.use("/tenants/:tenantId/*", requireTenantAccess());
11827
- }
11828
- app26.route("/api/users/:userId/organizations", userOrganizations_default);
11829
- app26.route("/api/invitations", invitations_default);
11830
- app26.route("/tenants/:tenantId", routes_default);
11831
- app26.route("/tenants/:tenantId", projectFull_default);
11832
- app26.route("/oauth", oauth_default);
11833
- setupOpenAPIRoutes(app26);
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);
11834
11984
  const baseApp = new Hono();
11835
- baseApp.route("/", app26);
11985
+ baseApp.route("/", app27);
11836
11986
  return baseApp;
11837
11987
  }
11838
- var logger10 = getLogger("initialization");
11988
+ var logger11 = getLogger("initialization");
11839
11989
  async function initializeDefaultUser(authInstance) {
11840
11990
  const { INKEEP_AGENTS_MANAGE_UI_USERNAME, INKEEP_AGENTS_MANAGE_UI_PASSWORD, DISABLE_AUTH } = env;
11841
11991
  const hasCredentials = INKEEP_AGENTS_MANAGE_UI_USERNAME && INKEEP_AGENTS_MANAGE_UI_PASSWORD;
@@ -11850,23 +12000,23 @@ async function initializeDefaultUser(authInstance) {
11850
12000
  logo: null,
11851
12001
  metadata: null
11852
12002
  });
11853
- logger10.info({ organizationId: orgId }, "Created default organization");
12003
+ logger11.info({ organizationId: orgId }, "Created default organization");
11854
12004
  } else {
11855
- logger10.info({ organizationId: orgId }, "Organization already exists");
12005
+ logger11.info({ organizationId: orgId }, "Organization already exists");
11856
12006
  }
11857
12007
  if (!hasCredentials || DISABLE_AUTH || !authInstance) {
11858
- logger10.info({ hasCredentials: false }, "Skipping default user creation");
12008
+ logger11.info({ hasCredentials: false }, "Skipping default user creation");
11859
12009
  return;
11860
12010
  }
11861
12011
  try {
11862
12012
  let user = await getUserByEmail(dbClient_default)(INKEEP_AGENTS_MANAGE_UI_USERNAME);
11863
12013
  if (user) {
11864
- logger10.info(
12014
+ logger11.info(
11865
12015
  { email: INKEEP_AGENTS_MANAGE_UI_USERNAME, userId: user.id },
11866
12016
  "Default user already exists"
11867
12017
  );
11868
12018
  } else {
11869
- logger10.info(
12019
+ logger11.info(
11870
12020
  { email: INKEEP_AGENTS_MANAGE_UI_USERNAME },
11871
12021
  "Creating default user with Better Auth..."
11872
12022
  );
@@ -11885,7 +12035,7 @@ async function initializeDefaultUser(authInstance) {
11885
12035
  if (!user) {
11886
12036
  throw new Error("User was created but could not be retrieved from database");
11887
12037
  }
11888
- logger10.info(
12038
+ logger11.info(
11889
12039
  {
11890
12040
  email: user.email,
11891
12041
  id: user.id
@@ -11902,14 +12052,14 @@ async function initializeDefaultUser(authInstance) {
11902
12052
  role: "owner",
11903
12053
  createdAt: /* @__PURE__ */ new Date()
11904
12054
  });
11905
- logger10.info({ userId: user.id, organizationId: orgId }, "Added user as organization owner");
12055
+ logger11.info({ userId: user.id, organizationId: orgId }, "Added user as organization owner");
11906
12056
  } else {
11907
- logger10.info(
12057
+ logger11.info(
11908
12058
  { userId: user.id, organizationId: orgId },
11909
12059
  "User already a member of organization"
11910
12060
  );
11911
12061
  }
11912
- logger10.info(
12062
+ logger11.info(
11913
12063
  {
11914
12064
  organizationId: orgId,
11915
12065
  organizationSlug: env.TENANT_ID,
@@ -11919,7 +12069,7 @@ async function initializeDefaultUser(authInstance) {
11919
12069
  "\u2705 Initialization complete - login with these credentials"
11920
12070
  );
11921
12071
  } catch (error) {
11922
- logger10.error(
12072
+ logger11.error(
11923
12073
  { error, email: INKEEP_AGENTS_MANAGE_UI_USERNAME },
11924
12074
  "\u274C Failed to create default user"
11925
12075
  );
package/dist/factory.js CHANGED
@@ -1 +1 @@
1
- export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-7YBMBKBI.js';
1
+ export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-6E4QM6FE.js';
package/dist/index.d.ts CHANGED
@@ -30,9 +30,31 @@ declare const auth: better_auth.Auth<{
30
30
  updateAge: number;
31
31
  };
32
32
  advanced: {
33
+ ipAddress?: {
34
+ ipAddressHeaders?: string[];
35
+ disableIpTracking?: boolean;
36
+ } | undefined;
37
+ useSecureCookies?: boolean | undefined;
38
+ disableCSRFCheck?: boolean | undefined;
39
+ disableOriginCheck?: boolean | undefined;
33
40
  crossSubDomainCookies: {
34
- enabled: true;
41
+ enabled: boolean;
42
+ additionalCookies?: string[];
43
+ domain?: string;
35
44
  };
45
+ cookies?: {
46
+ [key: string]: {
47
+ name?: string;
48
+ attributes?: better_auth.CookieOptions;
49
+ };
50
+ } | undefined;
51
+ defaultCookieAttributes?: better_auth.CookieOptions | undefined;
52
+ cookiePrefix?: string | undefined;
53
+ database?: {
54
+ defaultFindManyLimit?: number;
55
+ useNumberId?: boolean;
56
+ generateId?: better_auth.GenerateIdFn | false | "serial" | "uuid";
57
+ } | undefined;
36
58
  };
37
59
  trustedOrigins: string[];
38
60
  plugins: [{
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createAuth0Provider, createManagementHono, env, initializeDefaultUser, dbClient_default } from './chunk-7YBMBKBI.js';
2
- export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-7YBMBKBI.js';
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.36.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.36.0"
35
+ "@inkeep/agents-core": "^0.37.0"
35
36
  },
36
37
  "optionalDependencies": {
37
38
  "keytar": "^7.9.0"