remote-codex 0.11.53 → 0.11.54

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.
@@ -3713,6 +3713,8 @@ var HostedSandboxService = class {
3713
3713
  var RELAY_REQUEST_TIMEOUT_MS = 3e4;
3714
3714
  var RELAY_PORTAL_METADATA_TIMEOUT_MS = 900;
3715
3715
  var WEBSOCKET_OPEN = 1;
3716
+ var SUPERVISOR_REPLACED_CLOSE_CODE = 1012;
3717
+ var SUPERVISOR_REPLACED_CLOSE_REASON = "Supervisor connection replaced.";
3716
3718
  var hostedBootstrapPromises = /* @__PURE__ */ new Map();
3717
3719
  var RELAY_COOKIE_NAME = "remote_codex_relay_session";
3718
3720
  var threadAccessSchema = z.enum(["read", "control"]);
@@ -4654,16 +4656,13 @@ function buildRelayServer(config2, options = {}) {
4654
4656
  }
4655
4657
  const connectedAt = (/* @__PURE__ */ new Date()).toISOString();
4656
4658
  const existing = state.supervisors.get(deviceId);
4657
- existing?.socket.send(
4658
- JSON.stringify({
4659
- type: "relay.connected",
4660
- timestamp: connectedAt,
4661
- deviceId
4662
- })
4663
- );
4664
4659
  existing?.clientSockets.forEach(
4665
4660
  (clientConnection) => clientConnection.socket.close()
4666
4661
  );
4662
+ existing?.socket.close(
4663
+ SUPERVISOR_REPLACED_CLOSE_CODE,
4664
+ SUPERVISOR_REPLACED_CLOSE_REASON
4665
+ );
4667
4666
  const connection = {
4668
4667
  deviceId,
4669
4668
  socket,
@@ -37994,6 +37994,7 @@ var RelayTunnelClient = class {
37994
37994
  }
37995
37995
  }, RELAY_CONNECT_TIMEOUT_MS);
37996
37996
  socket.addEventListener("open", () => {
37997
+ console.log(`Relay tunnel connected to ${url2.origin}.`);
37997
37998
  this.clearConnectTimeout();
37998
37999
  this.reconnectDelayMs = RELAY_RECONNECT_INITIAL_DELAY_MS;
37999
38000
  this.sendHeartbeat();
@@ -38003,10 +38004,23 @@ var RelayTunnelClient = class {
38003
38004
  this.sendHeartbeat();
38004
38005
  }, RELAY_HEARTBEAT_INTERVAL_MS);
38005
38006
  });
38006
- socket.addEventListener("close", () => {
38007
+ socket.addEventListener("close", (event) => {
38008
+ if (this.stopped || this.socket !== socket) {
38009
+ return;
38010
+ }
38011
+ const closeEvent = event;
38012
+ const reason = closeEvent?.reason?.trim() || "no reason provided";
38013
+ const code = closeEvent?.code ?? "unknown";
38014
+ console.error(
38015
+ `Relay tunnel closed (code ${code}: ${reason}); reconnecting.`
38016
+ );
38007
38017
  this.closeAndReconnect(socket);
38008
38018
  });
38009
38019
  socket.addEventListener("error", () => {
38020
+ if (this.stopped || this.socket !== socket) {
38021
+ return;
38022
+ }
38023
+ console.error("Relay tunnel websocket error; reconnecting.");
38010
38024
  this.closeAndReconnect(socket);
38011
38025
  });
38012
38026
  socket.addEventListener("message", (event) => {
@@ -38162,6 +38176,7 @@ var RelayTunnelClient = class {
38162
38176
  this.reconnectHandle = null;
38163
38177
  this.start();
38164
38178
  }, delayMs);
38179
+ console.error(`Relay tunnel reconnect scheduled in ${delayMs} ms.`);
38165
38180
  }
38166
38181
  clearReconnect() {
38167
38182
  if (this.reconnectHandle) {
@@ -685,6 +685,8 @@ async function startRelaySupervisorTmux() {
685
685
  return;
686
686
  }
687
687
 
688
+ fs.mkdirSync(path.dirname(relaySupervisorLogPath), { recursive: true });
689
+ rotateRelaySupervisorLog();
688
690
  const command = relaySupervisorTmuxCommand();
689
691
  const result = spawnSync('tmux', ['new-session', '-d', '-s', relaySupervisorTmuxSession, command], {
690
692
  cwd: packageRoot,
@@ -721,7 +723,7 @@ function relaySupervisorTmuxCommand() {
721
723
  const envPrefix = nonEmptyEnv('REMOTE_CODEX_RELAY_SUPERVISOR_CONFIG')
722
724
  ? `REMOTE_CODEX_RELAY_SUPERVISOR_CONFIG=${shellQuote(process.env.REMOTE_CODEX_RELAY_SUPERVISOR_CONFIG)}`
723
725
  : '';
724
- const command = `${shellQuote(process.execPath)} ${shellQuote(fileURLToPath(import.meta.url))} relay-supervisor run`;
726
+ const command = `${shellQuote(process.execPath)} ${shellQuote(fileURLToPath(import.meta.url))} relay-supervisor run 2>&1 | tee -a ${shellQuote(relaySupervisorLogPath)}`;
725
727
  return envPrefix ? `${envPrefix} ${command}` : command;
726
728
  }
727
729
 
@@ -776,6 +778,7 @@ function stopRelaySupervisorTmux() {
776
778
 
777
779
  function printRelaySupervisorTmuxCommands() {
778
780
  console.log(`Attach logs: tmux attach -t ${shellQuote(relaySupervisorTmuxSession)}`);
781
+ console.log(`Persistent logs: ${relaySupervisorLogPath}`);
779
782
  console.log('Status: remote-codex relay-supervisor status');
780
783
  console.log('Stop: remote-codex relay-supervisor stop');
781
784
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remote-codex",
3
- "version": "0.11.53",
3
+ "version": "0.11.54",
4
4
  "description": "Local web supervisor for Codex workspaces and threads.",
5
5
  "license": "MIT",
6
6
  "type": "module",