@automaton-labs/aib 0.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 +578 -0
- package/dist/bin/aib.js +2 -0
- package/dist/bin/cli.js +3 -0
- package/dist/client/http-client.js +1 -0
- package/dist/client/transport-options.js +1 -0
- package/dist/client/websocket-client.js +1 -0
- package/dist/commands/add-missing-imports-preview-cache.js +2 -0
- package/dist/commands/add-missing-imports.js +2 -0
- package/dist/commands/apply-module-plan.js +3 -0
- package/dist/commands/captured-input.js +2 -0
- package/dist/commands/config-command.js +3 -0
- package/dist/commands/diagnostics-command.js +3 -0
- package/dist/commands/doctor.js +1 -0
- package/dist/commands/entity-resolution.js +1 -0
- package/dist/commands/execution-command.js +1 -0
- package/dist/commands/feedback-command.js +3 -0
- package/dist/commands/find-importers.js +1 -0
- package/dist/commands/find-unused-imports.js +1 -0
- package/dist/commands/generate-docs-command.js +6 -0
- package/dist/commands/help-command.js +3 -0
- package/dist/commands/imports-command.js +1 -0
- package/dist/commands/init-skill-usage.js +3 -0
- package/dist/commands/init-workspace.js +3 -0
- package/dist/commands/inspect-cycles.js +5 -0
- package/dist/commands/inspect-format.js +18 -0
- package/dist/commands/inspect-graph.js +9 -0
- package/dist/commands/inspect-imports.js +2 -0
- package/dist/commands/inspect-symbol-query.js +1 -0
- package/dist/commands/inspect-tree.js +5 -0
- package/dist/commands/inspect.js +16 -0
- package/dist/commands/json-file-input.js +1 -0
- package/dist/commands/list-instances.js +1 -0
- package/dist/commands/module-plan-cache.js +2 -0
- package/dist/commands/module-plan-command.js +1 -0
- package/dist/commands/module-plan-timeout.js +1 -0
- package/dist/commands/move-command.js +1 -0
- package/dist/commands/move-preview-cache.js +2 -0
- package/dist/commands/move-to-file.js +2 -0
- package/dist/commands/mutation-execution-cache.js +3 -0
- package/dist/commands/normalize-imports.js +4 -0
- package/dist/commands/observability-command.js +3 -0
- package/dist/commands/ping.js +1 -0
- package/dist/commands/print-config.js +1 -0
- package/dist/commands/quick-read.js +11 -0
- package/dist/commands/refactor-batch-builder.js +1 -0
- package/dist/commands/refactor-batch-execution-cache.js +1 -0
- package/dist/commands/refactor-batch-preview-cache.js +2 -0
- package/dist/commands/refactor-batch.js +4 -0
- package/dist/commands/refactor-command.js +1 -0
- package/dist/commands/rename-command.js +1 -0
- package/dist/commands/rename-entities.js +4 -0
- package/dist/commands/rename-execution-cache.js +1 -0
- package/dist/commands/rename-input.js +1 -0
- package/dist/commands/rename-preview-cache.js +2 -0
- package/dist/commands/result-view.js +6 -0
- package/dist/commands/runtime-command.js +4 -0
- package/dist/commands/runtime-info.js +1 -0
- package/dist/commands/session-workspace.js +31 -0
- package/dist/commands/shared.js +1 -0
- package/dist/commands/sync-command.js +2 -0
- package/dist/commands/validate-module-plan.js +2 -0
- package/dist/commands/workspace-cache.js +1 -0
- package/dist/compatibility/policy.js +1 -0
- package/dist/config/auto-start-ide.js +1 -0
- package/dist/config/defaults.js +1 -0
- package/dist/config/env-vars.js +1 -0
- package/dist/config/glob-match.js +1 -0
- package/dist/config/import-rules.js +1 -0
- package/dist/config/local-config.js +3 -0
- package/dist/config/mutation-comments.js +1 -0
- package/dist/config/path-aliases.js +1 -0
- package/dist/config/path-display.js +1 -0
- package/dist/config/product-storage.js +1 -0
- package/dist/config/resolve-command-alias.js +1 -0
- package/dist/config/resolve.js +1 -0
- package/dist/config/workspace-root.js +3 -0
- package/dist/config/workspace-state.js +1 -0
- package/dist/content/content-bundle.js +1 -0
- package/dist/diagnostics/module-plan-timeline.js +2 -0
- package/dist/diagnostics/readiness-text.js +8 -0
- package/dist/discovery/registry.js +1 -0
- package/dist/discovery/select-instance.js +1 -0
- package/dist/dsl/aib-dsl.js +1 -0
- package/dist/help/bootstrap.md +924 -0
- package/dist/help/diagnostics/doctor.json +70 -0
- package/dist/help/docs/basics.md +14 -0
- package/dist/help/docs/dsl.md +25 -0
- package/dist/help/docs/help-format.md +12 -0
- package/dist/help/docs/imports.normalize.md +36 -0
- package/dist/help/docs/inspect.code.md +29 -0
- package/dist/help/docs/inspect.deps.md +32 -0
- package/dist/help/docs/inspect.duplicates.md +72 -0
- package/dist/help/docs/inspect.exports.md +34 -0
- package/dist/help/docs/inspect.file.md +32 -0
- package/dist/help/docs/inspect.graph.md +112 -0
- package/dist/help/docs/inspect.imports.md +15 -0
- package/dist/help/docs/inspect.md +71 -0
- package/dist/help/docs/inspect.members.md +24 -0
- package/dist/help/docs/inspect.tree.md +30 -0
- package/dist/help/docs/inspect.usages.md +48 -0
- package/dist/help/docs/modulePlan.md +51 -0
- package/dist/help/docs/move.md +37 -0
- package/dist/help/docs/mutation.md +47 -0
- package/dist/help/docs/patterns.md +178 -0
- package/dist/help/docs/prefs.md +40 -0
- package/dist/help/docs/qr.md +33 -0
- package/dist/help/docs/refactor.batch.md +44 -0
- package/dist/help/docs/rename.md +39 -0
- package/dist/help/docs/selectors.md +23 -0
- package/dist/help/docs/session.md +61 -0
- package/dist/help/docs/view.md +30 -0
- package/dist/help/dsl/bootstrap.md +924 -0
- package/dist/help/dsl/docs/basics.md +14 -0
- package/dist/help/dsl/docs/dsl.md +25 -0
- package/dist/help/dsl/docs/help-format.md +12 -0
- package/dist/help/dsl/docs/imports.normalize.md +36 -0
- package/dist/help/dsl/docs/inspect.code.md +29 -0
- package/dist/help/dsl/docs/inspect.deps.md +32 -0
- package/dist/help/dsl/docs/inspect.duplicates.md +72 -0
- package/dist/help/dsl/docs/inspect.exports.md +34 -0
- package/dist/help/dsl/docs/inspect.file.md +32 -0
- package/dist/help/dsl/docs/inspect.graph.md +112 -0
- package/dist/help/dsl/docs/inspect.imports.md +15 -0
- package/dist/help/dsl/docs/inspect.md +71 -0
- package/dist/help/dsl/docs/inspect.members.md +24 -0
- package/dist/help/dsl/docs/inspect.tree.md +30 -0
- package/dist/help/dsl/docs/inspect.usages.md +48 -0
- package/dist/help/dsl/docs/modulePlan.md +51 -0
- package/dist/help/dsl/docs/move.md +37 -0
- package/dist/help/dsl/docs/mutation.md +47 -0
- package/dist/help/dsl/docs/patterns.md +178 -0
- package/dist/help/dsl/docs/prefs.md +40 -0
- package/dist/help/dsl/docs/qr.md +33 -0
- package/dist/help/dsl/docs/refactor.batch.md +44 -0
- package/dist/help/dsl/docs/rename.md +39 -0
- package/dist/help/dsl/docs/selectors.md +23 -0
- package/dist/help/dsl/docs/session.md +61 -0
- package/dist/help/dsl/docs/view.md +30 -0
- package/dist/help/dsl/full.md +924 -0
- package/dist/help/dsl/snippets/agents.md +14 -0
- package/dist/help/dsl/topics/basics.md +12 -0
- package/dist/help/dsl/topics/dsl.md +23 -0
- package/dist/help/dsl/topics/help-format.md +10 -0
- package/dist/help/dsl/topics/imports.normalize.md +34 -0
- package/dist/help/dsl/topics/inspect.code.md +27 -0
- package/dist/help/dsl/topics/inspect.deps.md +30 -0
- package/dist/help/dsl/topics/inspect.duplicates.md +43 -0
- package/dist/help/dsl/topics/inspect.exports.md +32 -0
- package/dist/help/dsl/topics/inspect.file.md +30 -0
- package/dist/help/dsl/topics/inspect.graph.md +110 -0
- package/dist/help/dsl/topics/inspect.imports.md +13 -0
- package/dist/help/dsl/topics/inspect.md +69 -0
- package/dist/help/dsl/topics/inspect.members.md +22 -0
- package/dist/help/dsl/topics/inspect.tree.md +20 -0
- package/dist/help/dsl/topics/inspect.usages.md +46 -0
- package/dist/help/dsl/topics/modulePlan.md +38 -0
- package/dist/help/dsl/topics/move.md +27 -0
- package/dist/help/dsl/topics/mutation.md +45 -0
- package/dist/help/dsl/topics/patterns.md +176 -0
- package/dist/help/dsl/topics/prefs.md +38 -0
- package/dist/help/dsl/topics/qr.md +31 -0
- package/dist/help/dsl/topics/refactor.batch.md +33 -0
- package/dist/help/dsl/topics/rename.md +25 -0
- package/dist/help/dsl/topics/selectors.md +21 -0
- package/dist/help/dsl/topics/session.md +59 -0
- package/dist/help/dsl/topics/view.md +28 -0
- package/dist/help/full.md +924 -0
- package/dist/help/help-meta.json +113 -0
- package/dist/help/index.md +167 -0
- package/dist/help/json/bootstrap.md +1074 -0
- package/dist/help/json/docs/basics.md +15 -0
- package/dist/help/json/docs/dsl.md +25 -0
- package/dist/help/json/docs/help-format.md +12 -0
- package/dist/help/json/docs/imports.normalize.md +47 -0
- package/dist/help/json/docs/inspect.code.md +41 -0
- package/dist/help/json/docs/inspect.deps.md +46 -0
- package/dist/help/json/docs/inspect.duplicates.md +65 -0
- package/dist/help/json/docs/inspect.exports.md +40 -0
- package/dist/help/json/docs/inspect.file.md +38 -0
- package/dist/help/json/docs/inspect.graph.md +139 -0
- package/dist/help/json/docs/inspect.imports.md +15 -0
- package/dist/help/json/docs/inspect.md +87 -0
- package/dist/help/json/docs/inspect.members.md +32 -0
- package/dist/help/json/docs/inspect.tree.md +30 -0
- package/dist/help/json/docs/inspect.usages.md +61 -0
- package/dist/help/json/docs/modulePlan.md +70 -0
- package/dist/help/json/docs/move.md +53 -0
- package/dist/help/json/docs/mutation.md +62 -0
- package/dist/help/json/docs/patterns.md +178 -0
- package/dist/help/json/docs/prefs.md +40 -0
- package/dist/help/json/docs/qr.md +33 -0
- package/dist/help/json/docs/refactor.batch.md +72 -0
- package/dist/help/json/docs/rename.md +47 -0
- package/dist/help/json/docs/selectors.md +23 -0
- package/dist/help/json/docs/session.md +77 -0
- package/dist/help/json/docs/view.md +30 -0
- package/dist/help/json/full.md +1074 -0
- package/dist/help/json/snippets/agents.md +14 -0
- package/dist/help/json/topics/basics.md +13 -0
- package/dist/help/json/topics/dsl.md +23 -0
- package/dist/help/json/topics/help-format.md +10 -0
- package/dist/help/json/topics/imports.normalize.md +45 -0
- package/dist/help/json/topics/inspect.code.md +39 -0
- package/dist/help/json/topics/inspect.deps.md +44 -0
- package/dist/help/json/topics/inspect.duplicates.md +37 -0
- package/dist/help/json/topics/inspect.exports.md +38 -0
- package/dist/help/json/topics/inspect.file.md +36 -0
- package/dist/help/json/topics/inspect.graph.md +137 -0
- package/dist/help/json/topics/inspect.imports.md +13 -0
- package/dist/help/json/topics/inspect.md +85 -0
- package/dist/help/json/topics/inspect.members.md +30 -0
- package/dist/help/json/topics/inspect.tree.md +20 -0
- package/dist/help/json/topics/inspect.usages.md +59 -0
- package/dist/help/json/topics/modulePlan.md +57 -0
- package/dist/help/json/topics/move.md +43 -0
- package/dist/help/json/topics/mutation.md +60 -0
- package/dist/help/json/topics/patterns.md +176 -0
- package/dist/help/json/topics/prefs.md +38 -0
- package/dist/help/json/topics/qr.md +31 -0
- package/dist/help/json/topics/refactor.batch.md +61 -0
- package/dist/help/json/topics/rename.md +42 -0
- package/dist/help/json/topics/selectors.md +21 -0
- package/dist/help/json/topics/session.md +59 -0
- package/dist/help/json/topics/view.md +28 -0
- package/dist/help/snippets/agents.md +14 -0
- package/dist/help/topics/basics.md +12 -0
- package/dist/help/topics/dsl.md +23 -0
- package/dist/help/topics/help-format.md +10 -0
- package/dist/help/topics/imports.normalize.md +34 -0
- package/dist/help/topics/inspect.code.md +27 -0
- package/dist/help/topics/inspect.deps.md +30 -0
- package/dist/help/topics/inspect.duplicates.md +43 -0
- package/dist/help/topics/inspect.exports.md +32 -0
- package/dist/help/topics/inspect.file.md +30 -0
- package/dist/help/topics/inspect.graph.md +110 -0
- package/dist/help/topics/inspect.imports.md +13 -0
- package/dist/help/topics/inspect.md +69 -0
- package/dist/help/topics/inspect.members.md +22 -0
- package/dist/help/topics/inspect.tree.md +20 -0
- package/dist/help/topics/inspect.usages.md +46 -0
- package/dist/help/topics/modulePlan.md +38 -0
- package/dist/help/topics/move.md +27 -0
- package/dist/help/topics/mutation.md +45 -0
- package/dist/help/topics/patterns.md +176 -0
- package/dist/help/topics/prefs.md +38 -0
- package/dist/help/topics/qr.md +31 -0
- package/dist/help/topics/refactor.batch.md +33 -0
- package/dist/help/topics/rename.md +25 -0
- package/dist/help/topics/selectors.md +21 -0
- package/dist/help/topics/session.md +59 -0
- package/dist/help/topics/view.md +28 -0
- package/dist/ide-launch/common.cjs +162 -0
- package/dist/managed-host/extension-vsix-resolver.js +1 -0
- package/dist/managed-host/manage-serve-web-host.cjs +141 -0
- package/dist/managed-host/serve-web-autostart.js +1 -0
- package/dist/managed-host/serve-web-host.cjs +1790 -0
- package/dist/metrics/central-metrics.js +2 -0
- package/dist/observability/config.js +1 -0
- package/dist/observability/context.js +1 -0
- package/dist/observability/failure-snapshot.js +2 -0
- package/dist/observability/recent.js +2 -0
- package/dist/payloads/read-stdin-json.js +1 -0
- package/dist/runtime/bundled-node.js +1 -0
- package/dist/runtime/input-source.js +1 -0
- package/dist/runtime/managed-runtime-provisioning.js +1 -0
- package/dist/runtime/run-command.js +1 -0
- package/dist/selectors/parse-entities.js +1 -0
- package/dist/session/client.js +1 -0
- package/dist/session/paths.js +1 -0
- package/dist/session/server.js +6 -0
- package/dist/shared/agent-text.js +1 -0
- package/dist/shared/diagnostic-catalog.js +1 -0
- package/dist/shared/diagnostics.js +1 -0
- package/dist/shared/errors.js +28 -0
- package/dist/shared/event-loop.js +1 -0
- package/dist/shared/hints.js +1 -0
- package/dist/shared/metrics.js +1 -0
- package/dist/shared/operations.js +1 -0
- package/dist/shared/presentation.js +4 -0
- package/dist/shared/protocol.js +1 -0
- package/dist/shared/routes.js +1 -0
- package/dist/shared/stdout.js +2 -0
- package/dist/shared/types.js +1 -0
- package/dist/tracing/config.js +2 -0
- package/dist/tracing/trace.js +3 -0
- package/extension/vscode-refactor-bridge-extension.vsix +0 -0
- package/package.json +39 -0
- package/runtimes/launcher/win-x64/aib.exe +0 -0
- package/scripts/install-windows-launcher.cjs +58 -0
- package/scripts/postinstall.cjs +28 -0
- package/scripts/provision-runtime.cjs +299 -0
|
@@ -0,0 +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
|
+
});
|
|
@@ -0,0 +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}}}
|