@enactprotocol/shared 1.0.14 → 1.2.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/dist/api/enact-api.js +2 -2
- package/dist/api/types.d.ts +10 -3
- package/dist/core/DaggerExecutionProvider.d.ts +1 -1
- package/dist/core/DaggerExecutionProvider.js +23 -19
- package/dist/core/EnactCore.d.ts +36 -19
- package/dist/core/EnactCore.js +157 -219
- package/dist/core/NativeExecutionProvider.d.ts +9 -0
- package/dist/core/NativeExecutionProvider.js +16 -0
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -4
- package/dist/lib/enact-direct.d.ts +0 -15
- package/dist/lib/enact-direct.js +0 -11
- package/dist/security/sign.d.ts +5 -5
- package/dist/security/sign.js +247 -113
- package/dist/security/verification-enforcer.d.ts +12 -0
- package/dist/security/verification-enforcer.js +26 -3
- package/dist/services/McpCoreService.d.ts +0 -12
- package/dist/services/McpCoreService.js +0 -9
- package/dist/types.d.ts +5 -4
- package/dist/utils/config.js +1 -1
- package/package.json +3 -6
- package/src/api/enact-api.ts +2 -2
- package/src/api/types.ts +11 -4
- package/src/core/DaggerExecutionProvider.ts +26 -13
- package/src/core/EnactCore.ts +226 -270
- package/src/index.ts +0 -5
- package/src/lib/enact-direct.ts +0 -21
- package/src/services/McpCoreService.ts +0 -20
- package/src/types.ts +10 -12
- package/src/utils/config.ts +1 -1
- package/src/security/index.ts +0 -3
- package/src/security/security.ts +0 -188
- package/src/security/sign.ts +0 -797
- package/src/security/verification-enforcer.ts +0 -268
package/dist/api/enact-api.js
CHANGED
|
@@ -33,7 +33,7 @@ export class EnactApiClient {
|
|
|
33
33
|
}
|
|
34
34
|
const responseData = await response.json();
|
|
35
35
|
// Debug logging to help identify response structure issues
|
|
36
|
-
if (process.env.NODE_ENV === "development" || process.env.DEBUG) {
|
|
36
|
+
if ((process.env.NODE_ENV === "development" || process.env.DEBUG) && !process.env.ENACT_SILENT) {
|
|
37
37
|
console.error(`API Response for ${endpoint}:`, responseData);
|
|
38
38
|
}
|
|
39
39
|
return responseData;
|
|
@@ -103,7 +103,7 @@ export class EnactApiClient {
|
|
|
103
103
|
const endpoint = "/functions/v1/tools-search";
|
|
104
104
|
try {
|
|
105
105
|
// Log the request for debugging
|
|
106
|
-
if (process.env.NODE_ENV === "development" || process.env.DEBUG) {
|
|
106
|
+
if ((process.env.NODE_ENV === "development" || process.env.DEBUG) && !process.env.ENACT_SILENT) {
|
|
107
107
|
console.error(`Search request to ${endpoint}:`, JSON.stringify(query, null, 2));
|
|
108
108
|
}
|
|
109
109
|
const response = await this.makeRequest(endpoint, {
|
package/dist/api/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface EnactToolDefinition {
|
|
|
2
2
|
name: string;
|
|
3
3
|
description: string;
|
|
4
4
|
command: string;
|
|
5
|
+
from?: string;
|
|
5
6
|
version?: string;
|
|
6
7
|
timeout?: string;
|
|
7
8
|
tags?: string[];
|
|
@@ -34,7 +35,14 @@ export interface EnactToolDefinition {
|
|
|
34
35
|
value: string;
|
|
35
36
|
role?: string;
|
|
36
37
|
};
|
|
37
|
-
signatures?:
|
|
38
|
+
signatures?: {
|
|
39
|
+
signer: string;
|
|
40
|
+
algorithm: string;
|
|
41
|
+
type: string;
|
|
42
|
+
value: string;
|
|
43
|
+
created: string;
|
|
44
|
+
role?: string;
|
|
45
|
+
}[];
|
|
38
46
|
raw_content?: string;
|
|
39
47
|
namespace?: string;
|
|
40
48
|
enact?: string;
|
|
@@ -77,7 +85,6 @@ export interface EnactExecOptions {
|
|
|
77
85
|
timeout?: string;
|
|
78
86
|
dry?: boolean;
|
|
79
87
|
verbose?: boolean;
|
|
80
|
-
skipVerification?: boolean;
|
|
81
|
-
verifyPolicy?: string;
|
|
82
88
|
force?: boolean;
|
|
89
|
+
dangerouslySkipVerification?: boolean;
|
|
83
90
|
}
|
|
@@ -67,7 +67,7 @@ export declare class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
67
67
|
verbose?: boolean;
|
|
68
68
|
showSpinner?: boolean;
|
|
69
69
|
streamOutput?: boolean;
|
|
70
|
-
}): Promise<CommandResult>;
|
|
70
|
+
}, tool?: EnactTool): Promise<CommandResult>;
|
|
71
71
|
/**
|
|
72
72
|
* Execute command using Dagger connect with proper session management
|
|
73
73
|
*/
|
|
@@ -294,7 +294,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
294
294
|
logger.warn(`Attempt ${attempt}: Engine unhealthy, resetting...`);
|
|
295
295
|
await this.resetEngineContainer();
|
|
296
296
|
}
|
|
297
|
-
const result = await this.executeCommand(tool.command, inputs, environment, tool.timeout);
|
|
297
|
+
const result = await this.executeCommand(tool.command, inputs, environment, tool.timeout, undefined, tool);
|
|
298
298
|
logger.debug(`Command result: exitCode=${result.exitCode}, stdout length=${result.stdout?.length || 0}, stderr length=${result.stderr?.length || 0}`);
|
|
299
299
|
const output = this.parseOutput(result.stdout, tool);
|
|
300
300
|
return {
|
|
@@ -389,7 +389,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
389
389
|
}
|
|
390
390
|
return "EXECUTION_ERROR";
|
|
391
391
|
}
|
|
392
|
-
async executeCommand(command, inputs, environment, timeout, options) {
|
|
392
|
+
async executeCommand(command, inputs, environment, timeout, options, tool) {
|
|
393
393
|
const verbose = options?.verbose ?? false;
|
|
394
394
|
const showSpinner = options?.showSpinner ?? false;
|
|
395
395
|
// Create abort controller for this execution
|
|
@@ -410,16 +410,18 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
410
410
|
// Substitute template variables in command (Enact Protocol style)
|
|
411
411
|
const substitutedCommand = this.substituteCommandVariables(command, inputs);
|
|
412
412
|
if (verbose) {
|
|
413
|
+
// Determine which container image to use - prefer tool's 'from' field over default baseImage
|
|
414
|
+
const containerImage = tool?.from || this.options.baseImage;
|
|
413
415
|
try {
|
|
414
416
|
const pc = require("picocolors");
|
|
415
417
|
console.error(pc.cyan("\n🐳 Executing Enact command in Dagger container:"));
|
|
416
418
|
console.error(pc.white(substitutedCommand));
|
|
417
|
-
console.error(pc.gray(`
|
|
419
|
+
console.error(pc.gray(`Container image: ${containerImage}${tool?.from ? ' (from tool.from)' : ' (default baseImage)'}`));
|
|
418
420
|
}
|
|
419
421
|
catch (e) {
|
|
420
422
|
console.error("\n🐳 Executing Enact command in Dagger container:");
|
|
421
423
|
console.error(substitutedCommand);
|
|
422
|
-
console.error(`
|
|
424
|
+
console.error(`Container image: ${containerImage}${tool?.from ? ' (from tool.from)' : ' (default baseImage)'}`);
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
// Parse and apply timeout with engine timeout consideration
|
|
@@ -428,7 +430,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
428
430
|
logger.debug(`Parsed timeout: ${effectiveTimeout}ms (command: ${timeoutMs}ms, engine: ${this.options.engineTimeout}ms)`);
|
|
429
431
|
// Execute command with enhanced error handling and timeout management
|
|
430
432
|
const result = await Promise.race([
|
|
431
|
-
this.executeWithConnect(substitutedCommand, environment, inputs),
|
|
433
|
+
this.executeWithConnect(substitutedCommand, environment, inputs, tool),
|
|
432
434
|
this.createTimeoutPromise(effectiveTimeout),
|
|
433
435
|
]);
|
|
434
436
|
if (spinner) {
|
|
@@ -462,7 +464,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
462
464
|
/**
|
|
463
465
|
* Execute command using Dagger connect with proper session management
|
|
464
466
|
*/
|
|
465
|
-
async executeWithConnect(command, environment, inputs) {
|
|
467
|
+
async executeWithConnect(command, environment, inputs, tool) {
|
|
466
468
|
return new Promise((resolve, reject) => {
|
|
467
469
|
// Setup abort handling
|
|
468
470
|
const abortHandler = () => {
|
|
@@ -474,7 +476,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
474
476
|
connect(async (client) => {
|
|
475
477
|
try {
|
|
476
478
|
logger.debug("🔗 Connected to Dagger client");
|
|
477
|
-
const container = await this.setupContainer(client, environment, inputs);
|
|
479
|
+
const container = await this.setupContainer(client, environment, inputs, tool);
|
|
478
480
|
logger.debug("📦 Container setup complete");
|
|
479
481
|
const commandResult = await this.executeInContainer(container, command);
|
|
480
482
|
logger.debug("⚡ Command execution complete");
|
|
@@ -505,10 +507,12 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
505
507
|
/**
|
|
506
508
|
* Enhanced container setup with better tool detection and installation
|
|
507
509
|
*/
|
|
508
|
-
async setupContainer(client, environment, inputs) {
|
|
509
|
-
|
|
510
|
+
async setupContainer(client, environment, inputs, tool) {
|
|
511
|
+
// Determine which container image to use - prefer tool's 'from' field over default baseImage
|
|
512
|
+
const containerImage = tool?.from || this.options.baseImage;
|
|
513
|
+
logger.debug(`🚀 Setting up container with image: ${containerImage}${tool?.from ? ' (from tool.from)' : ' (default baseImage)'}`);
|
|
510
514
|
// Start with base container
|
|
511
|
-
let container = client.container().from(
|
|
515
|
+
let container = client.container().from(containerImage);
|
|
512
516
|
logger.debug("📦 Base container created");
|
|
513
517
|
// Set working directory
|
|
514
518
|
container = container.withWorkdir(this.options.workdir);
|
|
@@ -520,7 +524,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
520
524
|
logger.debug(`🌍 Added ${Object.keys(environment.vars).length} environment variables`);
|
|
521
525
|
// Install common tools needed for Enact commands
|
|
522
526
|
if (this.options.enableNetwork) {
|
|
523
|
-
container = await this.installCommonTools(container);
|
|
527
|
+
container = await this.installCommonTools(container, containerImage);
|
|
524
528
|
logger.debug("🔧 Common tools installed");
|
|
525
529
|
}
|
|
526
530
|
else {
|
|
@@ -541,18 +545,18 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
541
545
|
* Install common tools that Enact commands might need
|
|
542
546
|
* Enhanced with better error handling and timeout
|
|
543
547
|
*/
|
|
544
|
-
async installCommonTools(container) {
|
|
545
|
-
logger.debug(`🔧 Installing common tools for
|
|
548
|
+
async installCommonTools(container, containerImage) {
|
|
549
|
+
logger.debug(`🔧 Installing common tools for container image: ${containerImage}`);
|
|
546
550
|
try {
|
|
547
551
|
// For node images, most tools are already available, so we can skip installation
|
|
548
|
-
if (
|
|
552
|
+
if (containerImage.includes("node:")) {
|
|
549
553
|
logger.debug("📦 Node.js image detected, skipping tool installation (most tools already available)");
|
|
550
554
|
return container;
|
|
551
555
|
}
|
|
552
556
|
// Determine package manager based on base image
|
|
553
|
-
const isAlpine =
|
|
554
|
-
const isDebian =
|
|
555
|
-
|
|
557
|
+
const isAlpine = containerImage.includes("alpine");
|
|
558
|
+
const isDebian = containerImage.includes("debian") ||
|
|
559
|
+
containerImage.includes("ubuntu");
|
|
556
560
|
if (isAlpine) {
|
|
557
561
|
logger.debug("📦 Detected Alpine Linux, installing basic tools");
|
|
558
562
|
// Alpine Linux uses apk package manager - with better timeout handling
|
|
@@ -572,7 +576,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
572
576
|
]);
|
|
573
577
|
}
|
|
574
578
|
else {
|
|
575
|
-
logger.warn(`Unknown
|
|
579
|
+
logger.warn(`Unknown container image ${containerImage}, skipping tool installation`);
|
|
576
580
|
}
|
|
577
581
|
logger.debug("✅ Common tools installation complete");
|
|
578
582
|
return container;
|
|
@@ -878,7 +882,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
|
|
|
878
882
|
verbose,
|
|
879
883
|
showSpinner: true,
|
|
880
884
|
streamOutput: false,
|
|
881
|
-
});
|
|
885
|
+
}, undefined);
|
|
882
886
|
if (result.exitCode !== 0) {
|
|
883
887
|
throw new Error(`Command failed with exit code ${result.exitCode}: ${result.stderr}`);
|
|
884
888
|
}
|
package/dist/core/EnactCore.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export interface EnactCoreOptions {
|
|
|
6
6
|
authToken?: string;
|
|
7
7
|
verbose?: boolean;
|
|
8
8
|
defaultTimeout?: string;
|
|
9
|
-
verificationPolicy?: "permissive" | "enterprise" | "paranoid";
|
|
10
9
|
daggerOptions?: {
|
|
11
10
|
baseImage?: string;
|
|
12
11
|
enableNetwork?: boolean;
|
|
@@ -24,11 +23,11 @@ export interface ToolSearchOptions {
|
|
|
24
23
|
}
|
|
25
24
|
export interface ToolExecuteOptions {
|
|
26
25
|
timeout?: string;
|
|
27
|
-
verifyPolicy?: "permissive" | "enterprise" | "paranoid";
|
|
28
|
-
skipVerification?: boolean;
|
|
29
26
|
force?: boolean;
|
|
30
27
|
dryRun?: boolean;
|
|
31
28
|
verbose?: boolean;
|
|
29
|
+
isLocalFile?: boolean;
|
|
30
|
+
dangerouslySkipVerification?: boolean;
|
|
32
31
|
}
|
|
33
32
|
export declare class EnactCore {
|
|
34
33
|
private apiClient;
|
|
@@ -40,21 +39,30 @@ export declare class EnactCore {
|
|
|
40
39
|
*/
|
|
41
40
|
setAuthToken(token: string): void;
|
|
42
41
|
/**
|
|
43
|
-
*
|
|
42
|
+
* Static method to search for tools (no execution provider needed)
|
|
43
|
+
*/
|
|
44
|
+
static searchTools(options: ToolSearchOptions, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<EnactTool[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Instance method wrapper for backward compatibility
|
|
44
47
|
*/
|
|
45
48
|
searchTools(options: ToolSearchOptions): Promise<EnactTool[]>;
|
|
46
49
|
/**
|
|
47
|
-
*
|
|
50
|
+
* Static fallback search method that gets all tools and filters locally
|
|
51
|
+
*/
|
|
52
|
+
private static searchToolsFallback;
|
|
53
|
+
/**
|
|
54
|
+
* Static method to get a specific tool by name
|
|
48
55
|
*/
|
|
49
|
-
|
|
56
|
+
static getToolByName(name: string, version?: string, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<EnactTool | null>;
|
|
50
57
|
/**
|
|
51
|
-
*
|
|
58
|
+
* Instance method wrapper for backward compatibility
|
|
52
59
|
*/
|
|
53
60
|
getToolByName(name: string, version?: string): Promise<EnactTool | null>;
|
|
54
61
|
/**
|
|
55
62
|
* Execute a tool by name
|
|
56
63
|
*/
|
|
57
64
|
executeToolByName(name: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
|
|
65
|
+
private verifyTool;
|
|
58
66
|
/**
|
|
59
67
|
* Execute a tool directly
|
|
60
68
|
*/
|
|
@@ -64,16 +72,11 @@ export declare class EnactCore {
|
|
|
64
72
|
*/
|
|
65
73
|
executeRawTool(toolYaml: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
|
|
66
74
|
/**
|
|
67
|
-
*
|
|
75
|
+
* Static method to check if a tool exists
|
|
68
76
|
*/
|
|
69
|
-
|
|
70
|
-
verified: boolean;
|
|
71
|
-
signatures: any[];
|
|
72
|
-
policy: string;
|
|
73
|
-
errors?: string[];
|
|
74
|
-
}>;
|
|
77
|
+
static toolExists(name: string, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<boolean>;
|
|
75
78
|
/**
|
|
76
|
-
*
|
|
79
|
+
* Instance method wrapper for backward compatibility
|
|
77
80
|
*/
|
|
78
81
|
toolExists(name: string): Promise<boolean>;
|
|
79
82
|
/**
|
|
@@ -85,7 +88,16 @@ export declare class EnactCore {
|
|
|
85
88
|
*/
|
|
86
89
|
getToolsByAuthor(author: string, limit?: number): Promise<EnactTool[]>;
|
|
87
90
|
/**
|
|
88
|
-
*
|
|
91
|
+
* Static method to get all tools with filters
|
|
92
|
+
*/
|
|
93
|
+
static getTools(options?: {
|
|
94
|
+
limit?: number;
|
|
95
|
+
offset?: number;
|
|
96
|
+
tags?: string[];
|
|
97
|
+
author?: string;
|
|
98
|
+
}, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<EnactTool[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Instance method wrapper for backward compatibility
|
|
89
101
|
*/
|
|
90
102
|
getTools(options?: {
|
|
91
103
|
limit?: number;
|
|
@@ -102,7 +114,14 @@ export declare class EnactCore {
|
|
|
102
114
|
server?: string;
|
|
103
115
|
}>;
|
|
104
116
|
/**
|
|
105
|
-
*
|
|
117
|
+
* Static method to publish a tool
|
|
118
|
+
*/
|
|
119
|
+
static publishTool(tool: EnactTool, authToken: string, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<{
|
|
120
|
+
success: boolean;
|
|
121
|
+
message: string;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Instance method wrapper for backward compatibility
|
|
106
125
|
*/
|
|
107
126
|
publishTool(tool: EnactTool): Promise<{
|
|
108
127
|
success: boolean;
|
|
@@ -118,7 +137,6 @@ export declare class EnactCore {
|
|
|
118
137
|
getStatus(): Promise<{
|
|
119
138
|
executionProvider: string;
|
|
120
139
|
apiUrl: string;
|
|
121
|
-
verificationPolicy: string;
|
|
122
140
|
defaultTimeout: string;
|
|
123
141
|
authenticated: boolean;
|
|
124
142
|
}>;
|
|
@@ -135,4 +153,3 @@ export declare class EnactCore {
|
|
|
135
153
|
*/
|
|
136
154
|
private generateExecutionId;
|
|
137
155
|
}
|
|
138
|
-
export declare const enactCore: EnactCore;
|