@mu-cabin/muc-cli 0.5.1 → 0.5.2
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/muc.mjs +19 -15
- package/package.json +1 -1
package/dist/muc.mjs
CHANGED
|
@@ -22241,10 +22241,9 @@ async function request(opts) {
|
|
|
22241
22241
|
recovered = true;
|
|
22242
22242
|
} catch (refreshErr) {
|
|
22243
22243
|
if (!(refreshErr instanceof CliError) || cred.rememberedPwd == null) throw refreshErr;
|
|
22244
|
-
if (isAssistantProfile()) throw refreshErr;
|
|
22245
22244
|
}
|
|
22246
22245
|
}
|
|
22247
|
-
if (!recovered && cred.rememberedPwd
|
|
22246
|
+
if (!recovered && cred.rememberedPwd) {
|
|
22248
22247
|
try {
|
|
22249
22248
|
await refreshViaRememberedPwd();
|
|
22250
22249
|
recovered = true;
|
|
@@ -22343,9 +22342,6 @@ async function doRefreshViaRememberedPwd() {
|
|
|
22343
22342
|
throw new CliError(
|
|
22344
22343
|
"AUTH_EXPIRED",
|
|
22345
22344
|
`rememberedPwd refresh rejected: code=${res.code} msg=${res.msg ?? ""}`.trim(),
|
|
22346
|
-
// This arm is gated off on the assistant profile (see request()'s
|
|
22347
|
-
// cascade), so in practice loginCmd() always returns `muc login`
|
|
22348
|
-
// here. Templated anyway for consistency + future-proofing.
|
|
22349
22345
|
`rerun \`${loginCmd()} --account <UID>\` interactively to mint fresh credentials`
|
|
22350
22346
|
);
|
|
22351
22347
|
}
|
|
@@ -22522,13 +22518,6 @@ function register(program3, variant) {
|
|
|
22522
22518
|
"rerun without --token-pwd, or pass --account + (--password-stdin or interactive prompt)"
|
|
22523
22519
|
);
|
|
22524
22520
|
}
|
|
22525
|
-
if (isAssistant && opts.remember === true) {
|
|
22526
|
-
throw new CliError(
|
|
22527
|
-
"USAGE",
|
|
22528
|
-
"--remember is not supported on the assistant profile",
|
|
22529
|
-
"the assistant daemon's refresh cascade stops at Step 2 by design (see http.ts); drop --remember (and run with --no-remember to wipe any pre-existing blob)"
|
|
22530
|
-
);
|
|
22531
|
-
}
|
|
22532
22521
|
const existing = loadCredentials();
|
|
22533
22522
|
const accountRaw = opts.account ?? process.env.MUC_ACCOUNT ?? existing?.uid;
|
|
22534
22523
|
if (!accountRaw) {
|
|
@@ -23163,6 +23152,7 @@ var Output3 = external_exports.object({
|
|
|
23163
23152
|
tokenPwdSet: external_exports.boolean(),
|
|
23164
23153
|
tokenPwdExpireAt: external_exports.number().optional(),
|
|
23165
23154
|
tokenPwdExpiresIn: external_exports.string().optional(),
|
|
23155
|
+
remembered: external_exports.boolean(),
|
|
23166
23156
|
savedAt: external_exports.number(),
|
|
23167
23157
|
credentialsPath: external_exports.string()
|
|
23168
23158
|
});
|
|
@@ -23216,6 +23206,7 @@ function register3(program3) {
|
|
|
23216
23206
|
tokenPwdSet: Boolean(c.tokenPwd),
|
|
23217
23207
|
tokenPwdExpireAt: c.tokenPwdExpireAt,
|
|
23218
23208
|
tokenPwdExpiresIn: relativeFromNow(c.tokenPwdExpireAt),
|
|
23209
|
+
remembered: Boolean(c.rememberedPwd),
|
|
23219
23210
|
savedAt: c.savedAt,
|
|
23220
23211
|
credentialsPath: credentialsPath()
|
|
23221
23212
|
};
|
|
@@ -24016,9 +24007,13 @@ async function openChatSession(cred, opts = {}) {
|
|
|
24016
24007
|
} catch (refreshErr) {
|
|
24017
24008
|
const msg = String(refreshErr?.message ?? refreshErr);
|
|
24018
24009
|
if (msg.includes("61018") || /tokenPwd|自动登陆/.test(msg)) {
|
|
24010
|
+
if (cred.rememberedPwd) {
|
|
24011
|
+
const rememberedFresh = await refreshViaRememberedPwd();
|
|
24012
|
+
return await tryChatLogin(rememberedFresh, opts, cfg);
|
|
24013
|
+
}
|
|
24019
24014
|
const lc = isAssistantProfile() ? "muc assistant-login" : "muc login";
|
|
24020
24015
|
throw new Error(
|
|
24021
|
-
`chat login failed: access token expired AND saved tokenPwd is no longer valid (server returned 61018). Run \`${lc}\` with your password to mint fresh credentials, then retry.`
|
|
24016
|
+
`chat login failed: access token expired AND saved tokenPwd is no longer valid (server returned 61018). Run \`${lc}\` with your password (add --remember to allow unattended daemon recovery) to mint fresh credentials, then retry.`
|
|
24022
24017
|
);
|
|
24023
24018
|
}
|
|
24024
24019
|
throw refreshErr;
|
|
@@ -28339,6 +28334,10 @@ function formatDuration(ms) {
|
|
|
28339
28334
|
}
|
|
28340
28335
|
|
|
28341
28336
|
// src/daemon/broker.ts
|
|
28337
|
+
function credentialsForReconnect(current, onDisk) {
|
|
28338
|
+
if (!onDisk || onDisk.uid !== current.uid) return current;
|
|
28339
|
+
return onDisk.savedAt >= current.savedAt ? onDisk : current;
|
|
28340
|
+
}
|
|
28342
28341
|
var ChatBroker = class {
|
|
28343
28342
|
kind;
|
|
28344
28343
|
paths;
|
|
@@ -28541,6 +28540,7 @@ var ChatBroker = class {
|
|
|
28541
28540
|
return true;
|
|
28542
28541
|
}
|
|
28543
28542
|
async openSocket() {
|
|
28543
|
+
this.cred = credentialsForReconnect(this.cred, loadCredentials());
|
|
28544
28544
|
const session = await openChatSession(this.cred, { os: this.os, debug: this.opts.debug });
|
|
28545
28545
|
const reloaded = loadCredentials();
|
|
28546
28546
|
if (reloaded) this.cred = reloaded;
|
|
@@ -33778,10 +33778,10 @@ var AssistantDaemon = class {
|
|
|
33778
33778
|
const loginCmd2 = isAssistantProfile() ? "muc assistant-login" : "muc login";
|
|
33779
33779
|
this.publishState(
|
|
33780
33780
|
"paused_auth",
|
|
33781
|
-
`access token expired and saved tokenPwd is invalid. Run \`${loginCmd2}\` to mint fresh credentials, then restart the daemon.`
|
|
33781
|
+
`access token expired and saved tokenPwd is invalid. Run \`${loginCmd2} --remember\` to mint fresh credentials and enable unattended recovery, then restart the daemon.`
|
|
33782
33782
|
);
|
|
33783
33783
|
this.statusBoard?.onPause("auth", msg);
|
|
33784
|
-
notifyMac("MUC Assistant paused", `auth expired \u2014 run \`${loginCmd2}\`, then restart the daemon`);
|
|
33784
|
+
notifyMac("MUC Assistant paused", `auth expired \u2014 run \`${loginCmd2} --remember\`, then restart the daemon`);
|
|
33785
33785
|
return false;
|
|
33786
33786
|
}
|
|
33787
33787
|
this.reconnectAttempts++;
|
|
@@ -33822,6 +33822,10 @@ var AssistantDaemon = class {
|
|
|
33822
33822
|
}
|
|
33823
33823
|
}
|
|
33824
33824
|
async openSocket() {
|
|
33825
|
+
const onDisk = loadCredentials();
|
|
33826
|
+
if (onDisk?.uid === this.cred.uid && onDisk.savedAt >= this.cred.savedAt) {
|
|
33827
|
+
this.cred = onDisk;
|
|
33828
|
+
}
|
|
33825
33829
|
const session = await openChatSession(this.cred, { os: this.os, debug: this.opts.debug });
|
|
33826
33830
|
const reloaded = loadCredentials();
|
|
33827
33831
|
if (reloaded) this.cred = reloaded;
|