botmux 3.18.4 → 3.18.6
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/dist/.runtime-build-id +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +130 -21
- package/dist/cli.js.map +1 -1
- package/dist/core/binary-install-shape.d.ts +77 -0
- package/dist/core/binary-install-shape.d.ts.map +1 -0
- package/dist/core/binary-install-shape.js +117 -0
- package/dist/core/binary-install-shape.js.map +1 -0
- package/dist/core/binary-self-update.d.ts +82 -0
- package/dist/core/binary-self-update.d.ts.map +1 -0
- package/dist/core/binary-self-update.js +239 -0
- package/dist/core/binary-self-update.js.map +1 -0
- package/dist/core/maintenance.d.ts +88 -1
- package/dist/core/maintenance.d.ts.map +1 -1
- package/dist/core/maintenance.js +149 -8
- package/dist/core/maintenance.js.map +1 -1
- package/dist/core/release-download.d.ts +13 -0
- package/dist/core/release-download.d.ts.map +1 -0
- package/dist/core/release-download.js +130 -0
- package/dist/core/release-download.js.map +1 -0
- package/dist/dashboard/hd2d-assets.d.ts +2 -3
- package/dist/dashboard/hd2d-assets.d.ts.map +1 -1
- package/dist/dashboard/hd2d-assets.js +7 -109
- package/dist/dashboard/hd2d-assets.js.map +1 -1
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +7 -1
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/settings-page.d.ts.map +1 -1
- package/dist/dashboard/web/settings-page.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard.js +120 -13
- package/dist/dashboard.js.map +1 -1
- package/dist/setup/open-platform-automation.d.ts.map +1 -1
- package/dist/setup/open-platform-automation.js +9 -12
- package/dist/setup/open-platform-automation.js.map +1 -1
- package/dist/utils/file-lock.d.ts +25 -0
- package/dist/utils/file-lock.d.ts.map +1 -1
- package/dist/utils/file-lock.js +34 -4
- package/dist/utils/file-lock.js.map +1 -1
- package/dist/utils/global-install.d.ts +19 -0
- package/dist/utils/global-install.d.ts.map +1 -1
- package/dist/utils/global-install.js +28 -1
- package/dist/utils/global-install.js.map +1 -1
- package/dist/utils/install-info.d.ts +37 -1
- package/dist/utils/install-info.d.ts.map +1 -1
- package/dist/utils/install-info.js +45 -3
- package/dist/utils/install-info.js.map +1 -1
- package/package.json +7 -7
|
@@ -20,6 +20,7 @@ import { spawn } from 'node:child_process';
|
|
|
20
20
|
import { type MaintenanceConfig } from '../global-config.js';
|
|
21
21
|
import { type RestartIntent } from '../services/restart-intent-store.js';
|
|
22
22
|
import { type GlobalInstallPlan } from '../utils/global-install.js';
|
|
23
|
+
import { type BinaryInstallShape, type UpdateStrategy } from './binary-self-update.js';
|
|
23
24
|
export interface MaintenanceState {
|
|
24
25
|
/** Local date the auto-update run was last handled (fired or skipped). */
|
|
25
26
|
autoUpdate?: {
|
|
@@ -39,6 +40,30 @@ export interface MaintenanceDeps {
|
|
|
39
40
|
currentVersion: () => string;
|
|
40
41
|
/** Updates the owning npm/pnpm/Bun global install (download/install only). */
|
|
41
42
|
runUpdate: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* What `runUpdate` actually installed, or '' when it could not be determined.
|
|
45
|
+
*
|
|
46
|
+
* ⚠️ WHY THIS EXISTS — THE BAKED VERSION SHADOWS A COMPLETED UPDATE, ON BOTH
|
|
47
|
+
* STRATEGIES. A compiled binary's version is baked in at compile time, and
|
|
48
|
+
* `botmuxVersionAt` returns that value for ANY directory you ask about. So
|
|
49
|
+
* `currentVersion()` after an update still reports this process's OLD version:
|
|
50
|
+
*
|
|
51
|
+
* · self-replace — the file on disk was swapped; nothing on disk is read.
|
|
52
|
+
* · package-manager — npm rewrote the install's package.json, but the baked
|
|
53
|
+
* value takes priority over reading it (measured:
|
|
54
|
+
* package.json says 3.19.0, the call returns 3.18.4).
|
|
55
|
+
*
|
|
56
|
+
* Either way `after === before`, so the tick logs "already on the latest
|
|
57
|
+
* version" and NEVER restarts onto what it just installed. Both branches
|
|
58
|
+
* therefore report the installed version explicitly — the self-replace path from
|
|
59
|
+
* what it downloaded, the package-manager path via `diskVersionAt` (which
|
|
60
|
+
* deliberately ignores the baked value).
|
|
61
|
+
*
|
|
62
|
+
* Returns '' when undeterminable, and the tick falls back to the re-read
|
|
63
|
+
* comparison. Under Node the baked value is absent, so all of this is a no-op
|
|
64
|
+
* and behaviour is byte-identical to before.
|
|
65
|
+
*/
|
|
66
|
+
installedVersion?: () => string;
|
|
42
67
|
writeIntent: (intent: RestartIntent) => void;
|
|
43
68
|
/** Spawn a detached `botmux restart` (this process is then killed by pm2). */
|
|
44
69
|
triggerRestart: () => void;
|
|
@@ -73,6 +98,23 @@ export declare function maintenanceRestartLogPath(): string;
|
|
|
73
98
|
export declare function globalInstallUpdateCwd(): string;
|
|
74
99
|
/** Run the ownership-aware update synchronously. */
|
|
75
100
|
export declare function installLatestBotmuxSync(plan?: GlobalInstallPlan): void;
|
|
101
|
+
/**
|
|
102
|
+
* Apply an update for whatever install shape this process is, resolving the
|
|
103
|
+
* strategy first so a compiled binary is handled instead of being rejected as an
|
|
104
|
+
* "unsupported install".
|
|
105
|
+
*
|
|
106
|
+
* Shared by the CLI (`botmux update`), the dashboard's `/api/update/run` and the
|
|
107
|
+
* scheduled auto-update so the three cannot drift — they previously all funnelled
|
|
108
|
+
* into `resolveGlobalInstallPlan`, which is exactly the call that fails in
|
|
109
|
+
* compiled mode.
|
|
110
|
+
*
|
|
111
|
+
* @param spec the version spec for the package-manager path, and the version to
|
|
112
|
+
* download for the self-replace path ('latest' resolves upstream).
|
|
113
|
+
*/
|
|
114
|
+
export declare function applyBotmuxUpdate(installRoot: string, version: string): Promise<{
|
|
115
|
+
strategy: UpdateStrategy['kind'];
|
|
116
|
+
detail: string;
|
|
117
|
+
}>;
|
|
76
118
|
/**
|
|
77
119
|
* Cross-process lock target that serializes global botmux updates
|
|
78
120
|
* between the scheduled auto-update (this daemon process) and a
|
|
@@ -92,12 +134,43 @@ export declare function globalInstallUpdateLockTarget(): string;
|
|
|
92
134
|
* restarts the rest (the 2026-06-11 incident). `setsid` starts it in a brand
|
|
93
135
|
* new session, reparented to init, immune to botmux-0's teardown. Without
|
|
94
136
|
* setsid we fall back to a plain spawn (still detached by the caller).
|
|
137
|
+
*
|
|
138
|
+
* ⚠️ COMPILED BINARY: there is no `cli.js` to pass. Under Node the shape is
|
|
139
|
+
* `node <dist/cli.js> restart`, where argv[2] is `restart`. A single-file
|
|
140
|
+
* executable IS the CLI, so the same shape becomes `<binary> <cli.js path>
|
|
141
|
+
* restart` — and argv[2] is then the PATH, not `restart`. MEASURED on the real
|
|
142
|
+
* v3.18.4 binary: it printed the help banner and **exited 0**, i.e. a restart
|
|
143
|
+
* that silently never happened while reporting success. So in standalone mode the
|
|
144
|
+
* entry argument is dropped entirely and the binary is invoked as
|
|
145
|
+
* `<binary> restart`.
|
|
95
146
|
*/
|
|
96
|
-
export declare function buildRestartLauncher(node: string, cliEntry: string, hasSetsid: boolean): {
|
|
147
|
+
export declare function buildRestartLauncher(node: string, cliEntry: string, hasSetsid: boolean, standalone?: boolean): {
|
|
97
148
|
cmd: string;
|
|
98
149
|
args: string[];
|
|
99
150
|
};
|
|
100
151
|
export declare function detachedRestartEnv(inheritedEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
152
|
+
/**
|
|
153
|
+
* Resolve the executable a detached restart should launch.
|
|
154
|
+
*
|
|
155
|
+
* ⚠️ WHY `process.execPath` IS NOT ALWAYS RIGHT FOR A COMPILED BINARY. For the
|
|
156
|
+
* self-replacing (install.sh) shape it is exactly right: the path is stable and we
|
|
157
|
+
* just swapped the bytes underneath it. But for a PACKAGE-MANAGER-owned binary the
|
|
158
|
+
* running path can be VERSIONED — pnpm's virtual store yields
|
|
159
|
+
* `…/.pnpm/botmux-linux-x64@<old version>/node_modules/botmux-linux-x64/botmux`.
|
|
160
|
+
* After the update, npm/pnpm's postinstall has re-pointed the stable launcher at
|
|
161
|
+
* the NEW subpackage, while this process's `execPath` still names the OLD one. So
|
|
162
|
+
* restarting from `execPath` either fails with ENOENT (the old store entry was
|
|
163
|
+
* pruned) or silently starts the OLD binary — an update that reports success and
|
|
164
|
+
* does not take effect.
|
|
165
|
+
*
|
|
166
|
+
* The stable launcher (`~/.botmux/bin/botmux`) is what both installers maintain and
|
|
167
|
+
* re-point, so it is the correct target after a package-manager update. Fall back
|
|
168
|
+
* to `execPath` when it is missing (nothing else to go on) — that is the
|
|
169
|
+
* pre-existing behaviour.
|
|
170
|
+
*
|
|
171
|
+
* Pure over its inputs so every branch is testable without a compiled binary.
|
|
172
|
+
*/
|
|
173
|
+
export declare function resolveStandaloneRestartExecutable(standalone: boolean, execPath: string, shape: BinaryInstallShape, launcherPath: string, launcherExists: boolean): string;
|
|
101
174
|
/**
|
|
102
175
|
* Spawn a detached `botmux restart`, immune to this process's own teardown
|
|
103
176
|
* (setsid → a new session reparented to init, so PM2 killing the current
|
|
@@ -108,6 +181,20 @@ export declare function detachedRestartEnv(inheritedEnv?: NodeJS.ProcessEnv): No
|
|
|
108
181
|
* @param reason short tag written to the log (e.g. 'auto-update', 'dashboard').
|
|
109
182
|
*/
|
|
110
183
|
export declare function spawnDetachedRestart(reason: string, activePackageRoot?: string, restartLeaseId?: string): ReturnType<typeof spawn>;
|
|
184
|
+
/**
|
|
185
|
+
* Perform a binary self-replace in a CHILD process and block until it finishes.
|
|
186
|
+
*
|
|
187
|
+
* WHY A CHILD AND NOT AN `await` HERE: `runMaintenanceTick` is synchronous and
|
|
188
|
+
* runs inside `withFileLockSync`, so it cannot await the download. Re-execing this
|
|
189
|
+
* same binary with a hidden `__self-update` subcommand keeps the lock semantics
|
|
190
|
+
* byte-identical to the package-manager branch (spawn one child, wait, throw on a
|
|
191
|
+
* non-zero exit) without turning the whole tick async — which would change the
|
|
192
|
+
* locking shape for the npm path too, the one that is currently working.
|
|
193
|
+
*
|
|
194
|
+
* Returns the version that was installed (printed by the child on its last line),
|
|
195
|
+
* or '' when the child reported success without a parseable version.
|
|
196
|
+
*/
|
|
197
|
+
export declare function runSelfReplaceBlocking(version?: string): string;
|
|
111
198
|
/** Start the maintenance loop. Call only on the primary daemon (bot-0). */
|
|
112
199
|
export declare function startMaintenance(): void;
|
|
113
200
|
export declare function stopMaintenance(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../src/core/maintenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAY,KAAK,EAAa,MAAM,oBAAoB,CAAC;AAMhE,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG/E,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../src/core/maintenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAY,KAAK,EAAa,MAAM,oBAAoB,CAAC;AAMhE,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG/E,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAU7C,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,UAAU,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,iBAAiB,GAAG,SAAS,CAAC;IAChD,SAAS,EAAE,MAAM,gBAAgB,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;I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,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAY/D;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIvE;AAED,wBAAgB,6BAA6B,IAAI,MAAM,CAEtD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,EAClB,UAAU,UAAQ,GACjB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAMjC;AAED,wBAAgB,kBAAkB,CAAC,YAAY,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAAC,UAAU,CAuCnG;AAWD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,kBAAkB,EACzB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,OAAO,GACtB,MAAM,CAMR;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,iBAAiB,CAAC,EAAE,MAAM,EAC1B,cAAc,CAAC,EAAE,MAAM,GACtB,UAAU,CAAC,OAAO,KAAK,CAAC,CAkD1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,SAAW,GAAG,MAAM,CAiBjE;AAoED,2EAA2E;AAC3E,wBAAgB,gBAAgB,IAAI,IAAI,CAavC;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
|
package/dist/core/maintenance.js
CHANGED
|
@@ -26,10 +26,13 @@ import { readGlobalConfig } from '../global-config.js';
|
|
|
26
26
|
import { evaluateDue } from './maintenance-schedule.js';
|
|
27
27
|
import { anyDaemonBusy } from './daemon-heartbeat.js';
|
|
28
28
|
import { claimRestartLease, clearRestartLease, hasActiveRestartLease, writeRestartIntent, } from '../services/restart-intent-store.js';
|
|
29
|
-
import { isLocalDevInstall, botmuxVersion, botmuxVersionAt, botmuxCliEntry, botmuxCliEntryAt, } from '../utils/install-info.js';
|
|
30
|
-
import { resolveGlobalInstallPlan, } from '../utils/global-install.js';
|
|
29
|
+
import { isLocalDevInstall, botmuxVersion, botmuxInstallRoot, botmuxVersionAt, diskVersionAt, botmuxCliEntry, botmuxCliEntryAt, } from '../utils/install-info.js';
|
|
30
|
+
import { resolveGlobalInstallPlan, formatGlobalInstallCommand, UnsupportedGlobalInstallError, } from '../utils/global-install.js';
|
|
31
31
|
import { withFileLockSync } from '../utils/file-lock.js';
|
|
32
32
|
import { scrubWorkflowWorkerEnv, stripDashboardH5Env } from '../utils/child-env.js';
|
|
33
|
+
import { isStandaloneBinary } from './self-spawn.js';
|
|
34
|
+
import { currentUpdateStrategy, currentBinaryInstallShape, replaceStandaloneBinary, } from './binary-self-update.js';
|
|
35
|
+
import { globalWrapperPath } from '../utils/local-dev-update.js';
|
|
33
36
|
/**
|
|
34
37
|
* One maintenance tick. The schedule is driven solely by auto-update's time
|
|
35
38
|
* (once/day). At that time: install the latest version (download only), and
|
|
@@ -67,7 +70,10 @@ export function runMaintenanceTick(deps) {
|
|
|
67
70
|
deps.withUpdateLock(() => {
|
|
68
71
|
before = deps.currentVersion();
|
|
69
72
|
deps.runUpdate();
|
|
70
|
-
|
|
73
|
+
// Both strategies report what they installed: a compiled binary's baked
|
|
74
|
+
// version shadows the disk on BOTH paths (see MaintenanceDeps.installedVersion).
|
|
75
|
+
const reported = deps.installedVersion?.() ?? '';
|
|
76
|
+
after = reported || deps.currentVersion();
|
|
71
77
|
if (after !== before && cfg.autoRestart?.enabled) {
|
|
72
78
|
deps.writeIntent({ kind: 'update', oldVersion: before, newVersion: after, at: new Date(now).toISOString() });
|
|
73
79
|
try {
|
|
@@ -160,6 +166,32 @@ export function installLatestBotmuxSync(plan = resolveGlobalInstallPlan()) {
|
|
|
160
166
|
throw new Error(`${plan.manager} install exited with ${result.status ?? result.signal ?? 'unknown status'}`);
|
|
161
167
|
}
|
|
162
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Apply an update for whatever install shape this process is, resolving the
|
|
171
|
+
* strategy first so a compiled binary is handled instead of being rejected as an
|
|
172
|
+
* "unsupported install".
|
|
173
|
+
*
|
|
174
|
+
* Shared by the CLI (`botmux update`), the dashboard's `/api/update/run` and the
|
|
175
|
+
* scheduled auto-update so the three cannot drift — they previously all funnelled
|
|
176
|
+
* into `resolveGlobalInstallPlan`, which is exactly the call that fails in
|
|
177
|
+
* compiled mode.
|
|
178
|
+
*
|
|
179
|
+
* @param spec the version spec for the package-manager path, and the version to
|
|
180
|
+
* download for the self-replace path ('latest' resolves upstream).
|
|
181
|
+
*/
|
|
182
|
+
export async function applyBotmuxUpdate(installRoot, version) {
|
|
183
|
+
const strategy = currentUpdateStrategy(installRoot);
|
|
184
|
+
if (strategy.kind === 'unsupported') {
|
|
185
|
+
throw new UnsupportedGlobalInstallError('unknown', process.execPath);
|
|
186
|
+
}
|
|
187
|
+
if (strategy.kind === 'self-replace') {
|
|
188
|
+
const r = await replaceStandaloneBinary(version, strategy.target);
|
|
189
|
+
return { strategy: 'self-replace', detail: `${r.asset} → ${r.target}` };
|
|
190
|
+
}
|
|
191
|
+
const plan = resolveGlobalInstallPlan(strategy.packageRoot, process.platform, `botmux@${version}`);
|
|
192
|
+
installLatestBotmuxSync(plan);
|
|
193
|
+
return { strategy: 'package-manager', detail: formatGlobalInstallCommand(plan) };
|
|
194
|
+
}
|
|
163
195
|
/**
|
|
164
196
|
* Cross-process lock target that serializes global botmux updates
|
|
165
197
|
* between the scheduled auto-update (this daemon process) and a
|
|
@@ -185,11 +217,23 @@ export function globalInstallUpdateLockTarget() {
|
|
|
185
217
|
* restarts the rest (the 2026-06-11 incident). `setsid` starts it in a brand
|
|
186
218
|
* new session, reparented to init, immune to botmux-0's teardown. Without
|
|
187
219
|
* setsid we fall back to a plain spawn (still detached by the caller).
|
|
220
|
+
*
|
|
221
|
+
* ⚠️ COMPILED BINARY: there is no `cli.js` to pass. Under Node the shape is
|
|
222
|
+
* `node <dist/cli.js> restart`, where argv[2] is `restart`. A single-file
|
|
223
|
+
* executable IS the CLI, so the same shape becomes `<binary> <cli.js path>
|
|
224
|
+
* restart` — and argv[2] is then the PATH, not `restart`. MEASURED on the real
|
|
225
|
+
* v3.18.4 binary: it printed the help banner and **exited 0**, i.e. a restart
|
|
226
|
+
* that silently never happened while reporting success. So in standalone mode the
|
|
227
|
+
* entry argument is dropped entirely and the binary is invoked as
|
|
228
|
+
* `<binary> restart`.
|
|
188
229
|
*/
|
|
189
|
-
export function buildRestartLauncher(node, cliEntry, hasSetsid) {
|
|
230
|
+
export function buildRestartLauncher(node, cliEntry, hasSetsid, standalone = false) {
|
|
231
|
+
// A compiled binary dispatches its own subcommands; passing a cli.js path
|
|
232
|
+
// would shift `restart` to argv[3] where nothing reads it.
|
|
233
|
+
const entryArgs = standalone ? ['restart'] : [cliEntry, 'restart'];
|
|
190
234
|
if (hasSetsid)
|
|
191
|
-
return { cmd: 'setsid', args: [node,
|
|
192
|
-
return { cmd: node, args:
|
|
235
|
+
return { cmd: 'setsid', args: [node, ...entryArgs] };
|
|
236
|
+
return { cmd: node, args: entryArgs };
|
|
193
237
|
}
|
|
194
238
|
export function detachedRestartEnv(inheritedEnv = process.env) {
|
|
195
239
|
const env = { ...inheritedEnv };
|
|
@@ -241,6 +285,37 @@ function setsidAvailable() {
|
|
|
241
285
|
return false;
|
|
242
286
|
}
|
|
243
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Resolve the executable a detached restart should launch.
|
|
290
|
+
*
|
|
291
|
+
* ⚠️ WHY `process.execPath` IS NOT ALWAYS RIGHT FOR A COMPILED BINARY. For the
|
|
292
|
+
* self-replacing (install.sh) shape it is exactly right: the path is stable and we
|
|
293
|
+
* just swapped the bytes underneath it. But for a PACKAGE-MANAGER-owned binary the
|
|
294
|
+
* running path can be VERSIONED — pnpm's virtual store yields
|
|
295
|
+
* `…/.pnpm/botmux-linux-x64@<old version>/node_modules/botmux-linux-x64/botmux`.
|
|
296
|
+
* After the update, npm/pnpm's postinstall has re-pointed the stable launcher at
|
|
297
|
+
* the NEW subpackage, while this process's `execPath` still names the OLD one. So
|
|
298
|
+
* restarting from `execPath` either fails with ENOENT (the old store entry was
|
|
299
|
+
* pruned) or silently starts the OLD binary — an update that reports success and
|
|
300
|
+
* does not take effect.
|
|
301
|
+
*
|
|
302
|
+
* The stable launcher (`~/.botmux/bin/botmux`) is what both installers maintain and
|
|
303
|
+
* re-point, so it is the correct target after a package-manager update. Fall back
|
|
304
|
+
* to `execPath` when it is missing (nothing else to go on) — that is the
|
|
305
|
+
* pre-existing behaviour.
|
|
306
|
+
*
|
|
307
|
+
* Pure over its inputs so every branch is testable without a compiled binary.
|
|
308
|
+
*/
|
|
309
|
+
export function resolveStandaloneRestartExecutable(standalone, execPath, shape, launcherPath, launcherExists) {
|
|
310
|
+
if (!standalone)
|
|
311
|
+
return execPath;
|
|
312
|
+
// We own this exact path and just replaced its contents — re-exec it.
|
|
313
|
+
if (shape === 'curl-binary')
|
|
314
|
+
return execPath;
|
|
315
|
+
if (shape === 'npm-binary' && launcherExists)
|
|
316
|
+
return launcherPath;
|
|
317
|
+
return execPath;
|
|
318
|
+
}
|
|
244
319
|
/**
|
|
245
320
|
* Spawn a detached `botmux restart`, immune to this process's own teardown
|
|
246
321
|
* (setsid → a new session reparented to init, so PM2 killing the current
|
|
@@ -261,8 +336,17 @@ export function spawnDetachedRestart(reason, activePackageRoot, restartLeaseId)
|
|
|
261
336
|
catch {
|
|
262
337
|
fd = undefined; // fall back to discarding output rather than failing the restart
|
|
263
338
|
}
|
|
339
|
+
// A compiled binary has no cli.js on disk: `botmuxCliEntryAt` would hand back a
|
|
340
|
+
// path that does not exist (measured: "/dist/cli.js"), and passing it shifts the
|
|
341
|
+
// subcommand out of argv[2]. buildRestartLauncher drops it in that mode; we
|
|
342
|
+
// still compute it for the Node path, which is unchanged.
|
|
343
|
+
const standalone = isStandaloneBinary();
|
|
264
344
|
const cliEntry = activePackageRoot ? botmuxCliEntryAt(activePackageRoot) : botmuxCliEntry();
|
|
265
|
-
|
|
345
|
+
// A package-manager-owned binary's own path can be versioned (pnpm store); after
|
|
346
|
+
// the update the stable launcher points at the new one while execPath does not.
|
|
347
|
+
const launcher = globalWrapperPath();
|
|
348
|
+
const executable = resolveStandaloneRestartExecutable(standalone, process.execPath, standalone ? currentBinaryInstallShape() : 'unknown', launcher, existsSync(launcher));
|
|
349
|
+
const { cmd, args } = buildRestartLauncher(executable, cliEntry, setsidAvailable(), standalone);
|
|
266
350
|
const child = spawn(cmd, args, {
|
|
267
351
|
detached: true,
|
|
268
352
|
stdio: fd !== undefined ? ['ignore', fd, fd] : 'ignore',
|
|
@@ -290,11 +374,45 @@ export function spawnDetachedRestart(reason, activePackageRoot, restartLeaseId)
|
|
|
290
374
|
}
|
|
291
375
|
return child;
|
|
292
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Perform a binary self-replace in a CHILD process and block until it finishes.
|
|
379
|
+
*
|
|
380
|
+
* WHY A CHILD AND NOT AN `await` HERE: `runMaintenanceTick` is synchronous and
|
|
381
|
+
* runs inside `withFileLockSync`, so it cannot await the download. Re-execing this
|
|
382
|
+
* same binary with a hidden `__self-update` subcommand keeps the lock semantics
|
|
383
|
+
* byte-identical to the package-manager branch (spawn one child, wait, throw on a
|
|
384
|
+
* non-zero exit) without turning the whole tick async — which would change the
|
|
385
|
+
* locking shape for the npm path too, the one that is currently working.
|
|
386
|
+
*
|
|
387
|
+
* Returns the version that was installed (printed by the child on its last line),
|
|
388
|
+
* or '' when the child reported success without a parseable version.
|
|
389
|
+
*/
|
|
390
|
+
export function runSelfReplaceBlocking(version = 'latest') {
|
|
391
|
+
const result = spawnSync(process.execPath, ['__self-update', version], {
|
|
392
|
+
cwd: globalInstallUpdateCwd(),
|
|
393
|
+
env: process.env,
|
|
394
|
+
encoding: 'utf-8',
|
|
395
|
+
// The download is ~100MB+ over a possibly proxied link; the package-manager
|
|
396
|
+
// branch has no timeout either (npm's own) so match that and let the outer
|
|
397
|
+
// schedule slip a day rather than killing a partial swap.
|
|
398
|
+
maxBuffer: 1024 * 1024,
|
|
399
|
+
});
|
|
400
|
+
if (result.error)
|
|
401
|
+
throw result.error;
|
|
402
|
+
if (result.status !== 0) {
|
|
403
|
+
const detail = (result.stderr || result.stdout || '').trim().split('\n').slice(-3).join('; ');
|
|
404
|
+
throw new Error(`self-update exited with ${result.status ?? result.signal ?? 'unknown status'}${detail ? `: ${detail}` : ''}`);
|
|
405
|
+
}
|
|
406
|
+
const m = /BOTMUX_SELF_UPDATE_VERSION=(\S+)/.exec(result.stdout || '');
|
|
407
|
+
return m?.[1] ?? '';
|
|
408
|
+
}
|
|
293
409
|
function productionDeps() {
|
|
294
410
|
// Kept after a successful resolve so post-pnpm-update version/restart lookups
|
|
295
411
|
// use the stable global node_modules/botmux symlink, not the removed
|
|
296
412
|
// .pnpm/botmux@old runtime realpath.
|
|
297
413
|
let installPlan;
|
|
414
|
+
// What runUpdate installed, for both strategies (see MaintenanceDeps.installedVersion).
|
|
415
|
+
let installedTo = '';
|
|
298
416
|
return {
|
|
299
417
|
now: () => Date.now(),
|
|
300
418
|
readConfig: () => readGlobalConfig().maintenance,
|
|
@@ -311,9 +429,32 @@ function productionDeps() {
|
|
|
311
429
|
? botmuxVersionAt(installPlan.activePackageRoot)
|
|
312
430
|
: botmuxVersion(),
|
|
313
431
|
runUpdate: () => {
|
|
314
|
-
|
|
432
|
+
installedTo = '';
|
|
433
|
+
const strategy = currentUpdateStrategy(botmuxInstallRoot());
|
|
434
|
+
if (strategy.kind === 'unsupported') {
|
|
435
|
+
throw new UnsupportedGlobalInstallError('unknown', process.execPath);
|
|
436
|
+
}
|
|
437
|
+
if (strategy.kind === 'self-replace') {
|
|
438
|
+
// The compiled binary owns its own file (install.sh location). The tick
|
|
439
|
+
// is synchronous and holds a cross-process lock, so run the async
|
|
440
|
+
// download to completion here rather than restructuring the whole tick:
|
|
441
|
+
// `runSelfReplaceBlocking` re-execs this binary with a hidden subcommand
|
|
442
|
+
// that performs the swap, which keeps the lock semantics identical to the
|
|
443
|
+
// package-manager branch (one child, awaited, non-zero exit ⇒ throw).
|
|
444
|
+
installedTo = runSelfReplaceBlocking();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
installPlan ??= resolveGlobalInstallPlan(strategy.packageRoot);
|
|
315
448
|
installLatestBotmuxSync(installPlan);
|
|
449
|
+
// Report what landed on DISK. For a compiled binary installed by a package
|
|
450
|
+
// manager, `currentVersion()` (→ botmuxVersionAt) returns this process's
|
|
451
|
+
// BAKED version and so cannot see the update npm just performed — measured,
|
|
452
|
+
// and it would make the tick log "already on the latest version" and skip the
|
|
453
|
+
// restart. diskVersionAt deliberately ignores the baked value. Under Node the
|
|
454
|
+
// two agree, so this is a no-op there.
|
|
455
|
+
installedTo = diskVersionAt(installPlan.activePackageRoot);
|
|
316
456
|
},
|
|
457
|
+
installedVersion: () => installedTo,
|
|
317
458
|
writeIntent: (intent) => writeRestartIntent(intent),
|
|
318
459
|
triggerRestart: () => {
|
|
319
460
|
const leaseId = claimRestartLease();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.js","sourceRoot":"","sources":["../../src/core/maintenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,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AG,EAAE;QAChB,IAAI,CAAC;YAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAAC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YAC3C,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC,CAAC;IACF,oEAAoE;IACpE,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IACnC,KAAK,GAAG,WAAW,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAC/C,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAChB,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,KAAK,EAAE,CAAC;QAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAAC,KAAK,GAAG,SAAS,CAAC;IAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type IncomingMessage } from 'node:http';
|
|
2
|
+
/** Resolve an outbound proxy: explicit config wins, then the standard env vars
|
|
3
|
+
* (which Node's global fetch ignores — the whole reason we hand-roll this). */
|
|
4
|
+
export declare function resolveHttpProxy(): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* GET a URL and resolve with the 200 response stream, following redirects and
|
|
7
|
+
* optionally tunnelling through an HTTP proxy.
|
|
8
|
+
*
|
|
9
|
+
* @param userAgent sent as `user-agent`; callers pass their own tag so server-side
|
|
10
|
+
* logs can tell the game assets apart from a self-update.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getReleaseStream(rawUrl: string, proxy: string | undefined, userAgent: string, redirectsLeft?: number): Promise<IncomingMessage>;
|
|
13
|
+
//# sourceMappingURL=release-download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-download.d.ts","sourceRoot":"","sources":["../../src/core/release-download.ts"],"names":[],"mappings":"AAqBA,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAKzE;gFACgF;AAChF,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAKrD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,EACjB,aAAa,SAAI,GAChB,OAAO,CAAC,eAAe,CAAC,CAuE1B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared release-asset download: GET a URL through an optional proxy, following
|
|
3
|
+
* redirects, and resolve with the 200 response stream.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `dashboard/hd2d-assets.ts` so the binary self-update
|
|
6
|
+
* (`core/binary-self-update.ts`) reuses exactly this transport instead of
|
|
7
|
+
* growing a second copy. Both callers fetch GitHub Release assets, and both need
|
|
8
|
+
* the same three things the naive version gets wrong:
|
|
9
|
+
*
|
|
10
|
+
* · `node:http`/`node:https` rather than `fetch`, so an explicitly configured
|
|
11
|
+
* proxy is actually honoured — undici ignores the proxy env vars, and Bun's
|
|
12
|
+
* fetch goes the other way and honours them too eagerly (see
|
|
13
|
+
* `core/loopback-fetch.ts` for that direction).
|
|
14
|
+
* · CONNECT tunnelling for HTTPS-via-HTTP-proxy.
|
|
15
|
+
* · Tearing down each hop before following a redirect: a lingering TLS socket
|
|
16
|
+
* layered over a CONNECT tunnel stalls the NEXT hop's handshake (observed:
|
|
17
|
+
* github.com → release-assets… drops with "socket disconnected before secure
|
|
18
|
+
* TLS" unless hop 1 is closed). GitHub Release downloads ALWAYS redirect, so
|
|
19
|
+
* this is the normal path, not an edge case.
|
|
20
|
+
*/
|
|
21
|
+
import { request as httpsRequest } from 'node:https';
|
|
22
|
+
import { request as httpRequest } from 'node:http';
|
|
23
|
+
import { connect as tlsConnect } from 'node:tls';
|
|
24
|
+
import { Buffer } from 'node:buffer';
|
|
25
|
+
import { readGlobalConfig } from '../global-config.js';
|
|
26
|
+
/** Resolve an outbound proxy: explicit config wins, then the standard env vars
|
|
27
|
+
* (which Node's global fetch ignores — the whole reason we hand-roll this). */
|
|
28
|
+
export function resolveHttpProxy() {
|
|
29
|
+
return readGlobalConfig().httpProxy
|
|
30
|
+
|| process.env.HTTPS_PROXY || process.env.https_proxy
|
|
31
|
+
|| process.env.HTTP_PROXY || process.env.http_proxy
|
|
32
|
+
|| undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* GET a URL and resolve with the 200 response stream, following redirects and
|
|
36
|
+
* optionally tunnelling through an HTTP proxy.
|
|
37
|
+
*
|
|
38
|
+
* @param userAgent sent as `user-agent`; callers pass their own tag so server-side
|
|
39
|
+
* logs can tell the game assets apart from a self-update.
|
|
40
|
+
*/
|
|
41
|
+
export function getReleaseStream(rawUrl, proxy, userAgent, redirectsLeft = 5) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
let target;
|
|
44
|
+
try {
|
|
45
|
+
target = new URL(rawUrl);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
reject(new Error(`URL 非法: ${rawUrl}`));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const isHttps = target.protocol === 'https:';
|
|
52
|
+
const handle = (res) => {
|
|
53
|
+
const sc = res.statusCode ?? 0;
|
|
54
|
+
if (sc >= 300 && sc < 400 && res.headers.location) {
|
|
55
|
+
// Tear down this hop's connection before following the redirect (see header).
|
|
56
|
+
res.destroy();
|
|
57
|
+
res.socket?.destroy();
|
|
58
|
+
if (redirectsLeft <= 0) {
|
|
59
|
+
reject(new Error('重定向次数过多'));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
resolve(getReleaseStream(new URL(res.headers.location, rawUrl).toString(), proxy, userAgent, redirectsLeft - 1));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (sc !== 200) {
|
|
66
|
+
res.resume();
|
|
67
|
+
reject(new Error(`HTTP ${sc}`));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
resolve(res);
|
|
71
|
+
};
|
|
72
|
+
let p;
|
|
73
|
+
if (proxy) {
|
|
74
|
+
try {
|
|
75
|
+
p = new URL(proxy);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
reject(new Error(`代理地址非法: ${proxy}`));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const proxyAuth = () => p?.username
|
|
83
|
+
? { 'proxy-authorization': `Basic ${Buffer.from(`${decodeURIComponent(p.username)}:${decodeURIComponent(p.password)}`).toString('base64')}` }
|
|
84
|
+
: {};
|
|
85
|
+
if (p && isHttps) {
|
|
86
|
+
// HTTPS via HTTP proxy: open a CONNECT tunnel, then TLS over the socket.
|
|
87
|
+
const port = target.port || '443';
|
|
88
|
+
const creq = httpRequest({
|
|
89
|
+
host: p.hostname, port: Number(p.port || 80), method: 'CONNECT', agent: false,
|
|
90
|
+
path: `${target.hostname}:${port}`,
|
|
91
|
+
headers: { host: `${target.hostname}:${port}`, ...proxyAuth() },
|
|
92
|
+
});
|
|
93
|
+
creq.on('connect', (cres, socket) => {
|
|
94
|
+
if (cres.statusCode !== 200) {
|
|
95
|
+
reject(new Error(`代理 CONNECT 失败: HTTP ${cres.statusCode}`));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const tls = tlsConnect({ socket, servername: target.hostname }, () => {
|
|
99
|
+
const greq = httpsRequest({
|
|
100
|
+
method: 'GET', path: `${target.pathname}${target.search}`,
|
|
101
|
+
headers: { host: target.host, 'user-agent': userAgent },
|
|
102
|
+
createConnection: () => tls,
|
|
103
|
+
}, handle);
|
|
104
|
+
greq.on('error', reject);
|
|
105
|
+
greq.end();
|
|
106
|
+
});
|
|
107
|
+
tls.on('error', reject);
|
|
108
|
+
});
|
|
109
|
+
creq.on('error', reject);
|
|
110
|
+
creq.end();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (p) {
|
|
114
|
+
// Plain HTTP via proxy: send the absolute-form request line to the proxy.
|
|
115
|
+
const greq = httpRequest({
|
|
116
|
+
host: p.hostname, port: Number(p.port || 80), method: 'GET', path: rawUrl,
|
|
117
|
+
headers: { host: target.host, 'user-agent': userAgent, ...proxyAuth() },
|
|
118
|
+
}, handle);
|
|
119
|
+
greq.on('error', reject);
|
|
120
|
+
greq.end();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// Direct (no proxy).
|
|
124
|
+
const mod = isHttps ? httpsRequest : httpRequest;
|
|
125
|
+
const greq = mod(rawUrl, { headers: { 'user-agent': userAgent } }, handle);
|
|
126
|
+
greq.on('error', reject);
|
|
127
|
+
greq.end();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=release-download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-download.js","sourceRoot":"","sources":["../../src/core/release-download.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAwB,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;gFACgF;AAChF,MAAM,UAAU,gBAAgB;IAC9B,OAAO,gBAAgB,EAAE,CAAC,SAAS;WAC9B,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW;WAClD,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO,C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E,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE;aACxE,EAAE,MAAM,CAAC,CAAC;YACX,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACzB,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,qBAAqB;QACrB,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;QACjD,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC3E,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveHttpProxy } from '../core/release-download.js';
|
|
2
|
+
export { resolveHttpProxy };
|
|
1
3
|
export declare const HD2D_ASSETS_TAG = "hd2d-assets-v2";
|
|
2
4
|
export declare const HD2D_CACHE_DIR: string;
|
|
3
5
|
export type Hd2dState = 'absent' | 'downloading' | 'ready' | 'error';
|
|
@@ -11,9 +13,6 @@ export interface Hd2dStatus {
|
|
|
11
13
|
* allow-list (defends the static route against path games). */
|
|
12
14
|
export declare function hd2dAssetPath(name: string): string | null;
|
|
13
15
|
export declare function hd2dStatus(): Hd2dStatus;
|
|
14
|
-
/** Resolve an outbound proxy: explicit config wins, then the standard env vars
|
|
15
|
-
* (which Node's global fetch ignores — the whole reason we hand-roll this). */
|
|
16
|
-
export declare function resolveHttpProxy(): string | undefined;
|
|
17
16
|
/** Idempotently kick off the asset download. Returns the current status
|
|
18
17
|
* immediately; callers poll `/api/game/status` for progress. */
|
|
19
18
|
export declare function startHd2dDownload(): Hd2dStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hd2d-assets.d.ts","sourceRoot":"","sources":["../../src/dashboard/hd2d-assets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hd2d-assets.d.ts","sourceRoot":"","sources":["../../src/dashboard/hd2d-assets.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAMjF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAahD,eAAO,MAAM,cAAc,QAA+D,CAAC;AAG3F,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AACrE,MAAM,WAAW,UAAU;IAAG,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AAMjG;gEACgE;AAChE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEzD;AAOD,wBAAgB,UAAU,IAAI,UAAU,CAKvC;AAiCD;iEACiE;AACjE,wBAAgB,iBAAiB,IAAI,UAAU,CAiB9C"}
|