@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.
Files changed (134) hide show
  1. package/README.md +44 -0
  2. package/package.json +16 -58
  3. package/src/config.ts +476 -0
  4. package/src/constants.ts +36 -0
  5. package/src/execution/command.ts +314 -0
  6. package/src/execution/index.ts +73 -0
  7. package/src/execution/runtime.ts +308 -0
  8. package/src/execution/types.ts +379 -0
  9. package/src/execution/validation.ts +508 -0
  10. package/src/index.ts +237 -30
  11. package/src/manifest/index.ts +36 -0
  12. package/src/manifest/loader.ts +187 -0
  13. package/src/manifest/parser.ts +173 -0
  14. package/src/manifest/validator.ts +309 -0
  15. package/src/paths.ts +108 -0
  16. package/src/registry.ts +219 -0
  17. package/src/resolver.ts +345 -0
  18. package/src/types/index.ts +30 -0
  19. package/src/types/manifest.ts +255 -0
  20. package/src/types.ts +5 -188
  21. package/src/utils/fs.ts +281 -0
  22. package/src/utils/logger.ts +270 -59
  23. package/src/utils/version.ts +304 -36
  24. package/tests/config.test.ts +515 -0
  25. package/tests/execution/command.test.ts +317 -0
  26. package/tests/execution/validation.test.ts +384 -0
  27. package/tests/fixtures/invalid-tool.yaml +4 -0
  28. package/tests/fixtures/valid-tool.md +62 -0
  29. package/tests/fixtures/valid-tool.yaml +40 -0
  30. package/tests/index.test.ts +8 -0
  31. package/tests/manifest/loader.test.ts +291 -0
  32. package/tests/manifest/parser.test.ts +345 -0
  33. package/tests/manifest/validator.test.ts +394 -0
  34. package/tests/manifest-types.test.ts +358 -0
  35. package/tests/paths.test.ts +153 -0
  36. package/tests/registry.test.ts +231 -0
  37. package/tests/resolver.test.ts +272 -0
  38. package/tests/utils/fs.test.ts +388 -0
  39. package/tests/utils/logger.test.ts +480 -0
  40. package/tests/utils/version.test.ts +390 -0
  41. package/tsconfig.json +12 -0
  42. package/tsconfig.tsbuildinfo +1 -0
  43. package/dist/LocalToolResolver.d.ts +0 -84
  44. package/dist/LocalToolResolver.js +0 -353
  45. package/dist/api/enact-api.d.ts +0 -130
  46. package/dist/api/enact-api.js +0 -428
  47. package/dist/api/index.d.ts +0 -2
  48. package/dist/api/index.js +0 -2
  49. package/dist/api/types.d.ts +0 -103
  50. package/dist/api/types.js +0 -1
  51. package/dist/constants.d.ts +0 -7
  52. package/dist/constants.js +0 -10
  53. package/dist/core/DaggerExecutionProvider.d.ts +0 -169
  54. package/dist/core/DaggerExecutionProvider.js +0 -1029
  55. package/dist/core/DirectExecutionProvider.d.ts +0 -23
  56. package/dist/core/DirectExecutionProvider.js +0 -406
  57. package/dist/core/EnactCore.d.ts +0 -162
  58. package/dist/core/EnactCore.js +0 -597
  59. package/dist/core/NativeExecutionProvider.d.ts +0 -9
  60. package/dist/core/NativeExecutionProvider.js +0 -16
  61. package/dist/core/index.d.ts +0 -3
  62. package/dist/core/index.js +0 -3
  63. package/dist/exec/index.d.ts +0 -3
  64. package/dist/exec/index.js +0 -3
  65. package/dist/exec/logger.d.ts +0 -11
  66. package/dist/exec/logger.js +0 -57
  67. package/dist/exec/validate.d.ts +0 -5
  68. package/dist/exec/validate.js +0 -167
  69. package/dist/index.d.ts +0 -21
  70. package/dist/index.js +0 -25
  71. package/dist/lib/enact-direct.d.ts +0 -150
  72. package/dist/lib/enact-direct.js +0 -159
  73. package/dist/lib/index.d.ts +0 -1
  74. package/dist/lib/index.js +0 -1
  75. package/dist/security/index.d.ts +0 -3
  76. package/dist/security/index.js +0 -3
  77. package/dist/security/security.d.ts +0 -23
  78. package/dist/security/security.js +0 -137
  79. package/dist/security/sign.d.ts +0 -103
  80. package/dist/security/sign.js +0 -666
  81. package/dist/security/verification-enforcer.d.ts +0 -53
  82. package/dist/security/verification-enforcer.js +0 -204
  83. package/dist/services/McpCoreService.d.ts +0 -98
  84. package/dist/services/McpCoreService.js +0 -124
  85. package/dist/services/index.d.ts +0 -1
  86. package/dist/services/index.js +0 -1
  87. package/dist/types.d.ts +0 -132
  88. package/dist/types.js +0 -3
  89. package/dist/utils/config.d.ts +0 -111
  90. package/dist/utils/config.js +0 -342
  91. package/dist/utils/env-loader.d.ts +0 -54
  92. package/dist/utils/env-loader.js +0 -270
  93. package/dist/utils/help.d.ts +0 -36
  94. package/dist/utils/help.js +0 -248
  95. package/dist/utils/index.d.ts +0 -7
  96. package/dist/utils/index.js +0 -7
  97. package/dist/utils/logger.d.ts +0 -35
  98. package/dist/utils/logger.js +0 -75
  99. package/dist/utils/silent-monitor.d.ts +0 -67
  100. package/dist/utils/silent-monitor.js +0 -242
  101. package/dist/utils/timeout.d.ts +0 -5
  102. package/dist/utils/timeout.js +0 -23
  103. package/dist/utils/version.d.ts +0 -4
  104. package/dist/utils/version.js +0 -35
  105. package/dist/web/env-manager-server.d.ts +0 -29
  106. package/dist/web/env-manager-server.js +0 -367
  107. package/dist/web/index.d.ts +0 -1
  108. package/dist/web/index.js +0 -1
  109. package/src/LocalToolResolver.ts +0 -424
  110. package/src/api/enact-api.ts +0 -604
  111. package/src/api/index.ts +0 -2
  112. package/src/api/types.ts +0 -114
  113. package/src/core/DaggerExecutionProvider.ts +0 -1357
  114. package/src/core/DirectExecutionProvider.ts +0 -484
  115. package/src/core/EnactCore.ts +0 -847
  116. package/src/core/index.ts +0 -3
  117. package/src/exec/index.ts +0 -3
  118. package/src/exec/logger.ts +0 -63
  119. package/src/exec/validate.ts +0 -238
  120. package/src/lib/enact-direct.ts +0 -254
  121. package/src/lib/index.ts +0 -1
  122. package/src/services/McpCoreService.ts +0 -201
  123. package/src/services/index.ts +0 -1
  124. package/src/utils/config.ts +0 -438
  125. package/src/utils/env-loader.ts +0 -370
  126. package/src/utils/help.ts +0 -257
  127. package/src/utils/index.ts +0 -7
  128. package/src/utils/silent-monitor.ts +0 -328
  129. package/src/utils/timeout.ts +0 -26
  130. package/src/web/env-manager-server.ts +0 -465
  131. package/src/web/index.ts +0 -1
  132. package/src/web/static/app.js +0 -663
  133. package/src/web/static/index.html +0 -117
  134. package/src/web/static/style.css +0 -291
@@ -1,169 +0,0 @@
1
- import { ExecutionProvider, type EnactTool, type ExecutionEnvironment, type ExecutionResult } from "../types.js";
2
- export interface DaggerExecutionOptions {
3
- baseImage?: string;
4
- workdir?: string;
5
- enableNetwork?: boolean;
6
- enableHostFS?: boolean;
7
- maxMemory?: string;
8
- maxCPU?: string;
9
- cacheVolume?: string;
10
- useShell?: boolean;
11
- engineTimeout?: number;
12
- maxRetries?: number;
13
- enableEngineHealthCheck?: boolean;
14
- }
15
- interface CommandResult {
16
- stdout: string;
17
- stderr: string;
18
- exitCode: number;
19
- }
20
- interface EngineHealthStatus {
21
- isHealthy: boolean;
22
- lastCheck: Date;
23
- consecutiveFailures: number;
24
- }
25
- export declare class DaggerExecutionProvider extends ExecutionProvider {
26
- private client;
27
- private options;
28
- private tempDir;
29
- private connectionCleanup;
30
- private engineHealth;
31
- private abortController;
32
- private activeSessions;
33
- private isShuttingDown;
34
- constructor(options?: DaggerExecutionOptions);
35
- setup(tool: EnactTool): Promise<boolean>;
36
- /**
37
- * Enhanced cleanup with comprehensive engine management and session tracking
38
- */
39
- cleanup(): Promise<boolean>;
40
- /**
41
- * Enhanced engine cleanup with better container detection
42
- */
43
- private performEngineCleanup;
44
- /**
45
- * Check engine health with comprehensive diagnostics
46
- */
47
- private checkEngineHealth;
48
- /**
49
- * Reset engine container when health check fails
50
- */
51
- private resetEngineContainer;
52
- /**
53
- * Start periodic engine health monitoring
54
- */
55
- private startEngineHealthMonitoring;
56
- /**
57
- * Wait for active sessions to complete with timeout
58
- */
59
- private waitForActiveSessions;
60
- resolveEnvironmentVariables(envConfig: Record<string, any>, namespace?: string): Promise<Record<string, any>>;
61
- execute(tool: EnactTool, inputs: Record<string, any>, environment: ExecutionEnvironment): Promise<ExecutionResult>;
62
- /**
63
- * Categorize errors for better handling
64
- */
65
- private categorizeError;
66
- executeCommand(command: string, inputs: Record<string, any>, environment: ExecutionEnvironment, timeout?: string, options?: {
67
- verbose?: boolean;
68
- showSpinner?: boolean;
69
- streamOutput?: boolean;
70
- }, tool?: EnactTool): Promise<CommandResult>;
71
- /**
72
- * Execute command using Dagger connect with proper session management
73
- */
74
- private executeWithConnect;
75
- /**
76
- * Setup directory mounting for the container
77
- */
78
- private setupDirectoryMount;
79
- /**
80
- * Enhanced container setup with better tool detection and installation
81
- */
82
- private setupContainer;
83
- /**
84
- * Install common tools that Enact commands might need
85
- * Enhanced with better error handling and timeout
86
- */
87
- private installCommonTools;
88
- /**
89
- * Execute command in container with enhanced error handling
90
- */
91
- private executeInContainer;
92
- /**
93
- * Enhanced execution error parsing
94
- */
95
- private parseExecutionError;
96
- /**
97
- * Apply resource limits based on Enact tool specifications
98
- */
99
- private applyResourceLimits;
100
- /**
101
- * Substitute template variables in Enact commands with enhanced security
102
- */
103
- private substituteCommandVariables;
104
- /**
105
- * Enhanced shell argument escaping
106
- */
107
- private escapeShellArg;
108
- /**
109
- * Prepare input files for Enact tools that expect file inputs
110
- */
111
- private prepareInputFiles;
112
- /**
113
- * Heuristics to determine if input should be treated as file content
114
- */
115
- private looksLikeFileContent;
116
- /**
117
- * Check if content looks like common file types
118
- */
119
- private hasCommonFileExtensions;
120
- /**
121
- * Generate appropriate filename for input content
122
- */
123
- private getInputFileName;
124
- /**
125
- * Map MIME types to file extensions
126
- */
127
- private getExtensionFromMimeType;
128
- /**
129
- * Enhanced command parsing for non-shell execution
130
- */
131
- private parseCommand;
132
- /**
133
- * Enhanced timeout promise with abort signal support
134
- */
135
- private createTimeoutPromise;
136
- /**
137
- * Parse command output according to Enact tool output schema
138
- */
139
- private parseOutput;
140
- /**
141
- * Execute command with exec.ts style interface for backwards compatibility
142
- */
143
- executeCommandExecStyle(command: string, timeout: string, verbose?: boolean, envVars?: Record<string, string>): Promise<void>;
144
- /**
145
- * Enhanced cleanup handlers with graceful shutdown
146
- */
147
- private registerCleanupHandlers;
148
- /**
149
- * Graceful shutdown with proper async cleanup
150
- */
151
- private gracefulShutdown;
152
- /**
153
- * Get current engine status for debugging
154
- */
155
- getEngineStatus(): {
156
- health: EngineHealthStatus;
157
- activeSessions: number;
158
- isShuttingDown: boolean;
159
- };
160
- /**
161
- * Manually trigger engine reset (for debugging/testing)
162
- */
163
- resetEngine(): Promise<void>;
164
- /**
165
- * Check if provider is ready for new executions
166
- */
167
- isReady(): boolean;
168
- }
169
- export {};