@automaton-labs/aib 0.0.5 → 0.0.7

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 (258) hide show
  1. package/dist/bin/cli.js +4 -2
  2. package/dist/commands/apply-module-plan.js +3 -3
  3. package/dist/commands/background-command.js +2 -0
  4. package/dist/commands/captured-input.js +1 -2
  5. package/dist/commands/config-command.js +2 -1
  6. package/dist/commands/config-output.js +10 -8
  7. package/dist/commands/control-plane-command.js +1 -0
  8. package/dist/commands/declaration-command.js +7 -0
  9. package/dist/commands/declaration-execution-cache.js +1 -0
  10. package/dist/commands/declaration-format.js +1 -0
  11. package/dist/commands/declaration-preview-cache.js +2 -0
  12. package/dist/commands/doctor.js +3 -1
  13. package/dist/commands/execution-command.js +1 -1
  14. package/dist/commands/file-command.js +1 -0
  15. package/dist/commands/file-move-to-dir-execution-cache.js +1 -0
  16. package/dist/commands/file-move-to-dir-preview-cache.js +2 -0
  17. package/dist/commands/file-move-to-dir.js +5 -0
  18. package/dist/commands/file-mutation-runtime.js +1 -0
  19. package/dist/commands/file-refactor-batch-execution-cache.js +1 -0
  20. package/dist/commands/file-refactor-batch-preview-cache.js +2 -0
  21. package/dist/commands/file-refactor-batch.js +5 -0
  22. package/dist/commands/file-rename-execution-cache.js +1 -0
  23. package/dist/commands/file-rename-preview-cache.js +2 -0
  24. package/dist/commands/file-rename.js +5 -0
  25. package/dist/commands/help-command.js +5 -5
  26. package/dist/commands/host-command.js +1 -0
  27. package/dist/commands/inspect-cycles.js +3 -3
  28. package/dist/commands/inspect-format.js +15 -15
  29. package/dist/commands/inspect-tree.js +2 -2
  30. package/dist/commands/inspect.js +12 -12
  31. package/dist/commands/move-to-file.js +2 -2
  32. package/dist/commands/ota-command.js +2 -0
  33. package/dist/commands/quick-read.js +8 -8
  34. package/dist/commands/refactor-batch.js +4 -4
  35. package/dist/commands/rename-entities.js +4 -4
  36. package/dist/commands/result-view.js +6 -5
  37. package/dist/commands/session-workspace.js +7 -7
  38. package/dist/commands/worker-command.js +1 -0
  39. package/dist/config/defaults.js +1 -1
  40. package/dist/config/env-vars.js +1 -1
  41. package/dist/config/path-aliases.js +1 -1
  42. package/dist/config/resolve-command-alias.js +1 -1
  43. package/dist/config/workspace-root.js +3 -3
  44. package/dist/content/content-bundle.js +1 -1
  45. package/dist/dsl/aib-dsl.js +1 -1
  46. package/dist/dsl/declaration-dsl.js +1 -0
  47. package/dist/dsl/file-move-to-dir-dsl.js +1 -0
  48. package/dist/dsl/file-refactor-batch-dsl.js +1 -0
  49. package/dist/dsl/file-rename-dsl.js +1 -0
  50. package/dist/help/bootstrap.bash.md +907 -0
  51. package/dist/help/bootstrap.md +105 -144
  52. package/dist/help/{json/bootstrap.md → bootstrap.pwsh.md} +216 -397
  53. package/dist/help/docs/dsl.md +4 -3
  54. package/dist/help/docs/file.move.md +46 -0
  55. package/dist/help/docs/file.rename.md +35 -0
  56. package/dist/help/docs/help-format.md +4 -7
  57. package/dist/help/docs/inspect.code.md +5 -5
  58. package/dist/help/docs/inspect.deps.md +7 -7
  59. package/dist/help/docs/inspect.file.md +2 -1
  60. package/dist/help/docs/inspect.graph.md +3 -3
  61. package/dist/help/docs/inspect.md +5 -5
  62. package/dist/help/docs/mutation.md +23 -13
  63. package/dist/help/docs/patterns.md +1 -5
  64. package/dist/help/docs/qr.md +7 -22
  65. package/dist/help/docs/quick-map.md +1 -0
  66. package/dist/help/docs/recipe.file-layout.md +15 -0
  67. package/dist/help/docs/rg.md +22 -0
  68. package/dist/help/docs/selectors.md +3 -2
  69. package/dist/help/docs/session.md +1 -1
  70. package/dist/help/dsl/bootstrap.bash.md +907 -0
  71. package/dist/help/dsl/bootstrap.md +105 -144
  72. package/dist/help/{json/full.md → dsl/bootstrap.pwsh.md} +216 -397
  73. package/dist/help/dsl/docs/dsl.md +4 -3
  74. package/dist/help/dsl/docs/file.move.md +46 -0
  75. package/dist/help/dsl/docs/file.rename.md +35 -0
  76. package/dist/help/dsl/docs/help-format.md +4 -7
  77. package/dist/help/dsl/docs/inspect.code.md +5 -5
  78. package/dist/help/dsl/docs/inspect.deps.md +7 -7
  79. package/dist/help/dsl/docs/inspect.file.md +2 -1
  80. package/dist/help/dsl/docs/inspect.graph.md +3 -3
  81. package/dist/help/dsl/docs/inspect.md +5 -5
  82. package/dist/help/dsl/docs/mutation.md +23 -13
  83. package/dist/help/dsl/docs/patterns.md +1 -5
  84. package/dist/help/dsl/docs/qr.md +7 -22
  85. package/dist/help/dsl/docs/quick-map.md +1 -0
  86. package/dist/help/dsl/docs/recipe.file-layout.md +15 -0
  87. package/dist/help/dsl/docs/rg.md +22 -0
  88. package/dist/help/dsl/docs/selectors.md +3 -2
  89. package/dist/help/dsl/docs/session.md +1 -1
  90. package/dist/help/dsl/full.md +105 -144
  91. package/dist/help/dsl/help-index.md +44 -0
  92. package/dist/help/dsl/tokens/qr.inline.examples.md +2 -0
  93. package/dist/help/dsl/tokens/stdin.examples.bash.md +8 -0
  94. package/dist/help/dsl/tokens/stdin.examples.pwsh.md +8 -0
  95. package/dist/help/dsl/tokens/stdin.examples.with-qr.bash.md +12 -0
  96. package/dist/help/dsl/tokens/stdin.examples.with-qr.pwsh.md +12 -0
  97. package/dist/help/dsl/topics/dsl.md +4 -3
  98. package/dist/help/dsl/topics/file.move.md +44 -0
  99. package/dist/help/dsl/topics/file.rename.md +33 -0
  100. package/dist/help/dsl/topics/help-format.md +4 -7
  101. package/dist/help/dsl/topics/inspect.code.md +5 -5
  102. package/dist/help/dsl/topics/inspect.deps.md +7 -7
  103. package/dist/help/dsl/topics/inspect.file.md +2 -1
  104. package/dist/help/dsl/topics/inspect.graph.md +3 -3
  105. package/dist/help/dsl/topics/inspect.md +5 -5
  106. package/dist/help/dsl/topics/mutation.md +23 -13
  107. package/dist/help/dsl/topics/patterns.md +1 -5
  108. package/dist/help/dsl/topics/qr.md +7 -22
  109. package/dist/help/dsl/topics/quick-map.md +1 -0
  110. package/dist/help/dsl/topics/recipe.file-layout.md +13 -0
  111. package/dist/help/dsl/topics/rg.md +20 -0
  112. package/dist/help/dsl/topics/selectors.md +3 -2
  113. package/dist/help/dsl/topics/session.md +1 -1
  114. package/dist/help/full.md +105 -144
  115. package/dist/help/help-index.md +44 -0
  116. package/dist/help/help-meta.json +45 -29
  117. package/dist/help/index.md +32 -75
  118. package/dist/help/tokens/qr.inline.examples.md +2 -0
  119. package/dist/help/tokens/stdin.examples.bash.md +8 -0
  120. package/dist/help/tokens/stdin.examples.pwsh.md +8 -0
  121. package/dist/help/tokens/stdin.examples.with-qr.bash.md +12 -0
  122. package/dist/help/tokens/stdin.examples.with-qr.pwsh.md +12 -0
  123. package/dist/help/topics/dsl.md +4 -3
  124. package/dist/help/topics/file.move.md +44 -0
  125. package/dist/help/topics/file.rename.md +33 -0
  126. package/dist/help/topics/help-format.md +4 -7
  127. package/dist/help/topics/inspect.code.md +5 -5
  128. package/dist/help/topics/inspect.deps.md +7 -7
  129. package/dist/help/topics/inspect.file.md +2 -1
  130. package/dist/help/topics/inspect.graph.md +3 -3
  131. package/dist/help/topics/inspect.md +5 -5
  132. package/dist/help/topics/mutation.md +23 -13
  133. package/dist/help/topics/patterns.md +1 -5
  134. package/dist/help/topics/qr.md +7 -22
  135. package/dist/help/topics/quick-map.md +1 -0
  136. package/dist/help/topics/recipe.file-layout.md +13 -0
  137. package/dist/help/topics/rg.md +20 -0
  138. package/dist/help/topics/selectors.md +3 -2
  139. package/dist/help/topics/session.md +1 -1
  140. package/dist/host/capabilities.js +1 -0
  141. package/dist/ide-launch/common.cjs +162 -162
  142. package/dist/managed-host/extension-vsix-resolver.js +1 -1
  143. package/dist/managed-host/manage-serve-web-host.cjs +141 -141
  144. package/dist/managed-host/serve-web-autostart.js +1 -1
  145. package/dist/managed-host/serve-web-host.cjs +1985 -1660
  146. package/dist/observability/config.js +1 -1
  147. package/dist/payloads/read-stdin-json.js +1 -1
  148. package/dist/rg-wrapper/core.js +6 -0
  149. package/dist/rg-wrapper/options.js +1 -0
  150. package/dist/rtk-wrapper/core.js +2 -0
  151. package/dist/runtime/input-source.js +1 -1
  152. package/dist/runtime/managed-runtime-provisioning.js +1 -1
  153. package/dist/runtime/run-command.js +1 -1
  154. package/dist/selectors/parse-entities.js +1 -1
  155. package/dist/session/daemon-state.js +2 -0
  156. package/dist/session/server.js +7 -6
  157. package/dist/shared/errors.js +14 -13
  158. package/dist/shared/operations.js +1 -1
  159. package/dist/shared/protocol.js +1 -1
  160. package/dist/shared/routes.js +1 -1
  161. package/dist/shared/stdin-examples.js +1 -0
  162. package/dist/shared/types.js +1 -1
  163. package/dist/tool-runtime/runtime-tools.js +1 -0
  164. package/dist/tracing/trace.js +5 -3
  165. package/dist/workers/control-plane/aib-control-plane-worker.cjs +80 -0
  166. package/dist/workers/control-plane/client-config.default.json +3 -0
  167. package/dist/workers/product-storage.js +1 -0
  168. package/dist/workers/registry.js +1 -0
  169. package/extension/vscode-refactor-bridge-extension.vsix +0 -0
  170. package/package.json +6 -4
  171. package/runtimes/launcher/linux-x64/aib +0 -0
  172. package/runtimes/launcher/win-x64/aib.exe +0 -0
  173. package/runtimes/tools/rg/darwin-arm64/rg +0 -0
  174. package/runtimes/tools/rg/darwin-x64/rg +0 -0
  175. package/runtimes/tools/rg/linux-arm64/rg +0 -0
  176. package/runtimes/tools/rg/linux-x64/rg +0 -0
  177. package/runtimes/tools/rg/manifest.json +36 -0
  178. package/runtimes/tools/rg/win32-x64/rg.exe +0 -0
  179. package/runtimes/tools/rtk/darwin-arm64/rtk +0 -0
  180. package/runtimes/tools/rtk/darwin-x64/rtk +0 -0
  181. package/runtimes/tools/rtk/linux-arm64/rtk +0 -0
  182. package/runtimes/tools/rtk/linux-x64/rtk +0 -0
  183. package/runtimes/tools/rtk/manifest.json +36 -0
  184. package/runtimes/tools/rtk/win32-x64/rtk.exe +0 -0
  185. package/scripts/provision-runtime.cjs +25 -1
  186. package/dist/help/json/docs/basics.md +0 -15
  187. package/dist/help/json/docs/config-setup.aliases.md +0 -56
  188. package/dist/help/json/docs/config-setup.excludes.md +0 -45
  189. package/dist/help/json/docs/config-setup.import-normalize.md +0 -86
  190. package/dist/help/json/docs/config-setup.import-rules.md +0 -96
  191. package/dist/help/json/docs/config-setup.tsconfigs.md +0 -33
  192. package/dist/help/json/docs/dsl.md +0 -25
  193. package/dist/help/json/docs/first-setup.md +0 -292
  194. package/dist/help/json/docs/help-format.md +0 -12
  195. package/dist/help/json/docs/help-protocol.md +0 -26
  196. package/dist/help/json/docs/imports.normalize.md +0 -47
  197. package/dist/help/json/docs/inspect.code.md +0 -41
  198. package/dist/help/json/docs/inspect.cycles.md +0 -38
  199. package/dist/help/json/docs/inspect.deps.md +0 -46
  200. package/dist/help/json/docs/inspect.duplicates.md +0 -65
  201. package/dist/help/json/docs/inspect.exports.md +0 -40
  202. package/dist/help/json/docs/inspect.file.md +0 -38
  203. package/dist/help/json/docs/inspect.graph.md +0 -139
  204. package/dist/help/json/docs/inspect.imports.md +0 -15
  205. package/dist/help/json/docs/inspect.md +0 -88
  206. package/dist/help/json/docs/inspect.members.md +0 -32
  207. package/dist/help/json/docs/inspect.tree.md +0 -32
  208. package/dist/help/json/docs/inspect.usages.md +0 -61
  209. package/dist/help/json/docs/modulePlan.md +0 -73
  210. package/dist/help/json/docs/move.md +0 -56
  211. package/dist/help/json/docs/mutation.md +0 -65
  212. package/dist/help/json/docs/patterns.md +0 -76
  213. package/dist/help/json/docs/prefs.md +0 -40
  214. package/dist/help/json/docs/qr.md +0 -37
  215. package/dist/help/json/docs/quick-map.md +0 -30
  216. package/dist/help/json/docs/refactor.batch.md +0 -72
  217. package/dist/help/json/docs/rename.md +0 -47
  218. package/dist/help/json/docs/reveal.md +0 -30
  219. package/dist/help/json/docs/selectors.md +0 -23
  220. package/dist/help/json/docs/session.md +0 -77
  221. package/dist/help/json/docs/view.md +0 -30
  222. package/dist/help/json/snippets/agents.md +0 -14
  223. package/dist/help/json/topics/basics.md +0 -13
  224. package/dist/help/json/topics/config-setup.aliases.md +0 -54
  225. package/dist/help/json/topics/config-setup.excludes.md +0 -43
  226. package/dist/help/json/topics/config-setup.import-normalize.md +0 -84
  227. package/dist/help/json/topics/config-setup.import-rules.md +0 -94
  228. package/dist/help/json/topics/config-setup.tsconfigs.md +0 -31
  229. package/dist/help/json/topics/dsl.md +0 -23
  230. package/dist/help/json/topics/first-setup.md +0 -290
  231. package/dist/help/json/topics/help-format.md +0 -10
  232. package/dist/help/json/topics/help-protocol.md +0 -24
  233. package/dist/help/json/topics/imports.normalize.md +0 -45
  234. package/dist/help/json/topics/inspect.code.md +0 -39
  235. package/dist/help/json/topics/inspect.cycles.md +0 -36
  236. package/dist/help/json/topics/inspect.deps.md +0 -44
  237. package/dist/help/json/topics/inspect.duplicates.md +0 -37
  238. package/dist/help/json/topics/inspect.exports.md +0 -38
  239. package/dist/help/json/topics/inspect.file.md +0 -36
  240. package/dist/help/json/topics/inspect.graph.md +0 -137
  241. package/dist/help/json/topics/inspect.imports.md +0 -13
  242. package/dist/help/json/topics/inspect.md +0 -86
  243. package/dist/help/json/topics/inspect.members.md +0 -30
  244. package/dist/help/json/topics/inspect.tree.md +0 -22
  245. package/dist/help/json/topics/inspect.usages.md +0 -59
  246. package/dist/help/json/topics/modulePlan.md +0 -60
  247. package/dist/help/json/topics/move.md +0 -46
  248. package/dist/help/json/topics/mutation.md +0 -63
  249. package/dist/help/json/topics/patterns.md +0 -74
  250. package/dist/help/json/topics/prefs.md +0 -38
  251. package/dist/help/json/topics/qr.md +0 -35
  252. package/dist/help/json/topics/quick-map.md +0 -28
  253. package/dist/help/json/topics/refactor.batch.md +0 -61
  254. package/dist/help/json/topics/rename.md +0 -42
  255. package/dist/help/json/topics/reveal.md +0 -28
  256. package/dist/help/json/topics/selectors.md +0 -21
  257. package/dist/help/json/topics/session.md +0 -59
  258. package/dist/help/json/topics/view.md +0 -28
@@ -1,141 +1,141 @@
1
- #!/usr/bin/env node
2
-
3
- const path = require("node:path");
4
- const {
5
- cleanupExpiredManagedServeWebHosts,
6
- getManagedServeWebHostStatus,
7
- killManagedServeWebHosts,
8
- runManagedServeWebWatchdog,
9
- startManagedServeWebHost,
10
- stopManagedServeWebHost
11
- } = require("./serve-web-host.cjs");
12
-
13
- function parseArgs(argv) {
14
- const command = argv[0] ?? "status";
15
- const options = {
16
- command,
17
- all: false,
18
- fixture: null,
19
- vsix: null,
20
- waitMs: 45_000,
21
- pollMs: 500,
22
- port: null,
23
- reuse: true,
24
- ideCommand: null,
25
- hostKind: null,
26
- chromePath: null,
27
- runDir: null,
28
- ttlMs: null,
29
- intervalMs: 30_000
30
- };
31
-
32
- for (let index = 1; index < argv.length; index += 1) {
33
- const current = argv[index];
34
- const next = argv[index + 1];
35
- if (current === "--fixture" && next) {
36
- options.fixture = path.resolve(next);
37
- index += 1;
38
- continue;
39
- }
40
- if (current === "--vsix" && next) {
41
- options.vsix = path.resolve(next);
42
- index += 1;
43
- continue;
44
- }
45
- if (current === "--wait-ms" && next) {
46
- options.waitMs = Number(next);
47
- index += 1;
48
- continue;
49
- }
50
- if (current === "--poll-ms" && next) {
51
- options.pollMs = Number(next);
52
- index += 1;
53
- continue;
54
- }
55
- if (current === "--port" && next) {
56
- options.port = Number(next);
57
- index += 1;
58
- continue;
59
- }
60
- if (current === "--ide-command" && next) {
61
- options.ideCommand = next;
62
- index += 1;
63
- continue;
64
- }
65
- if (current === "--host-kind" && next) {
66
- options.hostKind = next;
67
- index += 1;
68
- continue;
69
- }
70
- if (current === "--chrome-path" && next) {
71
- options.chromePath = looksLikePath(next) ? path.resolve(next) : next;
72
- index += 1;
73
- continue;
74
- }
75
- if (current === "--run-dir" && next) {
76
- options.runDir = path.resolve(next);
77
- index += 1;
78
- continue;
79
- }
80
- if (current === "--ttl-ms" && next) {
81
- options.ttlMs = Number(next);
82
- index += 1;
83
- continue;
84
- }
85
- if (current === "--interval-ms" && next) {
86
- options.intervalMs = Number(next);
87
- index += 1;
88
- continue;
89
- }
90
- if (current === "--no-reuse") {
91
- options.reuse = false;
92
- continue;
93
- }
94
- if (current === "--all") {
95
- options.all = true;
96
- continue;
97
- }
98
- throw new Error(`Unknown argument: ${current}`);
99
- }
100
-
101
- if (!["start", "status", "stop", "kill", "cleanup", "watchdog"].includes(options.command)) {
102
- throw new Error("Expected command: start, status, stop, kill, cleanup, or watchdog.");
103
- }
104
-
105
- return options;
106
- }
107
-
108
- function looksLikePath(value) {
109
- return value.includes("\\") || value.includes("/") || /^[A-Za-z]:/.test(value);
110
- }
111
-
112
- async function main() {
113
- const options = parseArgs(process.argv.slice(2));
114
- let result;
115
- if (options.command === "start") {
116
- result = await startManagedServeWebHost(options);
117
- } else if (options.command === "stop") {
118
- result = await stopManagedServeWebHost(options);
119
- } else if (options.command === "kill") {
120
- result = await killManagedServeWebHosts(options);
121
- } else if (options.command === "cleanup") {
122
- result = await cleanupExpiredManagedServeWebHosts(options);
123
- } else if (options.command === "watchdog") {
124
- result = await runManagedServeWebWatchdog(options);
125
- } else {
126
- result = await getManagedServeWebHostStatus(options);
127
- }
128
-
129
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
130
- if (result.ok === false) {
131
- process.exitCode = 1;
132
- }
133
- }
134
-
135
- main().catch((error) => {
136
- process.stdout.write(`${JSON.stringify({
137
- ok: false,
138
- error: error instanceof Error ? error.stack ?? error.message : String(error)
139
- }, null, 2)}\n`);
140
- process.exitCode = 1;
141
- });
1
+ #!/usr/bin/env node
2
+
3
+ const path = require("node:path");
4
+ const {
5
+ cleanupExpiredManagedServeWebHosts,
6
+ getManagedServeWebHostStatus,
7
+ killManagedServeWebHosts,
8
+ runManagedServeWebWatchdog,
9
+ startManagedServeWebHost,
10
+ stopManagedServeWebHost
11
+ } = require("./serve-web-host.cjs");
12
+
13
+ function parseArgs(argv) {
14
+ const command = argv[0] ?? "status";
15
+ const options = {
16
+ command,
17
+ all: false,
18
+ fixture: null,
19
+ vsix: null,
20
+ waitMs: 45_000,
21
+ pollMs: 500,
22
+ port: null,
23
+ reuse: true,
24
+ ideCommand: null,
25
+ hostKind: null,
26
+ chromePath: null,
27
+ runDir: null,
28
+ ttlMs: null,
29
+ intervalMs: 30_000
30
+ };
31
+
32
+ for (let index = 1; index < argv.length; index += 1) {
33
+ const current = argv[index];
34
+ const next = argv[index + 1];
35
+ if (current === "--fixture" && next) {
36
+ options.fixture = path.resolve(next);
37
+ index += 1;
38
+ continue;
39
+ }
40
+ if (current === "--vsix" && next) {
41
+ options.vsix = path.resolve(next);
42
+ index += 1;
43
+ continue;
44
+ }
45
+ if (current === "--wait-ms" && next) {
46
+ options.waitMs = Number(next);
47
+ index += 1;
48
+ continue;
49
+ }
50
+ if (current === "--poll-ms" && next) {
51
+ options.pollMs = Number(next);
52
+ index += 1;
53
+ continue;
54
+ }
55
+ if (current === "--port" && next) {
56
+ options.port = Number(next);
57
+ index += 1;
58
+ continue;
59
+ }
60
+ if (current === "--ide-command" && next) {
61
+ options.ideCommand = next;
62
+ index += 1;
63
+ continue;
64
+ }
65
+ if (current === "--host-kind" && next) {
66
+ options.hostKind = next;
67
+ index += 1;
68
+ continue;
69
+ }
70
+ if (current === "--chrome-path" && next) {
71
+ options.chromePath = looksLikePath(next) ? path.resolve(next) : next;
72
+ index += 1;
73
+ continue;
74
+ }
75
+ if (current === "--run-dir" && next) {
76
+ options.runDir = path.resolve(next);
77
+ index += 1;
78
+ continue;
79
+ }
80
+ if (current === "--ttl-ms" && next) {
81
+ options.ttlMs = Number(next);
82
+ index += 1;
83
+ continue;
84
+ }
85
+ if (current === "--interval-ms" && next) {
86
+ options.intervalMs = Number(next);
87
+ index += 1;
88
+ continue;
89
+ }
90
+ if (current === "--no-reuse") {
91
+ options.reuse = false;
92
+ continue;
93
+ }
94
+ if (current === "--all") {
95
+ options.all = true;
96
+ continue;
97
+ }
98
+ throw new Error(`Unknown argument: ${current}`);
99
+ }
100
+
101
+ if (!["start", "status", "stop", "kill", "cleanup", "watchdog"].includes(options.command)) {
102
+ throw new Error("Expected command: start, status, stop, kill, cleanup, or watchdog.");
103
+ }
104
+
105
+ return options;
106
+ }
107
+
108
+ function looksLikePath(value) {
109
+ return value.includes("\\") || value.includes("/") || /^[A-Za-z]:/.test(value);
110
+ }
111
+
112
+ async function main() {
113
+ const options = parseArgs(process.argv.slice(2));
114
+ let result;
115
+ if (options.command === "start") {
116
+ result = await startManagedServeWebHost(options);
117
+ } else if (options.command === "stop") {
118
+ result = await stopManagedServeWebHost(options);
119
+ } else if (options.command === "kill") {
120
+ result = await killManagedServeWebHosts(options);
121
+ } else if (options.command === "cleanup") {
122
+ result = await cleanupExpiredManagedServeWebHosts(options);
123
+ } else if (options.command === "watchdog") {
124
+ result = await runManagedServeWebWatchdog(options);
125
+ } else {
126
+ result = await getManagedServeWebHostStatus(options);
127
+ }
128
+
129
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
130
+ if (result.ok === false) {
131
+ process.exitCode = 1;
132
+ }
133
+ }
134
+
135
+ main().catch((error) => {
136
+ process.stdout.write(`${JSON.stringify({
137
+ ok: false,
138
+ error: error instanceof Error ? error.stack ?? error.message : String(error)
139
+ }, null, 2)}\n`);
140
+ process.exitCode = 1;
141
+ });
@@ -1 +1 @@
1
- "use strict";var x=exports&&exports.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),D=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),M=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var r=[];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[r.length]=s);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=t(e),s=0;s<r.length;s++)r[s]!=="default"&&x(n,e,r[s]);return D(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startManagedServeWebForCwd=W,exports.stopManagedServeWebForCwd=R,exports.stopAllManagedServeWeb=L,exports.killAllManagedServeWeb=O,exports.statusManagedServeWebForCwd=V,exports.statusAllManagedServeWeb=H,exports.cleanupExpiredManagedServeWebForCwd=j;const g=M(require("node:fs")),c=M(require("node:path")),_=require("node:child_process"),u=require("../config/env-vars"),l=require("../shared/errors"),w=require("../shared/diagnostics"),S=require("./extension-vsix-resolver"),h=require("../config/workspace-root"),P=require("../runtime/bundled-node"),k=require("../runtime/managed-runtime-provisioning");function N(){const t=[c.resolve(__dirname),process.cwd()];for(const e of t){let n=e;for(;;){const r=c.join(n,"scripts","managed-host","manage-serve-web-host.cjs"),s=c.join(n,"package.json");if(g.existsSync(r)&&g.existsSync(s))return n;const o=c.dirname(n);if(o===n)break;n=o}}return null}function E(t){const e=process.env[t];return e&&e.trim()?c.resolve(e.trim()):null}function A(t){const e=process.env[t];return e&&e.trim()?e.trim():null}function T(){const t=process.env[u.CLI_ENV.managedHostWaitMs];if(t===void 0||t.trim()==="")return 45e3;const e=Number(t);if(!Number.isInteger(e)||e<=0)throw new l.CliError("AUTO_START_IDE_INVALID_WAIT_MS",`Expected ${u.CLI_ENV.managedHostWaitMs} to be a positive integer.`,{env:u.CLI_ENV.managedHostWaitMs,value:t,hints:(0,w.buildAutoStartIdeHints)()});return e}function f(){const t=E(u.CLI_ENV.managedHostScript),e=T(),n=A(u.CLI_ENV.ideCommand),r=E(u.CLI_ENV.chromePath),s=E(u.CLI_ENV.managedHostRunDir),o=N(),a=c.resolve(__dirname,"..","..");(0,k.ensureManagedRuntimeProvisioned)(a);const i=A(u.CLI_ENV.managedHostKind)??y(a),d=(0,P.resolveNodeRuntime)(a);if(t){const m=(0,S.resolveExtensionVsixPath)({repoRoot:o,packageRoot:a});return{scriptPath:t,vsixPath:m.path,vsixSource:m.source,cwd:c.dirname(t),waitMs:e,ideCommand:n,hostKind:i,chromePath:r,runDir:s,nodeCommand:d.command,nodeSource:d.source,source:"env"}}const p=c.join(__dirname,"manage-serve-web-host.cjs");if(g.existsSync(p)){const m=(0,S.resolveExtensionVsixPath)({repoRoot:o,packageRoot:a});return{scriptPath:p,vsixPath:m.path,vsixSource:m.source,cwd:c.resolve(__dirname,"..",".."),waitMs:e,ideCommand:n,hostKind:i,chromePath:r,runDir:s,nodeCommand:d.command,nodeSource:d.source,source:"packaged-cli"}}if(o){const m=(0,S.resolveExtensionVsixPath)({repoRoot:o,packageRoot:a});return{scriptPath:c.join(o,"scripts","managed-host","manage-serve-web-host.cjs"),vsixPath:m.path,vsixSource:m.source,cwd:o,waitMs:e,ideCommand:n,hostKind:i,chromePath:r,runDir:s,nodeCommand:d.command,nodeSource:d.source,source:"repo-dev-fallback"}}throw new l.CliError("AUTO_START_IDE_UNAVAILABLE","Managed IDE auto-start is unavailable because no packaged managed-host assets or development repo managed-host scripts were found.",{searchedFrom:[c.resolve(__dirname),process.cwd()],optionalEnv:[u.CLI_ENV.managedHostScript,u.CLI_ENV.extensionVsix],hints:(0,w.buildAutoStartIdeHints)()})}function y(t){const e=c.join(t,"runtimes","code-server","node_modules","code-server","out","node","entry.js");return g.existsSync(e)?"code-server":null}function C(t,e,n,r){if(!g.existsSync(t))throw new l.CliError(e,n,{...r,hints:(0,w.buildAutoStartIdeHints)(),path:t})}function v(t){try{return JSON.parse(t)}catch(e){throw new l.CliError("AUTO_START_IDE_INVALID_OUTPUT","Managed IDE host returned non-JSON output.",{stdout:t,parseError:e instanceof Error?e.message:String(e)})}}async function W(t){const e=f(),r=(0,h.resolveRequiredWorkspaceRoot)(t).root,s=b(r),o=F(r);C(e.scriptPath,"AUTO_START_IDE_SCRIPT_NOT_FOUND","Managed IDE auto-start needs a managed host script.",{env:u.CLI_ENV.managedHostScript,source:e.source}),C(e.vsixPath,"AUTO_START_IDE_VSIX_NOT_FOUND","Managed IDE auto-start needs a packaged extension VSIX.",{env:u.CLI_ENV.extensionVsix,source:e.source,vsixSource:e.vsixSource,hint:e.source==="repo-dev-fallback"?"Run npm --prefix packages/extension run package:vsix before using --auto-start-ide.":`Set ${u.CLI_ENV.extensionVsix} to an existing packaged VSIX path.`});const a=[e.scriptPath,"start","--fixture",r,"--vsix",e.vsixPath,"--wait-ms",String(e.waitMs),"--ttl-ms",String(s),"--interval-ms",String(o)];e.ideCommand&&a.push("--ide-command",e.ideCommand),e.hostKind&&a.push("--host-kind",e.hostKind),e.chromePath&&a.push("--chrome-path",e.chromePath),e.runDir&&a.push("--run-dir",e.runDir);const i=(0,_.spawnSync)(e.nodeCommand,a,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:e.waitMs+45e3,stdio:["ignore","pipe","pipe"]}),d=i.stdout??"",p=d.trim()?v(d):null;if(i.status!==0||!p||p.ok!==!0)throw new l.CliError("AUTO_START_IDE_FAILED","Managed IDE auto-start failed.",{status:i.status,signal:i.signal,error:i.error?i.error.message:null,stdout:d,stderr:i.stderr??"",runtime:{source:e.source,scriptPath:e.scriptPath,vsixPath:e.vsixPath,vsixSource:e.vsixSource,waitMs:e.waitMs,ideCommand:e.ideCommand,hostKind:e.hostKind,chromePath:e.chromePath,runDir:e.runDir,nodeCommand:e.nodeCommand,nodeSource:e.nodeSource},hints:(0,w.buildAutoStartIdeHints)(),payload:p});return p}async function R(t){const e=f(),n=(0,h.resolveRequiredWorkspaceRoot)(t),r=[e.scriptPath,"stop","--fixture",n.root];e.ideCommand&&r.push("--ide-command",e.ideCommand),e.hostKind&&r.push("--host-kind",e.hostKind);const s=(0,_.spawnSync)(e.nodeCommand,r,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),o=s.stdout??"",a=o.trim()?v(o):null;if(s.status!==0||!a||a.ok!==!0)throw new l.CliError("MANAGED_IDE_STOP_FAILED","Managed IDE stop failed.",{status:s.status,signal:s.signal,error:s.error?s.error.message:null,stdout:o,stderr:s.stderr??"",workspaceRoot:n.root});return K(n.root,a)}async function L(){return I(["stop","--all"],"MANAGED_IDE_STOP_FAILED")}async function O(){return I(["kill","--all"],"MANAGED_IDE_KILL_FAILED")}async function V(t){const e=f(),n=(0,h.resolveRequiredWorkspaceRoot)(t),r=[e.scriptPath,"status","--fixture",n.root];e.ideCommand&&r.push("--ide-command",e.ideCommand),e.hostKind&&r.push("--host-kind",e.hostKind);const s=(0,_.spawnSync)(e.nodeCommand,r,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),o=s.stdout??"",a=o.trim()?v(o):null;if(s.status!==0||!a||a.ok!==!0)throw new l.CliError("MANAGED_IDE_STATUS_FAILED","Managed IDE status failed.",{status:s.status,signal:s.signal,error:s.error?s.error.message:null,stdout:o,stderr:s.stderr??"",workspaceRoot:n.root});return q(n.root,a)}async function H(){return I(["status","--all"],"MANAGED_IDE_STATUS_FAILED")}async function j(t){const e=f(),n=(0,h.resolveRequiredWorkspaceRoot)(t),r=b(n.root),s=[e.scriptPath,"cleanup","--ttl-ms",String(r)];e.ideCommand&&s.push("--ide-command",e.ideCommand),e.hostKind&&s.push("--host-kind",e.hostKind);const o=(0,_.spawnSync)(e.nodeCommand,s,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),a=o.stdout??"",i=a.trim()?v(a):null;if(o.status!==0||!i||i.ok!==!0)throw new l.CliError("MANAGED_IDE_CLEANUP_FAILED","Managed IDE cleanup failed.",{status:o.status,signal:o.signal,error:o.error?o.error.message:null,stdout:a,stderr:o.stderr??"",workspaceRoot:n.root});return i}function I(t,e){const n=f(),r=(0,_.spawnSync)(n.nodeCommand,[n.scriptPath,...t],{cwd:n.cwd,encoding:"utf8",windowsHide:!0,timeout:45e3,stdio:["ignore","pipe","pipe"]}),s=r.stdout??"",o=s.trim()?v(s):null;if(r.status!==0||!o||o.ok!==!0)throw new l.CliError(e,"Managed IDE runtime command failed.",{status:r.status,signal:r.signal,error:r.error?r.error.message:null,stdout:s,stderr:r.stderr??"",args:t});return o}function b(t){if(!(0,h.readWorkspaceBooleanConfig)(t,"runtime.autoStopManagedIde",!0))return 0;const n=(0,h.readWorkspaceNumberConfig)(t,"runtime.managedIdeTtlMinutes",15);return n>0?Math.round(n*6e4):0}function F(t){const e=(0,h.readWorkspaceNumberConfig)(t,"runtime.managedIdeWatchdogIntervalMs",3e4);return e>0?Math.round(e):3e4}function K(t,e){return{stopped:e.stopped===!0,workspaceRoot:t,...typeof e.hostId=="string"?{hostId:e.hostId}:{},...typeof e.reason=="string"?{reason:e.reason}:{}}}function q(t,e){const n=e.metadata&&typeof e.metadata=="object"&&!Array.isArray(e.metadata)?e.metadata:{},r=e.health&&typeof e.health=="object"&&!Array.isArray(e.health)?e.health:{};return{ok:!0,workspaceRoot:t,workspace:".",hostId:typeof e.hostId=="string"?e.hostId:null,host:typeof n.hostKind=="string"?n.hostKind:"managed",running:e.running===!0,healthy:e.healthy===!0,reason:typeof e.reason=="string"?e.reason:null,health:{serveWebAlive:r.serveWebAlive===!0,browserAlive:r.browserAlive===!0,extensionHostAlive:r.extensionHostAlive===!0,workspaceMatches:r.workspaceMatches===!0,vsixMatches:r.vsixMatches===!0}}}
1
+ "use strict";var N=exports&&exports.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),y=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),C=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[n.length]=o);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),o=0;o<n.length;o++)n[o]!=="default"&&N(r,e,n[o]);return y(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startManagedServeWebForCwd=H,exports.stopManagedServeWebForCwd=U,exports.stopAllManagedServeWeb=q,exports.killAllManagedServeWeb=G,exports.statusManagedServeWebForCwd=B,exports.statusAllManagedServeWeb=J,exports.cleanupExpiredManagedServeWebForCwd=X;const f=C(require("node:fs")),l=C(require("node:path")),_=require("node:child_process"),m=require("../config/env-vars"),p=require("../shared/errors"),E=require("../shared/diagnostics"),M=require("./extension-vsix-resolver"),g=require("../config/workspace-root"),W=require("../runtime/bundled-node"),b=require("../runtime/managed-runtime-provisioning"),R=2e3,v=new Map;function L(){const t=[l.resolve(__dirname),process.cwd()];for(const e of t){let r=e;for(;;){const n=l.join(r,"scripts","managed-host","manage-serve-web-host.cjs"),o=l.join(r,"package.json");if(f.existsSync(n)&&f.existsSync(o))return r;const s=l.dirname(r);if(s===r)break;r=s}}return null}function I(t){const e=process.env[t];return e&&e.trim()?l.resolve(e.trim()):null}function P(t){const e=process.env[t];return e&&e.trim()?e.trim():null}function O(){const t=process.env[m.CLI_ENV.managedHostWaitMs];if(t===void 0||t.trim()==="")return 45e3;const e=Number(t);if(!Number.isInteger(e)||e<=0)throw new p.CliError("AUTO_START_IDE_INVALID_WAIT_MS",`Expected ${m.CLI_ENV.managedHostWaitMs} to be a positive integer.`,{env:m.CLI_ENV.managedHostWaitMs,value:t,hints:(0,E.buildAutoStartIdeHints)()});return e}function w(){const t=I(m.CLI_ENV.managedHostScript),e=O(),r=P(m.CLI_ENV.ideCommand),n=I(m.CLI_ENV.chromePath),o=I(m.CLI_ENV.managedHostRunDir),s=L(),a=l.resolve(__dirname,"..","..");(0,b.ensureManagedRuntimeProvisioned)(a);const i=P(m.CLI_ENV.managedHostKind)??V(a),d=(0,W.resolveNodeRuntime)(a);if(t){const u=(0,M.resolveExtensionVsixPath)({repoRoot:s,packageRoot:a});return{scriptPath:t,vsixPath:u.path,vsixSource:u.source,cwd:l.dirname(t),waitMs:e,ideCommand:r,hostKind:i,chromePath:n,runDir:o,nodeCommand:d.command,nodeSource:d.source,source:"env"}}const c=l.join(__dirname,"manage-serve-web-host.cjs");if(f.existsSync(c)){const u=(0,M.resolveExtensionVsixPath)({repoRoot:s,packageRoot:a});return{scriptPath:c,vsixPath:u.path,vsixSource:u.source,cwd:l.resolve(__dirname,"..",".."),waitMs:e,ideCommand:r,hostKind:i,chromePath:n,runDir:o,nodeCommand:d.command,nodeSource:d.source,source:"packaged-cli"}}if(s){const u=(0,M.resolveExtensionVsixPath)({repoRoot:s,packageRoot:a});return{scriptPath:l.join(s,"scripts","managed-host","manage-serve-web-host.cjs"),vsixPath:u.path,vsixSource:u.source,cwd:s,waitMs:e,ideCommand:r,hostKind:i,chromePath:n,runDir:o,nodeCommand:d.command,nodeSource:d.source,source:"repo-dev-fallback"}}throw new p.CliError("AUTO_START_IDE_UNAVAILABLE","Managed IDE auto-start is unavailable because no packaged managed-host assets or development repo managed-host scripts were found.",{searchedFrom:[l.resolve(__dirname),process.cwd()],optionalEnv:[m.CLI_ENV.managedHostScript,m.CLI_ENV.extensionVsix],hints:(0,E.buildAutoStartIdeHints)()})}function V(t){const e=l.join(t,"runtimes","code-server","node_modules","code-server","out","node","entry.js");return f.existsSync(e)&&(0,b.managedRuntimePlatformStatus)(t).ok?"code-server":null}function D(t,e,r,n){if(!f.existsSync(t))throw new p.CliError(e,r,{...n,hints:(0,E.buildAutoStartIdeHints)(),path:t})}function S(t){try{return JSON.parse(t)}catch(e){throw new p.CliError("AUTO_START_IDE_INVALID_OUTPUT","Managed IDE host returned non-JSON output.",{stdout:t,parseError:e instanceof Error?e.message:String(e)})}}async function H(t){const e=w(),n=(0,g.resolveRequiredWorkspaceRoot)(t).root,o=x(n),s=$(n);D(e.scriptPath,"AUTO_START_IDE_SCRIPT_NOT_FOUND","Managed IDE auto-start needs a managed host script.",{env:m.CLI_ENV.managedHostScript,source:e.source}),D(e.vsixPath,"AUTO_START_IDE_VSIX_NOT_FOUND","Managed IDE auto-start needs a packaged extension VSIX.",{env:m.CLI_ENV.extensionVsix,source:e.source,vsixSource:e.vsixSource,hint:e.source==="repo-dev-fallback"?"Run npm --prefix packages/extension run package:vsix before using --auto-start-ide.":`Set ${m.CLI_ENV.extensionVsix} to an existing packaged VSIX path.`});const a=[e.scriptPath,"start","--fixture",n,"--vsix",e.vsixPath,"--wait-ms",String(e.waitMs),"--ttl-ms",String(o),"--interval-ms",String(s)];e.ideCommand&&a.push("--ide-command",e.ideCommand),e.hostKind&&a.push("--host-kind",e.hostKind),e.chromePath&&a.push("--chrome-path",e.chromePath),e.runDir&&a.push("--run-dir",e.runDir);const i=F(e,n),d=v.get(i);if(d?.promise)return d.promise;if(d?.error&&d.failedUntil!==void 0&&d.failedUntil>Date.now())throw d.error;const c=j(e,a).catch(u=>{throw v.set(i,{failedUntil:Date.now()+R,error:u}),u}).finally(()=>{v.get(i)?.promise===c&&v.delete(i)});return v.set(i,{promise:c}),c}async function j(t,e){const r=await K(t.nodeCommand,e,{cwd:t.cwd,timeoutMs:t.waitMs+45e3}),n=r.stdout,o=n.trim()?S(n):null;if(r.status!==0||!o||o.ok!==!0)throw new p.CliError("AUTO_START_IDE_FAILED","Managed IDE auto-start failed.",{status:r.status,signal:r.signal,error:r.error?r.error.message:null,stdout:n,stderr:r.stderr??"",runtime:{source:t.source,scriptPath:t.scriptPath,vsixPath:t.vsixPath,vsixSource:t.vsixSource,waitMs:t.waitMs,ideCommand:t.ideCommand,hostKind:t.hostKind,chromePath:t.chromePath,runDir:t.runDir,nodeCommand:t.nodeCommand,nodeSource:t.nodeSource},hints:(0,E.buildAutoStartIdeHints)(),payload:o});return o}function F(t,e){return[l.resolve(e),t.hostKind??"",t.scriptPath,t.vsixPath,t.runDir??"",t.ideCommand??"",t.chromePath??"",t.nodeCommand].join("\0")}function K(t,e,r){return new Promise(n=>{let o="",s="",a=!1,i=!1,d=null;const c=(0,_.spawn)(t,e,{cwd:r.cwd,windowsHide:!0,stdio:["ignore","pipe","pipe"]}),u=h=>{a||(a=!0,clearTimeout(T),n(h))},T=setTimeout(()=>{i=!0,c.kill()},r.timeoutMs);c.stdout.setEncoding("utf8"),c.stderr.setEncoding("utf8"),c.stdout.on("data",h=>{o+=h}),c.stderr.on("data",h=>{s+=h}),c.on("error",h=>{d=h}),c.on("close",(h,k)=>{u({status:h,signal:k,error:i?new Error(`Timed out after ${r.timeoutMs}ms.`):d,stdout:o,stderr:s})})})}async function U(t){const e=w(),r=(0,g.resolveRequiredWorkspaceRoot)(t),n=[e.scriptPath,"stop","--fixture",r.root];e.ideCommand&&n.push("--ide-command",e.ideCommand),e.hostKind&&n.push("--host-kind",e.hostKind);const o=(0,_.spawnSync)(e.nodeCommand,n,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),s=o.stdout??"",a=s.trim()?S(s):null;if(o.status!==0||!a||a.ok!==!0)throw new p.CliError("MANAGED_IDE_STOP_FAILED","Managed IDE stop failed.",{status:o.status,signal:o.signal,error:o.error?o.error.message:null,stdout:s,stderr:o.stderr??"",workspaceRoot:r.root});return z(r.root,a)}async function q(){return A(["stop","--all"],"MANAGED_IDE_STOP_FAILED")}async function G(){return A(["kill","--all"],"MANAGED_IDE_KILL_FAILED")}async function B(t){const e=w(),r=(0,g.resolveRequiredWorkspaceRoot)(t),n=[e.scriptPath,"status","--fixture",r.root];e.ideCommand&&n.push("--ide-command",e.ideCommand),e.hostKind&&n.push("--host-kind",e.hostKind);const o=(0,_.spawnSync)(e.nodeCommand,n,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),s=o.stdout??"",a=s.trim()?S(s):null;if(o.status!==0||!a||a.ok!==!0)throw new p.CliError("MANAGED_IDE_STATUS_FAILED","Managed IDE status failed.",{status:o.status,signal:o.signal,error:o.error?o.error.message:null,stdout:s,stderr:o.stderr??"",workspaceRoot:r.root});return Q(r.root,a)}async function J(){return A(["status","--all"],"MANAGED_IDE_STATUS_FAILED")}async function X(t){const e=w(),r=(0,g.resolveRequiredWorkspaceRoot)(t),n=x(r.root),o=[e.scriptPath,"cleanup","--ttl-ms",String(n)];e.ideCommand&&o.push("--ide-command",e.ideCommand),e.hostKind&&o.push("--host-kind",e.hostKind);const s=(0,_.spawnSync)(e.nodeCommand,o,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),a=s.stdout??"",i=a.trim()?S(a):null;if(s.status!==0||!i||i.ok!==!0)throw new p.CliError("MANAGED_IDE_CLEANUP_FAILED","Managed IDE cleanup failed.",{status:s.status,signal:s.signal,error:s.error?s.error.message:null,stdout:a,stderr:s.stderr??"",workspaceRoot:r.root});return i}function A(t,e){const r=w(),n=(0,_.spawnSync)(r.nodeCommand,[r.scriptPath,...t],{cwd:r.cwd,encoding:"utf8",windowsHide:!0,timeout:45e3,stdio:["ignore","pipe","pipe"]}),o=n.stdout??"",s=o.trim()?S(o):null;if(n.status!==0||!s||s.ok!==!0)throw new p.CliError(e,"Managed IDE runtime command failed.",{status:n.status,signal:n.signal,error:n.error?n.error.message:null,stdout:o,stderr:n.stderr??"",args:t});return s}function x(t){if(!(0,g.readWorkspaceBooleanConfig)(t,"runtime.autoStopManagedIde",!0))return 0;const r=(0,g.readWorkspaceNumberConfig)(t,"runtime.managedIdeTtlMinutes",15);return r>0?Math.round(r*6e4):0}function $(t){const e=(0,g.readWorkspaceNumberConfig)(t,"runtime.managedIdeWatchdogIntervalMs",3e4);return e>0?Math.round(e):3e4}function z(t,e){return{stopped:e.stopped===!0,workspaceRoot:t,...typeof e.hostId=="string"?{hostId:e.hostId}:{},...typeof e.reason=="string"?{reason:e.reason}:{}}}function Q(t,e){const r=e.metadata&&typeof e.metadata=="object"&&!Array.isArray(e.metadata)?e.metadata:{},n=e.health&&typeof e.health=="object"&&!Array.isArray(e.health)?e.health:{};return{ok:!0,workspaceRoot:t,workspace:".",hostId:typeof e.hostId=="string"?e.hostId:null,host:typeof r.hostKind=="string"?r.hostKind:"managed",running:e.running===!0,healthy:e.healthy===!0,reason:typeof e.reason=="string"?e.reason:null,health:{serveWebAlive:n.serveWebAlive===!0,browserAlive:n.browserAlive===!0,extensionHostAlive:n.extensionHostAlive===!0,workspaceMatches:n.workspaceMatches===!0,vsixMatches:n.vsixMatches===!0}}}