@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.
- package/README.md +44 -0
- package/dist/config.d.ts +164 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +386 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +15 -5
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +24 -8
- package/dist/constants.js.map +1 -0
- package/dist/execution/command.d.ts +102 -0
- package/dist/execution/command.d.ts.map +1 -0
- package/dist/execution/command.js +262 -0
- package/dist/execution/command.js.map +1 -0
- package/dist/execution/index.d.ts +12 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +17 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/runtime.d.ts +82 -0
- package/dist/execution/runtime.d.ts.map +1 -0
- package/dist/execution/runtime.js +273 -0
- package/dist/execution/runtime.js.map +1 -0
- package/dist/execution/types.d.ts +306 -0
- package/dist/execution/types.d.ts.map +1 -0
- package/dist/execution/types.js +14 -0
- package/dist/execution/types.js.map +1 -0
- package/dist/execution/validation.d.ts +43 -0
- package/dist/execution/validation.d.ts.map +1 -0
- package/dist/execution/validation.js +430 -0
- package/dist/execution/validation.js.map +1 -0
- package/dist/index.d.ts +21 -21
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -25
- package/dist/index.js.map +1 -0
- package/dist/manifest/index.d.ts +7 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +10 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/loader.d.ts +76 -0
- package/dist/manifest/loader.d.ts.map +1 -0
- package/dist/manifest/loader.js +146 -0
- package/dist/manifest/loader.js.map +1 -0
- package/dist/manifest/parser.d.ts +64 -0
- package/dist/manifest/parser.d.ts.map +1 -0
- package/dist/manifest/parser.js +135 -0
- package/dist/manifest/parser.js.map +1 -0
- package/dist/manifest/validator.d.ts +95 -0
- package/dist/manifest/validator.d.ts.map +1 -0
- package/dist/manifest/validator.js +258 -0
- package/dist/manifest/validator.js.map +1 -0
- package/dist/paths.d.ts +57 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +93 -0
- package/dist/paths.js.map +1 -0
- package/dist/registry.d.ts +73 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +147 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolver.d.ts +89 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +282 -0
- package/dist/resolver.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/manifest.d.ts +201 -0
- package/dist/types/manifest.d.ts.map +1 -0
- package/dist/types/manifest.js +13 -0
- package/dist/types/manifest.js.map +1 -0
- package/dist/types.d.ts +5 -132
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -3
- package/dist/types.js.map +1 -0
- package/dist/utils/fs.d.ts +105 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +233 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/logger.d.ts +102 -25
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +214 -57
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/version.d.ts +60 -2
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +255 -31
- package/dist/utils/version.js.map +1 -0
- package/package.json +16 -58
- package/src/config.ts +510 -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 +238 -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/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/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/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/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/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/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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,qDAAqD;AACrD,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAE9B,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAE/E;;;GAGG;AACH,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,GAAG,QAAQ,MAAM,CAAC;AAE5E;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,QAAQ,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command interpolation and parsing
|
|
3
|
+
*
|
|
4
|
+
* Handles ${parameter} substitution in command templates with proper escaping.
|
|
5
|
+
*/
|
|
6
|
+
import type { InterpolationOptions, ParsedCommand } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Parse a command template into tokens
|
|
9
|
+
*
|
|
10
|
+
* @param command - Command template with ${parameter} placeholders
|
|
11
|
+
* @returns Parsed command with tokens and parameter list
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseCommand(command: string): ParsedCommand;
|
|
14
|
+
/**
|
|
15
|
+
* Shell-escape a value for safe inclusion in a command
|
|
16
|
+
*
|
|
17
|
+
* Uses single quotes and handles embedded single quotes.
|
|
18
|
+
* Example: "it's a test" becomes "'it'\"'\"'s a test'"
|
|
19
|
+
*
|
|
20
|
+
* @param value - Value to escape
|
|
21
|
+
* @returns Shell-safe escaped string
|
|
22
|
+
*/
|
|
23
|
+
export declare function shellEscape(value: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Convert a value to string for command interpolation
|
|
26
|
+
*
|
|
27
|
+
* Handles different types:
|
|
28
|
+
* - string: as-is
|
|
29
|
+
* - number: toString()
|
|
30
|
+
* - boolean: "true" or "false"
|
|
31
|
+
* - object/array: JSON.stringify
|
|
32
|
+
* - null/undefined: empty string
|
|
33
|
+
*
|
|
34
|
+
* @param value - Value to convert
|
|
35
|
+
* @param jsonifyObjects - Whether to JSON-stringify objects
|
|
36
|
+
* @returns String representation
|
|
37
|
+
*/
|
|
38
|
+
export declare function valueToString(value: unknown, jsonifyObjects?: boolean): string;
|
|
39
|
+
/**
|
|
40
|
+
* Interpolate a command template with parameter values
|
|
41
|
+
*
|
|
42
|
+
* @param command - Command template or parsed command
|
|
43
|
+
* @param params - Parameter values
|
|
44
|
+
* @param options - Interpolation options
|
|
45
|
+
* @returns Interpolated command string
|
|
46
|
+
* @throws Error if required parameter is missing and onMissing is "error"
|
|
47
|
+
*/
|
|
48
|
+
export declare function interpolateCommand(command: string | ParsedCommand, params: Record<string, unknown>, options?: InterpolationOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* Parse a command string respecting quotes
|
|
51
|
+
*
|
|
52
|
+
* Splits a command into arguments, respecting single and double quotes.
|
|
53
|
+
*
|
|
54
|
+
* @param command - Command string to parse
|
|
55
|
+
* @returns Array of command arguments
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseCommandArgs(command: string): string[];
|
|
58
|
+
/**
|
|
59
|
+
* Wrap a command with sh -c for execution
|
|
60
|
+
*
|
|
61
|
+
* Useful when the command contains shell features like pipes, redirects, etc.
|
|
62
|
+
*
|
|
63
|
+
* @param command - Command to wrap
|
|
64
|
+
* @returns Arguments for sh -c execution
|
|
65
|
+
*/
|
|
66
|
+
export declare function wrapWithShell(command: string): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Check if a command needs shell wrapping
|
|
69
|
+
*
|
|
70
|
+
* Returns true if the command contains shell special characters.
|
|
71
|
+
*
|
|
72
|
+
* @param command - Command to check
|
|
73
|
+
* @returns Whether the command needs sh -c wrapping
|
|
74
|
+
*/
|
|
75
|
+
export declare function needsShellWrap(command: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Prepare a command for execution
|
|
78
|
+
*
|
|
79
|
+
* Parses the command and determines if it needs shell wrapping.
|
|
80
|
+
*
|
|
81
|
+
* @param command - Command template
|
|
82
|
+
* @param params - Parameter values for interpolation
|
|
83
|
+
* @param options - Interpolation options
|
|
84
|
+
* @returns Command ready for execution [program, ...args]
|
|
85
|
+
*/
|
|
86
|
+
export declare function prepareCommand(command: string, params: Record<string, unknown>, options?: InterpolationOptions): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Validate that all required parameters are provided
|
|
89
|
+
*
|
|
90
|
+
* @param command - Parsed command
|
|
91
|
+
* @param params - Provided parameters
|
|
92
|
+
* @returns Array of missing parameter names
|
|
93
|
+
*/
|
|
94
|
+
export declare function getMissingParams(command: string | ParsedCommand, params: Record<string, unknown>): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Get all parameters in a command template
|
|
97
|
+
*
|
|
98
|
+
* @param command - Command template
|
|
99
|
+
* @returns Array of parameter names
|
|
100
|
+
*/
|
|
101
|
+
export declare function getCommandParams(command: string): string[];
|
|
102
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/execution/command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAgB,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAOjF;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escaping.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Pattern to match ${parameter} in command strings
|
|
8
|
+
*/
|
|
9
|
+
const PARAM_PATTERN = /\$\{([^}]+)\}/g;
|
|
10
|
+
/**
|
|
11
|
+
* Parse a command template into tokens
|
|
12
|
+
*
|
|
13
|
+
* @param command - Command template with ${parameter} placeholders
|
|
14
|
+
* @returns Parsed command with tokens and parameter list
|
|
15
|
+
*/
|
|
16
|
+
export function parseCommand(command) {
|
|
17
|
+
const tokens = [];
|
|
18
|
+
const parameters = [];
|
|
19
|
+
let lastIndex = 0;
|
|
20
|
+
let match = null;
|
|
21
|
+
// Reset regex state
|
|
22
|
+
PARAM_PATTERN.lastIndex = 0;
|
|
23
|
+
match = PARAM_PATTERN.exec(command);
|
|
24
|
+
while (match !== null) {
|
|
25
|
+
// Add literal text before this match
|
|
26
|
+
if (match.index > lastIndex) {
|
|
27
|
+
tokens.push({
|
|
28
|
+
type: "literal",
|
|
29
|
+
value: command.slice(lastIndex, match.index),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Add the parameter token
|
|
33
|
+
const paramName = match[1];
|
|
34
|
+
if (paramName) {
|
|
35
|
+
tokens.push({
|
|
36
|
+
type: "parameter",
|
|
37
|
+
name: paramName,
|
|
38
|
+
});
|
|
39
|
+
if (!parameters.includes(paramName)) {
|
|
40
|
+
parameters.push(paramName);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
lastIndex = match.index + match[0].length;
|
|
44
|
+
match = PARAM_PATTERN.exec(command);
|
|
45
|
+
}
|
|
46
|
+
// Add any remaining literal text
|
|
47
|
+
if (lastIndex < command.length) {
|
|
48
|
+
tokens.push({
|
|
49
|
+
type: "literal",
|
|
50
|
+
value: command.slice(lastIndex),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
original: command,
|
|
55
|
+
tokens,
|
|
56
|
+
parameters,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Shell-escape a value for safe inclusion in a command
|
|
61
|
+
*
|
|
62
|
+
* Uses single quotes and handles embedded single quotes.
|
|
63
|
+
* Example: "it's a test" becomes "'it'\"'\"'s a test'"
|
|
64
|
+
*
|
|
65
|
+
* @param value - Value to escape
|
|
66
|
+
* @returns Shell-safe escaped string
|
|
67
|
+
*/
|
|
68
|
+
export function shellEscape(value) {
|
|
69
|
+
// If the value is empty, return empty quoted string
|
|
70
|
+
if (value === "") {
|
|
71
|
+
return "''";
|
|
72
|
+
}
|
|
73
|
+
// If value contains no special characters, return as-is
|
|
74
|
+
if (/^[a-zA-Z0-9._\-/]+$/.test(value)) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
// Use single quotes, escaping any embedded single quotes
|
|
78
|
+
// The technique: end quote, add escaped quote, start new quote
|
|
79
|
+
// 'it'"'"'s' means: 'it' + "'" + 's'
|
|
80
|
+
return `'${value.replace(/'/g, "'\"'\"'")}'`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Convert a value to string for command interpolation
|
|
84
|
+
*
|
|
85
|
+
* Handles different types:
|
|
86
|
+
* - string: as-is
|
|
87
|
+
* - number: toString()
|
|
88
|
+
* - boolean: "true" or "false"
|
|
89
|
+
* - object/array: JSON.stringify
|
|
90
|
+
* - null/undefined: empty string
|
|
91
|
+
*
|
|
92
|
+
* @param value - Value to convert
|
|
93
|
+
* @param jsonifyObjects - Whether to JSON-stringify objects
|
|
94
|
+
* @returns String representation
|
|
95
|
+
*/
|
|
96
|
+
export function valueToString(value, jsonifyObjects = true) {
|
|
97
|
+
if (value === null || value === undefined) {
|
|
98
|
+
return "";
|
|
99
|
+
}
|
|
100
|
+
if (typeof value === "string") {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
104
|
+
return String(value);
|
|
105
|
+
}
|
|
106
|
+
if (jsonifyObjects && (typeof value === "object" || Array.isArray(value))) {
|
|
107
|
+
return JSON.stringify(value);
|
|
108
|
+
}
|
|
109
|
+
return String(value);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Interpolate a command template with parameter values
|
|
113
|
+
*
|
|
114
|
+
* @param command - Command template or parsed command
|
|
115
|
+
* @param params - Parameter values
|
|
116
|
+
* @param options - Interpolation options
|
|
117
|
+
* @returns Interpolated command string
|
|
118
|
+
* @throws Error if required parameter is missing and onMissing is "error"
|
|
119
|
+
*/
|
|
120
|
+
export function interpolateCommand(command, params, options = {}) {
|
|
121
|
+
const { escape: shouldEscape = true, jsonifyObjects = true, onMissing = "error" } = options;
|
|
122
|
+
const parsed = typeof command === "string" ? parseCommand(command) : command;
|
|
123
|
+
const parts = [];
|
|
124
|
+
for (const token of parsed.tokens) {
|
|
125
|
+
if (token.type === "literal") {
|
|
126
|
+
parts.push(token.value);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const paramName = token.name;
|
|
130
|
+
const value = params[paramName];
|
|
131
|
+
if (value === undefined) {
|
|
132
|
+
switch (onMissing) {
|
|
133
|
+
case "error":
|
|
134
|
+
throw new Error(`Missing required parameter: ${paramName}`);
|
|
135
|
+
case "empty":
|
|
136
|
+
parts.push("");
|
|
137
|
+
break;
|
|
138
|
+
case "keep":
|
|
139
|
+
parts.push(`\${${paramName}}`);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const stringValue = valueToString(value, jsonifyObjects);
|
|
145
|
+
parts.push(shouldEscape ? shellEscape(stringValue) : stringValue);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return parts.join("");
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Parse a command string respecting quotes
|
|
153
|
+
*
|
|
154
|
+
* Splits a command into arguments, respecting single and double quotes.
|
|
155
|
+
*
|
|
156
|
+
* @param command - Command string to parse
|
|
157
|
+
* @returns Array of command arguments
|
|
158
|
+
*/
|
|
159
|
+
export function parseCommandArgs(command) {
|
|
160
|
+
const args = [];
|
|
161
|
+
let current = "";
|
|
162
|
+
let inSingleQuote = false;
|
|
163
|
+
let inDoubleQuote = false;
|
|
164
|
+
let escapeNext = false;
|
|
165
|
+
for (let i = 0; i < command.length; i++) {
|
|
166
|
+
const char = command[i];
|
|
167
|
+
if (escapeNext) {
|
|
168
|
+
current += char;
|
|
169
|
+
escapeNext = false;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (char === "\\") {
|
|
173
|
+
escapeNext = true;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (char === "'" && !inDoubleQuote) {
|
|
177
|
+
inSingleQuote = !inSingleQuote;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (char === '"' && !inSingleQuote) {
|
|
181
|
+
inDoubleQuote = !inDoubleQuote;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (char === " " && !inSingleQuote && !inDoubleQuote) {
|
|
185
|
+
if (current.length > 0) {
|
|
186
|
+
args.push(current);
|
|
187
|
+
current = "";
|
|
188
|
+
}
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
current += char;
|
|
192
|
+
}
|
|
193
|
+
// Add the last argument
|
|
194
|
+
if (current.length > 0) {
|
|
195
|
+
args.push(current);
|
|
196
|
+
}
|
|
197
|
+
return args;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Wrap a command with sh -c for execution
|
|
201
|
+
*
|
|
202
|
+
* Useful when the command contains shell features like pipes, redirects, etc.
|
|
203
|
+
*
|
|
204
|
+
* @param command - Command to wrap
|
|
205
|
+
* @returns Arguments for sh -c execution
|
|
206
|
+
*/
|
|
207
|
+
export function wrapWithShell(command) {
|
|
208
|
+
return ["sh", "-c", command];
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Check if a command needs shell wrapping
|
|
212
|
+
*
|
|
213
|
+
* Returns true if the command contains shell special characters.
|
|
214
|
+
*
|
|
215
|
+
* @param command - Command to check
|
|
216
|
+
* @returns Whether the command needs sh -c wrapping
|
|
217
|
+
*/
|
|
218
|
+
export function needsShellWrap(command) {
|
|
219
|
+
// Check for shell operators and features
|
|
220
|
+
return /[|&;<>()$`\\"\n*?[\]#~=%]/.test(command);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Prepare a command for execution
|
|
224
|
+
*
|
|
225
|
+
* Parses the command and determines if it needs shell wrapping.
|
|
226
|
+
*
|
|
227
|
+
* @param command - Command template
|
|
228
|
+
* @param params - Parameter values for interpolation
|
|
229
|
+
* @param options - Interpolation options
|
|
230
|
+
* @returns Command ready for execution [program, ...args]
|
|
231
|
+
*/
|
|
232
|
+
export function prepareCommand(command, params, options = {}) {
|
|
233
|
+
// Interpolate parameters
|
|
234
|
+
const interpolated = interpolateCommand(command, params, options);
|
|
235
|
+
// Check if we need shell wrapping
|
|
236
|
+
if (needsShellWrap(interpolated)) {
|
|
237
|
+
return wrapWithShell(interpolated);
|
|
238
|
+
}
|
|
239
|
+
// Parse into arguments
|
|
240
|
+
return parseCommandArgs(interpolated);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Validate that all required parameters are provided
|
|
244
|
+
*
|
|
245
|
+
* @param command - Parsed command
|
|
246
|
+
* @param params - Provided parameters
|
|
247
|
+
* @returns Array of missing parameter names
|
|
248
|
+
*/
|
|
249
|
+
export function getMissingParams(command, params) {
|
|
250
|
+
const parsed = typeof command === "string" ? parseCommand(command) : command;
|
|
251
|
+
return parsed.parameters.filter((param) => params[param] === undefined);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Get all parameters in a command template
|
|
255
|
+
*
|
|
256
|
+
* @param command - Command template
|
|
257
|
+
* @returns Array of parameter names
|
|
258
|
+
*/
|
|
259
|
+
export function getCommandParams(command) {
|
|
260
|
+
return parseCommand(command).parameters;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/execution/command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,KAAK,GAA2B,IAAI,CAAC;IAEzC,oBAAoB;IACpB,aAAa,CAAC,SAAS,GAAG,CAAC,CAAC;IAE5B,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,KAAK,KAAK,IAAI,EAAE,CAAC;QACtB,qCAAqC;QACrC,IAAI,KAAK,CAAC,KAAK,GAAG,SAAS,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC;aAC7C,CAAC,CAAC;QACL,CAAC;QAED,0BAA0B;QAC1B,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;YAEH,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBACpC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1C,KAAK,GAAG,aAAa,CAA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;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution Engine Module
|
|
3
|
+
*
|
|
4
|
+
* Provides containerized tool execution using the Dagger SDK.
|
|
5
|
+
* This is the main entry point for Phase 3 of Enact CLI 2.0.
|
|
6
|
+
*/
|
|
7
|
+
export type { ExecutionInput, FileInput, ExecutionOutput, ExecutionResult, ExecutionMetadata, ExecutionError, ExecutionErrorCode, ExecutionOptions, RetryConfig, ContainerRuntime, RuntimeDetection, RuntimeStatus, EngineHealth, EngineState, ExecutionProvider, ParsedCommand, CommandToken, InterpolationOptions, InputValidationResult, InputValidationError, DryRunResult, } from "./types.js";
|
|
8
|
+
export { DEFAULT_RETRY_CONFIG } from "./types.js";
|
|
9
|
+
export { detectRuntime, clearRuntimeCache, isRuntimeAvailable, getAvailableRuntimes, RuntimeStatusTracker, createRuntimeTracker, } from "./runtime.js";
|
|
10
|
+
export { parseCommand, interpolateCommand, shellEscape, parseCommandArgs, prepareCommand, getMissingParams, } from "./command.js";
|
|
11
|
+
export { validateInputs, applyDefaults, getRequiredParams, getParamInfo, } from "./validation.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAEV,cAAc,EACd,SAAS,EACT,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAElB,gBAAgB,EAChB,WAAW,EAEX,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EAEb,YAAY,EACZ,WAAW,EAEX,iBAAiB,EAEjB,aAAa,EACb,YAAY,EACZ,oBAAoB,EAEpB,qBAAqB,EACrB,oBAAoB,EAEpB,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution Engine Module
|
|
3
|
+
*
|
|
4
|
+
* Provides containerized tool execution using the Dagger SDK.
|
|
5
|
+
* This is the main entry point for Phase 3 of Enact CLI 2.0.
|
|
6
|
+
*/
|
|
7
|
+
// Constants
|
|
8
|
+
export { DEFAULT_RETRY_CONFIG } from "./types.js";
|
|
9
|
+
// Runtime detection
|
|
10
|
+
export { detectRuntime, clearRuntimeCache, isRuntimeAvailable, getAvailableRuntimes, RuntimeStatusTracker, createRuntimeTracker, } from "./runtime.js";
|
|
11
|
+
// Command interpolation
|
|
12
|
+
export { parseCommand, interpolateCommand, shellEscape, parseCommandArgs, prepareCommand, getMissingParams, } from "./command.js";
|
|
13
|
+
// Input validation
|
|
14
|
+
export { validateInputs, applyDefaults, getRequiredParams, getParamInfo, } from "./validation.js";
|
|
15
|
+
// NOTE: Dagger provider moved to @enactprotocol/execution package
|
|
16
|
+
// This keeps @enactprotocol/shared browser-safe (no Dagger SDK dependency)
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmCH,YAAY;AACZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,oBAAoB;AACpB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,wBAAwB;AACxB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,kEAAkE;AAClE,2EAA2E"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container runtime detection
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects available container runtimes (docker, podman, nerdctl)
|
|
5
|
+
* and provides runtime status monitoring.
|
|
6
|
+
*/
|
|
7
|
+
import type { ContainerRuntime, RuntimeDetection, RuntimeStatus } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Detect available container runtime
|
|
10
|
+
*
|
|
11
|
+
* Checks for docker, podman, and nerdctl in order of preference.
|
|
12
|
+
* Results are cached for 1 minute.
|
|
13
|
+
*
|
|
14
|
+
* @returns Detection result with runtime info or error
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectRuntime(): RuntimeDetection;
|
|
17
|
+
/**
|
|
18
|
+
* Clear the cached detection result
|
|
19
|
+
* Useful after installing a runtime
|
|
20
|
+
*/
|
|
21
|
+
export declare function clearRuntimeCache(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Force detection of a specific runtime
|
|
24
|
+
*
|
|
25
|
+
* @param runtime - The runtime to check
|
|
26
|
+
* @returns Whether the runtime is available
|
|
27
|
+
*/
|
|
28
|
+
export declare function isRuntimeAvailable(runtime: ContainerRuntime): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get all available runtimes
|
|
31
|
+
*
|
|
32
|
+
* @returns Array of available runtimes
|
|
33
|
+
*/
|
|
34
|
+
export declare function getAvailableRuntimes(): ContainerRuntime[];
|
|
35
|
+
/**
|
|
36
|
+
* Runtime status tracker for health monitoring
|
|
37
|
+
*/
|
|
38
|
+
export declare class RuntimeStatusTracker {
|
|
39
|
+
private status;
|
|
40
|
+
private healthCheckInterval;
|
|
41
|
+
constructor(runtime: ContainerRuntime);
|
|
42
|
+
/**
|
|
43
|
+
* Record a successful operation
|
|
44
|
+
*/
|
|
45
|
+
recordSuccess(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Record a failed operation
|
|
48
|
+
*
|
|
49
|
+
* @returns Whether the engine should be reset (3+ consecutive failures)
|
|
50
|
+
*/
|
|
51
|
+
recordFailure(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get current status
|
|
54
|
+
*/
|
|
55
|
+
getStatus(): RuntimeStatus;
|
|
56
|
+
/**
|
|
57
|
+
* Check if engine needs reset
|
|
58
|
+
*/
|
|
59
|
+
needsReset(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Reset failure count after engine restart
|
|
62
|
+
*/
|
|
63
|
+
resetFailureCount(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Start periodic health checks
|
|
66
|
+
*
|
|
67
|
+
* @param intervalMs - Check interval in milliseconds (default: 60000)
|
|
68
|
+
* @param onUnhealthy - Callback when engine becomes unhealthy
|
|
69
|
+
*/
|
|
70
|
+
startHealthChecks(intervalMs?: number, onUnhealthy?: (status: RuntimeStatus) => void): void;
|
|
71
|
+
/**
|
|
72
|
+
* Stop periodic health checks
|
|
73
|
+
*/
|
|
74
|
+
stopHealthChecks(): void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a runtime status tracker for the detected runtime
|
|
78
|
+
*
|
|
79
|
+
* @returns Status tracker or null if no runtime found
|
|
80
|
+
*/
|
|
81
|
+
export declare function createRuntimeTracker(): RuntimeStatusTracker | null;
|
|
82
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/execution/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAoFjF;;;;;;;GAOG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAgChD;AAsCD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAErE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,EAAE,CAEzD;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,mBAAmB,CAA+C;gBAE9D,OAAO,EAAE,gBAAgB;IAUrC;;OAEG;IACH,aAAa,IAAI,IAAI;IAMrB;;;;OAIG;IACH,aAAa,IAAI,OAAO;IAYxB;;OAEG;IACH,SAAS,IAAI,aAAa;IAI1B;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;;;;OAKG;IACH,iBAAiB,CAAC,UAAU,SAAQ,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI;IAgB1F;;OAEG;IACH,gBAAgB,IAAI,IAAI;CAMzB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,oBAAoB,GAAG,IAAI,CAMlE"}
|