@enactprotocol/shared 1.2.13 → 2.0.1

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 (207) hide show
  1. package/README.md +44 -0
  2. package/dist/config.d.ts +164 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +386 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/constants.d.ts +15 -5
  7. package/dist/constants.d.ts.map +1 -0
  8. package/dist/constants.js +24 -8
  9. package/dist/constants.js.map +1 -0
  10. package/dist/execution/command.d.ts +102 -0
  11. package/dist/execution/command.d.ts.map +1 -0
  12. package/dist/execution/command.js +262 -0
  13. package/dist/execution/command.js.map +1 -0
  14. package/dist/execution/index.d.ts +12 -0
  15. package/dist/execution/index.d.ts.map +1 -0
  16. package/dist/execution/index.js +17 -0
  17. package/dist/execution/index.js.map +1 -0
  18. package/dist/execution/runtime.d.ts +82 -0
  19. package/dist/execution/runtime.d.ts.map +1 -0
  20. package/dist/execution/runtime.js +273 -0
  21. package/dist/execution/runtime.js.map +1 -0
  22. package/dist/execution/types.d.ts +306 -0
  23. package/dist/execution/types.d.ts.map +1 -0
  24. package/dist/execution/types.js +14 -0
  25. package/dist/execution/types.js.map +1 -0
  26. package/dist/execution/validation.d.ts +43 -0
  27. package/dist/execution/validation.d.ts.map +1 -0
  28. package/dist/execution/validation.js +430 -0
  29. package/dist/execution/validation.js.map +1 -0
  30. package/dist/index.d.ts +21 -21
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +49 -25
  33. package/dist/index.js.map +1 -0
  34. package/dist/manifest/index.d.ts +7 -0
  35. package/dist/manifest/index.d.ts.map +1 -0
  36. package/dist/manifest/index.js +10 -0
  37. package/dist/manifest/index.js.map +1 -0
  38. package/dist/manifest/loader.d.ts +76 -0
  39. package/dist/manifest/loader.d.ts.map +1 -0
  40. package/dist/manifest/loader.js +146 -0
  41. package/dist/manifest/loader.js.map +1 -0
  42. package/dist/manifest/parser.d.ts +64 -0
  43. package/dist/manifest/parser.d.ts.map +1 -0
  44. package/dist/manifest/parser.js +135 -0
  45. package/dist/manifest/parser.js.map +1 -0
  46. package/dist/manifest/validator.d.ts +95 -0
  47. package/dist/manifest/validator.d.ts.map +1 -0
  48. package/dist/manifest/validator.js +258 -0
  49. package/dist/manifest/validator.js.map +1 -0
  50. package/dist/paths.d.ts +57 -0
  51. package/dist/paths.d.ts.map +1 -0
  52. package/dist/paths.js +93 -0
  53. package/dist/paths.js.map +1 -0
  54. package/dist/registry.d.ts +73 -0
  55. package/dist/registry.d.ts.map +1 -0
  56. package/dist/registry.js +147 -0
  57. package/dist/registry.js.map +1 -0
  58. package/dist/resolver.d.ts +89 -0
  59. package/dist/resolver.d.ts.map +1 -0
  60. package/dist/resolver.js +282 -0
  61. package/dist/resolver.js.map +1 -0
  62. package/dist/types/index.d.ts +6 -0
  63. package/dist/types/index.d.ts.map +1 -0
  64. package/dist/types/index.js +5 -0
  65. package/dist/types/index.js.map +1 -0
  66. package/dist/types/manifest.d.ts +201 -0
  67. package/dist/types/manifest.d.ts.map +1 -0
  68. package/dist/types/manifest.js +13 -0
  69. package/dist/types/manifest.js.map +1 -0
  70. package/dist/types.d.ts +5 -132
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/types.js +5 -3
  73. package/dist/types.js.map +1 -0
  74. package/dist/utils/fs.d.ts +105 -0
  75. package/dist/utils/fs.d.ts.map +1 -0
  76. package/dist/utils/fs.js +233 -0
  77. package/dist/utils/fs.js.map +1 -0
  78. package/dist/utils/logger.d.ts +102 -25
  79. package/dist/utils/logger.d.ts.map +1 -0
  80. package/dist/utils/logger.js +214 -57
  81. package/dist/utils/logger.js.map +1 -0
  82. package/dist/utils/version.d.ts +60 -2
  83. package/dist/utils/version.d.ts.map +1 -0
  84. package/dist/utils/version.js +255 -31
  85. package/dist/utils/version.js.map +1 -0
  86. package/package.json +16 -58
  87. package/src/config.ts +510 -0
  88. package/src/constants.ts +36 -0
  89. package/src/execution/command.ts +314 -0
  90. package/src/execution/index.ts +73 -0
  91. package/src/execution/runtime.ts +308 -0
  92. package/src/execution/types.ts +379 -0
  93. package/src/execution/validation.ts +508 -0
  94. package/src/index.ts +238 -30
  95. package/src/manifest/index.ts +36 -0
  96. package/src/manifest/loader.ts +187 -0
  97. package/src/manifest/parser.ts +173 -0
  98. package/src/manifest/validator.ts +309 -0
  99. package/src/paths.ts +108 -0
  100. package/src/registry.ts +219 -0
  101. package/src/resolver.ts +345 -0
  102. package/src/types/index.ts +30 -0
  103. package/src/types/manifest.ts +255 -0
  104. package/src/types.ts +5 -188
  105. package/src/utils/fs.ts +281 -0
  106. package/src/utils/logger.ts +270 -59
  107. package/src/utils/version.ts +304 -36
  108. package/tests/config.test.ts +515 -0
  109. package/tests/execution/command.test.ts +317 -0
  110. package/tests/execution/validation.test.ts +384 -0
  111. package/tests/fixtures/invalid-tool.yaml +4 -0
  112. package/tests/fixtures/valid-tool.md +62 -0
  113. package/tests/fixtures/valid-tool.yaml +40 -0
  114. package/tests/index.test.ts +8 -0
  115. package/tests/manifest/loader.test.ts +291 -0
  116. package/tests/manifest/parser.test.ts +345 -0
  117. package/tests/manifest/validator.test.ts +394 -0
  118. package/tests/manifest-types.test.ts +358 -0
  119. package/tests/paths.test.ts +153 -0
  120. package/tests/registry.test.ts +231 -0
  121. package/tests/resolver.test.ts +272 -0
  122. package/tests/utils/fs.test.ts +388 -0
  123. package/tests/utils/logger.test.ts +480 -0
  124. package/tests/utils/version.test.ts +390 -0
  125. package/tsconfig.json +12 -0
  126. package/dist/LocalToolResolver.d.ts +0 -84
  127. package/dist/LocalToolResolver.js +0 -353
  128. package/dist/api/enact-api.d.ts +0 -130
  129. package/dist/api/enact-api.js +0 -428
  130. package/dist/api/index.d.ts +0 -2
  131. package/dist/api/index.js +0 -2
  132. package/dist/api/types.d.ts +0 -103
  133. package/dist/api/types.js +0 -1
  134. package/dist/core/DaggerExecutionProvider.d.ts +0 -169
  135. package/dist/core/DaggerExecutionProvider.js +0 -1029
  136. package/dist/core/DirectExecutionProvider.d.ts +0 -23
  137. package/dist/core/DirectExecutionProvider.js +0 -406
  138. package/dist/core/EnactCore.d.ts +0 -162
  139. package/dist/core/EnactCore.js +0 -597
  140. package/dist/core/NativeExecutionProvider.d.ts +0 -9
  141. package/dist/core/NativeExecutionProvider.js +0 -16
  142. package/dist/core/index.d.ts +0 -3
  143. package/dist/core/index.js +0 -3
  144. package/dist/exec/index.d.ts +0 -3
  145. package/dist/exec/index.js +0 -3
  146. package/dist/exec/logger.d.ts +0 -11
  147. package/dist/exec/logger.js +0 -57
  148. package/dist/exec/validate.d.ts +0 -5
  149. package/dist/exec/validate.js +0 -167
  150. package/dist/lib/enact-direct.d.ts +0 -150
  151. package/dist/lib/enact-direct.js +0 -159
  152. package/dist/lib/index.d.ts +0 -1
  153. package/dist/lib/index.js +0 -1
  154. package/dist/security/index.d.ts +0 -3
  155. package/dist/security/index.js +0 -3
  156. package/dist/security/security.d.ts +0 -23
  157. package/dist/security/security.js +0 -137
  158. package/dist/security/sign.d.ts +0 -103
  159. package/dist/security/sign.js +0 -666
  160. package/dist/security/verification-enforcer.d.ts +0 -53
  161. package/dist/security/verification-enforcer.js +0 -204
  162. package/dist/services/McpCoreService.d.ts +0 -98
  163. package/dist/services/McpCoreService.js +0 -124
  164. package/dist/services/index.d.ts +0 -1
  165. package/dist/services/index.js +0 -1
  166. package/dist/utils/config.d.ts +0 -111
  167. package/dist/utils/config.js +0 -342
  168. package/dist/utils/env-loader.d.ts +0 -54
  169. package/dist/utils/env-loader.js +0 -270
  170. package/dist/utils/help.d.ts +0 -36
  171. package/dist/utils/help.js +0 -248
  172. package/dist/utils/index.d.ts +0 -7
  173. package/dist/utils/index.js +0 -7
  174. package/dist/utils/silent-monitor.d.ts +0 -67
  175. package/dist/utils/silent-monitor.js +0 -242
  176. package/dist/utils/timeout.d.ts +0 -5
  177. package/dist/utils/timeout.js +0 -23
  178. package/dist/web/env-manager-server.d.ts +0 -29
  179. package/dist/web/env-manager-server.js +0 -367
  180. package/dist/web/index.d.ts +0 -1
  181. package/dist/web/index.js +0 -1
  182. package/src/LocalToolResolver.ts +0 -424
  183. package/src/api/enact-api.ts +0 -604
  184. package/src/api/index.ts +0 -2
  185. package/src/api/types.ts +0 -114
  186. package/src/core/DaggerExecutionProvider.ts +0 -1357
  187. package/src/core/DirectExecutionProvider.ts +0 -484
  188. package/src/core/EnactCore.ts +0 -847
  189. package/src/core/index.ts +0 -3
  190. package/src/exec/index.ts +0 -3
  191. package/src/exec/logger.ts +0 -63
  192. package/src/exec/validate.ts +0 -238
  193. package/src/lib/enact-direct.ts +0 -254
  194. package/src/lib/index.ts +0 -1
  195. package/src/services/McpCoreService.ts +0 -201
  196. package/src/services/index.ts +0 -1
  197. package/src/utils/config.ts +0 -438
  198. package/src/utils/env-loader.ts +0 -370
  199. package/src/utils/help.ts +0 -257
  200. package/src/utils/index.ts +0 -7
  201. package/src/utils/silent-monitor.ts +0 -328
  202. package/src/utils/timeout.ts +0 -26
  203. package/src/web/env-manager-server.ts +0 -465
  204. package/src/web/index.ts +0 -1
  205. package/src/web/static/app.js +0 -663
  206. package/src/web/static/index.html +0 -117
  207. package/src/web/static/style.css +0 -291
@@ -1,53 +0,0 @@
1
- import type { EnactTool, ExecutionResult } from "../types";
2
- export interface SecurityPolicy {
3
- allowSkipVerification: boolean;
4
- allowUnsigned: boolean;
5
- requireInteractiveConfirmation: boolean;
6
- defaultVerificationPolicy: "permissive" | "enterprise" | "paranoid";
7
- }
8
- export interface VerificationEnforcementOptions {
9
- skipVerification?: boolean;
10
- verifyPolicy?: "permissive" | "enterprise" | "paranoid";
11
- force?: boolean;
12
- allowUnsigned?: boolean;
13
- isLocalFile?: boolean;
14
- interactive?: boolean;
15
- }
16
- export interface VerificationEnforcementResult {
17
- allowed: boolean;
18
- reason: string;
19
- verificationResult?: {
20
- isValid: boolean;
21
- message: string;
22
- validSignatures: number;
23
- totalSignatures: number;
24
- verifiedSigners: Array<{
25
- signer: string;
26
- role?: string;
27
- keyId: string;
28
- }>;
29
- errors: string[];
30
- };
31
- error?: {
32
- message: string;
33
- code: string;
34
- details?: any;
35
- };
36
- }
37
- /**
38
- * Enforce mandatory signature verification for tool execution
39
- * This is the central function that should be called before ANY tool execution
40
- */
41
- /**
42
- * Get security policy based on execution context
43
- */
44
- export declare function getSecurityPolicy(options: VerificationEnforcementOptions): SecurityPolicy;
45
- export declare function enforceSignatureVerification(tool: EnactTool, options?: VerificationEnforcementOptions): Promise<VerificationEnforcementResult>;
46
- /**
47
- * Create an execution result for verification failure
48
- */
49
- export declare function createVerificationFailureResult(tool: EnactTool, verificationResult: VerificationEnforcementResult, executionId: string): ExecutionResult;
50
- /**
51
- * Log security audit information for tool execution
52
- */
53
- export declare function logSecurityAudit(tool: EnactTool, verificationResult: VerificationEnforcementResult, executionAllowed: boolean, options: VerificationEnforcementOptions): void;
@@ -1,204 +0,0 @@
1
- // src/security/verification-enforcer.ts - Mandatory signature verification enforcement
2
- import { verifyTool, VERIFICATION_POLICIES, } from "./sign";
3
- import logger from "../exec/logger";
4
- /**
5
- * Enforce mandatory signature verification for tool execution
6
- * This is the central function that should be called before ANY tool execution
7
- */
8
- /**
9
- * Get security policy based on execution context
10
- */
11
- export function getSecurityPolicy(options) {
12
- // Local files have different security policies
13
- if (options.isLocalFile) {
14
- return {
15
- allowSkipVerification: true,
16
- allowUnsigned: true,
17
- requireInteractiveConfirmation: false,
18
- defaultVerificationPolicy: "permissive",
19
- };
20
- }
21
- // Production/registry tools have strict policies
22
- return {
23
- allowSkipVerification: false,
24
- allowUnsigned: false,
25
- requireInteractiveConfirmation: !!options.interactive,
26
- defaultVerificationPolicy: options.verifyPolicy || "permissive",
27
- };
28
- }
29
- export async function enforceSignatureVerification(tool, options = {}) {
30
- const toolName = tool.name || "unknown";
31
- // Apply centralized security policy based on context
32
- const securityPolicy = getSecurityPolicy(options);
33
- // Check if verification is explicitly skipped
34
- if (options.skipVerification && securityPolicy.allowSkipVerification) {
35
- logger.warn(`🚨 SECURITY WARNING: Signature verification skipped for tool: ${toolName}`);
36
- logger.warn(` This bypasses security measures and is NOT recommended for production use!`);
37
- return {
38
- allowed: true,
39
- reason: `Verification skipped by request for tool: ${toolName}`,
40
- verificationResult: {
41
- isValid: false,
42
- message: "Verification skipped",
43
- validSignatures: 0,
44
- totalSignatures: 0,
45
- verifiedSigners: [],
46
- errors: ["Signature verification was explicitly skipped"],
47
- },
48
- };
49
- }
50
- // Check if tool has any signatures
51
- const hasSignatures = !!(tool.signatures && Object.keys(tool.signatures).length > 0) ||
52
- !!tool.signature;
53
- if (!hasSignatures) {
54
- logger.warn(`⚠️ Tool has no signatures: ${toolName}`);
55
- // Only allow unsigned tools if policy permits (for development/testing)
56
- if (options.allowUnsigned || securityPolicy.allowUnsigned) {
57
- logger.warn(` Allowing unsigned tool execution due to allowUnsigned flag (DEV/TEST ONLY)`);
58
- return {
59
- allowed: true,
60
- reason: `Unsigned tool allowed by explicit permission: ${toolName}`,
61
- verificationResult: {
62
- isValid: false,
63
- message: "No signatures found, but execution allowed",
64
- validSignatures: 0,
65
- totalSignatures: 0,
66
- verifiedSigners: [],
67
- errors: [
68
- "Tool has no signatures but execution was explicitly allowed",
69
- ],
70
- },
71
- };
72
- }
73
- // Reject unsigned tools by default
74
- return {
75
- allowed: false,
76
- reason: `Tool has no signatures and unsigned execution is not permitted: ${toolName}`,
77
- error: {
78
- message: `Tool "${toolName}" has no cryptographic signatures. For security, only signed tools can be executed.`,
79
- code: "NO_SIGNATURES_FOUND",
80
- details: {
81
- toolName,
82
- hasSignature: !!tool.signature,
83
- hasSignatures: !!tool.signatures,
84
- signatureCount: tool.signatures
85
- ? Object.keys(tool.signatures).length
86
- : 0,
87
- },
88
- },
89
- };
90
- }
91
- // Perform signature verification
92
- try {
93
- logger.info(`🔐 Verifying signatures for tool: ${toolName}`);
94
- // Determine verification policy
95
- const policyKey = (options.verifyPolicy || "permissive").toUpperCase();
96
- const policy = VERIFICATION_POLICIES[policyKey] || VERIFICATION_POLICIES.PERMISSIVE;
97
- logger.info(` Using verification policy: ${policyKey.toLowerCase()}`);
98
- if (policy.minimumSignatures) {
99
- logger.info(` Minimum signatures required: ${policy.minimumSignatures}`);
100
- }
101
- if (policy.requireRoles) {
102
- logger.info(` Required roles: ${policy.requireRoles.join(", ")}`);
103
- }
104
- // Verify the tool
105
- const verificationResult = await verifyTool(tool, policy);
106
- if (verificationResult.isValid) {
107
- logger.info(`✅ Signature verification passed for tool: ${toolName}`);
108
- logger.info(` Valid signatures: ${verificationResult.validSignatures}/${verificationResult.totalSignatures}`);
109
- if (verificationResult.verifiedSigners.length > 0) {
110
- logger.info(` Verified signers: ${verificationResult.verifiedSigners
111
- .map((s) => `${s.signer}${s.role ? ` (${s.role})` : ""}`)
112
- .join(", ")}`);
113
- }
114
- return {
115
- allowed: true,
116
- reason: `Tool signature verification passed: ${verificationResult.message}`,
117
- verificationResult,
118
- };
119
- }
120
- else {
121
- logger.error(`❌ Signature verification failed for tool: ${toolName}`);
122
- logger.error(` Policy: ${policyKey.toLowerCase()}`);
123
- logger.error(` Valid signatures: ${verificationResult.validSignatures}/${verificationResult.totalSignatures}`);
124
- if (verificationResult.errors.length > 0) {
125
- logger.error(` Errors:`);
126
- verificationResult.errors.forEach((error) => logger.error(` - ${error}`));
127
- }
128
- return {
129
- allowed: false,
130
- reason: `Tool signature verification failed: ${verificationResult.message}`,
131
- verificationResult,
132
- error: {
133
- message: `Tool "${toolName}" failed signature verification. ${verificationResult.message}`,
134
- code: "SIGNATURE_VERIFICATION_FAILED",
135
- details: {
136
- toolName,
137
- policy: policyKey.toLowerCase(),
138
- validSignatures: verificationResult.validSignatures,
139
- totalSignatures: verificationResult.totalSignatures,
140
- errors: verificationResult.errors,
141
- verifiedSigners: verificationResult.verifiedSigners,
142
- },
143
- },
144
- };
145
- }
146
- }
147
- catch (error) {
148
- const errorMessage = error instanceof Error ? error.message : "Unknown verification error";
149
- logger.error(`💥 Signature verification error for tool: ${toolName} - ${errorMessage}`);
150
- return {
151
- allowed: false,
152
- reason: `Signature verification error: ${errorMessage}`,
153
- error: {
154
- message: `Signature verification failed due to error: ${errorMessage}`,
155
- code: "VERIFICATION_ERROR",
156
- details: { toolName, originalError: error },
157
- },
158
- };
159
- }
160
- }
161
- /**
162
- * Create an execution result for verification failure
163
- */
164
- export function createVerificationFailureResult(tool, verificationResult, executionId) {
165
- return {
166
- success: false,
167
- error: verificationResult.error || {
168
- message: verificationResult.reason,
169
- code: "VERIFICATION_FAILED",
170
- },
171
- metadata: {
172
- executionId,
173
- toolName: tool.name || "unknown",
174
- version: tool.version,
175
- executedAt: new Date().toISOString(),
176
- environment: "direct",
177
- command: tool.command,
178
- },
179
- };
180
- }
181
- /**
182
- * Log security audit information for tool execution
183
- */
184
- export function logSecurityAudit(tool, verificationResult, executionAllowed, options) {
185
- const auditLog = {
186
- timestamp: new Date().toISOString(),
187
- tool: tool.name || "unknown",
188
- version: tool.version,
189
- command: tool.command,
190
- executionAllowed,
191
- verificationSkipped: options.skipVerification || false,
192
- verificationPolicy: options.verifyPolicy || "permissive",
193
- verificationResult: verificationResult.verificationResult
194
- ? {
195
- isValid: verificationResult.verificationResult.isValid,
196
- validSignatures: verificationResult.verificationResult.validSignatures,
197
- totalSignatures: verificationResult.verificationResult.totalSignatures,
198
- verifiedSigners: verificationResult.verificationResult.verifiedSigners,
199
- }
200
- : null,
201
- errors: verificationResult.error ? [verificationResult.error.message] : [],
202
- };
203
- logger.info(`🔍 Security Audit Log:`, auditLog);
204
- }
@@ -1,98 +0,0 @@
1
- import type { EnactTool, ExecutionResult } from "../types";
2
- export declare class McpCoreService {
3
- private core;
4
- constructor(options?: {
5
- apiUrl?: string;
6
- supabaseUrl?: string;
7
- authToken?: string;
8
- });
9
- /**
10
- * Create McpCoreService with config-based URLs
11
- */
12
- static create(options?: {
13
- apiUrl?: string;
14
- supabaseUrl?: string;
15
- authToken?: string;
16
- }): Promise<McpCoreService>;
17
- /**
18
- * Set authentication token
19
- */
20
- setAuthToken(token: string): void;
21
- /**
22
- * Search for tools
23
- */
24
- searchTools(query: string, options?: {
25
- limit?: number;
26
- tags?: string[];
27
- author?: string;
28
- }): Promise<EnactTool[]>;
29
- /**
30
- * Get a specific tool by name
31
- */
32
- getToolInfo(name: string): Promise<EnactTool | null>;
33
- /**
34
- * Execute a tool by name
35
- */
36
- executeToolByName(name: string, inputs?: Record<string, any>, options?: {
37
- timeout?: string;
38
- force?: boolean;
39
- dryRun?: boolean;
40
- }): Promise<ExecutionResult>;
41
- /**
42
- * Execute a tool from raw YAML definition
43
- */
44
- executeRawTool(toolYaml: string, inputs?: Record<string, any>, options?: {
45
- timeout?: string;
46
- force?: boolean;
47
- dryRun?: boolean;
48
- }): Promise<ExecutionResult>;
49
- /**
50
- * Check if a tool exists
51
- */
52
- toolExists(name: string): Promise<boolean>;
53
- /**
54
- * Get tools by tags
55
- */
56
- getToolsByTags(tags: string[], limit?: number): Promise<EnactTool[]>;
57
- /**
58
- * Get tools by author
59
- */
60
- getToolsByAuthor(author: string, limit?: number): Promise<EnactTool[]>;
61
- /**
62
- * Get all tools with filters
63
- */
64
- getTools(options?: {
65
- limit?: number;
66
- offset?: number;
67
- tags?: string[];
68
- author?: string;
69
- }): Promise<EnactTool[]>;
70
- /**
71
- * Get authentication status
72
- */
73
- getAuthStatus(): Promise<{
74
- authenticated: boolean;
75
- user?: string;
76
- server?: string;
77
- }>;
78
- /**
79
- * Check if service is available (always true for core service)
80
- */
81
- isAvailable(): Promise<boolean>;
82
- /**
83
- * Get service path info (not applicable for core service)
84
- */
85
- getPathInfo(): Promise<{
86
- detectedPath: string | null;
87
- isAvailable: boolean;
88
- version?: string;
89
- }>;
90
- /**
91
- * Publish a tool (requires authentication)
92
- */
93
- publishTool(tool: EnactTool): Promise<{
94
- success: boolean;
95
- message: string;
96
- }>;
97
- }
98
- export declare const mcpCoreService: McpCoreService;
@@ -1,124 +0,0 @@
1
- // src/services/McpCoreService.ts - Direct core integration for MCP server
2
- import { EnactCore } from "../core/EnactCore";
3
- import { getFrontendUrl, getApiUrl } from "../utils/config";
4
- export class McpCoreService {
5
- constructor(options) {
6
- this.core = new EnactCore({
7
- apiUrl: options?.apiUrl || "https://enact.tools",
8
- supabaseUrl: options?.supabaseUrl || "https://xjnhhxwxovjifdxdwzih.supabase.co",
9
- authToken: options?.authToken,
10
- });
11
- }
12
- /**
13
- * Create McpCoreService with config-based URLs
14
- */
15
- static async create(options) {
16
- const frontendUrl = options?.apiUrl || await getFrontendUrl();
17
- const apiUrl = options?.supabaseUrl || await getApiUrl();
18
- return new McpCoreService({
19
- ...options,
20
- apiUrl: frontendUrl,
21
- supabaseUrl: apiUrl,
22
- });
23
- }
24
- /**
25
- * Set authentication token
26
- */
27
- setAuthToken(token) {
28
- this.core.setAuthToken(token);
29
- }
30
- /**
31
- * Search for tools
32
- */
33
- async searchTools(query, options) {
34
- const searchOptions = {
35
- query,
36
- limit: options?.limit,
37
- tags: options?.tags,
38
- author: options?.author,
39
- };
40
- return await this.core.searchTools(searchOptions);
41
- }
42
- /**
43
- * Get a specific tool by name
44
- */
45
- async getToolInfo(name) {
46
- return await this.core.getToolByName(name);
47
- }
48
- /**
49
- * Execute a tool by name
50
- */
51
- async executeToolByName(name, inputs = {}, options) {
52
- const executeOptions = {
53
- timeout: options?.timeout,
54
- force: options?.force,
55
- dryRun: options?.dryRun,
56
- };
57
- return await this.core.executeToolByName(name, inputs, executeOptions);
58
- }
59
- /**
60
- * Execute a tool from raw YAML definition
61
- */
62
- async executeRawTool(toolYaml, inputs = {}, options) {
63
- const executeOptions = {
64
- timeout: options?.timeout,
65
- force: options?.force,
66
- dryRun: options?.dryRun,
67
- };
68
- return await this.core.executeRawTool(toolYaml, inputs, executeOptions);
69
- }
70
- /**
71
- * Check if a tool exists
72
- */
73
- async toolExists(name) {
74
- return await this.core.toolExists(name);
75
- }
76
- /**
77
- * Get tools by tags
78
- */
79
- async getToolsByTags(tags, limit = 20) {
80
- return await this.core.getToolsByTags(tags, limit);
81
- }
82
- /**
83
- * Get tools by author
84
- */
85
- async getToolsByAuthor(author, limit = 20) {
86
- return await this.core.getToolsByAuthor(author, limit);
87
- }
88
- /**
89
- * Get all tools with filters
90
- */
91
- async getTools(options) {
92
- return await this.core.getTools(options);
93
- }
94
- /**
95
- * Get authentication status
96
- */
97
- async getAuthStatus() {
98
- return await this.core.getAuthStatus();
99
- }
100
- /**
101
- * Check if service is available (always true for core service)
102
- */
103
- async isAvailable() {
104
- return true;
105
- }
106
- /**
107
- * Get service path info (not applicable for core service)
108
- */
109
- async getPathInfo() {
110
- return {
111
- detectedPath: "core-library",
112
- isAvailable: true,
113
- version: "2.0.0-core",
114
- };
115
- }
116
- /**
117
- * Publish a tool (requires authentication)
118
- */
119
- async publishTool(tool) {
120
- return await this.core.publishTool(tool);
121
- }
122
- }
123
- // Create and export singleton instance
124
- export const mcpCoreService = new McpCoreService();
@@ -1 +0,0 @@
1
- export * from './McpCoreService';
@@ -1 +0,0 @@
1
- export * from './McpCoreService';
@@ -1,111 +0,0 @@
1
- export interface EnactConfig {
2
- defaultUrl?: string;
3
- history?: string[];
4
- urls?: {
5
- frontend?: string;
6
- api?: string;
7
- };
8
- }
9
- /**
10
- * Ensure config directory and file exist
11
- */
12
- export declare function ensureConfig(): Promise<void>;
13
- /**
14
- * Read the config file
15
- */
16
- export declare function readConfig(): Promise<EnactConfig>;
17
- /**
18
- * Write to the config file
19
- */
20
- export declare function writeConfig(config: EnactConfig): Promise<void>;
21
- /**
22
- * Add a file to the publish history
23
- */
24
- export declare function addToHistory(filePath: string): Promise<void>;
25
- /**
26
- * Get the publish history
27
- */
28
- export declare function getHistory(): Promise<string[]>;
29
- /**
30
- * Set the default publish URL
31
- */
32
- export declare function setDefaultUrl(url: string): Promise<void>;
33
- /**
34
- * Get the default publish URL
35
- */
36
- export declare function getDefaultUrl(): Promise<string | undefined>;
37
- export interface TrustedKeyMeta {
38
- name: string;
39
- description?: string;
40
- addedAt: string;
41
- source: "default" | "user" | "organization";
42
- keyFile: string;
43
- }
44
- export interface TrustedKey {
45
- id: string;
46
- name: string;
47
- publicKey: string;
48
- description?: string;
49
- addedAt: string;
50
- source: "default" | "user" | "organization";
51
- keyFile: string;
52
- }
53
- /**
54
- * Get the frontend URL with fallbacks
55
- */
56
- export declare function getFrontendUrl(): Promise<string>;
57
- /**
58
- * Get the API URL with fallbacks
59
- */
60
- export declare function getApiUrl(): Promise<string>;
61
- /**
62
- * Set the frontend URL in config
63
- */
64
- export declare function setFrontendUrl(url: string): Promise<void>;
65
- /**
66
- * Set the API URL in config
67
- */
68
- export declare function setApiUrl(url: string): Promise<void>;
69
- /**
70
- * Reset URLs to defaults
71
- */
72
- export declare function resetUrls(): Promise<void>;
73
- /**
74
- * Get current URL configuration
75
- */
76
- export declare function getUrlConfig(): Promise<{
77
- frontend: {
78
- value: string;
79
- source: string;
80
- };
81
- api: {
82
- value: string;
83
- source: string;
84
- };
85
- }>;
86
- /**
87
- * Read all trusted keys from directory
88
- */
89
- export declare function getTrustedKeys(): Promise<TrustedKey[]>;
90
- /**
91
- * Add a trusted key
92
- */
93
- export declare function addTrustedKey(keyData: {
94
- id: string;
95
- name: string;
96
- publicKey: string;
97
- description?: string;
98
- source?: "user" | "organization";
99
- }): Promise<void>;
100
- /**
101
- * Remove a trusted key
102
- */
103
- export declare function removeTrustedKey(keyId: string): Promise<void>;
104
- /**
105
- * Get a specific trusted key
106
- */
107
- export declare function getTrustedKey(keyId: string): Promise<TrustedKey | null>;
108
- /**
109
- * Check if a public key is trusted
110
- */
111
- export declare function isKeyTrusted(publicKey: string): Promise<boolean>;