@inkeep/agents-manage-api 0.39.5 → 0.41.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 +163 -57
  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 +64 -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 +206 -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,51 @@
1
+ import * as client from "openid-client";
2
+
3
+ //#region src/sso-helpers.ts
4
+ async function createOIDCProvider(options) {
5
+ try {
6
+ const issuerUrl = new URL(`https://${options.domain}`);
7
+ const metadata = (await client.discovery(issuerUrl, client.randomPKCECodeVerifier())).serverMetadata();
8
+ if (!metadata.issuer || !metadata.authorization_endpoint || !metadata.token_endpoint || !metadata.userinfo_endpoint || !metadata.jwks_uri) console.log("Some OIDC configuration endpoints are missing, which might cause issues with SSO");
9
+ const oidcConfig = {
10
+ clientId: options.clientId,
11
+ clientSecret: options.clientSecret,
12
+ discoveryEndpoint: `https://${options.domain}/.well-known/openid-configuration`,
13
+ authorizationEndpoint: metadata.authorization_endpoint,
14
+ tokenEndpoint: metadata.token_endpoint,
15
+ userinfoEndpoint: metadata.userinfo_endpoint,
16
+ jwksEndpoint: metadata.jwks_uri,
17
+ scopes: options.scopes || [
18
+ "openid",
19
+ "email",
20
+ "profile"
21
+ ],
22
+ pkce: options.pkce !== false,
23
+ mapping: {
24
+ id: "sub",
25
+ email: "email",
26
+ emailVerified: "email_verified",
27
+ name: "name",
28
+ image: "picture"
29
+ }
30
+ };
31
+ return {
32
+ providerId: options.providerId,
33
+ issuer: metadata.issuer,
34
+ domain: options.domain,
35
+ organizationId: options.organizationId,
36
+ oidcConfig
37
+ };
38
+ } catch (error) {
39
+ console.error(`Error discovering OIDC configuration for ${options.domain}:`, error);
40
+ return null;
41
+ }
42
+ }
43
+ async function createAuth0Provider(options) {
44
+ return await createOIDCProvider({
45
+ ...options,
46
+ providerId: "auth0"
47
+ });
48
+ }
49
+
50
+ //#endregion
51
+ export { createAuth0Provider, createOIDCProvider };
@@ -0,0 +1,47 @@
1
+ import { CredentialStoreRegistry, ServerConfig } from "@inkeep/agents-core";
2
+ import { createAuth } from "@inkeep/agents-core/auth";
3
+
4
+ //#region src/types/app.d.ts
5
+
6
+ /**
7
+ * Base authentication variables set by session middleware
8
+ * Available in all authenticated routes
9
+ */
10
+ type BaseAppVariables = {
11
+ auth: ReturnType<typeof createAuth> | null;
12
+ userId: string;
13
+ userEmail: string;
14
+ tenantId: string;
15
+ tenantRole: string;
16
+ };
17
+ /**
18
+ * Extended app variables with credential store support
19
+ * Used in routes that need credential management
20
+ */
21
+ type AppVariablesWithCredentials = BaseAppVariables & {
22
+ credentialStores: CredentialStoreRegistry;
23
+ };
24
+ /**
25
+ * Extended app variables with server config and credential stores
26
+ * Used in routes that need full server configuration
27
+ */
28
+ type AppVariablesWithServerConfig = BaseAppVariables & {
29
+ serverConfig: ServerConfig;
30
+ credentialStores: CredentialStoreRegistry;
31
+ };
32
+ /**
33
+ * Minimal app variables for public/OAuth routes
34
+ * Does not include authentication variables
35
+ */
36
+ type PublicAppVariables = {
37
+ credentialStores: CredentialStoreRegistry;
38
+ };
39
+ /**
40
+ * Minimal app variables for OAuth routes with server config
41
+ */
42
+ type PublicAppVariablesWithServerConfig = {
43
+ serverConfig: ServerConfig;
44
+ credentialStores: CredentialStoreRegistry;
45
+ };
46
+ //#endregion
47
+ export { AppVariablesWithCredentials, AppVariablesWithServerConfig, BaseAppVariables, PublicAppVariables, PublicAppVariablesWithServerConfig };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,33 @@
1
+ import { cors } from "hono/cors";
2
+
3
+ //#region src/utils/cors.d.ts
4
+ type CorsOptions = Parameters<typeof cors>[0];
5
+ /**
6
+ * Extract the base domain from a hostname (e.g., 'app.preview.inkeep.com' -> 'preview.inkeep.com')
7
+ * For hostnames with 3+ parts, returns the last 3 parts (subdomain.domain.tld)
8
+ * For hostnames with 2 parts, returns as-is (domain.tld)
9
+ */
10
+ declare function getBaseDomain(hostname: string): string;
11
+ /**
12
+ * Check if a request origin is allowed for CORS
13
+ *
14
+ * Development: Allow any localhost origin
15
+ * Production/Preview: Allow the specific UI URL, or any subdomain of the same base domain
16
+ *
17
+ * @returns true if origin is allowed (also narrows type to string)
18
+ */
19
+ declare function isOriginAllowed(origin: string | undefined): origin is string;
20
+ /**
21
+ * CORS configuration for auth routes (Better Auth, session endpoints)
22
+ */
23
+ declare const authCorsConfig: CorsOptions;
24
+ /**
25
+ * CORS configuration for playground routes
26
+ */
27
+ declare const playgroundCorsConfig: CorsOptions;
28
+ /**
29
+ * CORS configuration for default API routes
30
+ */
31
+ declare const defaultCorsConfig: CorsOptions;
32
+ //#endregion
33
+ export { authCorsConfig, defaultCorsConfig, getBaseDomain, isOriginAllowed, playgroundCorsConfig };
@@ -0,0 +1,98 @@
1
+ import { env } from "../env.js";
2
+
3
+ //#region src/utils/cors.ts
4
+ /**
5
+ * Extract the base domain from a hostname (e.g., 'app.preview.inkeep.com' -> 'preview.inkeep.com')
6
+ * For hostnames with 3+ parts, returns the last 3 parts (subdomain.domain.tld)
7
+ * For hostnames with 2 parts, returns as-is (domain.tld)
8
+ */
9
+ function getBaseDomain(hostname) {
10
+ const parts = hostname.split(".");
11
+ if (parts.length >= 3) return parts.slice(-3).join(".");
12
+ return hostname;
13
+ }
14
+ /**
15
+ * Check if a request origin is allowed for CORS
16
+ *
17
+ * Development: Allow any localhost origin
18
+ * Production/Preview: Allow the specific UI URL, or any subdomain of the same base domain
19
+ *
20
+ * @returns true if origin is allowed (also narrows type to string)
21
+ */
22
+ function isOriginAllowed(origin) {
23
+ if (!origin) return false;
24
+ try {
25
+ const requestUrl = new URL(origin);
26
+ const apiUrl = new URL(env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002");
27
+ const uiUrl = env.INKEEP_AGENTS_MANAGE_UI_URL ? new URL(env.INKEEP_AGENTS_MANAGE_UI_URL) : null;
28
+ if (apiUrl.hostname === "localhost" || apiUrl.hostname === "127.0.0.1") return requestUrl.hostname === "localhost" || requestUrl.hostname === "127.0.0.1";
29
+ if (uiUrl && requestUrl.hostname === uiUrl.hostname) return true;
30
+ if (getBaseDomain(requestUrl.hostname) === getBaseDomain(apiUrl.hostname)) return true;
31
+ return false;
32
+ } catch {
33
+ return false;
34
+ }
35
+ }
36
+ /**
37
+ * Origin handler for CORS middleware
38
+ */
39
+ const originHandler = (origin) => isOriginAllowed(origin) ? origin : null;
40
+ /**
41
+ * CORS configuration for auth routes (Better Auth, session endpoints)
42
+ */
43
+ const authCorsConfig = {
44
+ origin: originHandler,
45
+ allowHeaders: [
46
+ "content-type",
47
+ "Content-Type",
48
+ "authorization",
49
+ "Authorization",
50
+ "User-Agent"
51
+ ],
52
+ allowMethods: [
53
+ "POST",
54
+ "GET",
55
+ "OPTIONS"
56
+ ],
57
+ exposeHeaders: ["Content-Length"],
58
+ maxAge: 600,
59
+ credentials: true
60
+ };
61
+ /**
62
+ * CORS configuration for playground routes
63
+ */
64
+ const playgroundCorsConfig = {
65
+ origin: originHandler,
66
+ allowHeaders: [
67
+ "content-type",
68
+ "Content-Type",
69
+ "authorization",
70
+ "Authorization",
71
+ "User-Agent"
72
+ ],
73
+ allowMethods: ["POST", "OPTIONS"],
74
+ exposeHeaders: ["Content-Length"],
75
+ maxAge: 600,
76
+ credentials: true
77
+ };
78
+ /**
79
+ * CORS configuration for default API routes
80
+ */
81
+ const defaultCorsConfig = {
82
+ origin: originHandler,
83
+ allowMethods: [
84
+ "GET",
85
+ "POST",
86
+ "PUT",
87
+ "DELETE",
88
+ "OPTIONS",
89
+ "PATCH"
90
+ ],
91
+ allowHeaders: ["*"],
92
+ exposeHeaders: ["Content-Length"],
93
+ maxAge: 86400,
94
+ credentials: true
95
+ };
96
+
97
+ //#endregion
98
+ export { authCorsConfig, defaultCorsConfig, getBaseDomain, isOriginAllowed, playgroundCorsConfig };
@@ -0,0 +1,71 @@
1
+ import { McpTokenExchangeResult } from "@inkeep/agents-core";
2
+
3
+ //#region src/utils/oauth-service.d.ts
4
+
5
+ /**
6
+ * Retrieve and remove PKCE verifier
7
+ */
8
+ declare function retrievePKCEVerifier(state: string): {
9
+ codeVerifier: string;
10
+ toolId: string;
11
+ tenantId: string;
12
+ projectId: string;
13
+ clientInformation: any;
14
+ metadata: any;
15
+ resourceUrl?: string;
16
+ } | null;
17
+ /**
18
+ * OAuth client configuration
19
+ */
20
+ interface OAuthClientConfig {
21
+ defaultClientId?: string;
22
+ clientName?: string;
23
+ clientUri?: string;
24
+ logoUri?: string;
25
+ redirectBaseUrl?: string;
26
+ }
27
+ /**
28
+ * OAuth flow initiation result
29
+ */
30
+ interface OAuthInitiationResult {
31
+ redirectUrl: string;
32
+ state: string;
33
+ }
34
+ /**
35
+ * Token exchange result
36
+ */
37
+ interface TokenExchangeResult {
38
+ tokens: McpTokenExchangeResult;
39
+ }
40
+ /**
41
+ * OAuth service class that handles the complete OAuth flow
42
+ */
43
+ declare class OAuthService {
44
+ private defaultConfig;
45
+ constructor(config?: OAuthClientConfig);
46
+ /**
47
+ * Initiate OAuth flow for an MCP tool using MCP SDK
48
+ */
49
+ initiateOAuthFlow(params: {
50
+ tenantId: string;
51
+ projectId: string;
52
+ toolId: string;
53
+ mcpServerUrl: string;
54
+ baseUrl?: string;
55
+ }): Promise<OAuthInitiationResult>;
56
+ /**
57
+ * Exchange authorization code for access tokens using MCP SDK with stored metadata
58
+ */
59
+ exchangeCodeForTokens(params: {
60
+ code: string;
61
+ codeVerifier: string;
62
+ clientInformation: any;
63
+ metadata: any;
64
+ resourceUrl?: string;
65
+ mcpServerUrl: string;
66
+ baseUrl?: string;
67
+ }): Promise<TokenExchangeResult>;
68
+ }
69
+ declare const oauthService: OAuthService;
70
+ //#endregion
71
+ export { oauthService, retrievePKCEVerifier };
@@ -0,0 +1,106 @@
1
+ import { env } from "../env.js";
2
+ import { getLogger as getLogger$1 } from "../logger.js";
3
+ import { exchangeMcpAuthorizationCode, initiateMcpOAuthFlow } from "@inkeep/agents-core";
4
+
5
+ //#region src/utils/oauth-service.ts
6
+ const logger = getLogger$1("oauth-service");
7
+ const pkceStore = /* @__PURE__ */ new Map();
8
+ /**
9
+ * Store PKCE verifier and OAuth metadata for later use in token exchange
10
+ */
11
+ function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientInformation, metadata, resourceUrl) {
12
+ pkceStore.set(state, {
13
+ codeVerifier,
14
+ toolId,
15
+ tenantId,
16
+ projectId,
17
+ clientInformation,
18
+ metadata,
19
+ resourceUrl
20
+ });
21
+ setTimeout(() => {
22
+ pkceStore.delete(state);
23
+ }, 600 * 1e3);
24
+ }
25
+ /**
26
+ * Retrieve and remove PKCE verifier
27
+ */
28
+ function retrievePKCEVerifier(state) {
29
+ const data = pkceStore.get(state);
30
+ if (data) {
31
+ pkceStore.delete(state);
32
+ return data;
33
+ }
34
+ return null;
35
+ }
36
+ /**
37
+ * OAuth service class that handles the complete OAuth flow
38
+ */
39
+ var OAuthService = class {
40
+ defaultConfig;
41
+ constructor(config = {}) {
42
+ this.defaultConfig = {
43
+ defaultClientId: config.defaultClientId || process.env.DEFAULT_OAUTH_CLIENT_ID || "mcp-client",
44
+ clientName: config.clientName || process.env.OAUTH_CLIENT_NAME || "Inkeep Agent Framework",
45
+ clientUri: config.clientUri || process.env.OAUTH_CLIENT_URI || "https://inkeep.com",
46
+ logoUri: config.logoUri || process.env.OAUTH_CLIENT_LOGO_URI || "https://inkeep.com/images/logos/inkeep-logo-blue.svg",
47
+ redirectBaseUrl: config.redirectBaseUrl || env.INKEEP_AGENTS_MANAGE_API_URL
48
+ };
49
+ }
50
+ /**
51
+ * Initiate OAuth flow for an MCP tool using MCP SDK
52
+ */
53
+ async initiateOAuthFlow(params) {
54
+ const { tenantId, projectId, toolId, mcpServerUrl, baseUrl } = params;
55
+ const redirectUri = `${baseUrl || this.defaultConfig.redirectBaseUrl}/oauth/callback`;
56
+ const state = `tool_${toolId}`;
57
+ const authResult = await initiateMcpOAuthFlow({
58
+ mcpServerUrl,
59
+ redirectUri,
60
+ state,
61
+ clientName: this.defaultConfig.clientName,
62
+ clientUri: this.defaultConfig.clientUri,
63
+ logoUri: this.defaultConfig.logoUri,
64
+ defaultClientId: this.defaultConfig.defaultClientId,
65
+ logger
66
+ });
67
+ storePKCEVerifier(state, authResult.codeVerifier, toolId, tenantId, projectId, authResult.clientInformation, authResult.metadata, authResult.resourceUrl);
68
+ logger.info({
69
+ toolId,
70
+ authorizationUrl: authResult.authorizationUrl,
71
+ tenantId,
72
+ projectId,
73
+ scopes: authResult.scopes
74
+ }, "MCP OAuth flow initiated successfully");
75
+ return {
76
+ redirectUrl: authResult.authorizationUrl,
77
+ state
78
+ };
79
+ }
80
+ /**
81
+ * Exchange authorization code for access tokens using MCP SDK with stored metadata
82
+ */
83
+ async exchangeCodeForTokens(params) {
84
+ const { code, codeVerifier, clientInformation, metadata, resourceUrl, mcpServerUrl, baseUrl } = params;
85
+ const tokens = await exchangeMcpAuthorizationCode({
86
+ mcpServerUrl,
87
+ metadata,
88
+ clientInformation,
89
+ authorizationCode: code,
90
+ codeVerifier,
91
+ redirectUri: `${baseUrl || this.defaultConfig.redirectBaseUrl}/oauth/callback`,
92
+ resourceUrl,
93
+ logger
94
+ });
95
+ logger.info({
96
+ tokenType: tokens.token_type,
97
+ hasRefreshToken: !!tokens.refresh_token,
98
+ clientId: clientInformation.client_id
99
+ }, "MCP token exchange successful");
100
+ return { tokens };
101
+ }
102
+ };
103
+ const oauthService = new OAuthService();
104
+
105
+ //#endregion
106
+ export { oauthService, retrievePKCEVerifier };
@@ -0,0 +1,9 @@
1
+ //#region src/utils/signoz-helpers.d.ts
2
+ /**
3
+ * Helper function to enforce projectId filter on SigNoz queries.
4
+ * This modifies the query payload to ensure all builder queries include
5
+ * a server-side project.id filter, preventing client-side filter bypass.
6
+ */
7
+ declare function enforceProjectFilter(payload: any, projectId: string): any;
8
+ //#endregion
9
+ export { enforceProjectFilter };
@@ -0,0 +1,33 @@
1
+ //#region src/utils/signoz-helpers.ts
2
+ /**
3
+ * Helper function to enforce projectId filter on SigNoz queries.
4
+ * This modifies the query payload to ensure all builder queries include
5
+ * a server-side project.id filter, preventing client-side filter bypass.
6
+ */
7
+ function enforceProjectFilter(payload, projectId) {
8
+ const modifiedPayload = JSON.parse(JSON.stringify(payload));
9
+ if (modifiedPayload.compositeQuery?.builderQueries) for (const queryKey in modifiedPayload.compositeQuery.builderQueries) {
10
+ const query = modifiedPayload.compositeQuery.builderQueries[queryKey];
11
+ if (!query.filters) query.filters = {
12
+ op: "AND",
13
+ items: []
14
+ };
15
+ query.filters.items = query.filters.items.filter((item) => item.key?.key !== "project.id");
16
+ query.filters.items.push({
17
+ key: {
18
+ key: "project.id",
19
+ dataType: "string",
20
+ type: "tag",
21
+ isColumn: false,
22
+ isJSON: false,
23
+ id: "false"
24
+ },
25
+ op: "=",
26
+ value: projectId
27
+ });
28
+ }
29
+ return modifiedPayload;
30
+ }
31
+
32
+ //#endregion
33
+ export { enforceProjectFilter };
@@ -0,0 +1,17 @@
1
+ import { DatabaseClient } from "@inkeep/agents-core";
2
+
3
+ //#region src/utils/temp-api-keys.d.ts
4
+ interface CreateTempApiKeyParams {
5
+ tenantId: string;
6
+ projectId: string;
7
+ agentId: string;
8
+ userId: string;
9
+ expiryHours?: number;
10
+ }
11
+ interface TempApiKeyResult {
12
+ apiKey: string;
13
+ expiresAt: string;
14
+ }
15
+ declare function createTempApiKey(db: DatabaseClient, params: CreateTempApiKeyParams): Promise<TempApiKeyResult>;
16
+ //#endregion
17
+ export { CreateTempApiKeyParams, TempApiKeyResult, createTempApiKey };
@@ -0,0 +1,26 @@
1
+ import { createApiKey, generateApiKey } from "@inkeep/agents-core";
2
+
3
+ //#region src/utils/temp-api-keys.ts
4
+ async function createTempApiKey(db, params) {
5
+ const expiryHours = params.expiryHours || 1;
6
+ const expiresAt = new Date(Date.now() + expiryHours * 60 * 60 * 1e3);
7
+ const keyData = await generateApiKey();
8
+ await createApiKey(db)({
9
+ id: keyData.id,
10
+ publicId: keyData.publicId,
11
+ keyHash: keyData.keyHash,
12
+ keyPrefix: keyData.keyPrefix,
13
+ name: `playground-temp-${params.userId}`,
14
+ tenantId: params.tenantId,
15
+ projectId: params.projectId,
16
+ agentId: params.agentId,
17
+ expiresAt: expiresAt.toISOString()
18
+ });
19
+ return {
20
+ apiKey: keyData.key,
21
+ expiresAt: expiresAt.toISOString()
22
+ };
23
+ }
24
+
25
+ //#endregion
26
+ export { createTempApiKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-manage-api",
3
- "version": "0.39.5",
3
+ "version": "0.41.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",
@@ -17,24 +17,19 @@
17
17
  },
18
18
  "type": "module",
19
19
  "dependencies": {
20
+ "@electric-sql/pglite": "^0.3.13",
20
21
  "@hono/mcp": "^0.1.5",
21
- "@composio/core": "^0.2.4",
22
- "@hono/node-server": "^1.14.3",
23
22
  "@hono/swagger-ui": "^0.5.1",
24
- "@modelcontextprotocol/sdk": "^1.17.0",
25
- "@nangohq/node": "^0.69.5",
26
- "@nangohq/types": "^0.69.5",
23
+ "@modelcontextprotocol/sdk": "1.24.3",
27
24
  "axios": "^1.7.9",
28
- "dotenv": "^17.2.1",
29
25
  "drizzle-orm": "^0.44.4",
30
26
  "hono": "^4.10.4",
31
27
  "hono-pino": "^0.10.1",
32
- "jose": "^6.1.0",
33
28
  "nanoid": "^5.1.5",
34
29
  "openid-client": "^6.6.4",
35
30
  "pino": "^9.7.0",
36
- "@inkeep/agents-core": "^0.39.5",
37
- "@inkeep/agents-manage-mcp": "^0.39.5"
31
+ "@inkeep/agents-core": "^0.41.0",
32
+ "@inkeep/agents-manage-mcp": "^0.41.0"
38
33
  },
39
34
  "peerDependencies": {
40
35
  "@hono/zod-openapi": "^1.1.5",
@@ -44,12 +39,9 @@
44
39
  "keytar": "^7.9.0"
45
40
  },
46
41
  "devDependencies": {
47
- "@electric-sql/pglite": "^0.3.13",
48
42
  "@hono/vite-dev-server": "^0.20.1",
49
43
  "@types/node": "^20.11.24",
50
44
  "@vitest/coverage-v8": "^3.2.4",
51
- "nodemon": "^3.1.0",
52
- "pino-pretty": "^13.0.0",
53
45
  "tsx": "^4.7.1",
54
46
  "typescript": "^5.3.3",
55
47
  "vite": "^7.1.11",
@@ -72,6 +64,7 @@
72
64
  "directory": "agents-manage-api"
73
65
  },
74
66
  "scripts": {
67
+ "knip": "knip --directory .. --workspace agents-manage-api --dependencies",
75
68
  "dev": "vite",
76
69
  "build": "tsdown",
77
70
  "start": "node dist/index.js",