episoda 0.2.76 → 0.2.77

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.
@@ -2116,6 +2116,7 @@ var require_websocket_client = __commonJS({
2116
2116
  * @param token - OAuth access token
2117
2117
  * @param machineId - Optional machine identifier for multi-machine support
2118
2118
  * @param deviceInfo - Optional device information (hostname, OS, daemonPid)
2119
+ * EP1119: Added environment and containerId for cloud routing
2119
2120
  */
2120
2121
  async connect(url, token, machineId, deviceInfo) {
2121
2122
  this.url = url;
@@ -2125,6 +2126,8 @@ var require_websocket_client = __commonJS({
2125
2126
  this.osPlatform = deviceInfo?.osPlatform;
2126
2127
  this.osArch = deviceInfo?.osArch;
2127
2128
  this.daemonPid = deviceInfo?.daemonPid;
2129
+ this.environment = deviceInfo?.environment;
2130
+ this.containerId = deviceInfo?.containerId;
2128
2131
  this.isDisconnecting = false;
2129
2132
  this.isGracefulShutdown = false;
2130
2133
  this.isIntentionalDisconnect = false;
@@ -2162,7 +2165,9 @@ var require_websocket_client = __commonJS({
2162
2165
  type: "auth",
2163
2166
  token,
2164
2167
  version: version_1.VERSION,
2168
+ environment: this.environment,
2165
2169
  machineId,
2170
+ containerId: this.containerId,
2166
2171
  hostname: this.hostname,
2167
2172
  osPlatform: this.osPlatform,
2168
2173
  osArch: this.osArch,
@@ -2463,7 +2468,9 @@ var require_websocket_client = __commonJS({
2463
2468
  hostname: this.hostname,
2464
2469
  osPlatform: this.osPlatform,
2465
2470
  osArch: this.osArch,
2466
- daemonPid: this.daemonPid
2471
+ daemonPid: this.daemonPid,
2472
+ environment: this.environment,
2473
+ containerId: this.containerId
2467
2474
  }).then(() => {
2468
2475
  console.log("[EpisodaClient] Reconnection successful");
2469
2476
  this.reconnectAttempts = 0;
@@ -2741,7 +2748,7 @@ var require_package = __commonJS({
2741
2748
  "package.json"(exports2, module2) {
2742
2749
  module2.exports = {
2743
2750
  name: "episoda",
2744
- version: "0.2.76",
2751
+ version: "0.2.77",
2745
2752
  description: "CLI tool for Episoda local development workflow orchestration",
2746
2753
  main: "dist/index.js",
2747
2754
  types: "dist/index.d.ts",
@@ -6402,13 +6409,19 @@ var PreviewManager = class extends import_events3.EventEmitter {
6402
6409
  *
6403
6410
  * Must be called before starting any previews.
6404
6411
  * Initializes the tunnel manager (ensures cloudflared, cleans orphans).
6412
+ * EP1119: Skips tunnel initialization in cloud mode - supervisord manages cloudflared there.
6405
6413
  */
6406
6414
  async initialize() {
6407
6415
  if (this.initialized) {
6408
6416
  return;
6409
6417
  }
6410
6418
  console.log("[PreviewManager] Initializing...");
6411
- await this.tunnel.initialize();
6419
+ const modeConfig = getDaemonModeConfig();
6420
+ if (modeConfig.mode === "cloud") {
6421
+ console.log("[PreviewManager] EP1119: Skipping TunnelManager init in cloud mode");
6422
+ } else {
6423
+ await this.tunnel.initialize();
6424
+ }
6412
6425
  this.initialized = true;
6413
6426
  console.log("[PreviewManager] Initialized");
6414
6427
  }
@@ -6425,7 +6438,7 @@ var PreviewManager = class extends import_events3.EventEmitter {
6425
6438
  * @returns Result with success status and preview URL
6426
6439
  */
6427
6440
  async startPreview(config) {
6428
- const { moduleUid, worktreePath, port = DEFAULT_PORT, customCommand } = config;
6441
+ const { moduleUid, worktreePath, port = DEFAULT_PORT, customCommand, skipTunnel } = config;
6429
6442
  if (!worktreePath) {
6430
6443
  return { success: false, error: "Worktree path is required" };
6431
6444
  }
@@ -6489,6 +6502,17 @@ var PreviewManager = class extends import_events3.EventEmitter {
6489
6502
  state.state = "running";
6490
6503
  this.emitStateChange(moduleUid, "running");
6491
6504
  console.log(`[PreviewManager] Dev server running on port ${port}`);
6505
+ if (skipTunnel) {
6506
+ console.log(`[PreviewManager] EP1119: Skipping tunnel management for ${moduleUid} (cloud mode)`);
6507
+ state.state = "live";
6508
+ this.emitStateChange(moduleUid, "live");
6509
+ this.startingModules.delete(moduleUid);
6510
+ return {
6511
+ success: true,
6512
+ previewUrl: void 0
6513
+ // URL comes from Cloudflare Named Tunnel, not local
6514
+ };
6515
+ }
6492
6516
  console.log(`[PreviewManager] Starting Named Tunnel for ${moduleUid}...`);
6493
6517
  state.state = "tunneling";
6494
6518
  this.emitStateChange(moduleUid, "tunneling");
@@ -8640,7 +8664,9 @@ var Daemon = class _Daemon {
8640
8664
  moduleUid: cmd.moduleUid,
8641
8665
  worktreePath: worktree.path,
8642
8666
  port,
8643
- customCommand
8667
+ customCommand,
8668
+ skipTunnel: modeConfig.mode === "cloud"
8669
+ // EP1119: Cloud mode - supervisord handles cloudflared
8644
8670
  });
8645
8671
  if (startResult.success) {
8646
8672
  console.log(`[Daemon] EP1024: Preview started for ${cmd.moduleUid}: ${startResult.previewUrl}`);
@@ -9017,11 +9043,16 @@ var Daemon = class _Daemon {
9017
9043
  };
9018
9044
  client.once("auth_error", errorHandler);
9019
9045
  });
9046
+ const modeConfig = getDaemonModeConfig();
9047
+ const environment = modeConfig.mode;
9048
+ const containerId = process.env.EPISODA_CONTAINER_ID;
9020
9049
  await client.connect(wsUrl, config.access_token, this.machineId, {
9021
9050
  hostname: os8.hostname(),
9022
9051
  osPlatform: os8.platform(),
9023
9052
  osArch: os8.arch(),
9024
- daemonPid
9053
+ daemonPid,
9054
+ environment,
9055
+ containerId
9025
9056
  });
9026
9057
  console.log(`[Daemon] Successfully connected to project ${projectId}`);
9027
9058
  await authSuccessPromise;