@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,57 +0,0 @@
1
- import pino from "pino";
2
- // Determine if the environment is silent (e.g., CI, testing, or specific env var)
3
- const isSilentMode = () => process.env.CI === "true" ||
4
- process.env.NODE_ENV === "test" ||
5
- process.env.ENACT_SILENT === "true" ||
6
- process.env.ENACT_SKIP_INTERACTIVE === "true";
7
- // Base logger configuration
8
- const logger = pino({
9
- level: process.env.LOG_LEVEL || "info",
10
- // In tests, we don't want the pretty transport, as it adds noise.
11
- // The output is captured anyway.
12
- ...(process.env.NODE_ENV !== "test" && {
13
- transport: {
14
- target: "pino-pretty",
15
- options: {
16
- colorize: true,
17
- ignore: "pid,hostname",
18
- translateTime: "SYS:standard",
19
- },
20
- },
21
- }),
22
- });
23
- // Wrapper to dynamically check silent mode on each call
24
- const wrappedLogger = {
25
- info: (...args) => {
26
- if (!isSilentMode()) {
27
- logger.info(...args);
28
- }
29
- },
30
- warn: (...args) => {
31
- if (!isSilentMode()) {
32
- logger.warn(...args);
33
- }
34
- },
35
- error: (...args) => {
36
- // The silent tests expect errors to be silent too.
37
- if (!isSilentMode()) {
38
- logger.error(...args);
39
- }
40
- },
41
- debug: (...args) => {
42
- if (!isSilentMode() && (process.env.DEBUG || process.env.VERBOSE)) {
43
- logger.debug(...args);
44
- }
45
- },
46
- // Expose a way to check if client logging is enabled (for MCP)
47
- clientLoggingEnabled: () => !process.env.ENACT_MCP_CLIENT,
48
- isLevelEnabled: (level) => {
49
- if (isSilentMode()) {
50
- return false;
51
- }
52
- return logger.isLevelEnabled(level);
53
- },
54
- // Keep original pino instance available if needed
55
- pino: logger,
56
- };
57
- export default wrappedLogger;
@@ -1,5 +0,0 @@
1
- import type { EnactTool, JSONSchemaDefinition } from "../types";
2
- export declare function validateAgainstSchema(value: any, schema: JSONSchemaDefinition, fieldName: string): void;
3
- export declare function validateToolStructure(tool: EnactTool): void;
4
- export declare function validateInputs(tool: EnactTool, inputs: Record<string, any>): Record<string, any>;
5
- export declare function validateOutput(tool: EnactTool, output: any): any;
@@ -1,167 +0,0 @@
1
- export function validateAgainstSchema(value, schema, fieldName) {
2
- const { type, format, enum: enumValues, minimum, maximum, pattern, required, } = schema;
3
- // Type validation
4
- if (type) {
5
- let validType = false;
6
- switch (type) {
7
- case "string":
8
- validType = typeof value === "string";
9
- break;
10
- case "number":
11
- case "integer":
12
- validType = typeof value === "number";
13
- if (type === "integer" && !Number.isInteger(value)) {
14
- validType = false;
15
- }
16
- break;
17
- case "boolean":
18
- validType = typeof value === "boolean";
19
- break;
20
- case "array":
21
- validType = Array.isArray(value);
22
- break;
23
- case "object":
24
- validType =
25
- typeof value === "object" && value !== null && !Array.isArray(value);
26
- break;
27
- }
28
- if (!validType) {
29
- throw new Error(`Invalid type for ${fieldName}: expected ${type}`);
30
- }
31
- }
32
- // For object types, validate required properties
33
- if (type === "object" && required && Array.isArray(required)) {
34
- for (const requiredProp of required) {
35
- if (value[requiredProp] === undefined) {
36
- throw new Error(`Missing required property: ${requiredProp} in ${fieldName}`);
37
- }
38
- }
39
- }
40
- // Format validation (simplified)
41
- if (format && type === "string") {
42
- const formatValidators = {
43
- email: /^.+@.+\..+$/,
44
- "date-time": /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d+)?(Z|[+-]\d{2}:\d{2})$/,
45
- uri: /^https?:\/\/.+/,
46
- };
47
- if (formatValidators[format] && !formatValidators[format].test(value)) {
48
- throw new Error(`Invalid format for ${fieldName}: expected ${format}`);
49
- }
50
- }
51
- // Enum validation
52
- if (enumValues && !enumValues.includes(value)) {
53
- throw new Error(`Invalid value for ${fieldName}: must be one of [${enumValues.join(", ")}]`);
54
- }
55
- // Range validation for numbers
56
- if ((minimum !== undefined || maximum !== undefined) &&
57
- typeof value === "number") {
58
- if (minimum !== undefined && value < minimum) {
59
- throw new Error(`Value for ${fieldName} must be >= ${minimum}`);
60
- }
61
- if (maximum !== undefined && value > maximum) {
62
- throw new Error(`Value for ${fieldName} must be <= ${maximum}`);
63
- }
64
- }
65
- // Pattern validation for strings
66
- if (pattern &&
67
- typeof value === "string" &&
68
- !new RegExp(pattern).test(value)) {
69
- throw new Error(`Value for ${fieldName} must match pattern: ${pattern}`);
70
- }
71
- }
72
- export function validateToolStructure(tool) {
73
- // Check required fields
74
- const requiredFields = ["name", "description", "command"];
75
- for (const field of requiredFields) {
76
- if (!tool[field]) {
77
- throw new Error(`Missing required field: ${field} in tool ${JSON.stringify(tool)}`);
78
- }
79
- }
80
- // Validate name format - supports hierarchical names with forward slashes
81
- if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]*(?:\/[a-zA-Z0-9][a-zA-Z0-9_-]*)*$/.test(tool.name)) {
82
- throw new Error(`Invalid tool name: ${tool.name}. Must follow hierarchical format like "tool-name" or "org/package/tool-name".`);
83
- }
84
- // Validate command is not empty
85
- if (!tool.command.trim()) {
86
- throw new Error("Command field cannot be empty");
87
- }
88
- // Validate timeout format if provided
89
- if (tool.timeout) {
90
- if (!/^\d+[smh]$/.test(tool.timeout)) {
91
- throw new Error(`Invalid timeout format: ${tool.timeout}. Must be Go duration format like "30s", "5m", "1h"`);
92
- }
93
- }
94
- // Validate environment variables structure
95
- if (tool.env) {
96
- for (const [varName, config] of Object.entries(tool.env)) {
97
- if (!config.description ||
98
- !config.source ||
99
- config.required === undefined) {
100
- throw new Error(`Environment variable ${varName} must have description, source, and required fields`);
101
- }
102
- if (!/^[A-Z][A-Z0-9_]*$/.test(varName)) {
103
- throw new Error(`Invalid environment variable name: ${varName}. Must be uppercase with underscores`);
104
- }
105
- }
106
- }
107
- // Validate authors structure if provided
108
- if (tool.authors) {
109
- for (const author of tool.authors) {
110
- if (!author.name) {
111
- throw new Error("Author must have a name field");
112
- }
113
- if (author.email && !/^.+@.+\..+$/.test(author.email)) {
114
- throw new Error(`Invalid email format for author: ${author.email}`);
115
- }
116
- if (author.url && !/^https?:\/\/.+/.test(author.url)) {
117
- throw new Error(`Invalid URL format for author: ${author.url}`);
118
- }
119
- }
120
- }
121
- }
122
- export function validateInputs(tool, inputs) {
123
- const validatedInputs = {};
124
- if (!tool.inputSchema || !tool.inputSchema.properties) {
125
- return inputs;
126
- }
127
- // Check for required fields
128
- const requiredFields = tool.inputSchema.required || [];
129
- for (const field of requiredFields) {
130
- if (inputs[field] === undefined) {
131
- throw new Error(`Missing required input: ${field}`);
132
- }
133
- }
134
- // Validate and extract values
135
- for (const [key, schema] of Object.entries(tool.inputSchema.properties)) {
136
- if (inputs[key] !== undefined) {
137
- validateAgainstSchema(inputs[key], schema, key);
138
- validatedInputs[key] = inputs[key];
139
- }
140
- else if (schema.default !== undefined) {
141
- validatedInputs[key] = schema.default;
142
- }
143
- }
144
- return validatedInputs;
145
- }
146
- export function validateOutput(tool, output) {
147
- if (!tool.outputSchema) {
148
- return output;
149
- }
150
- try {
151
- // Validate the entire output against the schema
152
- validateAgainstSchema(output, tool.outputSchema, "output");
153
- // Also check required fields specifically
154
- if (tool.outputSchema.required &&
155
- Array.isArray(tool.outputSchema.required)) {
156
- for (const requiredField of tool.outputSchema.required) {
157
- if (output[requiredField] === undefined) {
158
- throw new Error(`Missing required output field: ${requiredField}`);
159
- }
160
- }
161
- }
162
- return output;
163
- }
164
- catch (error) {
165
- throw new Error(`Output validation failed: ${error.message}`);
166
- }
167
- }
@@ -1,150 +0,0 @@
1
- import { type ToolSearchOptions, type ToolExecuteOptions } from "../core/EnactCore";
2
- import type { EnactTool, ExecutionResult } from "../types";
3
- /**
4
- * Direct Enact Library Interface
5
- *
6
- * This provides a simple, direct interface for MCP servers to use Enact
7
- * without any CLI process spawning. All operations happen in-process.
8
- */
9
- export declare class EnactDirect {
10
- private core;
11
- constructor(options?: {
12
- apiUrl?: string;
13
- supabaseUrl?: string;
14
- authToken?: string;
15
- defaultTimeout?: string;
16
- });
17
- /**
18
- * Create EnactDirect with config-based URLs
19
- */
20
- static create(options?: {
21
- apiUrl?: string;
22
- supabaseUrl?: string;
23
- authToken?: string;
24
- defaultTimeout?: string;
25
- }): Promise<EnactDirect>;
26
- /**
27
- * Execute a tool by name with inputs
28
- *
29
- * @param name - Tool name (e.g., "my-org/data-processor")
30
- * @param inputs - Input parameters for the tool
31
- * @param options - Execution options
32
- * @returns Execution result
33
- */
34
- executeToolByName(name: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
35
- /**
36
- * Search for tools matching a query
37
- *
38
- * @param options - Search options
39
- * @returns Array of matching tools
40
- */
41
- searchTools(options: ToolSearchOptions): Promise<EnactTool[]>;
42
- /**
43
- * Get detailed information about a specific tool
44
- *
45
- * @param name - Tool name
46
- * @param version - Optional specific version
47
- * @returns Tool information or null if not found
48
- */
49
- getToolInfo(name: string, version?: string): Promise<EnactTool | null>;
50
- /**
51
- * Execute a tool from raw YAML definition
52
- *
53
- * @param toolYaml - YAML tool definition
54
- * @param inputs - Input parameters
55
- * @param options - Execution options
56
- * @returns Execution result
57
- */
58
- executeRawTool(toolYaml: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
59
- /**
60
- * Check if a tool exists in the registry
61
- *
62
- * @param name - Tool name
63
- * @returns True if tool exists
64
- */
65
- toolExists(name: string): Promise<boolean>;
66
- /**
67
- * Get all tools with optional filtering
68
- *
69
- * @param options - Filter options
70
- * @returns Array of tools
71
- */
72
- getTools(options?: {
73
- limit?: number;
74
- offset?: number;
75
- tags?: string[];
76
- author?: string;
77
- }): Promise<EnactTool[]>;
78
- /**
79
- * Get tools by specific tags
80
- *
81
- * @param tags - Array of tags to filter by
82
- * @param limit - Maximum number of results
83
- * @returns Array of tools
84
- */
85
- getToolsByTags(tags: string[], limit?: number): Promise<EnactTool[]>;
86
- /**
87
- * Get tools by a specific author
88
- *
89
- * @param author - Author name
90
- * @param limit - Maximum number of results
91
- * @returns Array of tools
92
- */
93
- getToolsByAuthor(author: string, limit?: number): Promise<EnactTool[]>;
94
- /**
95
- * Get the current status of the Enact core
96
- *
97
- * @returns Status information
98
- */
99
- getStatus(): Promise<{
100
- executionProvider: string;
101
- apiUrl: string;
102
- defaultTimeout: string;
103
- authenticated: boolean;
104
- }>;
105
- /**
106
- * Set authentication token
107
- *
108
- * @param token - Authentication token
109
- */
110
- setAuthToken(token: string): void;
111
- /**
112
- * Get authentication status
113
- *
114
- * @returns Authentication status
115
- */
116
- getAuthStatus(): Promise<{
117
- authenticated: boolean;
118
- user?: string;
119
- server?: string;
120
- }>;
121
- /**
122
- * Publish a tool (requires authentication)
123
- *
124
- * @param tool - Tool definition to publish
125
- * @returns Publication result
126
- */
127
- publishTool(tool: EnactTool): Promise<{
128
- success: boolean;
129
- message: string;
130
- }>;
131
- }
132
- export declare const enactDirect: EnactDirect;
133
- export declare const executeToolByName: (name: string, inputs?: Record<string, any>, options?: ToolExecuteOptions) => Promise<ExecutionResult>;
134
- export declare const searchTools: (options: ToolSearchOptions) => Promise<EnactTool[]>;
135
- export declare const getToolInfo: (name: string, version?: string) => Promise<EnactTool | null>;
136
- export declare const executeRawTool: (toolYaml: string, inputs?: Record<string, any>, options?: ToolExecuteOptions) => Promise<ExecutionResult>;
137
- export declare const getToolsByTags: (tags: string[], limit?: number) => Promise<EnactTool[]>;
138
- export declare const getToolsByAuthor: (author: string, limit?: number) => Promise<EnactTool[]>;
139
- export declare const toolExists: (name: string) => Promise<boolean>;
140
- export declare const getAuthStatus: () => Promise<{
141
- authenticated: boolean;
142
- user?: string;
143
- server?: string;
144
- }>;
145
- export declare const publishTool: (tool: EnactTool) => Promise<{
146
- success: boolean;
147
- message: string;
148
- }>;
149
- export { EnactCore, type ToolSearchOptions, type ToolExecuteOptions, } from "../core/EnactCore";
150
- export type { EnactTool, ExecutionResult } from "../types";
@@ -1,159 +0,0 @@
1
- // src/lib/enact-direct.ts - Library interface for direct usage by MCP servers
2
- import { EnactCore, } from "../core/EnactCore";
3
- import { getFrontendUrl, getApiUrl } from "../utils/config";
4
- /**
5
- * Direct Enact Library Interface
6
- *
7
- * This provides a simple, direct interface for MCP servers to use Enact
8
- * without any CLI process spawning. All operations happen in-process.
9
- */
10
- export class EnactDirect {
11
- constructor(options = {}) {
12
- // We need to handle async config loading in a factory method
13
- this.core = new EnactCore({
14
- apiUrl: options.apiUrl || process.env.ENACT_FRONTEND_URL || "https://enact.tools",
15
- supabaseUrl: options.supabaseUrl || process.env.ENACT_API_URL || "https://xjnhhxwxovjifdxdwzih.supabase.co",
16
- executionProvider: "direct",
17
- authToken: options.authToken || process.env.ENACT_AUTH_TOKEN,
18
- defaultTimeout: options.defaultTimeout || "30s",
19
- });
20
- }
21
- /**
22
- * Create EnactDirect with config-based URLs
23
- */
24
- static async create(options = {}) {
25
- const frontendUrl = options.apiUrl || process.env.ENACT_FRONTEND_URL || await getFrontendUrl();
26
- const apiUrl = options.supabaseUrl || process.env.ENACT_API_URL || await getApiUrl();
27
- return new EnactDirect({
28
- ...options,
29
- apiUrl: frontendUrl,
30
- supabaseUrl: apiUrl,
31
- });
32
- }
33
- /**
34
- * Execute a tool by name with inputs
35
- *
36
- * @param name - Tool name (e.g., "my-org/data-processor")
37
- * @param inputs - Input parameters for the tool
38
- * @param options - Execution options
39
- * @returns Execution result
40
- */
41
- async executeToolByName(name, inputs = {}, options = {}) {
42
- return this.core.executeToolByName(name, inputs, options);
43
- }
44
- /**
45
- * Search for tools matching a query
46
- *
47
- * @param options - Search options
48
- * @returns Array of matching tools
49
- */
50
- async searchTools(options) {
51
- return this.core.searchTools(options);
52
- }
53
- /**
54
- * Get detailed information about a specific tool
55
- *
56
- * @param name - Tool name
57
- * @param version - Optional specific version
58
- * @returns Tool information or null if not found
59
- */
60
- async getToolInfo(name, version) {
61
- return this.core.getToolInfo(name, version);
62
- }
63
- /**
64
- * Execute a tool from raw YAML definition
65
- *
66
- * @param toolYaml - YAML tool definition
67
- * @param inputs - Input parameters
68
- * @param options - Execution options
69
- * @returns Execution result
70
- */
71
- async executeRawTool(toolYaml, inputs = {}, options = {}) {
72
- return this.core.executeRawTool(toolYaml, inputs, options);
73
- }
74
- /**
75
- * Check if a tool exists in the registry
76
- *
77
- * @param name - Tool name
78
- * @returns True if tool exists
79
- */
80
- async toolExists(name) {
81
- return this.core.toolExists(name);
82
- }
83
- /**
84
- * Get all tools with optional filtering
85
- *
86
- * @param options - Filter options
87
- * @returns Array of tools
88
- */
89
- async getTools(options = {}) {
90
- return this.core.getTools(options);
91
- }
92
- /**
93
- * Get tools by specific tags
94
- *
95
- * @param tags - Array of tags to filter by
96
- * @param limit - Maximum number of results
97
- * @returns Array of tools
98
- */
99
- async getToolsByTags(tags, limit = 20) {
100
- return this.core.getToolsByTags(tags, limit);
101
- }
102
- /**
103
- * Get tools by a specific author
104
- *
105
- * @param author - Author name
106
- * @param limit - Maximum number of results
107
- * @returns Array of tools
108
- */
109
- async getToolsByAuthor(author, limit = 20) {
110
- return this.core.getToolsByAuthor(author, limit);
111
- }
112
- /**
113
- * Get the current status of the Enact core
114
- *
115
- * @returns Status information
116
- */
117
- async getStatus() {
118
- return this.core.getStatus();
119
- }
120
- /**
121
- * Set authentication token
122
- *
123
- * @param token - Authentication token
124
- */
125
- setAuthToken(token) {
126
- this.core.setAuthToken(token);
127
- }
128
- /**
129
- * Get authentication status
130
- *
131
- * @returns Authentication status
132
- */
133
- async getAuthStatus() {
134
- return this.core.getAuthStatus();
135
- }
136
- /**
137
- * Publish a tool (requires authentication)
138
- *
139
- * @param tool - Tool definition to publish
140
- * @returns Publication result
141
- */
142
- async publishTool(tool) {
143
- return this.core.publishTool(tool);
144
- }
145
- }
146
- // Create and export a default instance
147
- export const enactDirect = new EnactDirect();
148
- // Export convenience functions using the default instance
149
- export const executeToolByName = (name, inputs = {}, options = {}) => enactDirect.executeToolByName(name, inputs, options);
150
- export const searchTools = (options) => enactDirect.searchTools(options);
151
- export const getToolInfo = (name, version) => enactDirect.getToolInfo(name, version);
152
- export const executeRawTool = (toolYaml, inputs = {}, options = {}) => enactDirect.executeRawTool(toolYaml, inputs, options);
153
- export const getToolsByTags = (tags, limit = 20) => enactDirect.getToolsByTags(tags, limit);
154
- export const getToolsByAuthor = (author, limit = 20) => enactDirect.getToolsByAuthor(author, limit);
155
- export const toolExists = (name) => enactDirect.toolExists(name);
156
- export const getAuthStatus = () => enactDirect.getAuthStatus();
157
- export const publishTool = (tool) => enactDirect.publishTool(tool);
158
- // Also export the core for advanced usage
159
- export { EnactCore, } from "../core/EnactCore";
@@ -1 +0,0 @@
1
- export * from './enact-direct';
package/dist/lib/index.js DELETED
@@ -1 +0,0 @@
1
- export * from './enact-direct';
@@ -1,3 +0,0 @@
1
- export * from './security';
2
- export * from './sign';
3
- export * from './verification-enforcer';
@@ -1,3 +0,0 @@
1
- export * from './security';
2
- export * from './sign';
3
- export * from './verification-enforcer';
@@ -1,23 +0,0 @@
1
- import type { EnactTool } from "../types";
2
- /**
3
- * Verify the signature of an Enact tool before execution
4
- * @param tool The tool to verify
5
- * @returns Boolean indicating validity
6
- */
7
- /**
8
- * Verify that a command is safe to execute
9
- * @param command The command to verify
10
- * @param tool The tool containing the command
11
- * @returns Object with safety status and warnings
12
- */
13
- export declare function verifyCommandSafety(command: string, tool: EnactTool): {
14
- isSafe: boolean;
15
- warnings: string[];
16
- blocked?: string[];
17
- };
18
- /**
19
- * Sanitize environment variables to prevent injection attacks
20
- * @param envVars Environment variables to sanitize
21
- * @returns Sanitized environment variables
22
- */
23
- export declare function sanitizeEnvironmentVariables(envVars: Record<string, any>): Record<string, string>;