@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,428 +0,0 @@
1
- import { getFrontendUrl, getApiUrl } from "../utils/config";
2
- export class EnactApiClient {
3
- constructor(baseUrl, supabaseUrl) {
4
- this.baseUrl = baseUrl.replace(/\/$/, ""); // Remove trailing slash
5
- this.supabaseUrl = supabaseUrl.replace(/\/$/, "");
6
- }
7
- /**
8
- * Create API client with config-based URLs
9
- */
10
- static async create(baseUrl, supabaseUrl) {
11
- const frontendUrl = baseUrl || await getFrontendUrl();
12
- const apiUrl = supabaseUrl || await getApiUrl();
13
- return new EnactApiClient(frontendUrl, apiUrl);
14
- }
15
- // Helper method to make authenticated requests
16
- async makeRequest(endpoint, options = {}, token, tokenType = "jwt") {
17
- const url = endpoint.startsWith("http")
18
- ? endpoint
19
- : `${this.supabaseUrl}${endpoint}`;
20
- const headers = {
21
- "Content-Type": "application/json",
22
- ...options.headers,
23
- };
24
- // Add authentication headers if token provided
25
- if (token) {
26
- if (tokenType === "jwt") {
27
- headers.Authorization = `Bearer ${token}`;
28
- }
29
- else {
30
- headers["X-API-Key"] = token;
31
- }
32
- }
33
- const response = await fetch(url, {
34
- ...options,
35
- headers,
36
- });
37
- if (!response.ok) {
38
- const errorData = await response
39
- .json()
40
- .catch(() => ({ error: "Unknown error" }));
41
- throw new EnactApiError(`${errorData.error || response.statusText}`, response.status, endpoint);
42
- }
43
- const responseData = await response.json();
44
- // Debug logging to help identify response structure issues
45
- if ((process.env.NODE_ENV === "development" || process.env.DEBUG) && !process.env.ENACT_SILENT) {
46
- console.error(`API Response for ${endpoint}:`, responseData);
47
- }
48
- return responseData;
49
- }
50
- // =================
51
- // PUBLIC ENDPOINTS
52
- // =================
53
- /**
54
- * Get all tools (public, no auth required)
55
- */
56
- async getTools(params) {
57
- const searchParams = new URLSearchParams();
58
- if (params?.limit)
59
- searchParams.set("limit", params.limit.toString());
60
- if (params?.offset)
61
- searchParams.set("offset", params.offset.toString());
62
- if (params?.tags)
63
- searchParams.set("tags", params.tags.join(","));
64
- if (params?.author)
65
- searchParams.set("author", params.author);
66
- const query = searchParams.toString();
67
- const endpoint = `/functions/v1/tools${query ? `?${query}` : ""}`;
68
- const response = await this.makeRequest(endpoint);
69
- // Handle different response structures
70
- if (Array.isArray(response)) {
71
- return response;
72
- }
73
- else if (response.data && Array.isArray(response.data)) {
74
- return response.data;
75
- }
76
- else if (response.tools && Array.isArray(response.tools)) {
77
- return response.tools;
78
- }
79
- else {
80
- console.warn("Unexpected response structure for getTools:", response);
81
- return [];
82
- }
83
- }
84
- /**
85
- * Get specific tool details (public, no auth required)
86
- */
87
- async getTool(name) {
88
- const endpoint = `/functions/v1/tools/${encodeURIComponent(name)}`;
89
- return this.makeRequest(endpoint);
90
- }
91
- /**
92
- * Get tool usage statistics (public, no auth required)
93
- */
94
- async getToolUsage(name) {
95
- const endpoint = `/functions/v1/tools/${encodeURIComponent(name)}/usage`;
96
- return this.makeRequest(endpoint);
97
- }
98
- /**
99
- * Log tool usage (public, no auth required)
100
- */
101
- async logToolUsage(name, usage) {
102
- const endpoint = `/functions/v1/tools/${encodeURIComponent(name)}/usage`;
103
- return this.makeRequest(endpoint, {
104
- method: "POST",
105
- body: JSON.stringify(usage),
106
- });
107
- }
108
- /**
109
- * Search tools with semantic/text search (public, no auth required)
110
- */
111
- async searchTools(query) {
112
- const endpoint = "/functions/v1/tools-search";
113
- try {
114
- // Log the request for debugging
115
- if ((process.env.NODE_ENV === "development" || process.env.DEBUG) && !process.env.ENACT_SILENT) {
116
- console.error(`Search request to ${endpoint}:`, JSON.stringify(query, null, 2));
117
- }
118
- const response = await this.makeRequest(endpoint, {
119
- method: "POST",
120
- body: JSON.stringify(query),
121
- });
122
- // Handle different response structures
123
- if (Array.isArray(response)) {
124
- return response;
125
- }
126
- else if (response.data && Array.isArray(response.data)) {
127
- return response.data;
128
- }
129
- else if (response.results && Array.isArray(response.results)) {
130
- return response.results;
131
- }
132
- else if (response.tools && Array.isArray(response.tools)) {
133
- return response.tools;
134
- }
135
- else {
136
- console.warn("Unexpected response structure for searchTools:", response);
137
- return [];
138
- }
139
- }
140
- catch (error) {
141
- // Enhanced error logging
142
- if (error instanceof EnactApiError) {
143
- console.error(`Search API error (${error.statusCode}): ${error.message}`);
144
- console.error(`Endpoint: ${error.endpoint}`);
145
- // If it's a 502 error, provide more specific guidance
146
- if (error.statusCode === 502) {
147
- console.error("502 Bad Gateway error - this usually indicates:");
148
- console.error("• The API server is temporarily unavailable");
149
- console.error("• The search service is overloaded");
150
- console.error("• Network connectivity issues");
151
- console.error("• Try again in a few moments");
152
- }
153
- }
154
- else {
155
- console.error("Unexpected search error:", error);
156
- }
157
- // Re-throw the error
158
- throw error;
159
- }
160
- }
161
- // ===================
162
- // AUTHENTICATED ENDPOINTS
163
- // ===================
164
- /**
165
- * Publish/create new tool (requires authentication)
166
- */
167
- async publishTool(tool, token, tokenType = "cli") {
168
- const endpoint = "/functions/v1/tools";
169
- return this.makeRequest(endpoint, {
170
- method: "POST",
171
- body: JSON.stringify(tool),
172
- }, token, tokenType);
173
- }
174
- /**
175
- * Update existing tool (requires authentication, must be owner)
176
- */
177
- async updateTool(name, tool, token, tokenType = "cli") {
178
- const endpoint = `/functions/v1/tools/${encodeURIComponent(name)}`;
179
- return this.makeRequest(endpoint, {
180
- method: "PUT",
181
- body: JSON.stringify(tool),
182
- }, token, tokenType);
183
- }
184
- /**
185
- * Delete tool (requires authentication, must be owner)
186
- */
187
- async deleteTool(name, token, tokenType = "cli") {
188
- const endpoint = `/functions/v1/tools/${encodeURIComponent(name)}`;
189
- return this.makeRequest(endpoint, {
190
- method: "DELETE",
191
- }, token, tokenType);
192
- }
193
- /**
194
- * Create new CLI token (requires JWT authentication)
195
- */
196
- async createCLIToken(tokenData, jwtToken) {
197
- const endpoint = "/functions/v1/cli-token";
198
- return this.makeRequest(endpoint, {
199
- method: "POST",
200
- body: JSON.stringify(tokenData),
201
- }, jwtToken, "jwt");
202
- }
203
- /**
204
- * List user's CLI tokens (requires JWT authentication)
205
- */
206
- async getCLITokens(jwtToken) {
207
- const endpoint = "/functions/v1/cli-token";
208
- return this.makeRequest(endpoint, {
209
- method: "GET",
210
- }, jwtToken, "jwt");
211
- }
212
- /**
213
- * Delete CLI token (requires JWT authentication, must be owner)
214
- */
215
- async deleteCLIToken(tokenId, jwtToken) {
216
- const endpoint = `/functions/v1/cli-token/${tokenId}`;
217
- return this.makeRequest(endpoint, {
218
- method: "DELETE",
219
- }, jwtToken, "jwt");
220
- }
221
- /**
222
- * Exchange OAuth authorization code for access token
223
- */
224
- async exchangeOAuthCode(oauthData) {
225
- const endpoint = "/functions/v1/cli-oauth";
226
- return this.makeRequest(endpoint, {
227
- method: "POST",
228
- body: JSON.stringify(oauthData),
229
- });
230
- }
231
- /**
232
- * Generate embeddings for tools (requires authentication)
233
- */
234
- async generateEmbeddings(data, token, tokenType = "cli") {
235
- const endpoint = "/functions/v1/generate-embeddings";
236
- return this.makeRequest(endpoint, {
237
- method: "POST",
238
- body: JSON.stringify(data),
239
- }, token, tokenType);
240
- }
241
- // ===================
242
- // CONVENIENCE METHODS
243
- // ===================
244
- /**
245
- * Check if a tool exists
246
- */
247
- async toolExists(name) {
248
- try {
249
- await this.getTool(name);
250
- return true;
251
- }
252
- catch (error) {
253
- if (error instanceof Error && error.message.includes("404")) {
254
- return false;
255
- }
256
- throw error;
257
- }
258
- }
259
- /**
260
- * Publish or update tool based on existence
261
- */
262
- async publishOrUpdateTool(tool, token, tokenType = "cli") {
263
- let exists;
264
- try {
265
- exists = await this.toolExists(tool.name);
266
- }
267
- catch (error) {
268
- exists = false;
269
- }
270
- if (exists) {
271
- const result = await this.updateTool(tool.name, tool, token, tokenType);
272
- return { isUpdate: true, result };
273
- }
274
- else {
275
- const result = await this.publishTool(tool, token, tokenType);
276
- return { isUpdate: false, result };
277
- }
278
- }
279
- /**
280
- * Search tools by tags
281
- */
282
- async getToolsByTags(tags, limit = 20) {
283
- return this.searchTools({
284
- query: tags.join(" "),
285
- tags,
286
- limit,
287
- });
288
- }
289
- /**
290
- * Get tools by author
291
- */
292
- async getToolsByAuthor(author, limit = 20) {
293
- return this.getTools({
294
- author,
295
- limit,
296
- });
297
- }
298
- /**
299
- * Get a user's public key
300
- */
301
- async getUserPublicKey(userId) {
302
- const url = `${this.supabaseUrl}/functions/v1/tools/user/public-key/${userId}`;
303
- const headers = {
304
- Accept: "application/json",
305
- "Content-Type": "application/json",
306
- };
307
- try {
308
- const response = await fetch(url, {
309
- method: "GET",
310
- headers,
311
- });
312
- if (!response.ok) {
313
- const errorText = await response.text();
314
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
315
- try {
316
- const errorJson = JSON.parse(errorText);
317
- if (errorJson.message) {
318
- errorMessage = errorJson.message;
319
- }
320
- else if (errorJson.error) {
321
- errorMessage = errorJson.error;
322
- }
323
- }
324
- catch {
325
- // If we can't parse JSON, stick with the original error message
326
- }
327
- throw new EnactApiError(errorMessage, response.status);
328
- }
329
- const data = await response.json();
330
- return data;
331
- }
332
- catch (error) {
333
- if (error instanceof EnactApiError) {
334
- throw error;
335
- }
336
- // Handle network errors
337
- if (error instanceof Error) {
338
- if (error.message.includes("fetch")) {
339
- throw new EnactApiError("Network error: Could not connect to Enact API", 0);
340
- }
341
- throw new EnactApiError(error.message, 0);
342
- }
343
- throw new EnactApiError("Unknown error occurred", 0);
344
- }
345
- }
346
- async signTool(toolId, payload, token, tokenType = "cli") {
347
- const endpoint = `/functions/v1/tools/${encodeURIComponent(toolId)}/signatures`;
348
- return this.makeRequest(endpoint, {
349
- method: "POST",
350
- body: JSON.stringify(payload),
351
- }, token, tokenType);
352
- }
353
- // ===================
354
- // OAUTH FLOW HELPERS
355
- // ===================
356
- /**
357
- * Generate OAuth authorization URL
358
- */
359
- generateOAuthUrl(options) {
360
- const params = new URLSearchParams({
361
- response_type: "code",
362
- client_id: options.clientId,
363
- redirect_uri: options.redirectUri,
364
- scope: options.scope,
365
- state: options.state,
366
- code_challenge: options.codeChallenge,
367
- code_challenge_method: options.codeChallengeMethod,
368
- });
369
- return `${this.baseUrl}/auth/cli/oauth?${params.toString()}`;
370
- }
371
- /**
372
- * Validate tool definition before publishing
373
- */
374
- validateTool(tool) {
375
- const errors = [];
376
- if (!tool.name || typeof tool.name !== "string") {
377
- errors.push("Tool name is required and must be a string");
378
- }
379
- else if (!/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_\/-]+$/.test(tool.name)) {
380
- errors.push("Tool name must follow hierarchical format: org/package/tool-name");
381
- }
382
- if (!tool.description || typeof tool.description !== "string") {
383
- errors.push("Tool description is required and must be a string");
384
- }
385
- if (!tool.command || typeof tool.command !== "string") {
386
- errors.push("Tool command is required and must be a string");
387
- }
388
- if (tool.timeout && typeof tool.timeout === "string") {
389
- if (!/^\d+[smh]$/.test(tool.timeout)) {
390
- errors.push('Timeout must be in Go duration format (e.g., "30s", "5m", "1h")');
391
- }
392
- }
393
- if (tool.tags && !Array.isArray(tool.tags)) {
394
- errors.push("Tags must be an array of strings");
395
- }
396
- if (tool.inputSchema && typeof tool.inputSchema !== "object") {
397
- errors.push("inputSchema must be a valid JSON Schema object");
398
- }
399
- if (tool.outputSchema && typeof tool.outputSchema !== "object") {
400
- errors.push("outputSchema must be a valid JSON Schema object");
401
- }
402
- return {
403
- valid: errors.length === 0,
404
- errors,
405
- };
406
- }
407
- }
408
- // Export a default instance factory
409
- export async function createDefaultApiClient() {
410
- return await EnactApiClient.create();
411
- }
412
- // Keep backward compatibility with sync usage
413
- export const enactApi = new EnactApiClient("https://enact.tools", "https://xjnhhxwxovjifdxdwzih.supabase.co");
414
- // Export error types for better error handling
415
- export class EnactApiError extends Error {
416
- constructor(message, statusCode, endpoint) {
417
- super(message);
418
- this.statusCode = statusCode;
419
- this.endpoint = endpoint;
420
- this.name = "EnactApiError";
421
- }
422
- }
423
- // Helper function to create API client with custom configuration
424
- export function createEnactApiClient(baseUrl, supabaseUrl) {
425
- const defaultFrontend = "https://enact.tools";
426
- const defaultApi = "https://xjnhhxwxovjifdxdwzih.supabase.co";
427
- return new EnactApiClient(baseUrl || defaultFrontend, supabaseUrl || defaultApi);
428
- }
@@ -1,2 +0,0 @@
1
- export * from './enact-api';
2
- export * from './types';
package/dist/api/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './enact-api';
2
- export * from './types';
@@ -1,103 +0,0 @@
1
- export interface EnactToolDefinition {
2
- name: string;
3
- description: string;
4
- verified?: boolean;
5
- command: string;
6
- from?: string;
7
- version?: string;
8
- timeout?: string;
9
- tags?: string[];
10
- inputSchema?: any;
11
- outputSchema?: any;
12
- examples?: any[];
13
- annotations?: {
14
- title?: string;
15
- readOnlyHint?: boolean;
16
- destructiveHint?: boolean;
17
- idempotentHint?: boolean;
18
- openWorldHint?: boolean;
19
- };
20
- env?: Record<string, {
21
- description: string;
22
- source?: string;
23
- required: boolean;
24
- default?: string;
25
- }>;
26
- resources?: {
27
- memory?: string;
28
- gpu?: string;
29
- disk?: string;
30
- };
31
- signature?: {
32
- algorithm: string;
33
- type: string;
34
- signer: string;
35
- created: string;
36
- value: string;
37
- role?: string;
38
- };
39
- signatures?: {
40
- signer: string;
41
- algorithm: string;
42
- type: string;
43
- value: string;
44
- created: string;
45
- role?: string;
46
- }[];
47
- raw_content?: string;
48
- namespace?: string;
49
- enact?: string;
50
- [key: string]: any;
51
- }
52
- export interface ToolSearchQuery {
53
- query: string;
54
- limit?: number;
55
- tags?: string[];
56
- format?: string;
57
- }
58
- export interface ToolUsage {
59
- action: "view" | "download" | "execute";
60
- metadata?: any;
61
- }
62
- export interface CLITokenCreate {
63
- name?: string;
64
- }
65
- export interface OAuthTokenExchange {
66
- grant_type: "authorization_code";
67
- code: string;
68
- redirect_uri: string;
69
- client_id: string;
70
- code_verifier: string;
71
- }
72
- export interface ApiResponse<T = any> {
73
- success: boolean;
74
- data?: T;
75
- error?: string;
76
- }
77
- export interface VerificationPolicy {
78
- minimumSignatures?: number;
79
- trustedSigners?: string[];
80
- allowedAlgorithms?: string[];
81
- }
82
- export interface EnactExecOptions {
83
- help?: boolean;
84
- input?: string;
85
- params?: string;
86
- timeout?: string;
87
- dry?: boolean;
88
- verbose?: boolean;
89
- force?: boolean;
90
- dangerouslySkipVerification?: boolean;
91
- mount?: string;
92
- }
93
- export interface ToolSignaturePayload {
94
- algorithm: "sha256";
95
- created: string;
96
- key_id: string;
97
- public_key: string;
98
- role: "author";
99
- signer: string;
100
- timestamp: number;
101
- type: "ecdsa-p256";
102
- value: string;
103
- }
package/dist/api/types.js DELETED
@@ -1 +0,0 @@
1
- export {};