@nice-code/commander 0.91.0 → 0.92.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 +11 -0
- package/build/cli.cjs +47 -6
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +47 -7
- package/build/cli.mjs.map +1 -1
- package/build/client/assets/index-CNwEukpv.js +23 -0
- package/build/client/assets/index-CNwEukpv.js.map +1 -0
- package/build/client/index.html +1 -1
- package/build/{main-Cf9OmhIY.cjs → main-B_0GjEIc.cjs} +3 -1
- package/build/main-B_0GjEIc.cjs.map +1 -0
- package/build/{main-O9jpzqPH.mjs → main-Gp2uG70g.mjs} +4 -2
- package/build/{main-O9jpzqPH.mjs.map → main-Gp2uG70g.mjs.map} +1 -1
- package/package.json +6 -6
- package/build/client/assets/index-Caho-x2i.js +0 -23
- package/build/client/assets/index-Caho-x2i.js.map +0 -1
- package/build/main-Cf9OmhIY.cjs.map +0 -1
package/build/cli.mjs
CHANGED
|
@@ -9218,6 +9218,8 @@ var AcceptorSecureSession = class {
|
|
|
9218
9218
|
_pipe;
|
|
9219
9219
|
_authed = false;
|
|
9220
9220
|
_plain = false;
|
|
9221
|
+
_handshakeStarted = false;
|
|
9222
|
+
_handshakeFailed = false;
|
|
9221
9223
|
/** The channel tags the client advertised in its `hello`, captured for the handler's codec selection. */
|
|
9222
9224
|
_helloChannels;
|
|
9223
9225
|
/** Serializes inbound processing (handshake + decryption are async). */
|
|
@@ -9231,7 +9233,19 @@ var AcceptorSecureSession = class {
|
|
|
9231
9233
|
* acceptor and carried through here because only the decrypted frame reveals its lane.
|
|
9232
9234
|
*/
|
|
9233
9235
|
receive(frame, wireBytes) {
|
|
9234
|
-
this._inboundChain = this._inboundChain.then(() =>
|
|
9236
|
+
this._inboundChain = this._inboundChain.then(() => {
|
|
9237
|
+
if (!this._handshakeFailed) return this._receive(frame, wireBytes);
|
|
9238
|
+
}).catch((err) => {
|
|
9239
|
+
console.error("[ws-server] failed to process inbound frame", err);
|
|
9240
|
+
if (!this._handshakeStarted || this._authed || this._handshakeFailed) return;
|
|
9241
|
+
this._handshakeFailed = true;
|
|
9242
|
+
try {
|
|
9243
|
+
this.config.send(encodeHandshakeMessage({
|
|
9244
|
+
t: "reject",
|
|
9245
|
+
reason: "server handshake failed; check server logs"
|
|
9246
|
+
}));
|
|
9247
|
+
} catch {}
|
|
9248
|
+
});
|
|
9235
9249
|
}
|
|
9236
9250
|
async _receive(frame, wireBytes) {
|
|
9237
9251
|
if (this._plain) {
|
|
@@ -9252,6 +9266,7 @@ var AcceptorSecureSession = class {
|
|
|
9252
9266
|
bytes: wireBytes ?? 0,
|
|
9253
9267
|
lane: "handshake"
|
|
9254
9268
|
});
|
|
9269
|
+
this._handshakeStarted = true;
|
|
9255
9270
|
await this.config.link.initialize();
|
|
9256
9271
|
if (this._handshake == null) this._handshake = createServerHandshake({
|
|
9257
9272
|
link: this.config.link,
|
|
@@ -23334,6 +23349,13 @@ async function commanderPackageVersion() {
|
|
|
23334
23349
|
return cached;
|
|
23335
23350
|
}
|
|
23336
23351
|
//#endregion
|
|
23352
|
+
//#region src/daemon/runtime.ts
|
|
23353
|
+
/** Check before advertising a daemon whose HTTP works but whose wire handshake cannot run. */
|
|
23354
|
+
function commanderRuntimeError() {
|
|
23355
|
+
const runtime = process.versions.bun == null ? `Node ${process.version}` : `Bun ${process.versions.bun}`;
|
|
23356
|
+
if (process.versions.bun == null && Number(process.versions.node.split(".")[0]) < 22 || globalThis.crypto?.subtle == null || typeof globalThis.WebSocket !== "function") return `nice-commander requires Node >=22 or a current Bun with Web Crypto and WebSocket support; running ${runtime} (${process.execPath}). Upgrade Node, or run \`bunx --bun nice-commander\`. Plain \`bunx\` follows the binary's node shebang. If a daemon is already running, run \`nice-commander shutdown\` before retrying; shutdown stops its managed processes.`;
|
|
23357
|
+
}
|
|
23358
|
+
//#endregion
|
|
23337
23359
|
//#region src/protocol/statusRealm.ts
|
|
23338
23360
|
/**
|
|
23339
23361
|
* Read-only viewer for every authenticated identity — control authority lives in the ticket
|
|
@@ -23567,6 +23589,8 @@ async function replaceSkewedDaemon(paths, skewed) {
|
|
|
23567
23589
|
}
|
|
23568
23590
|
}
|
|
23569
23591
|
async function ensureDaemon(options) {
|
|
23592
|
+
const runtimeError = commanderRuntimeError();
|
|
23593
|
+
if (runtimeError != null) throw new Error(runtimeError);
|
|
23570
23594
|
const dataDir = options.dataDir != null ? resolve(options.dataDir) : resolveCommanderDataDir();
|
|
23571
23595
|
const paths = commanderStatePaths(dataDir, options.config.configKey);
|
|
23572
23596
|
const timeoutMs = options.handshakeTimeoutMs ?? HANDSHAKE_TIMEOUT_MS;
|
|
@@ -23841,6 +23865,20 @@ const commanderChannel = defineChannel({
|
|
|
23841
23865
|
toConnector: []
|
|
23842
23866
|
});
|
|
23843
23867
|
//#endregion
|
|
23868
|
+
//#region src/protocol/waitForStatusRealm.ts
|
|
23869
|
+
/** Retain cold-start retries, but report a failed dial instead of hiding it behind hydration. */
|
|
23870
|
+
async function waitForStatusRealm(connector, realm, timeoutMs) {
|
|
23871
|
+
let connectionError;
|
|
23872
|
+
connector.connect().catch((error) => {
|
|
23873
|
+
connectionError = error;
|
|
23874
|
+
});
|
|
23875
|
+
try {
|
|
23876
|
+
await realm.whenLive({ timeoutMs });
|
|
23877
|
+
} catch (error) {
|
|
23878
|
+
throw realm.attachError ?? connectionError ?? error;
|
|
23879
|
+
}
|
|
23880
|
+
}
|
|
23881
|
+
//#endregion
|
|
23844
23882
|
//#region src/cli/daemonClient.ts
|
|
23845
23883
|
/** The running daemon for this config, or null (dead record, failed ping, nothing on disk). */
|
|
23846
23884
|
async function findDaemon(config) {
|
|
@@ -23907,6 +23945,8 @@ async function mintTicket(record) {
|
|
|
23907
23945
|
return body.ticket;
|
|
23908
23946
|
}
|
|
23909
23947
|
async function connectDaemon(handle) {
|
|
23948
|
+
const runtimeError = commanderRuntimeError();
|
|
23949
|
+
if (runtimeError != null) throw new CliExit(EXIT.failure, runtimeError);
|
|
23910
23950
|
const { record } = handle;
|
|
23911
23951
|
if (record.realmSchemaHash !== commanderStatusRealm.schemaHash) throw new CliExit(EXIT.failure, `the daemon for this config (pid ${record.pid}, build ${record.packageVersion}) was started before an upgrade changed the status schema — this CLI (build ${await commanderPackageVersion()}) cannot read its state. Run \`nice-commander shutdown\` (it stops a daemon from any build), then retry.`);
|
|
23912
23952
|
const ticket = await mintTicket(record);
|
|
@@ -23940,12 +23980,12 @@ async function connectDaemon(handle) {
|
|
|
23940
23980
|
connection: realmConnection(connector),
|
|
23941
23981
|
assertOnAttach: () => {}
|
|
23942
23982
|
});
|
|
23943
|
-
connector.connect().catch(() => {});
|
|
23944
23983
|
try {
|
|
23945
|
-
await
|
|
23946
|
-
} catch {
|
|
23984
|
+
await waitForStatusRealm(connector, realm, 1e4);
|
|
23985
|
+
} catch (error) {
|
|
23986
|
+
realm.detach();
|
|
23947
23987
|
connector.dispose();
|
|
23948
|
-
const reason =
|
|
23988
|
+
const reason = String(error);
|
|
23949
23989
|
const hint = reason.includes("schema_mismatch") ? ` The daemon (pid ${record.pid}, build ${record.packageVersion}) and this CLI were built from different realm definitions — run \`nice-commander shutdown\` (it stops a daemon from any build), then retry.` : "";
|
|
23950
23990
|
throw new CliExit(EXIT.failure, `could not attach the status realm (${reason}).${hint}`);
|
|
23951
23991
|
}
|
|
@@ -25527,7 +25567,7 @@ async function withTimeout(ctx, run) {
|
|
|
25527
25567
|
async function main() {
|
|
25528
25568
|
const argv = process.argv.slice(2);
|
|
25529
25569
|
if (argv[0] === "daemon") {
|
|
25530
|
-
const { runCommanderDaemon } = await import("./main-
|
|
25570
|
+
const { runCommanderDaemon } = await import("./main-Gp2uG70g.mjs");
|
|
25531
25571
|
return runCommanderDaemon(argv.slice(1));
|
|
25532
25572
|
}
|
|
25533
25573
|
const parsed = parseCliArgs(argv);
|
|
@@ -25571,6 +25611,6 @@ main().then((code) => {
|
|
|
25571
25611
|
process.exitCode = EXIT.failure;
|
|
25572
25612
|
});
|
|
25573
25613
|
//#endregion
|
|
25574
|
-
export {
|
|
25614
|
+
export { envVarViews as A, serveChannel as C, createMemoryStorageAdapter_json as D, RuntimeCoordinate as E, readInstanceRecord as F, recordDaemonAlive as I, removeInstanceRecord as L, loadCommanderConfigFile as M, orderByDependency as N, validateCommanderConfig as O, withDependencies as P, writeInstanceRecord as R, wsAcceptorCarrier as S, ActionRuntime as T, ensureStateDir as _, commanderChannel as a, createRealmServerEngine as b, COMMANDER_HEALTH_PATH as c, COMMANDER_TICKET_PROTOCOL_PREFIX as d, COMMANDER_WS_PATH as f, commanderStatePaths as g, commanderPackageVersion as h, readEnvOverrides as i, overrideFingerprint as j, effectiveEnv as k, COMMANDER_LOGS_PATH as l, commanderRuntimeError as m, applyEnvMutation as n, commanderControlDomain as o, commanderStatusRealm as p, countOverrides as r, COMMANDER_BOOTSTRAP_PATH as s, parseLogsClientMessage as t, COMMANDER_TICKET_PATH as u, resolveCommanderDataDir as v, createDefaultServeLogger as w, httpAcceptorCarrier as x, createRealmAcceptor as y };
|
|
25575
25615
|
|
|
25576
25616
|
//# sourceMappingURL=cli.mjs.map
|