@enactprotocol/shared 1.2.13 → 2.0.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/README.md +44 -0
- package/package.json +16 -58
- package/src/config.ts +476 -0
- package/src/constants.ts +36 -0
- package/src/execution/command.ts +314 -0
- package/src/execution/index.ts +73 -0
- package/src/execution/runtime.ts +308 -0
- package/src/execution/types.ts +379 -0
- package/src/execution/validation.ts +508 -0
- package/src/index.ts +237 -30
- package/src/manifest/index.ts +36 -0
- package/src/manifest/loader.ts +187 -0
- package/src/manifest/parser.ts +173 -0
- package/src/manifest/validator.ts +309 -0
- package/src/paths.ts +108 -0
- package/src/registry.ts +219 -0
- package/src/resolver.ts +345 -0
- package/src/types/index.ts +30 -0
- package/src/types/manifest.ts +255 -0
- package/src/types.ts +5 -188
- package/src/utils/fs.ts +281 -0
- package/src/utils/logger.ts +270 -59
- package/src/utils/version.ts +304 -36
- package/tests/config.test.ts +515 -0
- package/tests/execution/command.test.ts +317 -0
- package/tests/execution/validation.test.ts +384 -0
- package/tests/fixtures/invalid-tool.yaml +4 -0
- package/tests/fixtures/valid-tool.md +62 -0
- package/tests/fixtures/valid-tool.yaml +40 -0
- package/tests/index.test.ts +8 -0
- package/tests/manifest/loader.test.ts +291 -0
- package/tests/manifest/parser.test.ts +345 -0
- package/tests/manifest/validator.test.ts +394 -0
- package/tests/manifest-types.test.ts +358 -0
- package/tests/paths.test.ts +153 -0
- package/tests/registry.test.ts +231 -0
- package/tests/resolver.test.ts +272 -0
- package/tests/utils/fs.test.ts +388 -0
- package/tests/utils/logger.test.ts +480 -0
- package/tests/utils/version.test.ts +390 -0
- package/tsconfig.json +12 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/LocalToolResolver.d.ts +0 -84
- package/dist/LocalToolResolver.js +0 -353
- package/dist/api/enact-api.d.ts +0 -130
- package/dist/api/enact-api.js +0 -428
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.js +0 -2
- package/dist/api/types.d.ts +0 -103
- package/dist/api/types.js +0 -1
- package/dist/constants.d.ts +0 -7
- package/dist/constants.js +0 -10
- package/dist/core/DaggerExecutionProvider.d.ts +0 -169
- package/dist/core/DaggerExecutionProvider.js +0 -1029
- package/dist/core/DirectExecutionProvider.d.ts +0 -23
- package/dist/core/DirectExecutionProvider.js +0 -406
- package/dist/core/EnactCore.d.ts +0 -162
- package/dist/core/EnactCore.js +0 -597
- package/dist/core/NativeExecutionProvider.d.ts +0 -9
- package/dist/core/NativeExecutionProvider.js +0 -16
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.js +0 -3
- package/dist/exec/index.d.ts +0 -3
- package/dist/exec/index.js +0 -3
- package/dist/exec/logger.d.ts +0 -11
- package/dist/exec/logger.js +0 -57
- package/dist/exec/validate.d.ts +0 -5
- package/dist/exec/validate.js +0 -167
- package/dist/index.d.ts +0 -21
- package/dist/index.js +0 -25
- package/dist/lib/enact-direct.d.ts +0 -150
- package/dist/lib/enact-direct.js +0 -159
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -1
- package/dist/security/index.d.ts +0 -3
- package/dist/security/index.js +0 -3
- package/dist/security/security.d.ts +0 -23
- package/dist/security/security.js +0 -137
- package/dist/security/sign.d.ts +0 -103
- package/dist/security/sign.js +0 -666
- package/dist/security/verification-enforcer.d.ts +0 -53
- package/dist/security/verification-enforcer.js +0 -204
- package/dist/services/McpCoreService.d.ts +0 -98
- package/dist/services/McpCoreService.js +0 -124
- package/dist/services/index.d.ts +0 -1
- package/dist/services/index.js +0 -1
- package/dist/types.d.ts +0 -132
- package/dist/types.js +0 -3
- package/dist/utils/config.d.ts +0 -111
- package/dist/utils/config.js +0 -342
- package/dist/utils/env-loader.d.ts +0 -54
- package/dist/utils/env-loader.js +0 -270
- package/dist/utils/help.d.ts +0 -36
- package/dist/utils/help.js +0 -248
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/index.js +0 -7
- package/dist/utils/logger.d.ts +0 -35
- package/dist/utils/logger.js +0 -75
- package/dist/utils/silent-monitor.d.ts +0 -67
- package/dist/utils/silent-monitor.js +0 -242
- package/dist/utils/timeout.d.ts +0 -5
- package/dist/utils/timeout.js +0 -23
- package/dist/utils/version.d.ts +0 -4
- package/dist/utils/version.js +0 -35
- package/dist/web/env-manager-server.d.ts +0 -29
- package/dist/web/env-manager-server.js +0 -367
- package/dist/web/index.d.ts +0 -1
- package/dist/web/index.js +0 -1
- package/src/LocalToolResolver.ts +0 -424
- package/src/api/enact-api.ts +0 -604
- package/src/api/index.ts +0 -2
- package/src/api/types.ts +0 -114
- package/src/core/DaggerExecutionProvider.ts +0 -1357
- package/src/core/DirectExecutionProvider.ts +0 -484
- package/src/core/EnactCore.ts +0 -847
- package/src/core/index.ts +0 -3
- package/src/exec/index.ts +0 -3
- package/src/exec/logger.ts +0 -63
- package/src/exec/validate.ts +0 -238
- package/src/lib/enact-direct.ts +0 -254
- package/src/lib/index.ts +0 -1
- package/src/services/McpCoreService.ts +0 -201
- package/src/services/index.ts +0 -1
- package/src/utils/config.ts +0 -438
- package/src/utils/env-loader.ts +0 -370
- package/src/utils/help.ts +0 -257
- package/src/utils/index.ts +0 -7
- package/src/utils/silent-monitor.ts +0 -328
- package/src/utils/timeout.ts +0 -26
- package/src/web/env-manager-server.ts +0 -465
- package/src/web/index.ts +0 -1
- package/src/web/static/app.js +0 -663
- package/src/web/static/index.html +0 -117
- package/src/web/static/style.css +0 -291
package/dist/exec/logger.js
DELETED
|
@@ -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;
|
package/dist/exec/validate.d.ts
DELETED
|
@@ -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;
|
package/dist/exec/validate.js
DELETED
|
@@ -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
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { EnactCore } from './core/EnactCore';
|
|
2
|
-
export { DirectExecutionProvider } from './core/DirectExecutionProvider';
|
|
3
|
-
export { DaggerExecutionProvider } from './core/DaggerExecutionProvider';
|
|
4
|
-
export type { EnactTool } from './types';
|
|
5
|
-
export type { EnactToolDefinition } from './api/types';
|
|
6
|
-
export { default as LocalToolResolver } from './LocalToolResolver';
|
|
7
|
-
export { default } from './LocalToolResolver';
|
|
8
|
-
export { default as logger } from './exec/logger';
|
|
9
|
-
export * from './exec/validate';
|
|
10
|
-
export * from './utils/config';
|
|
11
|
-
export * from './utils/env-loader';
|
|
12
|
-
export { showHelp } from './utils/help';
|
|
13
|
-
export { showVersion as utilsShowVersion } from './utils/version';
|
|
14
|
-
export * from './utils/logger';
|
|
15
|
-
export * from './utils/silent-monitor';
|
|
16
|
-
export * from './utils/timeout';
|
|
17
|
-
export * from './services/McpCoreService';
|
|
18
|
-
export * from './web/env-manager-server';
|
|
19
|
-
export * from './api/enact-api';
|
|
20
|
-
export type { ApiResponse, ToolSearchQuery, ToolUsage, CLITokenCreate, OAuthTokenExchange } from './api/types';
|
|
21
|
-
export * from './lib/enact-direct';
|
package/dist/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Core exports
|
|
2
|
-
export { EnactCore } from './core/EnactCore';
|
|
3
|
-
export { DirectExecutionProvider } from './core/DirectExecutionProvider';
|
|
4
|
-
export { DaggerExecutionProvider } from './core/DaggerExecutionProvider';
|
|
5
|
-
export { default as LocalToolResolver } from './LocalToolResolver';
|
|
6
|
-
export { default } from './LocalToolResolver';
|
|
7
|
-
// Exec utilities
|
|
8
|
-
export { default as logger } from './exec/logger';
|
|
9
|
-
export * from './exec/validate';
|
|
10
|
-
// Utils
|
|
11
|
-
export * from './utils/config';
|
|
12
|
-
export * from './utils/env-loader';
|
|
13
|
-
export { showHelp } from './utils/help';
|
|
14
|
-
export { showVersion as utilsShowVersion } from './utils/version';
|
|
15
|
-
export * from './utils/logger';
|
|
16
|
-
export * from './utils/silent-monitor';
|
|
17
|
-
export * from './utils/timeout';
|
|
18
|
-
// Services
|
|
19
|
-
export * from './services/McpCoreService';
|
|
20
|
-
// Web
|
|
21
|
-
export * from './web/env-manager-server';
|
|
22
|
-
// API
|
|
23
|
-
export * from './api/enact-api';
|
|
24
|
-
// Lib
|
|
25
|
-
export * from './lib/enact-direct';
|
|
@@ -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";
|
package/dist/lib/enact-direct.js
DELETED
|
@@ -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";
|
package/dist/lib/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './enact-direct';
|
package/dist/lib/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './enact-direct';
|
package/dist/security/index.d.ts
DELETED
package/dist/security/index.js
DELETED
|
@@ -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>;
|