@enactprotocol/shared 1.0.12

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 (97) hide show
  1. package/dist/LocalToolResolver.d.ts +84 -0
  2. package/dist/LocalToolResolver.js +353 -0
  3. package/dist/api/enact-api.d.ts +124 -0
  4. package/dist/api/enact-api.js +406 -0
  5. package/dist/api/index.d.ts +2 -0
  6. package/dist/api/index.js +2 -0
  7. package/dist/api/types.d.ts +83 -0
  8. package/dist/api/types.js +1 -0
  9. package/dist/core/DaggerExecutionProvider.d.ts +169 -0
  10. package/dist/core/DaggerExecutionProvider.js +996 -0
  11. package/dist/core/DirectExecutionProvider.d.ts +23 -0
  12. package/dist/core/DirectExecutionProvider.js +406 -0
  13. package/dist/core/EnactCore.d.ts +138 -0
  14. package/dist/core/EnactCore.js +609 -0
  15. package/dist/core/index.d.ts +3 -0
  16. package/dist/core/index.js +3 -0
  17. package/dist/exec/index.d.ts +3 -0
  18. package/dist/exec/index.js +3 -0
  19. package/dist/exec/logger.d.ts +11 -0
  20. package/dist/exec/logger.js +57 -0
  21. package/dist/exec/validate.d.ts +5 -0
  22. package/dist/exec/validate.js +167 -0
  23. package/dist/index.d.ts +25 -0
  24. package/dist/index.js +29 -0
  25. package/dist/lib/enact-direct.d.ts +156 -0
  26. package/dist/lib/enact-direct.js +158 -0
  27. package/dist/lib/index.d.ts +1 -0
  28. package/dist/lib/index.js +1 -0
  29. package/dist/security/index.d.ts +3 -0
  30. package/dist/security/index.js +3 -0
  31. package/dist/security/security.d.ts +23 -0
  32. package/dist/security/security.js +137 -0
  33. package/dist/security/sign.d.ts +103 -0
  34. package/dist/security/sign.js +532 -0
  35. package/dist/security/verification-enforcer.d.ts +41 -0
  36. package/dist/security/verification-enforcer.js +181 -0
  37. package/dist/services/McpCoreService.d.ts +102 -0
  38. package/dist/services/McpCoreService.js +120 -0
  39. package/dist/services/index.d.ts +1 -0
  40. package/dist/services/index.js +1 -0
  41. package/dist/types.d.ts +130 -0
  42. package/dist/types.js +3 -0
  43. package/dist/utils/config.d.ts +32 -0
  44. package/dist/utils/config.js +78 -0
  45. package/dist/utils/env-loader.d.ts +54 -0
  46. package/dist/utils/env-loader.js +270 -0
  47. package/dist/utils/help.d.ts +36 -0
  48. package/dist/utils/help.js +248 -0
  49. package/dist/utils/index.d.ts +7 -0
  50. package/dist/utils/index.js +7 -0
  51. package/dist/utils/logger.d.ts +35 -0
  52. package/dist/utils/logger.js +75 -0
  53. package/dist/utils/silent-monitor.d.ts +67 -0
  54. package/dist/utils/silent-monitor.js +242 -0
  55. package/dist/utils/timeout.d.ts +5 -0
  56. package/dist/utils/timeout.js +23 -0
  57. package/dist/utils/version.d.ts +4 -0
  58. package/dist/utils/version.js +14 -0
  59. package/dist/web/env-manager-server.d.ts +29 -0
  60. package/dist/web/env-manager-server.js +367 -0
  61. package/dist/web/index.d.ts +1 -0
  62. package/dist/web/index.js +1 -0
  63. package/package.json +79 -0
  64. package/src/LocalToolResolver.ts +424 -0
  65. package/src/api/enact-api.ts +569 -0
  66. package/src/api/index.ts +2 -0
  67. package/src/api/types.ts +93 -0
  68. package/src/core/DaggerExecutionProvider.ts +1308 -0
  69. package/src/core/DirectExecutionProvider.ts +484 -0
  70. package/src/core/EnactCore.ts +833 -0
  71. package/src/core/index.ts +3 -0
  72. package/src/exec/index.ts +3 -0
  73. package/src/exec/logger.ts +63 -0
  74. package/src/exec/validate.ts +238 -0
  75. package/src/index.ts +42 -0
  76. package/src/lib/enact-direct.ts +258 -0
  77. package/src/lib/index.ts +1 -0
  78. package/src/security/index.ts +3 -0
  79. package/src/security/security.ts +188 -0
  80. package/src/security/sign.ts +797 -0
  81. package/src/security/verification-enforcer.ts +268 -0
  82. package/src/services/McpCoreService.ts +203 -0
  83. package/src/services/index.ts +1 -0
  84. package/src/types.ts +190 -0
  85. package/src/utils/config.ts +97 -0
  86. package/src/utils/env-loader.ts +370 -0
  87. package/src/utils/help.ts +257 -0
  88. package/src/utils/index.ts +7 -0
  89. package/src/utils/logger.ts +83 -0
  90. package/src/utils/silent-monitor.ts +328 -0
  91. package/src/utils/timeout.ts +26 -0
  92. package/src/utils/version.ts +16 -0
  93. package/src/web/env-manager-server.ts +465 -0
  94. package/src/web/index.ts +1 -0
  95. package/src/web/static/app.js +663 -0
  96. package/src/web/static/index.html +117 -0
  97. package/src/web/static/style.css +291 -0
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,167 @@
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
+ }
@@ -0,0 +1,25 @@
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 './security/security';
18
+ export { verifyTool, shouldExecuteTool, VERIFICATION_POLICIES } from './security/sign';
19
+ export type { VerificationPolicy as SecurityVerificationPolicy } from './security/sign';
20
+ export * from './security/verification-enforcer';
21
+ export * from './services/McpCoreService';
22
+ export * from './web/env-manager-server';
23
+ export * from './api/enact-api';
24
+ export type { ApiResponse, ToolSearchQuery, ToolUsage, CLITokenCreate, OAuthTokenExchange } from './api/types';
25
+ export * from './lib/enact-direct';
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
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
+ // Security
19
+ export * from './security/security';
20
+ export { verifyTool, shouldExecuteTool, VERIFICATION_POLICIES } from './security/sign';
21
+ export * from './security/verification-enforcer';
22
+ // Services
23
+ export * from './services/McpCoreService';
24
+ // Web
25
+ export * from './web/env-manager-server';
26
+ // API
27
+ export * from './api/enact-api';
28
+ // Lib
29
+ export * from './lib/enact-direct';
@@ -0,0 +1,156 @@
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
+ verificationPolicy?: "permissive" | "enterprise" | "paranoid";
16
+ defaultTimeout?: string;
17
+ });
18
+ /**
19
+ * Execute a tool by name with inputs
20
+ *
21
+ * @param name - Tool name (e.g., "my-org/data-processor")
22
+ * @param inputs - Input parameters for the tool
23
+ * @param options - Execution options
24
+ * @returns Execution result
25
+ */
26
+ executeToolByName(name: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
27
+ /**
28
+ * Search for tools matching a query
29
+ *
30
+ * @param options - Search options
31
+ * @returns Array of matching tools
32
+ */
33
+ searchTools(options: ToolSearchOptions): Promise<EnactTool[]>;
34
+ /**
35
+ * Get detailed information about a specific tool
36
+ *
37
+ * @param name - Tool name
38
+ * @param version - Optional specific version
39
+ * @returns Tool information or null if not found
40
+ */
41
+ getToolInfo(name: string, version?: string): Promise<EnactTool | null>;
42
+ /**
43
+ * Verify a tool's cryptographic signatures
44
+ *
45
+ * @param name - Tool name
46
+ * @param policy - Verification policy
47
+ * @returns Verification result
48
+ */
49
+ verifyTool(name: string, policy?: "permissive" | "enterprise" | "paranoid"): Promise<{
50
+ verified: boolean;
51
+ signatures: any[];
52
+ policy: string;
53
+ errors?: string[];
54
+ }>;
55
+ /**
56
+ * Execute a tool from raw YAML definition
57
+ *
58
+ * @param toolYaml - YAML tool definition
59
+ * @param inputs - Input parameters
60
+ * @param options - Execution options
61
+ * @returns Execution result
62
+ */
63
+ executeRawTool(toolYaml: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
64
+ /**
65
+ * Check if a tool exists in the registry
66
+ *
67
+ * @param name - Tool name
68
+ * @returns True if tool exists
69
+ */
70
+ toolExists(name: string): Promise<boolean>;
71
+ /**
72
+ * Get all tools with optional filtering
73
+ *
74
+ * @param options - Filter options
75
+ * @returns Array of tools
76
+ */
77
+ getTools(options?: {
78
+ limit?: number;
79
+ offset?: number;
80
+ tags?: string[];
81
+ author?: string;
82
+ }): Promise<EnactTool[]>;
83
+ /**
84
+ * Get tools by specific tags
85
+ *
86
+ * @param tags - Array of tags to filter by
87
+ * @param limit - Maximum number of results
88
+ * @returns Array of tools
89
+ */
90
+ getToolsByTags(tags: string[], limit?: number): Promise<EnactTool[]>;
91
+ /**
92
+ * Get tools by a specific author
93
+ *
94
+ * @param author - Author name
95
+ * @param limit - Maximum number of results
96
+ * @returns Array of tools
97
+ */
98
+ getToolsByAuthor(author: string, limit?: number): Promise<EnactTool[]>;
99
+ /**
100
+ * Get the current status of the Enact core
101
+ *
102
+ * @returns Status information
103
+ */
104
+ getStatus(): Promise<{
105
+ executionProvider: string;
106
+ apiUrl: string;
107
+ verificationPolicy: string;
108
+ defaultTimeout: string;
109
+ authenticated: boolean;
110
+ }>;
111
+ /**
112
+ * Set authentication token
113
+ *
114
+ * @param token - Authentication token
115
+ */
116
+ setAuthToken(token: string): void;
117
+ /**
118
+ * Get authentication status
119
+ *
120
+ * @returns Authentication status
121
+ */
122
+ getAuthStatus(): Promise<{
123
+ authenticated: boolean;
124
+ user?: string;
125
+ server?: string;
126
+ }>;
127
+ /**
128
+ * Publish a tool (requires authentication)
129
+ *
130
+ * @param tool - Tool definition to publish
131
+ * @returns Publication result
132
+ */
133
+ publishTool(tool: EnactTool): Promise<{
134
+ success: boolean;
135
+ message: string;
136
+ }>;
137
+ }
138
+ export declare const enactDirect: EnactDirect;
139
+ export declare const executeToolByName: (name: string, inputs?: Record<string, any>, options?: ToolExecuteOptions) => Promise<ExecutionResult>;
140
+ export declare const searchTools: (options: ToolSearchOptions) => Promise<EnactTool[]>;
141
+ export declare const getToolInfo: (name: string, version?: string) => Promise<EnactTool | null>;
142
+ export declare const executeRawTool: (toolYaml: string, inputs?: Record<string, any>, options?: ToolExecuteOptions) => Promise<ExecutionResult>;
143
+ export declare const getToolsByTags: (tags: string[], limit?: number) => Promise<EnactTool[]>;
144
+ export declare const getToolsByAuthor: (author: string, limit?: number) => Promise<EnactTool[]>;
145
+ export declare const toolExists: (name: string) => Promise<boolean>;
146
+ export declare const getAuthStatus: () => Promise<{
147
+ authenticated: boolean;
148
+ user?: string;
149
+ server?: string;
150
+ }>;
151
+ export declare const publishTool: (tool: EnactTool) => Promise<{
152
+ success: boolean;
153
+ message: string;
154
+ }>;
155
+ export { EnactCore, type ToolSearchOptions, type ToolExecuteOptions, } from "../core/EnactCore";
156
+ export type { EnactTool, ExecutionResult } from "../types";
@@ -0,0 +1,158 @@
1
+ // src/lib/enact-direct.ts - Library interface for direct usage by MCP servers
2
+ import { EnactCore, } from "../core/EnactCore";
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 class EnactDirect {
10
+ constructor(options = {}) {
11
+ this.core = new EnactCore({
12
+ apiUrl: options.apiUrl || process.env.ENACT_API_URL || "https://enact.tools",
13
+ supabaseUrl: options.supabaseUrl ||
14
+ process.env.ENACT_SUPABASE_URL ||
15
+ "https://xjnhhxwxovjifdxdwzih.supabase.co",
16
+ executionProvider: "direct",
17
+ authToken: options.authToken || process.env.ENACT_AUTH_TOKEN,
18
+ verificationPolicy: options.verificationPolicy || "permissive",
19
+ defaultTimeout: options.defaultTimeout || "30s",
20
+ });
21
+ }
22
+ /**
23
+ * Execute a tool by name with inputs
24
+ *
25
+ * @param name - Tool name (e.g., "my-org/data-processor")
26
+ * @param inputs - Input parameters for the tool
27
+ * @param options - Execution options
28
+ * @returns Execution result
29
+ */
30
+ async executeToolByName(name, inputs = {}, options = {}) {
31
+ return this.core.executeToolByName(name, inputs, options);
32
+ }
33
+ /**
34
+ * Search for tools matching a query
35
+ *
36
+ * @param options - Search options
37
+ * @returns Array of matching tools
38
+ */
39
+ async searchTools(options) {
40
+ return this.core.searchTools(options);
41
+ }
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
+ async getToolInfo(name, version) {
50
+ return this.core.getToolInfo(name, version);
51
+ }
52
+ /**
53
+ * Verify a tool's cryptographic signatures
54
+ *
55
+ * @param name - Tool name
56
+ * @param policy - Verification policy
57
+ * @returns Verification result
58
+ */
59
+ async verifyTool(name, policy) {
60
+ return this.core.verifyTool(name, policy);
61
+ }
62
+ /**
63
+ * Execute a tool from raw YAML definition
64
+ *
65
+ * @param toolYaml - YAML tool definition
66
+ * @param inputs - Input parameters
67
+ * @param options - Execution options
68
+ * @returns Execution result
69
+ */
70
+ async executeRawTool(toolYaml, inputs = {}, options = {}) {
71
+ return this.core.executeRawTool(toolYaml, inputs, options);
72
+ }
73
+ /**
74
+ * Check if a tool exists in the registry
75
+ *
76
+ * @param name - Tool name
77
+ * @returns True if tool exists
78
+ */
79
+ async toolExists(name) {
80
+ return this.core.toolExists(name);
81
+ }
82
+ /**
83
+ * Get all tools with optional filtering
84
+ *
85
+ * @param options - Filter options
86
+ * @returns Array of tools
87
+ */
88
+ async getTools(options = {}) {
89
+ return this.core.getTools(options);
90
+ }
91
+ /**
92
+ * Get tools by specific tags
93
+ *
94
+ * @param tags - Array of tags to filter by
95
+ * @param limit - Maximum number of results
96
+ * @returns Array of tools
97
+ */
98
+ async getToolsByTags(tags, limit = 20) {
99
+ return this.core.getToolsByTags(tags, limit);
100
+ }
101
+ /**
102
+ * Get tools by a specific author
103
+ *
104
+ * @param author - Author name
105
+ * @param limit - Maximum number of results
106
+ * @returns Array of tools
107
+ */
108
+ async getToolsByAuthor(author, limit = 20) {
109
+ return this.core.getToolsByAuthor(author, limit);
110
+ }
111
+ /**
112
+ * Get the current status of the Enact core
113
+ *
114
+ * @returns Status information
115
+ */
116
+ async getStatus() {
117
+ return this.core.getStatus();
118
+ }
119
+ /**
120
+ * Set authentication token
121
+ *
122
+ * @param token - Authentication token
123
+ */
124
+ setAuthToken(token) {
125
+ this.core.setAuthToken(token);
126
+ }
127
+ /**
128
+ * Get authentication status
129
+ *
130
+ * @returns Authentication status
131
+ */
132
+ async getAuthStatus() {
133
+ return this.core.getAuthStatus();
134
+ }
135
+ /**
136
+ * Publish a tool (requires authentication)
137
+ *
138
+ * @param tool - Tool definition to publish
139
+ * @returns Publication result
140
+ */
141
+ async publishTool(tool) {
142
+ return this.core.publishTool(tool);
143
+ }
144
+ }
145
+ // Create and export a default instance
146
+ export const enactDirect = new EnactDirect();
147
+ // Export convenience functions using the default instance
148
+ export const executeToolByName = (name, inputs = {}, options = {}) => enactDirect.executeToolByName(name, inputs, options);
149
+ export const searchTools = (options) => enactDirect.searchTools(options);
150
+ export const getToolInfo = (name, version) => enactDirect.getToolInfo(name, version);
151
+ export const executeRawTool = (toolYaml, inputs = {}, options = {}) => enactDirect.executeRawTool(toolYaml, inputs, options);
152
+ export const getToolsByTags = (tags, limit = 20) => enactDirect.getToolsByTags(tags, limit);
153
+ export const getToolsByAuthor = (author, limit = 20) => enactDirect.getToolsByAuthor(author, limit);
154
+ export const toolExists = (name) => enactDirect.toolExists(name);
155
+ export const getAuthStatus = () => enactDirect.getAuthStatus();
156
+ export const publishTool = (tool) => enactDirect.publishTool(tool);
157
+ // Also export the core for advanced usage
158
+ export { EnactCore, } from "../core/EnactCore";
@@ -0,0 +1 @@
1
+ export * from './enact-direct';
@@ -0,0 +1 @@
1
+ export * from './enact-direct';
@@ -0,0 +1,3 @@
1
+ export * from './security';
2
+ export * from './sign';
3
+ export * from './verification-enforcer';
@@ -0,0 +1,3 @@
1
+ export * from './security';
2
+ export * from './sign';
3
+ export * from './verification-enforcer';
@@ -0,0 +1,23 @@
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>;