@galaxy-stack/blackhole-cli 2.3.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -47
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +23 -2
- package/dist/application.js.map +1 -1
- package/dist/authorization.d.ts +22 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/authorization.js +42 -0
- package/dist/authorization.js.map +1 -0
- package/dist/cli-meta.d.ts +8 -0
- package/dist/cli-meta.d.ts.map +1 -1
- package/dist/cli-meta.js +11 -0
- package/dist/cli-meta.js.map +1 -1
- package/dist/cli.js +51 -27
- package/dist/cli.js.map +1 -1
- package/dist/config-command.d.ts +11 -14
- package/dist/config-command.d.ts.map +1 -1
- package/dist/config-command.js +41 -118
- package/dist/config-command.js.map +1 -1
- package/dist/doctor.d.ts +8 -2
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +11 -15
- package/dist/doctor.js.map +1 -1
- package/dist/file-index.d.ts +50 -0
- package/dist/file-index.d.ts.map +1 -1
- package/dist/file-index.js +124 -0
- package/dist/file-index.js.map +1 -1
- package/dist/harness/boot.d.ts +87 -0
- package/dist/harness/boot.d.ts.map +1 -0
- package/dist/harness/boot.js +111 -0
- package/dist/harness/boot.js.map +1 -0
- package/dist/harness/catalogs.d.ts +50 -0
- package/dist/harness/catalogs.d.ts.map +1 -0
- package/dist/harness/catalogs.js +34 -0
- package/dist/harness/catalogs.js.map +1 -0
- package/dist/harness/chat.d.ts +90 -0
- package/dist/harness/chat.d.ts.map +1 -0
- package/dist/harness/chat.js +260 -0
- package/dist/harness/chat.js.map +1 -0
- package/dist/harness/client.d.ts +72 -0
- package/dist/harness/client.d.ts.map +1 -0
- package/dist/harness/client.js +173 -0
- package/dist/harness/client.js.map +1 -0
- package/dist/harness/command.d.ts +22 -0
- package/dist/harness/command.d.ts.map +1 -0
- package/dist/harness/command.js +142 -0
- package/dist/harness/command.js.map +1 -0
- package/dist/harness/composer.d.ts +46 -0
- package/dist/harness/composer.d.ts.map +1 -0
- package/dist/harness/composer.js +127 -0
- package/dist/harness/composer.js.map +1 -0
- package/dist/harness/conversation.d.ts +75 -0
- package/dist/harness/conversation.d.ts.map +1 -0
- package/dist/harness/conversation.js +196 -0
- package/dist/harness/conversation.js.map +1 -0
- package/dist/harness/help.d.ts +56 -0
- package/dist/harness/help.d.ts.map +1 -0
- package/dist/harness/help.js +85 -0
- package/dist/harness/help.js.map +1 -0
- package/dist/harness/history.d.ts +108 -0
- package/dist/harness/history.d.ts.map +1 -0
- package/dist/harness/history.js +268 -0
- package/dist/harness/history.js.map +1 -0
- package/dist/harness/labels.d.ts +164 -0
- package/dist/harness/labels.d.ts.map +1 -0
- package/dist/harness/labels.js +271 -0
- package/dist/harness/labels.js.map +1 -0
- package/dist/harness/locate.d.ts +24 -0
- package/dist/harness/locate.d.ts.map +1 -0
- package/dist/harness/locate.js +69 -0
- package/dist/harness/locate.js.map +1 -0
- package/dist/harness/menus.d.ts +74 -0
- package/dist/harness/menus.d.ts.map +1 -0
- package/dist/harness/menus.js +140 -0
- package/dist/harness/menus.js.map +1 -0
- package/dist/harness/model-name.d.ts +73 -0
- package/dist/harness/model-name.d.ts.map +1 -0
- package/dist/harness/model-name.js +101 -0
- package/dist/harness/model-name.js.map +1 -0
- package/dist/harness/parts.d.ts +239 -0
- package/dist/harness/parts.d.ts.map +1 -0
- package/dist/harness/parts.js +266 -0
- package/dist/harness/parts.js.map +1 -0
- package/dist/harness/preset.d.ts +124 -0
- package/dist/harness/preset.d.ts.map +1 -0
- package/dist/harness/preset.js +197 -0
- package/dist/harness/preset.js.map +1 -0
- package/dist/harness/process.d.ts +55 -0
- package/dist/harness/process.d.ts.map +1 -0
- package/dist/harness/process.js +119 -0
- package/dist/harness/process.js.map +1 -0
- package/dist/harness/screen.d.ts +33 -0
- package/dist/harness/screen.d.ts.map +1 -0
- package/dist/harness/screen.js +1070 -0
- package/dist/harness/screen.js.map +1 -0
- package/dist/harness/sessions.d.ts +55 -0
- package/dist/harness/sessions.d.ts.map +1 -0
- package/dist/harness/sessions.js +92 -0
- package/dist/harness/sessions.js.map +1 -0
- package/dist/harness/skills.d.ts +90 -0
- package/dist/harness/skills.d.ts.map +1 -0
- package/dist/harness/skills.js +133 -0
- package/dist/harness/skills.js.map +1 -0
- package/dist/harness/slash-palette.d.ts +32 -0
- package/dist/harness/slash-palette.d.ts.map +1 -0
- package/dist/harness/slash-palette.js +48 -0
- package/dist/harness/slash-palette.js.map +1 -0
- package/dist/harness/slash.d.ts +113 -0
- package/dist/harness/slash.d.ts.map +1 -0
- package/dist/harness/slash.js +187 -0
- package/dist/harness/slash.js.map +1 -0
- package/dist/harness/trajectory.d.ts +74 -0
- package/dist/harness/trajectory.d.ts.map +1 -0
- package/dist/harness/trajectory.js +270 -0
- package/dist/harness/trajectory.js.map +1 -0
- package/dist/harness/tui.d.ts +28 -0
- package/dist/harness/tui.d.ts.map +1 -0
- package/dist/harness/tui.js +143 -0
- package/dist/harness/tui.js.map +1 -0
- package/dist/manual-config.d.ts +23 -10
- package/dist/manual-config.d.ts.map +1 -1
- package/dist/manual-config.js +45 -37
- package/dist/manual-config.js.map +1 -1
- package/dist/migrate.d.ts +32 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +155 -0
- package/dist/migrate.js.map +1 -0
- package/dist/options.d.ts +10 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +23 -4
- package/dist/options.js.map +1 -1
- package/dist/setup.d.ts +14 -10
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +25 -92
- package/dist/setup.js.map +1 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +11 -0
- package/dist/timeline.js.map +1 -1
- package/dist/web/command.d.ts +5 -1
- package/dist/web/command.d.ts.map +1 -1
- package/dist/web/command.js +22 -6
- package/dist/web/command.js.map +1 -1
- package/dist/web/credentials.d.ts +7 -5
- package/dist/web/credentials.d.ts.map +1 -1
- package/dist/web/credentials.js +13 -48
- package/dist/web/credentials.js.map +1 -1
- package/dist/web/doctor.d.ts +1 -1
- package/dist/web/doctor.d.ts.map +1 -1
- package/dist/web/doctor.js +42 -64
- package/dist/web/doctor.js.map +1 -1
- package/dist/web/options.d.ts +26 -2
- package/dist/web/options.d.ts.map +1 -1
- package/dist/web/options.js +54 -18
- package/dist/web/options.js.map +1 -1
- package/dist/web/paths.d.ts +1 -1
- package/dist/web/paths.d.ts.map +1 -1
- package/dist/web/paths.js +2 -2
- package/dist/web/paths.js.map +1 -1
- package/dist/web/web.d.ts +38 -16
- package/dist/web/web.d.ts.map +1 -1
- package/dist/web/web.js +166 -168
- package/dist/web/web.js.map +1 -1
- package/package.json +5 -4
- package/web/brand/lib/client.js +4 -4
- package/web/patches/gbh-ui.patch.yml +6 -24
package/dist/web/options.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fixed port `blackhole web` listens on unless a flag or the environment overrides it.
|
|
3
|
+
*
|
|
4
|
+
* A FIXED default, not a random one: the URL of the GUI is something a person types, bookmarks, or
|
|
5
|
+
* pastes into a bug report, so it must be the same today and tomorrow. 55906 is the CLI's; the
|
|
6
|
+
* desktop app owns 55907 and the lead's shared host keeps 5439 — three neighbours, no collision.
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_WEB_PORT = 55906;
|
|
9
|
+
/** The environment variable that overrides the default port without changing argv. */
|
|
10
|
+
export const WEB_PORT_ENV = "GBH_WEB_PORT";
|
|
1
11
|
const COMMANDS = ["web", "doctor", "config", "help", "version"];
|
|
2
12
|
const TOOLS_MODES = ["native", "ptc", "both"];
|
|
3
13
|
function isCommand(value) {
|
|
@@ -12,16 +22,37 @@ function takeValue(argv, index, flag) {
|
|
|
12
22
|
throw new Error(flag + " requires a value.");
|
|
13
23
|
return value;
|
|
14
24
|
}
|
|
15
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Reads the port the caller asked for through the environment.
|
|
27
|
+
* @param env - the environment to read; defaults to the process's own.
|
|
28
|
+
* @returns `GBH_WEB_PORT` when it is set to a valid port, else {@link DEFAULT_WEB_PORT}.
|
|
29
|
+
* @throws when the variable is set but is not a port number — a typo must not be silently ignored.
|
|
30
|
+
*/
|
|
31
|
+
export function portFromEnv(env = process.env) {
|
|
32
|
+
const raw = (env[WEB_PORT_ENV] ?? "").trim();
|
|
33
|
+
if (raw === "")
|
|
34
|
+
return DEFAULT_WEB_PORT;
|
|
35
|
+
const port = Number(raw);
|
|
36
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
37
|
+
throw new Error("Invalid " + WEB_PORT_ENV + ": " + raw);
|
|
38
|
+
return port;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parse gbh argv. Unknown flags fail loudly; the default command is web.
|
|
42
|
+
* @param argv - arguments after `web`.
|
|
43
|
+
* @returns the parsed options; the port is `--port` > `GBH_WEB_PORT` > 55906.
|
|
44
|
+
* @throws when a flag is unknown, a value is missing, or `GBH_WEB_PORT` is not a port.
|
|
45
|
+
*/
|
|
16
46
|
export function parseWebOptions(argv) {
|
|
17
47
|
const options = {
|
|
18
48
|
command: "web",
|
|
19
49
|
args: [],
|
|
20
|
-
port:
|
|
50
|
+
port: portFromEnv(),
|
|
21
51
|
host: "127.0.0.1",
|
|
22
52
|
open: true,
|
|
53
|
+
verbose: false,
|
|
23
54
|
brand: true,
|
|
24
|
-
profile: "
|
|
55
|
+
profile: "blackhole",
|
|
25
56
|
toolsMode: "ptc",
|
|
26
57
|
patches: [],
|
|
27
58
|
dryRun: false,
|
|
@@ -50,6 +81,10 @@ export function parseWebOptions(argv) {
|
|
|
50
81
|
options.open = false;
|
|
51
82
|
continue;
|
|
52
83
|
}
|
|
84
|
+
if (arg === "--verbose") {
|
|
85
|
+
options.verbose = true;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
53
88
|
if (arg === "--no-brand") {
|
|
54
89
|
options.brand = false;
|
|
55
90
|
continue;
|
|
@@ -124,30 +159,31 @@ export function parseWebOptions(argv) {
|
|
|
124
159
|
}
|
|
125
160
|
return options;
|
|
126
161
|
}
|
|
127
|
-
/**
|
|
162
|
+
/** `blackhole web` help text. */
|
|
128
163
|
export function webHelp() {
|
|
129
164
|
return [
|
|
130
|
-
"blackhole web - Galaxy Blackhole web GUI",
|
|
165
|
+
"blackhole web - Galaxy Blackhole web GUI (the blackhole-tauri harness)",
|
|
131
166
|
"",
|
|
132
167
|
"Usage:",
|
|
133
|
-
" blackhole web [options] Boot the
|
|
134
|
-
" blackhole web doctor [--json] Check the
|
|
135
|
-
" blackhole web config Print resolved paths",
|
|
168
|
+
" blackhole web [options] Boot the Galaxy Blackhole harness and open its URL",
|
|
169
|
+
" blackhole web doctor [--json] Check the harness checkout, bun, and the Galaxy key",
|
|
170
|
+
" blackhole web config Print the resolved paths",
|
|
136
171
|
" blackhole web --version",
|
|
137
172
|
" blackhole web --help",
|
|
138
173
|
"",
|
|
139
174
|
"Options:",
|
|
140
|
-
" --port <n> Listen port (default
|
|
141
|
-
"
|
|
175
|
+
" --port <n> Listen port (default 55906, or GBH_WEB_PORT when set)",
|
|
176
|
+
" A busy fixed port is an ERROR, never a silent jump; --port 0 asks",
|
|
177
|
+
" the OS for a free one (random, printed in the URL)",
|
|
178
|
+
" --host <host> Accepted for compatibility; the harness binds loopback only",
|
|
142
179
|
" --no-open Do not open the browser",
|
|
143
|
-
" --
|
|
144
|
-
" --profile <name>
|
|
145
|
-
" --
|
|
146
|
-
" --
|
|
147
|
-
" --
|
|
148
|
-
" --
|
|
149
|
-
"
|
|
150
|
-
" --dry-run Print the resolved DSH command and exit",
|
|
180
|
+
" --verbose Relay the harness log (same as GBH_LOG=debug)",
|
|
181
|
+
" --profile <name> Harness profile (default blackhole)",
|
|
182
|
+
" --patch <path> Extra harness patch overlay; repeatable",
|
|
183
|
+
" --home <dir> GBH_HOME for the harness (default ~/.galaxy/blackhole)",
|
|
184
|
+
" --dry-run Print the harness command and exit",
|
|
185
|
+
" --no-brand, --model, --preset, --tools-mode",
|
|
186
|
+
" Legacy flags: the Galaxy interface is built in, so they are ignored",
|
|
151
187
|
"",
|
|
152
188
|
].join("\n");
|
|
153
189
|
}
|
package/dist/web/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/web/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/web/options.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAEtC,sFAAsF;AACtF,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAqB3C,MAAM,QAAQ,GAA0B,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AACvF,MAAM,WAAW,GAAyB,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEpE,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAQ,QAA8B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAQ,WAAiC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,SAAS,CAAC,IAAuB,EAAE,KAAa,EAAE,IAAY;IACrE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,GAAG,oBAAoB,CAAC,CAAC;IAChG,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC9D,MAAM,GAAG,GAAG,CAAC,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ACf,CAAC"}
|
package/dist/web/paths.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare function uiPatchPath(): string;
|
|
|
10
10
|
export declare function brandPatchPath(): string;
|
|
11
11
|
/** The brand client package linked into the DSH profile node_modules. */
|
|
12
12
|
export declare function brandPackagePath(): string;
|
|
13
|
-
/** The
|
|
13
|
+
/** The Galaxy Blackhole harness home this deployment uses. */
|
|
14
14
|
export declare function defaultHome(): string;
|
|
15
15
|
/** Runtime overlay written when --model or --preset override the bundled patch. */
|
|
16
16
|
export declare function overlayPath(home: string): string;
|
package/dist/web/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/web/paths.ts"],"names":[],"mappings":"AAIA,wFAAwF;AACxF,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,2EAA2E;AAC3E,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,gEAAgE;AAChE,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,oEAAoE;AACpE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/web/paths.ts"],"names":[],"mappings":"AAIA,wFAAwF;AACxF,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,2EAA2E;AAC3E,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,gEAAgE;AAChE,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,oEAAoE;AACpE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,8DAA8D;AAC9D,wBAAgB,WAAW,IAAI,MAAM,CAIpC;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
package/dist/web/paths.js
CHANGED
|
@@ -25,12 +25,12 @@ export function brandPatchPath() {
|
|
|
25
25
|
export function brandPackagePath() {
|
|
26
26
|
return join(webDir(), "brand");
|
|
27
27
|
}
|
|
28
|
-
/** The
|
|
28
|
+
/** The Galaxy Blackhole harness home this deployment uses. */
|
|
29
29
|
export function defaultHome() {
|
|
30
30
|
const fromEnv = process.env.GBH_HOME;
|
|
31
31
|
if (fromEnv !== undefined && fromEnv.trim().length > 0)
|
|
32
32
|
return fromEnv.trim();
|
|
33
|
-
return join(homedir(), ".galaxy", "
|
|
33
|
+
return join(homedir(), ".galaxy", "blackhole");
|
|
34
34
|
}
|
|
35
35
|
/** Runtime overlay written when --model or --preset override the bundled patch. */
|
|
36
36
|
export function overlayPath(home) {
|
package/dist/web/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/web/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,wFAAwF;AACxF,MAAM,UAAU,WAAW;IACzB,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,mBAAmB,CA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AAC,CAAC;AAC1D,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,WAAW;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IAC9E,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/web/web.d.ts
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
import type { WebOptions } from "./options.js";
|
|
2
|
+
/**
|
|
3
|
+
* The line a busy FIXED port prints. A fixed default only earns its keep if a collision is stated
|
|
4
|
+
* out loud: silence would send the user to a URL nobody printed.
|
|
5
|
+
* @param port - the port that could not be bound.
|
|
6
|
+
* @returns one sentence with both ways out.
|
|
7
|
+
*/
|
|
8
|
+
export declare function busyPortMessage(port: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Probes whether this process could bind the port right now.
|
|
11
|
+
* @param port - the TCP port to try; 0 always counts as free because the OS picks one.
|
|
12
|
+
* @param host - bind host; the harness is loopback-only, so the probe is too.
|
|
13
|
+
* @returns true when the port is free.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isPortFree(port: number, host?: string): Promise<boolean>;
|
|
16
|
+
/** Everything a boot needs, resolved before anything is spawned. */
|
|
2
17
|
export interface WebPlan {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
/** The bun binary that runs the launcher. */
|
|
19
|
+
readonly command: string;
|
|
20
|
+
/** argv after the binary. */
|
|
21
|
+
readonly args: readonly string[];
|
|
22
|
+
/** Environment handed to the child. */
|
|
23
|
+
readonly env: NodeJS.ProcessEnv;
|
|
24
|
+
/** The harness home this run uses. */
|
|
25
|
+
readonly home: string;
|
|
26
|
+
/** The blackhole-tauri checkout that owns the launcher. */
|
|
27
|
+
readonly root: string;
|
|
28
|
+
/** Provenance, for `--dry-run`. */
|
|
29
|
+
readonly source: string;
|
|
30
|
+
/** Where the Galaxy key came from, when one was found. */
|
|
31
|
+
readonly keySource?: string;
|
|
10
32
|
}
|
|
11
|
-
/** Link the gbh brand client package into the profile node_modules (best effort). */
|
|
12
33
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* needs no privileges, and a plain copy is the last resort, so the caller can always decide honestly.
|
|
34
|
+
* Plan the harness boot.
|
|
35
|
+
* @param options - parsed command options.
|
|
36
|
+
* @returns everything the spawn needs.
|
|
37
|
+
* @throws with an actionable message when Bun or the checkout is missing.
|
|
18
38
|
*/
|
|
19
|
-
export declare function ensureBrandLink(home: string): string | undefined;
|
|
20
|
-
/** Resolve the DSH command, patch list, and environment for gbh web. */
|
|
21
39
|
export declare function planWeb(options: WebOptions): WebPlan;
|
|
22
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Boot the Galaxy Blackhole web GUI and open its authenticated URL.
|
|
42
|
+
* @param options - parsed command options.
|
|
43
|
+
* @returns the launcher exit code.
|
|
44
|
+
*/
|
|
23
45
|
export declare function runWeb(options: WebOptions): Promise<number>;
|
|
24
46
|
//# sourceMappingURL=web.d.ts.map
|
package/dist/web/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web/web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web/web.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAa7E;AAED,oEAAoE;AACpE,MAAM,WAAW,OAAO;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,uCAAuC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CA0BpD;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAoGjE"}
|
package/dist/web/web.js
CHANGED
|
@@ -1,209 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `blackhole web`: open the Galaxy Blackhole web GUI.
|
|
3
|
+
*
|
|
4
|
+
* The GUI is the blackhole-tauri harness (the same app the desktop shell loads),
|
|
5
|
+
* not the legacy in-process DSH build this package used to bundle. The launcher
|
|
6
|
+
* prints one authenticated URL; that URL is what this command opens, and its
|
|
7
|
+
* token must be exchanged by a navigation before any request is trusted.
|
|
8
|
+
*/
|
|
1
9
|
import { spawn } from "node:child_process";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
10
|
+
import { createServer } from "node:net";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { findBun, findTauriRoot, systemLocateEnvironment } from "../harness/locate.js";
|
|
14
|
+
import { BOOT_PHASES, bootPhaseFor, createBootReporter } from "../harness/boot.js";
|
|
15
|
+
import { resolveGalaxyKey } from "./credentials.js";
|
|
16
|
+
import { promoteLegacyCredential } from "../config-command.js";
|
|
7
17
|
import { galaxyCredentialsPath } from "@galaxy-stack/ai-coder-core/adapters/node/config/galaxy-credentials";
|
|
8
18
|
import { openUrl } from "./open-browser.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return JSON.stringify(value);
|
|
12
|
-
}
|
|
19
|
+
/** The URL the launcher prints once the harness serves. */
|
|
20
|
+
const READY_URL = /https?:\/\/127\.0\.0\.1:\d+\/\?token=[A-Za-z0-9._~+/=-]+/u;
|
|
13
21
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* documents/GALAXY_CREDENTIALS_SETTINGS_SYNC_PLAN.md), so the web GUI resolves the
|
|
19
|
-
* same references the CLI and the extension write. An explicit path beats the
|
|
20
|
-
* computed one, which keeps tests and relocated homes working.
|
|
22
|
+
* The line a busy FIXED port prints. A fixed default only earns its keep if a collision is stated
|
|
23
|
+
* out loud: silence would send the user to a URL nobody printed.
|
|
24
|
+
* @param port - the port that could not be bound.
|
|
25
|
+
* @returns one sentence with both ways out.
|
|
21
26
|
*/
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
rows.push("# Galaxy credentials: one shared document for the desktop app, the CLI, the extension, and this GUI.");
|
|
25
|
-
rows.push("- id: credentials");
|
|
26
|
-
rows.push(" config:");
|
|
27
|
-
rows.push(" path: " + yamlScalar(process.env.GALAXY_CREDENTIALS_PATH ?? galaxyCredentialsPath()));
|
|
28
|
-
rows.push("");
|
|
29
|
-
if (options.model !== undefined) {
|
|
30
|
-
rows.push("- id: agent-default-model");
|
|
31
|
-
rows.push(" config:");
|
|
32
|
-
rows.push(" provider: galaxy");
|
|
33
|
-
rows.push(" model: " + yamlScalar(options.model));
|
|
34
|
-
}
|
|
35
|
-
if (options.preset !== undefined) {
|
|
36
|
-
rows.push("- id: agent-preset-registry");
|
|
37
|
-
rows.push(" config:");
|
|
38
|
-
rows.push(" default: " + yamlScalar(options.preset));
|
|
39
|
-
}
|
|
40
|
-
mkdirSync(home, { recursive: true });
|
|
41
|
-
const path = overlayPath(home);
|
|
42
|
-
writeFileSync(path, rows.join("\n") + "\n", "utf8");
|
|
43
|
-
return path;
|
|
27
|
+
export function busyPortMessage(port) {
|
|
28
|
+
return "cổng " + String(port) + " đang bận — dùng --port <cổng khác>, hoặc --port 0 để lấy cổng ngẫu nhiên.";
|
|
44
29
|
}
|
|
45
30
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* code thought the slot was free, tried to create it, and collided with the thing it could not see.
|
|
31
|
+
* Probes whether this process could bind the port right now.
|
|
32
|
+
* @param port - the TCP port to try; 0 always counts as free because the OS picks one.
|
|
33
|
+
* @param host - bind host; the harness is loopback-only, so the probe is too.
|
|
34
|
+
* @returns true when the port is free.
|
|
51
35
|
*/
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
36
|
+
export function isPortFree(port, host = "127.0.0.1") {
|
|
37
|
+
if (port === 0)
|
|
38
|
+
return Promise.resolve(true);
|
|
39
|
+
return new Promise((resolveProbe) => {
|
|
40
|
+
const probe = createServer();
|
|
41
|
+
probe.once("error", () => {
|
|
42
|
+
probe.close();
|
|
43
|
+
resolveProbe(false);
|
|
44
|
+
});
|
|
45
|
+
probe.once("listening", () => {
|
|
46
|
+
probe.close(() => resolveProbe(true));
|
|
47
|
+
});
|
|
48
|
+
probe.listen(port, host);
|
|
49
|
+
});
|
|
65
50
|
}
|
|
66
|
-
/** Link the gbh brand client package into the profile node_modules (best effort). */
|
|
67
51
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* needs no privileges, and a plain copy is the last resort, so the caller can always decide honestly.
|
|
52
|
+
* Plan the harness boot.
|
|
53
|
+
* @param options - parsed command options.
|
|
54
|
+
* @returns everything the spawn needs.
|
|
55
|
+
* @throws with an actionable message when Bun or the checkout is missing.
|
|
73
56
|
*/
|
|
74
|
-
export function ensureBrandLink(home) {
|
|
75
|
-
const dir = join(home, "profiles", "node_modules", "@galaxy-stack");
|
|
76
|
-
const link = join(dir, "gbh-brand");
|
|
77
|
-
const target = brandPackagePath();
|
|
78
|
-
const alreadyLinked = () => {
|
|
79
|
-
try {
|
|
80
|
-
return readlinkSync(link) === target;
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
try {
|
|
87
|
-
mkdirSync(dir, { recursive: true });
|
|
88
|
-
if (existsAsEntry(link) && !alreadyLinked())
|
|
89
|
-
rmSync(link, { force: true, recursive: true });
|
|
90
|
-
if (existsAsEntry(link))
|
|
91
|
-
return link;
|
|
92
|
-
try {
|
|
93
|
-
symlinkSync(target, link, process.platform === "win32" ? "junction" : "dir");
|
|
94
|
-
return link;
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
cpSync(target, link, { recursive: true, dereference: true });
|
|
98
|
-
return link;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
/*
|
|
103
|
-
* A skin that cannot be installed must say why: silence here once cost an afternoon of guessing why the interface
|
|
104
|
-
* was not ours.
|
|
105
|
-
*/
|
|
106
|
-
process.stderr.write("galaxy web: cannot link the brand into " + dir + ": " + (error instanceof Error ? error.message : String(error)) + "\n");
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/** Resolve the DSH command, patch list, and environment for gbh web. */
|
|
111
57
|
export function planWeb(options) {
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const args = [...runtime.baseArgs, "--profile", options.profile];
|
|
128
|
-
for (const patch of patches)
|
|
58
|
+
const environment = systemLocateEnvironment();
|
|
59
|
+
const root = findTauriRoot(environment);
|
|
60
|
+
if (root === undefined)
|
|
61
|
+
throw new Error("Không tìm thấy blackhole-tauri. Đặt GBH_TAURI_ROOT tới bản checkout của nó.");
|
|
62
|
+
const bun = findBun(environment);
|
|
63
|
+
if (bun === undefined)
|
|
64
|
+
throw new Error("Không tìm thấy bun. Cài bun (https://bun.sh) hoặc đặt GBH_BUN.");
|
|
65
|
+
const home = options.home ?? ((process.env.GBH_HOME ?? "").trim() || join(homedir(), ".galaxy", "blackhole"));
|
|
66
|
+
// ONE port, the one the caller asked for. `--auto-port` is deliberately NOT passed: it is what made
|
|
67
|
+
// the printed URL change on every boot, and a fixed default is only fixed if a busy port fails loudly
|
|
68
|
+
// instead of sliding to a random one. `--port 0` still means "OS picks", which is the opt-in path.
|
|
69
|
+
const args = [join(root, "apps", "cli", "src", "main.ts"), "host", "--port", String(options.port)];
|
|
70
|
+
if (options.profile !== undefined && options.profile.length > 0)
|
|
71
|
+
args.push("--profile", options.profile);
|
|
72
|
+
for (const patch of options.patches)
|
|
129
73
|
args.push("--patch", patch);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const resolved = resolveGalaxyKey(home, env);
|
|
138
|
-
const keySource = resolved?.source ?? resolveGalaxyKeySource(home, env);
|
|
139
|
-
return {
|
|
140
|
-
command: runtime.command,
|
|
141
|
-
args,
|
|
74
|
+
const env = { ...process.env, GBH_HOME: home };
|
|
75
|
+
// GBH_CREDENTIALS moves the shared document for the harness; read the same file here.
|
|
76
|
+
const credentials = (process.env.GBH_CREDENTIALS ?? "").trim() || galaxyCredentialsPath();
|
|
77
|
+
const key = resolveGalaxyKey(env, credentials);
|
|
78
|
+
return Object.freeze({
|
|
79
|
+
command: bun,
|
|
80
|
+
args: Object.freeze(args),
|
|
142
81
|
env,
|
|
143
|
-
patches,
|
|
144
82
|
home,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
83
|
+
root,
|
|
84
|
+
source: "blackhole-tauri " + root,
|
|
85
|
+
...(key === undefined ? {} : { keySource: key.source }),
|
|
86
|
+
});
|
|
148
87
|
}
|
|
149
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Boot the Galaxy Blackhole web GUI and open its authenticated URL.
|
|
90
|
+
* @param options - parsed command options.
|
|
91
|
+
* @returns the launcher exit code.
|
|
92
|
+
*/
|
|
150
93
|
export async function runWeb(options) {
|
|
151
|
-
|
|
94
|
+
let plan;
|
|
95
|
+
try {
|
|
96
|
+
// The harness reads the shared document only; a key left in the legacy DSH store is promoted
|
|
97
|
+
// once before boot. A dry run never writes.
|
|
98
|
+
if (!options.dryRun)
|
|
99
|
+
promoteLegacyCredential();
|
|
100
|
+
plan = planWeb(options);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
process.stderr.write("blackhole web: " + (error instanceof Error ? error.message : String(error)) + "\n");
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
152
106
|
if (options.dryRun) {
|
|
153
107
|
process.stdout.write("cwd: " + process.cwd() + "\n");
|
|
154
|
-
process.stdout.write("
|
|
155
|
-
process.stdout.write("
|
|
156
|
-
process.stdout.write("galaxy key: " + (plan.keySource === undefined ? "NOT SET" : "set via " + plan.keySource) + "\n");
|
|
157
|
-
process.stdout.write("
|
|
158
|
-
for (const patch of plan.patches)
|
|
159
|
-
process.stdout.write(" " + patch + "\n");
|
|
160
|
-
process.stdout.write(shellQuote(plan.command) + " " + plan.args.map(shellQuote).join(" ") + "\n");
|
|
108
|
+
process.stdout.write("GBH_HOME=" + plan.home + "\n");
|
|
109
|
+
process.stdout.write("harness: " + plan.source + "\n");
|
|
110
|
+
process.stdout.write("galaxy key: " + (plan.keySource === undefined ? "NOT SET (hộp thoại GBH sẽ hỏi)" : "set via " + plan.keySource) + "\n");
|
|
111
|
+
process.stdout.write([plan.command, ...plan.args].map(value => JSON.stringify(value)).join(" ") + "\n");
|
|
161
112
|
return 0;
|
|
162
113
|
}
|
|
114
|
+
if (options.brand === false) {
|
|
115
|
+
process.stderr.write("blackhole web: giao diện Galaxy Blackhole là mặc định của harness; --no-brand không còn tác dụng.\n");
|
|
116
|
+
}
|
|
163
117
|
if (plan.keySource === undefined) {
|
|
164
|
-
process.stderr.write("
|
|
165
|
-
"The Galaxy Blackhole dialog will ask for it on first load and store it there.\n");
|
|
118
|
+
process.stderr.write("blackhole web: chưa có API key trong ~/.galaxy/credentials.yaml hoặc biến môi trường; hộp thoại của app sẽ hỏi ở lần mở đầu.\n");
|
|
166
119
|
}
|
|
167
|
-
|
|
120
|
+
// The harness exits with "port busy" on its own, but that line is swallowed with the rest of its log
|
|
121
|
+
// when --verbose is off — the user would just see nothing. Ask here, so the answer names the port and
|
|
122
|
+
// both ways out. 0 is exempt: the OS hands out a free port.
|
|
123
|
+
if (!(await isPortFree(options.port))) {
|
|
124
|
+
process.stderr.write("blackhole web: " + busyPortMessage(options.port) + "\n");
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
127
|
+
// One line of outcome, and only that line: the harness's own log (inspector devtools URL, plugin
|
|
128
|
+
// probes, mount notes) is noise for someone who just wants the GUI. --verbose or GBH_LOG=debug
|
|
129
|
+
// relays it, relabelled gbh.
|
|
130
|
+
const verbose = options.verbose || (process.env.GBH_LOG ?? "").trim().toLowerCase() === "debug";
|
|
131
|
+
const boot = verbose ? undefined : createBootReporter(process.stdout, BOOT_PHASES[0].label);
|
|
132
|
+
let phaseIndex = 0;
|
|
133
|
+
const advance = (phase) => {
|
|
134
|
+
if (phase === undefined)
|
|
135
|
+
return;
|
|
136
|
+
const index = BOOT_PHASES.findIndex(entry => entry.id === phase.id);
|
|
137
|
+
if (index <= phaseIndex)
|
|
138
|
+
return;
|
|
139
|
+
phaseIndex = index;
|
|
140
|
+
boot?.step(phase.label);
|
|
141
|
+
};
|
|
142
|
+
const child = spawn(plan.command, [...plan.args], { cwd: process.cwd(), env: plan.env, stdio: ["ignore", "pipe", "pipe"] });
|
|
168
143
|
let seen = "";
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
|
|
144
|
+
let settled = false;
|
|
145
|
+
/** Relay one launcher line, reading the harness's stock prefixes as gbh. */
|
|
146
|
+
const relayLine = (line, sink) => {
|
|
147
|
+
sink.write(line.replace(/^dsh (?=web:|inspector:|\b)/u, "gbh ").replace(/^\[bh\] ready /u, "gbh ready ") + "\n");
|
|
148
|
+
};
|
|
149
|
+
/** Fold one complete line into the boot: progress, optional relay, and the ready URL. */
|
|
150
|
+
const handleLine = (line, sink) => {
|
|
151
|
+
seen = (seen + line + "\n").slice(-16384);
|
|
152
|
+
advance(bootPhaseFor(line));
|
|
153
|
+
// The ready line is printed once, below, as this command's own result: relaying the host's copy
|
|
154
|
+
// as well would print the same URL twice under --verbose.
|
|
155
|
+
if (sink !== undefined && !READY_URL.test(line))
|
|
156
|
+
relayLine(line, sink);
|
|
157
|
+
if (settled)
|
|
172
158
|
return;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
159
|
+
const match = READY_URL.exec(seen);
|
|
160
|
+
if (match === null)
|
|
161
|
+
return;
|
|
162
|
+
settled = true;
|
|
163
|
+
boot?.clear();
|
|
164
|
+
// The token is the point of this line: it is the only way into this boot's session.
|
|
165
|
+
process.stdout.write("gbh web: " + match[0] + "\n");
|
|
166
|
+
if (options.open)
|
|
167
|
+
openUrl(match[0]);
|
|
168
|
+
};
|
|
169
|
+
/** A chunk reader that only ever hands complete lines to handleLine. */
|
|
170
|
+
const reader = (sink) => {
|
|
171
|
+
let buffer = "";
|
|
172
|
+
return (chunk) => {
|
|
173
|
+
buffer += chunk;
|
|
174
|
+
const lines = buffer.split(/\r?\n/u);
|
|
175
|
+
buffer = lines.pop() ?? "";
|
|
176
|
+
for (const line of lines)
|
|
177
|
+
handleLine(line, sink);
|
|
178
|
+
};
|
|
179
179
|
};
|
|
180
180
|
child.stdout?.setEncoding("utf8");
|
|
181
|
-
child.stdout?.on("data", (
|
|
182
|
-
process.stdout.write(chunk);
|
|
183
|
-
scan(chunk);
|
|
184
|
-
});
|
|
181
|
+
child.stdout?.on("data", reader(verbose ? process.stdout : undefined));
|
|
185
182
|
child.stderr?.setEncoding("utf8");
|
|
186
|
-
child.stderr?.on("data", (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
child.kill("SIGTERM");
|
|
192
|
-
};
|
|
193
|
-
process.on("SIGTERM", onSigterm);
|
|
194
|
-
const code = await new Promise((resolvePromise) => {
|
|
183
|
+
child.stderr?.on("data", reader(verbose ? process.stderr : undefined));
|
|
184
|
+
const onTerm = () => { if (!child.killed)
|
|
185
|
+
child.kill("SIGTERM"); };
|
|
186
|
+
process.on("SIGTERM", onTerm);
|
|
187
|
+
const code = await new Promise(resolvePromise => {
|
|
195
188
|
child.on("error", (error) => {
|
|
196
|
-
process.stderr.write("
|
|
189
|
+
process.stderr.write("blackhole web: không chạy được " + plan.command + ": " + error.message + "\n");
|
|
197
190
|
resolvePromise(1);
|
|
198
191
|
});
|
|
199
192
|
child.on("close", (exitCode, signal) => {
|
|
193
|
+
// Exit 3 is the host's "port busy" (apps/cli/src/main.ts EXIT.portBusy). Its own line was
|
|
194
|
+
// swallowed above, so the one port the user asked for is named again here — the race between the
|
|
195
|
+
// probe and the bind is exactly the case this covers.
|
|
196
|
+
if (exitCode === 3 && !settled)
|
|
197
|
+
process.stderr.write("blackhole web: " + busyPortMessage(options.port) + "\n");
|
|
200
198
|
if (exitCode !== null)
|
|
201
199
|
resolvePromise(exitCode);
|
|
202
200
|
else
|
|
203
201
|
resolvePromise(signal === "SIGINT" ? 130 : 1);
|
|
204
202
|
});
|
|
205
203
|
});
|
|
206
|
-
process.off("SIGTERM",
|
|
204
|
+
process.off("SIGTERM", onTerm);
|
|
207
205
|
return code;
|
|
208
206
|
}
|
|
209
207
|
//# sourceMappingURL=web.js.map
|