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