@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,248 +0,0 @@
1
- // src/utils/help.ts
2
- import pc from "picocolors";
3
- import { readFileSync } from "fs";
4
- import { join } from "path";
5
- /**
6
- * Get the package version from package.json
7
- */
8
- function getVersion() {
9
- try {
10
- const packageJsonPath = join(__dirname, "../../package.json");
11
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
12
- return packageJson.version || "0.1.0";
13
- }
14
- catch (error) {
15
- // Fallback version if package.json can't be read
16
- return "0.1.0";
17
- }
18
- }
19
- /**
20
- * Show the main help message
21
- */
22
- export function showHelp() {
23
- const version = getVersion();
24
- console.error(`
25
- ${pc.bold("Enact CLI")} ${pc.dim(`v${version}`)}
26
- ${pc.dim("A CLI tool for managing and publishing Enact tools")}
27
-
28
- ${pc.bold("Usage:")}
29
- ${pc.cyan("enact")} ${pc.green("<command>")} [options]
30
-
31
- ${pc.bold("Commands:")}
32
- ${pc.green("auth")} Manage authentication (login, logout, status, token)
33
- ${pc.green("env")} Manage environment variables (set, get, list, delete)
34
- ${pc.green("exec")} Execute a tool by fetching and running it
35
- ${pc.green("init")} Create a new tool definition
36
- ${pc.green("mcp")} MCP client integration (install, list, status)
37
- ${pc.green("publish")} Publish a tool to the registry
38
- ${pc.green("search")} Search for tools in the registry
39
- ${pc.green("sign")} Sign and verify tools with cryptographic signatures
40
- ${pc.green("remote")} Manage remote servers (add, list, remove)
41
- ${pc.green("user")} User operations (get public key)
42
-
43
- ${pc.bold("Global Options:")}
44
- ${pc.yellow("--help, -h")} Show help message
45
- ${pc.yellow("--version, -v")} Show version information
46
-
47
- ${pc.bold("Examples:")}
48
- ${pc.cyan("enact")} ${pc.dim("# Interactive mode")}
49
- ${pc.cyan("enact")} ${pc.green("search")} ${pc.yellow("--tags")} web,api ${pc.dim("# Search tools by tags")}
50
- ${pc.cyan("enact")} ${pc.green("exec")} enact/text/slugify ${pc.dim("# Execute a tool")}
51
- ${pc.cyan("enact")} ${pc.green("mcp")} install ${pc.yellow("--client")} claude-desktop ${pc.dim("# Install MCP server")}
52
- ${pc.cyan("enact")} ${pc.green("mcp")} install ${pc.yellow("--client")} goose ${pc.dim("# Install for Goose AI")}
53
- ${pc.cyan("enact")} ${pc.green("env")} set API_KEY --encrypt ${pc.dim("# Set encrypted env var")}
54
- ${pc.cyan("enact")} ${pc.green("sign")} verify my-tool.yaml ${pc.dim("# Verify tool signatures")}
55
- ${pc.cyan("enact")} ${pc.green("publish")} my-tool.yaml ${pc.dim("# Publish a tool")}
56
- ${pc.cyan("enact")} ${pc.green("auth")} login ${pc.dim("# Login with OAuth")}
57
- ${pc.cyan("enact")} ${pc.green("init")} ${pc.yellow("--minimal")} ${pc.dim("# Create minimal tool template")}
58
-
59
- ${pc.bold("More Help:")}
60
- ${pc.cyan("enact")} ${pc.green("<command>")} ${pc.yellow("--help")} ${pc.dim("# Show command-specific help")}
61
- `);
62
- }
63
- /**
64
- * Show version information
65
- */
66
- export function showVersion() {
67
- const version = getVersion();
68
- console.error(`@enactprotocol/cli v${version}`);
69
- }
70
- /**
71
- * Show help for the auth command
72
- */
73
- export function showAuthHelp() {
74
- console.error(`
75
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("<subcommand>")} [options]
76
-
77
- ${pc.bold("Manage authentication for Enact registry")}
78
-
79
- ${pc.bold("Subcommands:")}
80
- ${pc.blue("login")} Login using OAuth
81
- ${pc.blue("logout")} Logout and clear stored credentials
82
- ${pc.blue("status")} Check authentication status
83
- ${pc.blue("token")} Display current authentication token
84
-
85
- ${pc.bold("Options:")}
86
- ${pc.yellow("--help, -h")} Show this help message
87
- ${pc.yellow("--server, -s")} Specify server URL
88
- ${pc.yellow("--port, -p")} Specify port for OAuth callback
89
-
90
- ${pc.bold("Examples:")}
91
- ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("login")}
92
- ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("status")}
93
- ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("login")} ${pc.yellow("--server")} https://api.example.com
94
- `);
95
- }
96
- /**
97
- * Show help for the init command
98
- */
99
- export function showInitHelp() {
100
- console.error(`
101
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("init")} [options] [name]
102
-
103
- ${pc.bold("Create a new tool definition file")}
104
-
105
- ${pc.bold("Arguments:")}
106
- ${pc.blue("name")} Name for the new tool (optional)
107
-
108
- ${pc.bold("Options:")}
109
- ${pc.yellow("--help, -h")} Show this help message
110
- ${pc.yellow("--minimal, -m")} Create a minimal tool template
111
-
112
- ${pc.bold("Examples:")}
113
- ${pc.cyan("enact")} ${pc.green("init")}
114
- ${pc.cyan("enact")} ${pc.green("init")} my-awesome-tool
115
- ${pc.cyan("enact")} ${pc.green("init")} ${pc.yellow("--minimal")} simple-tool
116
- `);
117
- }
118
- /**
119
- * Show help for the publish command
120
- */
121
- export function showPublishHelp() {
122
- console.error(`
123
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("publish")} [options] [file]
124
-
125
- ${pc.bold("Publish a tool to the Enact registry")}
126
-
127
- ${pc.bold("Arguments:")}
128
- ${pc.blue("file")} The tool definition file to publish (YAML format)
129
-
130
- ${pc.bold("Options:")}
131
- ${pc.yellow("--help, -h")} Show this help message
132
- ${pc.yellow("--url")} Specify the registry URL
133
- ${pc.yellow("--token, -t")} Specify authentication token
134
-
135
- ${pc.bold("Examples:")}
136
- ${pc.cyan("enact")} ${pc.green("publish")} my-tool.yaml
137
- ${pc.cyan("enact")} ${pc.green("publish")} ${pc.yellow("--url")} https://registry.example.com my-tool.yaml
138
- ${pc.cyan("enact")} ${pc.green("publish")} ${pc.yellow("--token")} abc123 my-tool.yaml
139
- `);
140
- }
141
- /**
142
- * Show help for the search command
143
- */
144
- export function showSearchHelp() {
145
- console.error(`
146
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("search")} [options] [query]
147
-
148
- ${pc.bold("Search for tools in the Enact registry")}
149
-
150
- ${pc.bold("Arguments:")}
151
- ${pc.blue("query")} Search query (optional)
152
-
153
- ${pc.bold("Options:")}
154
- ${pc.yellow("--help, -h")} Show this help message
155
- ${pc.yellow("--limit, -l")} Limit number of results (default: 20)
156
- ${pc.yellow("--tags")} Filter by tags (comma-separated)
157
- ${pc.yellow("--author, -a")} Filter by author
158
- ${pc.yellow("--format, -f")} Output format (table, json, minimal)
159
-
160
- ${pc.bold("Examples:")}
161
- ${pc.cyan("enact")} ${pc.green("search")}
162
- ${pc.cyan("enact")} ${pc.green("search")} "web scraper"
163
- ${pc.cyan("enact")} ${pc.green("search")} ${pc.yellow("--tags")} web,api ${pc.yellow("--limit")} 10
164
- ${pc.cyan("enact")} ${pc.green("search")} ${pc.yellow("--author")} johndoe ${pc.yellow("--format")} json
165
- `);
166
- }
167
- /**
168
- * Show help for the remote command
169
- */
170
- export function showRemoteHelp() {
171
- console.error(`
172
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("<subcommand>")} [options]
173
-
174
- ${pc.bold("Manage remote Enact registry servers")}
175
-
176
- ${pc.bold("Subcommands:")}
177
- ${pc.blue("add")} Add a new remote server
178
- ${pc.blue("list")} List all configured remote servers
179
- ${pc.blue("remove")} Remove a remote server
180
-
181
- ${pc.bold("Options:")}
182
- ${pc.yellow("--help, -h")} Show this help message
183
-
184
- ${pc.bold("Examples:")}
185
- ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("add")}
186
- ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("list")}
187
- ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("remove")} origin
188
- `);
189
- }
190
- /**
191
- * Show help for the user command
192
- */
193
- export function showUserHelp() {
194
- console.error(`
195
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("<subcommand>")} [options]
196
-
197
- ${pc.bold("User operations for Enact registry")}
198
-
199
- ${pc.bold("Subcommands:")}
200
- ${pc.blue("public-key")} Get user's public key
201
-
202
- ${pc.bold("Options:")}
203
- ${pc.yellow("--help, -h")} Show this help message
204
- ${pc.yellow("--server, -s")} Specify server URL
205
- ${pc.yellow("--token, -t")} Specify authentication token
206
- ${pc.yellow("--format, -f")} Output format (default, json)
207
-
208
- ${pc.bold("Examples:")}
209
- ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("public-key")}
210
- ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("public-key")} ${pc.yellow("--format")} json
211
- ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("public-key")} ${pc.yellow("--server")} https://api.example.com
212
- `);
213
- }
214
- /**
215
- * Show help for the env command
216
- */
217
- export function showEnvHelp() {
218
- console.error(`
219
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("<subcommand>")} [options]
220
-
221
- ${pc.bold("Environment variable management for Enact CLI")}
222
-
223
- ${pc.bold("Subcommands:")}
224
- ${pc.blue("set")} ${pc.magenta("<name>")} [value] Set an environment variable
225
- ${pc.blue("get")} ${pc.magenta("<name>")} Get an environment variable
226
- ${pc.blue("list")} List all environment variables
227
- ${pc.blue("delete")} ${pc.magenta("<name>")} Delete an environment variable
228
- ${pc.blue("copy")} ${pc.magenta("<from>")} ${pc.magenta("<to>")} Copy variables between scopes
229
- ${pc.blue("export")} [format] Export variables (env|json|yaml)
230
- ${pc.blue("clear")} Clear all environment variables
231
-
232
- ${pc.bold("Options:")}
233
- ${pc.yellow("--help, -h")} Show this help message
234
- ${pc.yellow("--global")} Use global scope (default)
235
- ${pc.yellow("--project")} Use project scope
236
- ${pc.yellow("--encrypt")} Encrypt sensitive values
237
- ${pc.yellow("--format")} Output format (table|json)
238
- ${pc.yellow("--show")} Show actual values (default: hidden)
239
-
240
- ${pc.bold("Examples:")}
241
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("set")} OPENAI_API_KEY ${pc.yellow("--encrypt")}
242
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("set")} DATABASE_URL postgres://... ${pc.yellow("--project")}
243
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("get")} OPENAI_API_KEY ${pc.yellow("--show")}
244
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("list")} ${pc.yellow("--project")} ${pc.yellow("--format")} json
245
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("copy")} global project
246
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("export")} env > .env
247
- `);
248
- }
@@ -1,7 +0,0 @@
1
- export * from './config';
2
- export * from './env-loader';
3
- export { showHelp } from './help';
4
- export * from './logger';
5
- export * from './silent-monitor';
6
- export * from './timeout';
7
- export { showVersion } from './version';
@@ -1,7 +0,0 @@
1
- export * from './config';
2
- export * from './env-loader';
3
- export { showHelp } from './help';
4
- export * from './logger';
5
- export * from './silent-monitor';
6
- export * from './timeout';
7
- export { showVersion } from './version';
@@ -1,67 +0,0 @@
1
- /**
2
- * Runtime silent operation monitor for MCP server
3
- * This utility can be used to ensure the MCP server remains silent during operation
4
- */
5
- interface SilentOperationMonitor {
6
- startMonitoring(): void;
7
- stopMonitoring(): SilentOperationReport;
8
- isCurrentlyMonitoring(): boolean;
9
- getViolations(): string[];
10
- }
11
- interface SilentOperationReport {
12
- violations: string[];
13
- consoleOutputDetected: string[];
14
- processExitAttempts: number;
15
- readlineUsageDetected: boolean;
16
- duration: number;
17
- timestamp: string;
18
- }
19
- declare class McpSilentOperationMonitor implements SilentOperationMonitor {
20
- private isMonitoring;
21
- private violations;
22
- private consoleOutput;
23
- private processExitAttempts;
24
- private readlineUsageDetected;
25
- private startTime;
26
- private originalConsoleLog;
27
- private originalConsoleError;
28
- private originalConsoleWarn;
29
- private originalConsoleInfo;
30
- private originalProcessExit;
31
- private originalStdoutWrite;
32
- private originalStderrWrite;
33
- getOriginalConsoleError(): typeof console.error;
34
- constructor();
35
- startMonitoring(): void;
36
- stopMonitoring(): SilentOperationReport;
37
- isCurrentlyMonitoring(): boolean;
38
- getViolations(): string[];
39
- }
40
- /**
41
- * Global monitor instance
42
- */
43
- declare const globalMonitor: McpSilentOperationMonitor;
44
- /**
45
- * Decorator to ensure a function operates silently
46
- */
47
- export declare function ensureSilent<T extends (...args: any[]) => any>(fn: T): T;
48
- /**
49
- * Higher-order function to wrap MCP tool handlers for silent operation
50
- */
51
- export declare function silentMcpTool<T extends (...args: any[]) => Promise<any>>(handler: T): T;
52
- /**
53
- * Utility to check if environment is properly configured for silent operation
54
- */
55
- export declare function validateSilentEnvironment(): {
56
- valid: boolean;
57
- issues: string[];
58
- };
59
- /**
60
- * Logger specifically for MCP silent operation monitoring
61
- */
62
- export declare const silentLogger: {
63
- logViolation: (violation: string) => void;
64
- logReport: (report: SilentOperationReport) => void;
65
- };
66
- export { globalMonitor, McpSilentOperationMonitor };
67
- export type { SilentOperationMonitor, SilentOperationReport };
@@ -1,242 +0,0 @@
1
- /**
2
- * Runtime silent operation monitor for MCP server
3
- * This utility can be used to ensure the MCP server remains silent during operation
4
- */
5
- class McpSilentOperationMonitor {
6
- // Public getters for original methods
7
- getOriginalConsoleError() {
8
- return this.originalConsoleError;
9
- }
10
- constructor() {
11
- this.isMonitoring = false;
12
- this.violations = [];
13
- this.consoleOutput = [];
14
- this.processExitAttempts = 0;
15
- this.readlineUsageDetected = false;
16
- this.startTime = 0;
17
- // Store original methods
18
- this.originalConsoleLog = console.log;
19
- this.originalConsoleError = console.error;
20
- this.originalConsoleWarn = console.warn;
21
- this.originalConsoleInfo = console.info;
22
- this.originalProcessExit = process.exit;
23
- this.originalStdoutWrite = process.stdout.write;
24
- this.originalStderrWrite = process.stderr.write;
25
- }
26
- startMonitoring() {
27
- if (this.isMonitoring) {
28
- return;
29
- }
30
- this.isMonitoring = true;
31
- this.violations = [];
32
- this.consoleOutput = [];
33
- this.processExitAttempts = 0;
34
- this.readlineUsageDetected = false;
35
- this.startTime = Date.now();
36
- // Hook console methods
37
- console.log = (...args) => {
38
- const message = args.join(" ");
39
- this.consoleOutput.push(`[LOG] ${message}`);
40
- this.violations.push(`Console.log called: ${message}`);
41
- };
42
- console.error = (...args) => {
43
- const message = args.join(" ");
44
- this.consoleOutput.push(`[ERROR] ${message}`);
45
- this.violations.push(`Console.error called: ${message}`);
46
- };
47
- console.warn = (...args) => {
48
- const message = args.join(" ");
49
- this.consoleOutput.push(`[WARN] ${message}`);
50
- this.violations.push(`Console.warn called: ${message}`);
51
- };
52
- console.info = (...args) => {
53
- const message = args.join(" ");
54
- this.consoleOutput.push(`[INFO] ${message}`);
55
- this.violations.push(`Console.info called: ${message}`);
56
- };
57
- // Hook process.exit
58
- process.exit = ((code) => {
59
- this.processExitAttempts++;
60
- this.violations.push(`Process.exit called with code: ${code}`);
61
- throw new Error(`Process exit intercepted: ${code}`);
62
- });
63
- // Hook stdout/stderr
64
- process.stdout.write = ((chunk, ...args) => {
65
- if (typeof chunk === "string" && chunk.trim()) {
66
- this.consoleOutput.push(`[STDOUT] ${chunk}`);
67
- this.violations.push(`Process.stdout.write called: ${chunk.substring(0, 100)}...`);
68
- }
69
- return true;
70
- });
71
- process.stderr.write = ((chunk, ...args) => {
72
- if (typeof chunk === "string" && chunk.trim()) {
73
- this.consoleOutput.push(`[STDERR] ${chunk}`);
74
- this.violations.push(`Process.stderr.write called: ${chunk.substring(0, 100)}...`);
75
- }
76
- return true;
77
- });
78
- // Hook readline (if it gets required)
79
- const originalRequire = require;
80
- const monitor = this;
81
- global.require = function (id) {
82
- if (id === "readline" || id.includes("readline")) {
83
- monitor.readlineUsageDetected = true;
84
- monitor.violations.push("Readline module usage detected");
85
- }
86
- return originalRequire.apply(this, arguments);
87
- };
88
- }
89
- stopMonitoring() {
90
- if (!this.isMonitoring) {
91
- throw new Error("Monitor is not currently running");
92
- }
93
- // Restore original methods
94
- console.log = this.originalConsoleLog;
95
- console.error = this.originalConsoleError;
96
- console.warn = this.originalConsoleWarn;
97
- console.info = this.originalConsoleInfo;
98
- process.exit = this.originalProcessExit;
99
- process.stdout.write = this.originalStdoutWrite;
100
- process.stderr.write = this.originalStderrWrite;
101
- // Restore require
102
- global.require = require;
103
- this.isMonitoring = false;
104
- return {
105
- violations: [...this.violations],
106
- consoleOutputDetected: [...this.consoleOutput],
107
- processExitAttempts: this.processExitAttempts,
108
- readlineUsageDetected: this.readlineUsageDetected,
109
- duration: Date.now() - this.startTime,
110
- timestamp: new Date().toISOString(),
111
- };
112
- }
113
- isCurrentlyMonitoring() {
114
- return this.isMonitoring;
115
- }
116
- getViolations() {
117
- return [...this.violations];
118
- }
119
- }
120
- /**
121
- * Global monitor instance
122
- */
123
- const globalMonitor = new McpSilentOperationMonitor();
124
- /**
125
- * Decorator to ensure a function operates silently
126
- */
127
- export function ensureSilent(fn) {
128
- return ((...args) => {
129
- const wasMonitoring = globalMonitor.isCurrentlyMonitoring();
130
- if (!wasMonitoring) {
131
- globalMonitor.startMonitoring();
132
- }
133
- try {
134
- const result = fn(...args);
135
- // Handle both sync and async functions
136
- if (result && typeof result.then === "function") {
137
- return result.finally(() => {
138
- if (!wasMonitoring) {
139
- const report = globalMonitor.stopMonitoring();
140
- if (report.violations.length > 0) {
141
- throw new Error(`Silent operation violated: ${report.violations.join(", ")}`);
142
- }
143
- }
144
- });
145
- }
146
- else {
147
- if (!wasMonitoring) {
148
- const report = globalMonitor.stopMonitoring();
149
- if (report.violations.length > 0) {
150
- throw new Error(`Silent operation violated: ${report.violations.join(", ")}`);
151
- }
152
- }
153
- return result;
154
- }
155
- }
156
- catch (error) {
157
- if (!wasMonitoring && globalMonitor.isCurrentlyMonitoring()) {
158
- globalMonitor.stopMonitoring();
159
- }
160
- throw error;
161
- }
162
- });
163
- }
164
- /**
165
- * Higher-order function to wrap MCP tool handlers for silent operation
166
- */
167
- export function silentMcpTool(handler) {
168
- return (async (...args) => {
169
- const monitor = new McpSilentOperationMonitor();
170
- monitor.startMonitoring();
171
- try {
172
- const result = await handler(...args);
173
- const report = monitor.stopMonitoring();
174
- if (report.violations.length > 0) {
175
- // Log violations using the original console methods for debugging
176
- globalMonitor.getOriginalConsoleError()("🚨 MCP Tool Handler Violations:", report.violations);
177
- // In production, you might want to return an error response instead of throwing
178
- if (process.env.NODE_ENV === "production") {
179
- return {
180
- content: [
181
- {
182
- type: "text",
183
- text: "Internal error: Silent operation requirements violated",
184
- },
185
- ],
186
- isError: true,
187
- };
188
- }
189
- }
190
- return result;
191
- }
192
- catch (error) {
193
- const report = monitor.stopMonitoring();
194
- if (report.violations.length > 0) {
195
- globalMonitor.getOriginalConsoleError()("🚨 MCP Tool Handler Violations during error:", report.violations);
196
- }
197
- throw error;
198
- }
199
- });
200
- }
201
- /**
202
- * Utility to check if environment is properly configured for silent operation
203
- */
204
- export function validateSilentEnvironment() {
205
- const issues = [];
206
- // Check environment variables
207
- if (process.env.CI !== "true") {
208
- issues.push('CI environment variable not set to "true"');
209
- }
210
- if (process.env.ENACT_SKIP_INTERACTIVE !== "true") {
211
- issues.push('ENACT_SKIP_INTERACTIVE not set to "true"');
212
- }
213
- if (process.env.DEBUG === "true" || process.env.VERBOSE === "true") {
214
- issues.push("DEBUG or VERBOSE environment variables are enabled");
215
- }
216
- // Check if we're in a TTY (which might indicate interactive mode)
217
- if (process.stdin.isTTY) {
218
- issues.push("Process is running in TTY mode (potentially interactive)");
219
- }
220
- return {
221
- valid: issues.length === 0,
222
- issues,
223
- };
224
- }
225
- /**
226
- * Logger specifically for MCP silent operation monitoring
227
- */
228
- export const silentLogger = {
229
- logViolation: (violation) => {
230
- // Use stderr directly to bypass any console mocking
231
- process.stderr.write(`[SILENT-VIOLATION] ${new Date().toISOString()}: ${violation}\n`);
232
- },
233
- logReport: (report) => {
234
- if (report.violations.length > 0) {
235
- process.stderr.write(`[SILENT-REPORT] ${report.timestamp}: ${report.violations.length} violations in ${report.duration}ms\n`);
236
- report.violations.forEach((violation) => {
237
- process.stderr.write(` - ${violation}\n`);
238
- });
239
- }
240
- },
241
- };
242
- export { globalMonitor, McpSilentOperationMonitor };
@@ -1,5 +0,0 @@
1
- /**
2
- * Parse timeout string to milliseconds
3
- * Supports formats like "30s", "5m", "2h"
4
- */
5
- export declare function parseTimeout(timeout: string): number;
@@ -1,23 +0,0 @@
1
- // src/utils/timeout.ts - Shared timeout parsing utility
2
- /**
3
- * Parse timeout string to milliseconds
4
- * Supports formats like "30s", "5m", "2h"
5
- */
6
- export function parseTimeout(timeout) {
7
- const match = timeout.match(/^(\d+)([smh])$/);
8
- if (!match) {
9
- return 30000; // Default 30 seconds
10
- }
11
- const value = parseInt(match[1]);
12
- const unit = match[2];
13
- switch (unit) {
14
- case "s":
15
- return value * 1000;
16
- case "m":
17
- return value * 60 * 1000;
18
- case "h":
19
- return value * 60 * 60 * 1000;
20
- default:
21
- return 30000; // Default fallback
22
- }
23
- }
@@ -1,29 +0,0 @@
1
- interface PackageEnvInfo {
2
- namespace: string;
3
- path: string;
4
- variables: Record<string, string>;
5
- }
6
- /**
7
- * Get all package namespaces with environment variables
8
- */
9
- declare function getAllPackageNamespaces(): Promise<PackageEnvInfo[]>;
10
- /**
11
- * Get environment variables for a specific package namespace
12
- */
13
- declare function getPackageEnvVars(namespace: string): Promise<Record<string, string>>;
14
- /**
15
- * Set environment variable for a package namespace
16
- */
17
- declare function setPackageEnvVar(namespace: string, key: string, value: string): Promise<void>;
18
- /**
19
- * Delete environment variable for a package namespace
20
- */
21
- declare function deletePackageEnvVar(namespace: string, key: string): Promise<void>;
22
- /**
23
- * Start the web server
24
- */
25
- export declare function startEnvManagerServer(port?: number): Promise<{
26
- server: any;
27
- port: number;
28
- }>;
29
- export { getAllPackageNamespaces, getPackageEnvVars, setPackageEnvVar, deletePackageEnvVar, };