comfyui-mcp 0.50.33 → 0.50.35

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.
@@ -26,6 +26,7 @@ import { panelRecoveryContext } from "../services/panel-recovery.js";
26
26
  import { isPanelAutoInstallDisabled } from "../services/panel-installer.js";
27
27
  import { SelfRestarter, canSelfRestart } from "../services/self-restart.js";
28
28
  import { pairUrlDurability } from "./pair-durability.js";
29
+ import { loadOrCreatePairToken } from "./pair-token-store.js";
29
30
  import { SessionStore, workflowIdentityParts } from "./session-store.js";
30
31
  import { unreachableReason, noPanelTabReason, identityReason } from "./fence-refusal.js";
31
32
  import { SHARED_SESSION_SCOPE, isScopeAddress, conversationTabs, shouldRetireSharedAgent, messageOrigin, normalizeHelloBackend, workflowOriginNote, } from "../services/session-scope.js";
@@ -912,9 +913,32 @@ export async function runPanelOrchestrator() {
912
913
  let pairToken = envPairToken;
913
914
  let pairListenerStarted = false;
914
915
  let pairTunnel = null;
916
+ /**
917
+ * #875 — is a phone paired over a TUNNEL right now?
918
+ *
919
+ * Gates the self-restarter (see its allIdle below). A tunnel URL cannot survive
920
+ * a restart: cloudflared mints a fresh quick-tunnel hostname per run and there
921
+ * is no way to pin it, so restarting under a live tunnel breaks a phone that is
922
+ * connected at that moment. A LAN URL is fine — the token persists now — which
923
+ * is why this is narrowed to the tunnel rather than to pairing in general.
924
+ */
925
+ // Requires BOTH: a tunnel exists AND a client is connected through it right
926
+ // now. `pairTunnel` alone is not liveness — nothing stops the tunnel until the
927
+ // process exits, so gating on it would postpone every future update after a
928
+ // single pairing, rather than deferring to the next disconnect as intended.
929
+ const tunnelPairingLive = () => pairTunnel !== null && bridge.hasLiveHeadlessClient();
930
+ // #875 — the token is PERSISTED, not per-session. It used to be minted fresh on
931
+ // every run, so a self-restart (on by default, hourly npm check) invalidated the
932
+ // URL the phone had saved. The reporter experienced that as "updating the npm
933
+ // version bricks my communication with the agent" and asked to pin the version;
934
+ // the version was never the cause. An explicit COMFYUI_MCP_PAIR_TOKEN still wins.
935
+ let pairTokenPersisted = envPairToken !== null;
915
936
  const ensurePairListener = async () => {
916
- if (!pairToken)
917
- pairToken = randomBytes(24).toString("hex");
937
+ if (!pairToken) {
938
+ const loaded = loadOrCreatePairToken();
939
+ pairToken = loaded.token;
940
+ pairTokenPersisted = loaded.persisted;
941
+ }
918
942
  if (!pairListenerStarted) {
919
943
  await bridge.addListener("0.0.0.0", pairPort, pairToken);
920
944
  pairListenerStarted = true;
@@ -3966,7 +3990,7 @@ export async function runPanelOrchestrator() {
3966
3990
  // cause, and nothing here had told them.
3967
3991
  const durability = pairUrlDurability({
3968
3992
  mode,
3969
- pinnedToken: envPairToken !== null,
3993
+ stableToken: envPairToken !== null || pairTokenPersisted,
3970
3994
  autoRestart: canSelfRestart(),
3971
3995
  });
3972
3996
  logger.info(`[panel-orchestrator] pairing URL minted (${mode}) — ` +
@@ -5545,7 +5569,20 @@ export async function runPanelOrchestrator() {
5545
5569
  // …and the same for an ask answer the user actually gave that has not
5546
5570
  // reached the agent yet (#486). Restarting would destroy it silently.
5547
5571
  !AskAnswers.hasOutstanding() &&
5548
- !QueueMonitor.isBusy(),
5572
+ !QueueMonitor.isBusy() &&
5573
+ // #875 — a LIVE TUNNEL PAIRING SESSION defers the restart to the next
5574
+ // disconnect. The token now persists, so a LAN URL survives a restart; a
5575
+ // tunnel URL cannot, because cloudflared mints a fresh quick-tunnel
5576
+ // hostname every run and there is no way to pin it. Restarting under a live
5577
+ // tunnel therefore breaks a phone that is connected RIGHT NOW, to install
5578
+ // an update nobody asked for at that moment — which is what the reporter
5579
+ // experienced and (reasonably) blamed on the npm version.
5580
+ //
5581
+ // Deferral, not cancellation: the update check still runs and the restart
5582
+ // stays armed, so it fires as soon as the tunnel goes away. The cost is
5583
+ // that a tunnel left up indefinitely postpones updates indefinitely, which
5584
+ // is why noteTunnelDeferral announces it rather than doing it silently.
5585
+ !tunnelPairingLive(),
5549
5586
  announce: (text) => void bridge.push({ type: "say", text }),
5550
5587
  teardown: teardownCore,
5551
5588
  });