comfyui-mcp
Version:
Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline),
67 lines • 3.36 kB
JavaScript
/**
* #1963 — auto-update is conditional on how the user is currently connected.
*
* A restart severs a cloudflared quick-tunnel with certainty (the hostname
* rotates per run). A restart does not sever a LAN session with a stable pair
* token, and a relay URL is stable too. That is a property of the transport,
* not a guess about intent, so the gate is exact:
*
* applyUpdate = updateAvailable && !(activeTransport === "quick-tunnel" && pairingActive)
*
* Checking is always allowed (a few KB, safe on a metered link). Applying —
* writing the new package and restarting — is what must be gated.
*
* pairingActive is STICKY: it is "a tunnel was opened for this process and has
* not been torn down", not "a socket is open right now". A backgrounded phone
* has no live socket (#1961 / #1176); keying the gate on the socket is how a
* locked screen and a 5G/wifi handoff used to rotate the hostname anyway.
*
* The pair-time toggle `deferWhilePaired` (default ON) is the user-facing
* override: turning it off, or sending apply_updates_now, lets an update
* through even while the tunnel is up.
*/
/** Pair-time checkbox copy. English, and the identifier the panel renders. */
export const DEFER_WHILE_PAIRED_TOGGLE_LABEL = "Don't update while my phone is paired — updating restarts the orchestrator, which changes your tunnel address and disconnects this device.";
/**
* May we APPLY (disk mutate + restart) this update?
*
* Check is not this function's job and is always allowed. `updateAvailable` is
* the caller's: this answers only the transport half of the formula.
*/
export function autoUpdateApplyAllowed(input) {
if (input.deferWhilePaired === false)
return true;
return !(input.activeTransport === "quick-tunnel" && input.pairingActive);
}
/**
* pairingActive from the pairing tunnel handle. STICKY on purpose: the handle
* exists from the moment the URL is minted until process exit (nothing stops
* the tunnel earlier). A live-socket test is exactly the hole a pocketed phone
* falls through.
*/
export function pairingActiveOf(pairTunnel) {
return pairTunnel != null;
}
/** Phone pairing's tunnel is always a quick tunnel today (startQuickTunnel). */
export function pairingTransportOf(pairTunnel) {
return pairTunnel != null ? "quick-tunnel" : undefined;
}
/** What the pair_url frame carries so the panel can paint the toggle. */
export function pairAutoUpdateDisclosure(input) {
const deferWhilePaired = input.deferWhilePaired !== false;
return {
check: true,
apply: autoUpdateApplyAllowed({ ...input, deferWhilePaired }),
defer_while_paired: deferWhilePaired,
toggle_default_on: true,
toggle_label: DEFER_WHILE_PAIRED_TOGGLE_LABEL,
};
}
export function deferredAutoUpdateNote(opts) {
const who = opts.component === "panel" ? "ComfyUI-MCP panel" : "comfyui-mcp";
const versions = opts.from && opts.to ? ` ${opts.from} → ${opts.to}` : opts.to ? ` ${opts.to}` : "";
return (`⬆️ ${who}${versions} is available but not applied — a phone is paired over a mobile ` +
`tunnel, and applying would change the tunnel address and disconnect it. Update from ` +
`the desk, turn off “Don't update while my phone is paired”, or choose Update now.`);
}
//# sourceMappingURL=auto-update-gate.js.map