@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/api/enact-api.js
DELETED
|
@@ -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
|
-
}
|
package/dist/api/index.d.ts
DELETED
package/dist/api/index.js
DELETED
package/dist/api/types.d.ts
DELETED
|
@@ -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 {};
|
package/dist/constants.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared constants for Enact CLI
|
|
3
|
-
*/
|
|
4
|
-
export declare const DEFAULT_FRONTEND_URL = "https://enact.tools";
|
|
5
|
-
export declare const DEFAULT_API_URL = "https://xjnhhxwxovjifdxdwzih.supabase.co";
|
|
6
|
-
export declare const ENV_FRONTEND_URL = "ENACT_FRONTEND_URL";
|
|
7
|
-
export declare const ENV_API_URL = "ENACT_API_URL";
|
package/dist/constants.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared constants for Enact CLI
|
|
3
|
-
*/
|
|
4
|
-
// Frontend URL - used for OAuth redirects, registry browsing, documentation links
|
|
5
|
-
export const DEFAULT_FRONTEND_URL = "https://enact.tools";
|
|
6
|
-
// Backend API URL - used for all API calls (search, publish, etc.)
|
|
7
|
-
export const DEFAULT_API_URL = "https://xjnhhxwxovjifdxdwzih.supabase.co";
|
|
8
|
-
// Environment variable names for overriding defaults
|
|
9
|
-
export const ENV_FRONTEND_URL = "ENACT_FRONTEND_URL";
|
|
10
|
-
export const ENV_API_URL = "ENACT_API_URL";
|