@inkeep/agents-core 0.41.2 → 0.43.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/api-client/base-client.d.ts +87 -8
- package/dist/api-client/base-client.js +174 -1
- package/dist/api-client/eval-api-client.d.ts +47 -0
- package/dist/api-client/eval-api-client.js +65 -0
- package/dist/api-client/index.d.ts +4 -0
- package/dist/api-client/index.js +5 -0
- package/dist/api-client/manage-api-client.d.ts +34 -0
- package/dist/api-client/manage-api-client.js +104 -0
- package/dist/auth/auth.d.ts +86 -20
- package/dist/auth/auth.js +60 -2
- package/dist/auth/authz/client.d.ts +87 -0
- package/dist/auth/authz/client.js +196 -0
- package/dist/auth/authz/config.d.ts +103 -0
- package/dist/auth/authz/config.js +93 -0
- package/dist/auth/authz/index.d.ts +5 -0
- package/dist/auth/authz/index.js +6 -0
- package/dist/auth/authz/permissions.d.ts +53 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +106 -0
- package/dist/auth/authz/sync.js +321 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +9 -3
- package/dist/client-exports.js +4 -2
- package/dist/constants/context-breakdown.d.ts +61 -0
- package/dist/constants/context-breakdown.js +124 -0
- package/dist/constants/execution-limits-shared/defaults.d.ts +1 -1
- package/dist/constants/execution-limits-shared/defaults.js +1 -1
- package/dist/constants/execution-limits-shared/index.d.ts +1 -1
- package/dist/constants/otel-attributes.d.ts +4 -0
- package/dist/constants/otel-attributes.js +4 -0
- package/dist/context/ContextConfig.d.ts +2 -2
- package/dist/context/ContextConfig.js +3 -3
- package/dist/context/TemplateEngine.d.ts +0 -6
- package/dist/context/TemplateEngine.js +4 -19
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.js +1 -5
- package/dist/credential-stores/keychain-store.d.ts +20 -8
- package/dist/credential-stores/keychain-store.js +107 -43
- package/dist/credential-stuffer/CredentialStuffer.d.ts +1 -1
- package/dist/data-access/index.d.ts +34 -26
- package/dist/data-access/index.js +34 -26
- package/dist/data-access/manage/agentFull.d.ts +36 -0
- package/dist/data-access/{agentFull.js → manage/agentFull.js} +209 -7
- package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +64 -63
- package/dist/data-access/{agents.js → manage/agents.js} +80 -27
- package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +33 -33
- package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
- package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +26 -26
- package/dist/data-access/{contextConfigs.js → manage/contextConfigs.js} +3 -3
- package/dist/data-access/{credentialReferences.d.ts → manage/credentialReferences.d.ts} +17 -17
- package/dist/data-access/{credentialReferences.js → manage/credentialReferences.js} +2 -2
- package/dist/data-access/{dataComponents.d.ts → manage/dataComponents.d.ts} +26 -26
- package/dist/data-access/{dataComponents.js → manage/dataComponents.js} +7 -7
- package/dist/data-access/manage/evalConfig.d.ts +221 -0
- package/dist/data-access/manage/evalConfig.js +275 -0
- package/dist/data-access/{externalAgents.d.ts → manage/externalAgents.d.ts} +16 -16
- package/dist/data-access/{externalAgents.js → manage/externalAgents.js} +2 -2
- package/dist/data-access/manage/functionTools.d.ts +242 -0
- package/dist/data-access/{functionTools.js → manage/functionTools.js} +124 -30
- package/dist/data-access/{functions.d.ts → manage/functions.d.ts} +9 -9
- package/dist/data-access/{functions.js → manage/functions.js} +3 -3
- package/dist/data-access/manage/projectFull.d.ts +38 -0
- package/dist/data-access/{projectFull.js → manage/projectFull.js} +64 -65
- package/dist/data-access/manage/projectLifecycle.d.ts +119 -0
- package/dist/data-access/manage/projectLifecycle.js +234 -0
- package/dist/data-access/manage/projects.d.ts +75 -0
- package/dist/data-access/{projects.js → manage/projects.js} +15 -16
- package/dist/data-access/{subAgentExternalAgentRelations.d.ts → manage/subAgentExternalAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
- package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +65 -65
- package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
- package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
- package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +28 -28
- package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
- package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +65 -52
- package/dist/data-access/{tools.js → manage/tools.js} +109 -64
- package/dist/data-access/manage/triggers.d.ts +106 -0
- package/dist/data-access/manage/triggers.js +81 -0
- package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +37 -37
- package/dist/data-access/{apiKeys.js → runtime/apiKeys.js} +3 -3
- package/dist/data-access/runtime/cascade-delete.d.ts +77 -0
- package/dist/data-access/runtime/cascade-delete.js +111 -0
- package/dist/data-access/{contextCache.d.ts → runtime/contextCache.d.ts} +13 -13
- package/dist/data-access/{contextCache.js → runtime/contextCache.js} +5 -5
- package/dist/data-access/{conversations.d.ts → runtime/conversations.d.ts} +80 -31
- package/dist/data-access/{conversations.js → runtime/conversations.js} +13 -7
- package/dist/data-access/runtime/evalRuns.d.ts +120 -0
- package/dist/data-access/runtime/evalRuns.js +168 -0
- package/dist/data-access/{ledgerArtifacts.d.ts → runtime/ledgerArtifacts.d.ts} +13 -13
- package/dist/data-access/{ledgerArtifacts.js → runtime/ledgerArtifacts.js} +3 -3
- package/dist/data-access/{messages.d.ts → runtime/messages.d.ts} +24 -24
- package/dist/data-access/{messages.js → runtime/messages.js} +2 -2
- package/dist/data-access/{organizations.d.ts → runtime/organizations.d.ts} +16 -7
- package/dist/data-access/{organizations.js → runtime/organizations.js} +16 -4
- package/dist/data-access/runtime/projects.d.ts +62 -0
- package/dist/data-access/runtime/projects.js +90 -0
- package/dist/data-access/runtime/tasks.d.ts +55 -0
- package/dist/data-access/{tasks.js → runtime/tasks.js} +2 -2
- package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
- package/dist/data-access/runtime/triggerInvocations.js +54 -0
- package/dist/data-access/runtime/users.d.ts +19 -0
- package/dist/data-access/{users.js → runtime/users.js} +2 -2
- package/dist/data-access/validation.d.ts +4 -4
- package/dist/data-access/validation.js +1 -1
- package/dist/db/clean.d.ts +8 -4
- package/dist/db/clean.js +14 -105
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +7 -10
- package/dist/db/manage/dolt-cleanup.d.ts +51 -0
- package/dist/db/manage/dolt-cleanup.js +132 -0
- package/dist/db/manage/manage-client.d.ts +26 -0
- package/dist/db/manage/manage-client.js +68 -0
- package/dist/db/{schema.d.ts → manage/manage-schema.d.ts} +1257 -969
- package/dist/db/{schema.js → manage/manage-schema.js} +436 -334
- package/dist/db/manage/test-manage-client.d.ts +27 -0
- package/dist/db/manage/test-manage-client.js +68 -0
- package/dist/db/runtime/runtime-client.d.ts +20 -0
- package/dist/db/runtime/runtime-client.js +30 -0
- package/dist/db/runtime/runtime-schema.d.ts +2834 -0
- package/dist/db/runtime/runtime-schema.js +483 -0
- package/dist/db/runtime/test-runtime-client.d.ts +27 -0
- package/dist/db/{test-client.js → runtime/test-runtime-client.js} +11 -25
- package/dist/db/utils.d.ts +6 -0
- package/dist/db/utils.js +42 -0
- package/dist/dolt/branch.d.ts +62 -0
- package/dist/dolt/branch.js +82 -0
- package/dist/dolt/branches-api.d.ts +108 -0
- package/dist/dolt/branches-api.js +162 -0
- package/dist/dolt/commit.d.ts +94 -0
- package/dist/dolt/commit.js +103 -0
- package/dist/dolt/diff.d.ts +27 -0
- package/dist/dolt/diff.js +21 -0
- package/dist/dolt/index.d.ts +10 -0
- package/dist/dolt/index.js +11 -0
- package/dist/dolt/merge.d.ts +63 -0
- package/dist/dolt/merge.js +81 -0
- package/dist/dolt/migrate-all-branches.d.ts +4 -0
- package/dist/dolt/migrate-all-branches.js +83 -0
- package/dist/dolt/migrate-dolt.d.ts +1 -0
- package/dist/dolt/migrate-dolt.js +25 -0
- package/dist/dolt/ref-helpers.d.ts +19 -0
- package/dist/dolt/ref-helpers.js +65 -0
- package/dist/dolt/ref-middleware.d.ts +82 -0
- package/dist/dolt/ref-middleware.js +217 -0
- package/dist/dolt/ref-scope.d.ts +101 -0
- package/dist/dolt/ref-scope.js +231 -0
- package/dist/dolt/schema-sync.d.ts +135 -0
- package/dist/dolt/schema-sync.js +255 -0
- package/dist/env.d.ts +6 -4
- package/dist/env.js +3 -2
- package/dist/index.d.ts +73 -46
- package/dist/index.js +76 -49
- package/dist/types/@napi-rs__keyring/index.d.ts +14 -0
- package/dist/types/entities.d.ts +81 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +46 -5
- package/dist/types/utility.js +2 -1
- package/dist/utils/JsonTransformer.d.ts +42 -0
- package/dist/utils/JsonTransformer.js +103 -0
- package/dist/utils/apiKeys.d.ts +5 -1
- package/dist/utils/apiKeys.js +11 -1
- package/dist/utils/colors.d.ts +34 -0
- package/dist/utils/colors.js +49 -0
- package/dist/utils/credential-store-utils.d.ts +1 -1
- package/dist/utils/format-messages.d.ts +1 -1
- package/dist/utils/index.d.ts +8 -4
- package/dist/utils/index.js +8 -4
- package/dist/utils/internal-service-auth.d.ts +79 -0
- package/dist/utils/internal-service-auth.js +140 -0
- package/dist/utils/jmespath-utils.d.ts +152 -0
- package/dist/utils/jmespath-utils.js +213 -0
- package/dist/utils/jwt-helpers.d.ts +56 -0
- package/dist/utils/jwt-helpers.js +90 -0
- package/dist/utils/mcp-client.d.ts +1 -1
- package/dist/utils/mcp-client.js +1 -1
- package/dist/utils/service-token-auth.d.ts +9 -27
- package/dist/utils/service-token-auth.js +48 -96
- package/dist/utils/signature-validation.d.ts +2 -0
- package/dist/utils/signature-validation.js +3 -0
- package/dist/utils/template-interpolation.d.ts +22 -0
- package/dist/utils/template-interpolation.js +62 -0
- package/dist/utils/third-party-mcp-servers/composio-client.d.ts +13 -1
- package/dist/utils/third-party-mcp-servers/composio-client.js +47 -29
- package/dist/utils/third-party-mcp-servers/index.d.ts +2 -2
- package/dist/utils/third-party-mcp-servers/index.js +2 -2
- package/dist/utils/trigger-auth.d.ts +85 -0
- package/dist/utils/trigger-auth.js +233 -0
- package/dist/validation/agentFull.js +2 -4
- package/dist/validation/dolt-schemas.d.ts +49 -0
- package/dist/validation/dolt-schemas.js +44 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +4 -26
- package/dist/validation/drizzle-schema-helpers.js +5 -151
- package/dist/validation/index.d.ts +5 -4
- package/dist/validation/index.js +4 -3
- package/dist/validation/render-validation.js +19 -0
- package/dist/validation/schemas.d.ts +18223 -5148
- package/dist/validation/schemas.js +559 -12
- package/dist/validation/stream-event-schemas.d.ts +96 -1
- package/dist/validation/stream-event-schemas.js +67 -2
- package/drizzle/manage/0000_tearful_rhodey.sql +414 -0
- package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
- package/drizzle/manage/0002_bent_sunfire.sql +1 -0
- package/drizzle/manage/0003_tiny_captain_universe.sql +8 -0
- package/drizzle/manage/0004_curious_phil_sheldon.sql +2 -0
- package/drizzle/manage/0005_silent_shatterstar.sql +53 -0
- package/drizzle/manage/meta/0000_snapshot.json +2987 -0
- package/drizzle/manage/meta/0001_snapshot.json +3115 -0
- package/drizzle/manage/meta/0002_snapshot.json +3115 -0
- package/drizzle/manage/meta/0003_snapshot.json +3134 -0
- package/drizzle/manage/meta/0004_snapshot.json +3141 -0
- package/drizzle/manage/meta/0005_snapshot.json +3141 -0
- package/drizzle/manage/meta/_journal.json +48 -0
- package/drizzle/runtime/0008_silly_preak.sql +127 -0
- package/drizzle/runtime/0009_freezing_leo.sql +17 -0
- package/drizzle/runtime/meta/0008_snapshot.json +2263 -0
- package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
- package/drizzle/{meta → runtime/meta}/_journal.json +14 -0
- package/package.json +56 -18
- package/spicedb/schema.zed +114 -0
- package/dist/context/ContextFetcher.d.ts +0 -73
- package/dist/context/ContextFetcher.js +0 -291
- package/dist/context/ContextResolver.d.ts +0 -60
- package/dist/context/ContextResolver.js +0 -278
- package/dist/context/context.d.ts +0 -27
- package/dist/context/context.js +0 -128
- package/dist/context/contextCache.d.ts +0 -58
- package/dist/context/contextCache.js +0 -177
- package/dist/data-access/agentFull.d.ts +0 -33
- package/dist/data-access/functionTools.d.ts +0 -169
- package/dist/data-access/projectFull.d.ts +0 -32
- package/dist/data-access/projects.d.ts +0 -71
- package/dist/data-access/tasks.d.ts +0 -45
- package/dist/data-access/users.d.ts +0 -19
- package/dist/db/client.d.ts +0 -20
- package/dist/db/client.js +0 -28
- package/dist/db/test-client.d.ts +0 -31
- package/dist/middleware/contextValidation.d.ts +0 -46
- package/dist/middleware/contextValidation.js +0 -280
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.js +0 -3
- package/dist/utils/execution.d.ts +0 -22
- package/dist/utils/execution.js +0 -25
- /package/drizzle/{0000_exotic_mysterio.sql → runtime/0000_exotic_mysterio.sql} +0 -0
- /package/drizzle/{0001_calm_sheva_callister.sql → runtime/0001_calm_sheva_callister.sql} +0 -0
- /package/drizzle/{0002_puzzling_goblin_queen.sql → runtime/0002_puzzling_goblin_queen.sql} +0 -0
- /package/drizzle/{0003_sweet_human_robot.sql → runtime/0003_sweet_human_robot.sql} +0 -0
- /package/drizzle/{0004_cuddly_shooting_star.sql → runtime/0004_cuddly_shooting_star.sql} +0 -0
- /package/drizzle/{0005_reflective_starfox.sql → runtime/0005_reflective_starfox.sql} +0 -0
- /package/drizzle/{0006_stale_thaddeus_ross.sql → runtime/0006_stale_thaddeus_ross.sql} +0 -0
- /package/drizzle/{0007_slim_karma.sql → runtime/0007_slim_karma.sql} +0 -0
- /package/drizzle/{meta → runtime/meta}/0000_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0001_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0003_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0005_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0006_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0007_snapshot.json +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { JwtVerifyResult } from "./jwt-helpers.js";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/service-token-auth.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
|
-
* Service Token JWT Claims
|
|
6
|
+
* Service Token JWT Claims (for agent-to-agent communication)
|
|
4
7
|
*/
|
|
5
8
|
interface ServiceTokenPayload {
|
|
6
9
|
/** Issuer - always 'inkeep-agents' */
|
|
@@ -30,48 +33,27 @@ interface GenerateServiceTokenParams {
|
|
|
30
33
|
/**
|
|
31
34
|
* Result of verifying a service token
|
|
32
35
|
*/
|
|
33
|
-
|
|
34
|
-
valid: boolean;
|
|
35
|
-
payload?: ServiceTokenPayload;
|
|
36
|
-
error?: string;
|
|
37
|
-
}
|
|
36
|
+
type VerifyServiceTokenResult = JwtVerifyResult<ServiceTokenPayload>;
|
|
38
37
|
/**
|
|
39
|
-
* Generate a JWT token for
|
|
40
|
-
* Token expires in 5 minutes
|
|
41
|
-
*
|
|
42
|
-
* @param params - Token generation parameters
|
|
43
|
-
* @returns Signed JWT token string
|
|
38
|
+
* Generate a JWT token for agent-to-agent authentication.
|
|
39
|
+
* Token expires in 5 minutes.
|
|
44
40
|
*/
|
|
45
41
|
declare function generateServiceToken(params: GenerateServiceTokenParams): Promise<string>;
|
|
46
42
|
/**
|
|
47
43
|
* Verify and decode a service JWT token
|
|
48
|
-
*
|
|
49
|
-
* @param token - JWT token string to verify
|
|
50
|
-
* @returns Verification result with payload if valid
|
|
51
44
|
*/
|
|
52
45
|
declare function verifyServiceToken(token: string): Promise<VerifyServiceTokenResult>;
|
|
53
46
|
/**
|
|
54
|
-
* Validate that the token's tenant ID matches the expected tenant
|
|
55
|
-
* This prevents cross-tenant delegation attempts
|
|
56
|
-
*
|
|
57
|
-
* @param payload - Decoded token payload
|
|
58
|
-
* @param expectedTenantId - The tenant ID to validate against
|
|
59
|
-
* @returns true if tenant IDs match, false otherwise
|
|
47
|
+
* Validate that the token's tenant ID matches the expected tenant.
|
|
48
|
+
* This prevents cross-tenant delegation attempts.
|
|
60
49
|
*/
|
|
61
50
|
declare function validateTenantId(payload: ServiceTokenPayload, expectedTenantId: string): boolean;
|
|
62
51
|
/**
|
|
63
52
|
* Validate that the token's target agent ID matches the expected agent
|
|
64
|
-
*
|
|
65
|
-
* @param payload - Decoded token payload
|
|
66
|
-
* @param expectedTargetAgentId - The agent ID to validate against
|
|
67
|
-
* @returns true if agent IDs match, false otherwise
|
|
68
53
|
*/
|
|
69
54
|
declare function validateTargetAgent(payload: ServiceTokenPayload, expectedTargetAgentId: string): boolean;
|
|
70
55
|
/**
|
|
71
56
|
* Extract the Authorization header and verify the bearer token
|
|
72
|
-
*
|
|
73
|
-
* @param authHeader - The Authorization header value (e.g., "Bearer <token>")
|
|
74
|
-
* @returns Verification result with payload if valid
|
|
75
57
|
*/
|
|
76
58
|
declare function verifyAuthorizationHeader(authHeader: string | undefined): Promise<VerifyServiceTokenResult>;
|
|
77
59
|
//#endregion
|
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import { env } from "../env.js";
|
|
2
1
|
import { getLogger } from "./logger.js";
|
|
3
|
-
import {
|
|
2
|
+
import { extractBearerToken, signJwt, verifyJwt } from "./jwt-helpers.js";
|
|
4
3
|
|
|
5
4
|
//#region src/utils/service-token-auth.ts
|
|
6
5
|
const logger = getLogger("service-token-auth");
|
|
6
|
+
const ISSUER = "inkeep-agents";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
function getJwtSecret() {
|
|
12
|
-
const secret = env.INKEEP_AGENTS_JWT_SIGNING_SECRET;
|
|
13
|
-
const dev_secret = "insecure-dev-secret-change-in-production-min-32-chars";
|
|
14
|
-
if (!secret) {
|
|
15
|
-
if (env.ENVIRONMENT === "production") throw new Error("INKEEP_AGENTS_JWT_SIGNING_SECRET environment variable is required in production");
|
|
16
|
-
logger.warn({}, "INKEEP_AGENTS_JWT_SIGNING_SECRET not set, using insecure default. DO NOT USE IN PRODUCTION!");
|
|
17
|
-
return new TextEncoder().encode(dev_secret);
|
|
18
|
-
}
|
|
19
|
-
return new TextEncoder().encode(secret);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Generate a JWT token for team agent authentication
|
|
23
|
-
* Token expires in 5 minutes
|
|
24
|
-
*
|
|
25
|
-
* @param params - Token generation parameters
|
|
26
|
-
* @returns Signed JWT token string
|
|
8
|
+
* Generate a JWT token for agent-to-agent authentication.
|
|
9
|
+
* Token expires in 5 minutes.
|
|
27
10
|
*/
|
|
28
11
|
async function generateServiceToken(params) {
|
|
29
|
-
const secret = getJwtSecret();
|
|
30
12
|
try {
|
|
31
|
-
const token = await
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
const token = await signJwt({
|
|
14
|
+
issuer: ISSUER,
|
|
15
|
+
subject: params.originAgentId,
|
|
16
|
+
audience: params.targetAgentId,
|
|
17
|
+
expiresIn: "5m",
|
|
18
|
+
claims: {
|
|
19
|
+
tenantId: params.tenantId,
|
|
20
|
+
projectId: params.projectId
|
|
21
|
+
}
|
|
22
|
+
});
|
|
38
23
|
logger.debug({
|
|
39
24
|
originAgentId: params.originAgentId,
|
|
40
25
|
targetAgentId: params.targetAgentId,
|
|
@@ -48,64 +33,46 @@ async function generateServiceToken(params) {
|
|
|
48
33
|
}
|
|
49
34
|
/**
|
|
50
35
|
* Verify and decode a service JWT token
|
|
51
|
-
*
|
|
52
|
-
* @param token - JWT token string to verify
|
|
53
|
-
* @returns Verification result with payload if valid
|
|
54
36
|
*/
|
|
55
37
|
async function verifyServiceToken(token) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
issuer: "inkeep-agents",
|
|
60
|
-
algorithms: ["HS256"]
|
|
61
|
-
});
|
|
62
|
-
if (typeof payload.sub !== "string" || typeof payload.aud !== "string" || typeof payload.tenantId !== "string" || typeof payload.projectId !== "string") {
|
|
63
|
-
logger.warn({ payload }, "Invalid service token: missing required claims");
|
|
64
|
-
return {
|
|
65
|
-
valid: false,
|
|
66
|
-
error: "Invalid token: missing required claims"
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const validPayload = {
|
|
70
|
-
iss: payload.iss,
|
|
71
|
-
aud: payload.aud,
|
|
72
|
-
sub: payload.sub,
|
|
73
|
-
tenantId: payload.tenantId,
|
|
74
|
-
projectId: payload.projectId,
|
|
75
|
-
iat: payload.iat,
|
|
76
|
-
exp: payload.exp
|
|
77
|
-
};
|
|
78
|
-
logger.debug({
|
|
79
|
-
originAgentId: validPayload.sub,
|
|
80
|
-
targetAgentId: validPayload.aud,
|
|
81
|
-
tenantId: validPayload.tenantId
|
|
82
|
-
}, "Successfully verified team agent token");
|
|
38
|
+
const result = await verifyJwt(token, { issuer: ISSUER });
|
|
39
|
+
if (!result.valid || !result.payload) {
|
|
40
|
+
logger.warn({ error: result.error }, "Team agent token verification failed");
|
|
83
41
|
return {
|
|
84
|
-
valid:
|
|
85
|
-
|
|
42
|
+
valid: false,
|
|
43
|
+
error: result.error
|
|
86
44
|
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
valid: false,
|
|
92
|
-
error: error.message
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
logger.warn({ error }, "Team agent token verification failed with unknown error");
|
|
45
|
+
}
|
|
46
|
+
const payload = result.payload;
|
|
47
|
+
if (typeof payload.sub !== "string" || typeof payload.aud !== "string" || typeof payload.tenantId !== "string" || typeof payload.projectId !== "string") {
|
|
48
|
+
logger.warn({ payload }, "Invalid service token: missing required claims");
|
|
96
49
|
return {
|
|
97
50
|
valid: false,
|
|
98
|
-
error: "
|
|
51
|
+
error: "Invalid token: missing required claims"
|
|
99
52
|
};
|
|
100
53
|
}
|
|
54
|
+
const validPayload = {
|
|
55
|
+
iss: payload.iss,
|
|
56
|
+
aud: payload.aud,
|
|
57
|
+
sub: payload.sub,
|
|
58
|
+
tenantId: payload.tenantId,
|
|
59
|
+
projectId: payload.projectId,
|
|
60
|
+
iat: payload.iat,
|
|
61
|
+
exp: payload.exp
|
|
62
|
+
};
|
|
63
|
+
logger.debug({
|
|
64
|
+
originAgentId: validPayload.sub,
|
|
65
|
+
targetAgentId: validPayload.aud,
|
|
66
|
+
tenantId: validPayload.tenantId
|
|
67
|
+
}, "Successfully verified team agent token");
|
|
68
|
+
return {
|
|
69
|
+
valid: true,
|
|
70
|
+
payload: validPayload
|
|
71
|
+
};
|
|
101
72
|
}
|
|
102
73
|
/**
|
|
103
|
-
* Validate that the token's tenant ID matches the expected tenant
|
|
104
|
-
* This prevents cross-tenant delegation attempts
|
|
105
|
-
*
|
|
106
|
-
* @param payload - Decoded token payload
|
|
107
|
-
* @param expectedTenantId - The tenant ID to validate against
|
|
108
|
-
* @returns true if tenant IDs match, false otherwise
|
|
74
|
+
* Validate that the token's tenant ID matches the expected tenant.
|
|
75
|
+
* This prevents cross-tenant delegation attempts.
|
|
109
76
|
*/
|
|
110
77
|
function validateTenantId(payload, expectedTenantId) {
|
|
111
78
|
if (payload.tenantId !== expectedTenantId) {
|
|
@@ -121,10 +88,6 @@ function validateTenantId(payload, expectedTenantId) {
|
|
|
121
88
|
}
|
|
122
89
|
/**
|
|
123
90
|
* Validate that the token's target agent ID matches the expected agent
|
|
124
|
-
*
|
|
125
|
-
* @param payload - Decoded token payload
|
|
126
|
-
* @param expectedTargetAgentId - The agent ID to validate against
|
|
127
|
-
* @returns true if agent IDs match, false otherwise
|
|
128
91
|
*/
|
|
129
92
|
function validateTargetAgent(payload, expectedTargetAgentId) {
|
|
130
93
|
if (payload.aud !== expectedTargetAgentId) {
|
|
@@ -139,25 +102,14 @@ function validateTargetAgent(payload, expectedTargetAgentId) {
|
|
|
139
102
|
}
|
|
140
103
|
/**
|
|
141
104
|
* Extract the Authorization header and verify the bearer token
|
|
142
|
-
*
|
|
143
|
-
* @param authHeader - The Authorization header value (e.g., "Bearer <token>")
|
|
144
|
-
* @returns Verification result with payload if valid
|
|
145
105
|
*/
|
|
146
106
|
async function verifyAuthorizationHeader(authHeader) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
error: "Missing Authorization header"
|
|
150
|
-
};
|
|
151
|
-
if (!authHeader.startsWith("Bearer ")) return {
|
|
152
|
-
valid: false,
|
|
153
|
-
error: "Invalid Authorization header format. Expected: Bearer <token>"
|
|
154
|
-
};
|
|
155
|
-
const token = authHeader.substring(7);
|
|
156
|
-
if (!token) return {
|
|
107
|
+
const extracted = extractBearerToken(authHeader);
|
|
108
|
+
if (!extracted.token) return {
|
|
157
109
|
valid: false,
|
|
158
|
-
error:
|
|
110
|
+
error: extracted.error
|
|
159
111
|
};
|
|
160
|
-
return verifyServiceToken(token);
|
|
112
|
+
return verifyServiceToken(extracted.token);
|
|
161
113
|
}
|
|
162
114
|
|
|
163
115
|
//#endregion
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/utils/template-interpolation.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Interpolates a message template with placeholders from a payload object.
|
|
4
|
+
* Supports {{path.to.value}} placeholder syntax with dot notation for nested paths.
|
|
5
|
+
* Missing values are replaced with empty strings.
|
|
6
|
+
*
|
|
7
|
+
* @param template - Message template with {{placeholder}} syntax
|
|
8
|
+
* @param payload - Object containing values to interpolate
|
|
9
|
+
* @returns Interpolated message with all placeholders resolved
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const template = "User {{user.name}} from {{user.profile.location}} submitted: {{message}}";
|
|
13
|
+
* const payload = {
|
|
14
|
+
* user: { name: "Alice", profile: { location: "NYC" } },
|
|
15
|
+
* message: "Hello World"
|
|
16
|
+
* };
|
|
17
|
+
* interpolateTemplate(template, payload);
|
|
18
|
+
* // => "User Alice from NYC submitted: Hello World"
|
|
19
|
+
*/
|
|
20
|
+
declare function interpolateTemplate(template: string, payload: Record<string, unknown>): string;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { interpolateTemplate };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/utils/template-interpolation.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a nested path from an object using dot notation.
|
|
4
|
+
* Example: getValue({ user: { profile: { name: 'John' } } }, 'user.profile.name') => 'John'
|
|
5
|
+
*
|
|
6
|
+
* @param obj - The object to traverse
|
|
7
|
+
* @param path - Dot-separated path (e.g., 'user.profile.name')
|
|
8
|
+
* @returns The value at the path, or undefined if not found
|
|
9
|
+
*/
|
|
10
|
+
function getValue(obj, path) {
|
|
11
|
+
if (!obj || typeof obj !== "object") return;
|
|
12
|
+
const keys = path.split(".");
|
|
13
|
+
let current = obj;
|
|
14
|
+
for (const key of keys) {
|
|
15
|
+
if (current === null || current === void 0 || typeof current !== "object") return;
|
|
16
|
+
current = current[key];
|
|
17
|
+
}
|
|
18
|
+
return current;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts a value to string for template interpolation.
|
|
22
|
+
* Handles primitives, null, undefined gracefully.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The value to convert
|
|
25
|
+
* @returns String representation or empty string if undefined/null
|
|
26
|
+
*/
|
|
27
|
+
function valueToString(value) {
|
|
28
|
+
if (value === null || value === void 0) return "";
|
|
29
|
+
if (typeof value === "string") return value;
|
|
30
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
31
|
+
try {
|
|
32
|
+
return JSON.stringify(value);
|
|
33
|
+
} catch {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Interpolates a message template with placeholders from a payload object.
|
|
39
|
+
* Supports {{path.to.value}} placeholder syntax with dot notation for nested paths.
|
|
40
|
+
* Missing values are replaced with empty strings.
|
|
41
|
+
*
|
|
42
|
+
* @param template - Message template with {{placeholder}} syntax
|
|
43
|
+
* @param payload - Object containing values to interpolate
|
|
44
|
+
* @returns Interpolated message with all placeholders resolved
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const template = "User {{user.name}} from {{user.profile.location}} submitted: {{message}}";
|
|
48
|
+
* const payload = {
|
|
49
|
+
* user: { name: "Alice", profile: { location: "NYC" } },
|
|
50
|
+
* message: "Hello World"
|
|
51
|
+
* };
|
|
52
|
+
* interpolateTemplate(template, payload);
|
|
53
|
+
* // => "User Alice from NYC submitted: Hello World"
|
|
54
|
+
*/
|
|
55
|
+
function interpolateTemplate(template, payload) {
|
|
56
|
+
return template.replace(/\{\{([^}]+)\}\}/g, (_match, path) => {
|
|
57
|
+
return valueToString(getValue(payload, path.trim()));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { interpolateTemplate };
|
|
@@ -14,6 +14,18 @@ type CredentialScope = 'project' | 'user';
|
|
|
14
14
|
* - For user-scoped: uses the actual user ID (per-user credentials)
|
|
15
15
|
*/
|
|
16
16
|
declare function getComposioUserId(tenantId: string, projectId: string, credentialScope: CredentialScope, userId?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Build a Composio MCP URL with the appropriate user_id parameter
|
|
19
|
+
* Consolidates user_id injection logic used across the codebase
|
|
20
|
+
*
|
|
21
|
+
* @param baseUrl - The base MCP server URL
|
|
22
|
+
* @param tenantId - The tenant ID
|
|
23
|
+
* @param projectId - The project ID
|
|
24
|
+
* @param credentialScope - Whether credentials are 'project' or 'user' scoped
|
|
25
|
+
* @param userId - Optional user ID (required for user-scoped credentials)
|
|
26
|
+
* @returns The URL with user_id parameter set, or original URL if not a Composio URL
|
|
27
|
+
*/
|
|
28
|
+
declare function buildComposioMCPUrl(baseUrl: string, tenantId: string, projectId: string, credentialScope: CredentialScope, userId?: string): string;
|
|
17
29
|
/**
|
|
18
30
|
* Extract server ID from a Composio MCP URL
|
|
19
31
|
* Example: https://backend.composio.dev/v3/mcp/1234-1234-1234?user_id=... -> 1234-1234-1234
|
|
@@ -44,4 +56,4 @@ declare function fetchComposioServers(): Promise<PrebuiltMCPServer[]>;
|
|
|
44
56
|
*/
|
|
45
57
|
declare function fetchSingleComposioServer(tenantId: string, projectId: string, mcpServerUrl: string, credentialScope?: CredentialScope, userId?: string): Promise<PrebuiltMCPServer | null>;
|
|
46
58
|
//#endregion
|
|
47
|
-
export { CredentialScope, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated };
|
|
59
|
+
export { CredentialScope, buildComposioMCPUrl, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated };
|
|
@@ -7,7 +7,7 @@ import { Composio } from "@composio/core";
|
|
|
7
7
|
* Composio MCP Server Client
|
|
8
8
|
* Handles all Composio-specific operations for MCP server integration
|
|
9
9
|
*/
|
|
10
|
-
const logger = getLogger("composio-client");
|
|
10
|
+
const logger$1 = getLogger("composio-client");
|
|
11
11
|
const TOOLKIT_TO_CATEGORY = {
|
|
12
12
|
github: "development",
|
|
13
13
|
gitlab: "development",
|
|
@@ -67,6 +67,25 @@ function getComposioUserId(tenantId, projectId, credentialScope, userId) {
|
|
|
67
67
|
return deriveComposioUserId(tenantId, projectId);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
+
* Build a Composio MCP URL with the appropriate user_id parameter
|
|
71
|
+
* Consolidates user_id injection logic used across the codebase
|
|
72
|
+
*
|
|
73
|
+
* @param baseUrl - The base MCP server URL
|
|
74
|
+
* @param tenantId - The tenant ID
|
|
75
|
+
* @param projectId - The project ID
|
|
76
|
+
* @param credentialScope - Whether credentials are 'project' or 'user' scoped
|
|
77
|
+
* @param userId - Optional user ID (required for user-scoped credentials)
|
|
78
|
+
* @returns The URL with user_id parameter set, or original URL if not a Composio URL
|
|
79
|
+
*/
|
|
80
|
+
function buildComposioMCPUrl(baseUrl, tenantId, projectId, credentialScope, userId) {
|
|
81
|
+
if (!baseUrl.includes("composio.dev")) return baseUrl;
|
|
82
|
+
const urlObj = new URL(baseUrl);
|
|
83
|
+
if (urlObj.searchParams.has("user_id")) return baseUrl;
|
|
84
|
+
const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
|
|
85
|
+
urlObj.searchParams.set("user_id", composioUserId);
|
|
86
|
+
return urlObj.toString();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
70
89
|
* Extract server ID from a Composio MCP URL
|
|
71
90
|
* Example: https://backend.composio.dev/v3/mcp/1234-1234-1234?user_id=... -> 1234-1234-1234
|
|
72
91
|
*/
|
|
@@ -88,14 +107,14 @@ function extractComposioServerId(mcpUrl) {
|
|
|
88
107
|
async function deleteComposioConnectedAccount(accountId) {
|
|
89
108
|
const composioInstance = getComposioInstance();
|
|
90
109
|
if (!composioInstance) {
|
|
91
|
-
logger.info({}, "Composio not configured, skipping account deletion");
|
|
110
|
+
logger$1.info({}, "Composio not configured, skipping account deletion");
|
|
92
111
|
return false;
|
|
93
112
|
}
|
|
94
113
|
try {
|
|
95
114
|
await composioInstance.connectedAccounts.delete(accountId);
|
|
96
115
|
return true;
|
|
97
116
|
} catch (error) {
|
|
98
|
-
logger.warn({ error }, "Error deleting Composio connected account");
|
|
117
|
+
logger$1.warn({ error }, "Error deleting Composio connected account");
|
|
99
118
|
return false;
|
|
100
119
|
}
|
|
101
120
|
}
|
|
@@ -106,7 +125,7 @@ async function deleteComposioConnectedAccount(accountId) {
|
|
|
106
125
|
async function fetchComposioConnectedAccounts(derivedUserId) {
|
|
107
126
|
const composioInstance = getComposioInstance();
|
|
108
127
|
if (!composioInstance) {
|
|
109
|
-
logger.info({}, "Composio not configured, skipping connected accounts fetch");
|
|
128
|
+
logger$1.info({}, "Composio not configured, skipping connected accounts fetch");
|
|
110
129
|
return null;
|
|
111
130
|
}
|
|
112
131
|
try {
|
|
@@ -115,7 +134,7 @@ async function fetchComposioConnectedAccounts(derivedUserId) {
|
|
|
115
134
|
statuses: ["ACTIVE", "INITIATED"]
|
|
116
135
|
});
|
|
117
136
|
} catch (error) {
|
|
118
|
-
logger.error({ error }, "Error fetching Composio connected accounts");
|
|
137
|
+
logger$1.error({ error }, "Error fetching Composio connected accounts");
|
|
119
138
|
return null;
|
|
120
139
|
}
|
|
121
140
|
}
|
|
@@ -127,29 +146,28 @@ async function fetchComposioConnectedAccounts(derivedUserId) {
|
|
|
127
146
|
*/
|
|
128
147
|
async function isComposioMCPServerAuthenticated(tenantId, projectId, mcpServerUrl, credentialScope = "project", userId) {
|
|
129
148
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
130
|
-
logger.info({}, "Composio API key not configured, skipping auth check");
|
|
149
|
+
logger$1.info({}, "Composio API key not configured, skipping auth check");
|
|
131
150
|
return false;
|
|
132
151
|
}
|
|
133
152
|
const serverId = extractComposioServerId(mcpServerUrl);
|
|
134
153
|
if (!serverId) {
|
|
135
|
-
logger.info({ mcpServerUrl }, "Could not extract Composio server ID from URL");
|
|
154
|
+
logger$1.info({ mcpServerUrl }, "Could not extract Composio server ID from URL");
|
|
136
155
|
return false;
|
|
137
156
|
}
|
|
138
157
|
const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
|
|
139
158
|
const composioInstance = getComposioInstance();
|
|
140
159
|
if (!composioInstance) {
|
|
141
|
-
logger.info({}, "Composio not configured, skipping auth check");
|
|
160
|
+
logger$1.info({}, "Composio not configured, skipping auth check");
|
|
142
161
|
return false;
|
|
143
162
|
}
|
|
144
163
|
try {
|
|
145
|
-
const composioMcpServer = await composioInstance.mcp.get(serverId);
|
|
146
|
-
|
|
147
|
-
if (!firstAuthConfigId) return false;
|
|
148
|
-
const connectedAccounts = await fetchComposioConnectedAccounts(composioUserId);
|
|
164
|
+
const [composioMcpServer, connectedAccounts] = await Promise.all([composioInstance.mcp.get(serverId), fetchComposioConnectedAccounts(composioUserId)]);
|
|
165
|
+
if (!(composioMcpServer.authConfigIds.length > 0 ? composioMcpServer.authConfigIds[0] : null)) return false;
|
|
149
166
|
if (!connectedAccounts) return false;
|
|
150
|
-
|
|
167
|
+
const activeAuthConfigIds = new Set(connectedAccounts.items.filter((account) => account.status === "ACTIVE").map((account) => account.authConfig.id));
|
|
168
|
+
return composioMcpServer.authConfigIds.some((authConfigId) => activeAuthConfigIds.has(authConfigId));
|
|
151
169
|
} catch (error) {
|
|
152
|
-
logger.error({
|
|
170
|
+
logger$1.error({
|
|
153
171
|
error,
|
|
154
172
|
mcpServerUrl
|
|
155
173
|
}, "Error checking Composio authentication status");
|
|
@@ -184,7 +202,7 @@ function transformComposioServerData(composioMcpServer, isAuthenticated, url, th
|
|
|
184
202
|
async function ensureComposioAccount(composioMcpServer, derivedUserId, initiatedAccounts) {
|
|
185
203
|
const firstAuthConfigId = composioMcpServer.authConfigIds[0];
|
|
186
204
|
if (!firstAuthConfigId) {
|
|
187
|
-
logger.error({ serverId: composioMcpServer.id }, "No auth config ID found for MCP server");
|
|
205
|
+
logger$1.error({ serverId: composioMcpServer.id }, "No auth config ID found for MCP server");
|
|
188
206
|
return null;
|
|
189
207
|
}
|
|
190
208
|
const existingInitiatedAccount = initiatedAccounts.find((account) => account.authConfig.id === firstAuthConfigId);
|
|
@@ -192,12 +210,12 @@ async function ensureComposioAccount(composioMcpServer, derivedUserId, initiated
|
|
|
192
210
|
try {
|
|
193
211
|
const composioInstance = getComposioInstance();
|
|
194
212
|
if (!composioInstance) {
|
|
195
|
-
logger.error({ serverId: composioMcpServer.id }, "Composio not configured");
|
|
213
|
+
logger$1.error({ serverId: composioMcpServer.id }, "Composio not configured");
|
|
196
214
|
return null;
|
|
197
215
|
}
|
|
198
216
|
return (await composioInstance.connectedAccounts.link(derivedUserId, firstAuthConfigId)).redirectUrl ?? null;
|
|
199
217
|
} catch (error) {
|
|
200
|
-
logger.error({
|
|
218
|
+
logger$1.error({
|
|
201
219
|
serverId: composioMcpServer.id,
|
|
202
220
|
error
|
|
203
221
|
}, "Error creating connected account for MCP server");
|
|
@@ -212,24 +230,24 @@ async function ensureComposioAccount(composioMcpServer, derivedUserId, initiated
|
|
|
212
230
|
*/
|
|
213
231
|
async function getComposioOAuthRedirectUrl(tenantId, projectId, mcpServerUrl, credentialScope, userId) {
|
|
214
232
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
215
|
-
logger.info({}, "Composio API key not configured");
|
|
233
|
+
logger$1.info({}, "Composio API key not configured");
|
|
216
234
|
return null;
|
|
217
235
|
}
|
|
218
236
|
const serverId = extractComposioServerId(mcpServerUrl);
|
|
219
237
|
if (!serverId) {
|
|
220
|
-
logger.info({ mcpServerUrl }, "Could not extract Composio server ID from URL");
|
|
238
|
+
logger$1.info({ mcpServerUrl }, "Could not extract Composio server ID from URL");
|
|
221
239
|
return null;
|
|
222
240
|
}
|
|
223
241
|
const composioInstance = getComposioInstance();
|
|
224
242
|
if (!composioInstance) {
|
|
225
|
-
logger.info({}, "Composio not configured");
|
|
243
|
+
logger$1.info({}, "Composio not configured");
|
|
226
244
|
return null;
|
|
227
245
|
}
|
|
228
246
|
const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
|
|
229
247
|
try {
|
|
230
248
|
return await ensureComposioAccount(await composioInstance.mcp.get(serverId), composioUserId, (await fetchComposioConnectedAccounts(composioUserId))?.items.filter((account) => account.status === "INITIATED") ?? []);
|
|
231
249
|
} catch (error) {
|
|
232
|
-
logger.error({
|
|
250
|
+
logger$1.error({
|
|
233
251
|
error,
|
|
234
252
|
mcpServerUrl
|
|
235
253
|
}, "Failed to get Composio OAuth redirect URL");
|
|
@@ -256,12 +274,12 @@ async function transformComposioServer(composioMcpServer, authenticatedAuthConfi
|
|
|
256
274
|
*/
|
|
257
275
|
async function fetchComposioServers() {
|
|
258
276
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
259
|
-
logger.info({}, "COMPOSIO_API_KEY not configured, skipping Composio servers");
|
|
277
|
+
logger$1.info({}, "COMPOSIO_API_KEY not configured, skipping Composio servers");
|
|
260
278
|
return [];
|
|
261
279
|
}
|
|
262
280
|
const composioInstance = getComposioInstance();
|
|
263
281
|
if (!composioInstance) {
|
|
264
|
-
logger.info({}, "Composio not configured, returning empty list");
|
|
282
|
+
logger$1.info({}, "Composio not configured, returning empty list");
|
|
265
283
|
return [];
|
|
266
284
|
}
|
|
267
285
|
try {
|
|
@@ -272,7 +290,7 @@ async function fetchComposioServers() {
|
|
|
272
290
|
authConfigs: []
|
|
273
291
|
}))?.items.map((server) => transformComposioServerData(server, false, server.MCPUrl, void 0)) ?? [];
|
|
274
292
|
} catch (error) {
|
|
275
|
-
logger.error({ error }, "Failed to fetch Composio servers");
|
|
293
|
+
logger$1.error({ error }, "Failed to fetch Composio servers");
|
|
276
294
|
return [];
|
|
277
295
|
}
|
|
278
296
|
}
|
|
@@ -283,19 +301,19 @@ async function fetchComposioServers() {
|
|
|
283
301
|
*/
|
|
284
302
|
async function fetchSingleComposioServer(tenantId, projectId, mcpServerUrl, credentialScope = "project", userId) {
|
|
285
303
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
286
|
-
logger.debug({}, "COMPOSIO_API_KEY not configured");
|
|
304
|
+
logger$1.debug({}, "COMPOSIO_API_KEY not configured");
|
|
287
305
|
return null;
|
|
288
306
|
}
|
|
289
307
|
const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
|
|
290
308
|
const composioInstance = getComposioInstance();
|
|
291
309
|
if (!composioInstance) {
|
|
292
|
-
logger.info({}, "Composio not configured, returning null");
|
|
310
|
+
logger$1.info({}, "Composio not configured, returning null");
|
|
293
311
|
return null;
|
|
294
312
|
}
|
|
295
313
|
try {
|
|
296
314
|
const serverId = extractComposioServerId(mcpServerUrl);
|
|
297
315
|
if (!serverId) {
|
|
298
|
-
logger.error({ mcpServerUrl }, "Could not extract Composio server ID from URL");
|
|
316
|
+
logger$1.error({ mcpServerUrl }, "Could not extract Composio server ID from URL");
|
|
299
317
|
return null;
|
|
300
318
|
}
|
|
301
319
|
const composioMcpServer = await composioInstance.mcp.get(serverId);
|
|
@@ -307,7 +325,7 @@ async function fetchSingleComposioServer(tenantId, projectId, mcpServerUrl, cred
|
|
|
307
325
|
const initiatedAccounts = userConnectedAccounts?.items.filter((account) => account.status === "INITIATED");
|
|
308
326
|
return await transformComposioServer(composioMcpServer, new Set(activeAccounts?.map((account) => account.authConfig.id) ?? []), initiatedAccounts ?? [], composioUserId);
|
|
309
327
|
} catch (error) {
|
|
310
|
-
logger.error({
|
|
328
|
+
logger$1.error({
|
|
311
329
|
error,
|
|
312
330
|
mcpServerUrl
|
|
313
331
|
}, "Failed to fetch single Composio server");
|
|
@@ -316,4 +334,4 @@ async function fetchSingleComposioServer(tenantId, projectId, mcpServerUrl, cred
|
|
|
316
334
|
}
|
|
317
335
|
|
|
318
336
|
//#endregion
|
|
319
|
-
export { extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated };
|
|
337
|
+
export { buildComposioMCPUrl, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CredentialScope, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
|
|
1
|
+
import { CredentialScope, buildComposioMCPUrl, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
|
|
2
2
|
import { isThirdPartyMCPServerAuthenticated } from "./third-party-check.js";
|
|
3
|
-
export { CredentialScope, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
|
|
3
|
+
export { CredentialScope, buildComposioMCPUrl, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
|
|
1
|
+
import { buildComposioMCPUrl, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated } from "./composio-client.js";
|
|
2
2
|
import { isThirdPartyMCPServerAuthenticated } from "./third-party-check.js";
|
|
3
3
|
|
|
4
|
-
export { extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
|
|
4
|
+
export { buildComposioMCPUrl, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated, isThirdPartyMCPServerAuthenticated };
|