@episoda/cli 0.2.220 → 0.2.222

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/index.js CHANGED
@@ -31,7 +31,8 @@ var require_command_protocol = __commonJS({
31
31
  "../core/dist/command-protocol.js"(exports2) {
32
32
  "use strict";
33
33
  Object.defineProperty(exports2, "__esModule", { value: true });
34
- exports2.WORKTREE_STATUS_VALUES = void 0;
34
+ exports2.WORKTREE_STATUS_VALUES = exports2.DAEMON_PROTOCOL_VERSION = void 0;
35
+ exports2.DAEMON_PROTOCOL_VERSION = 2;
35
36
  exports2.WORKTREE_STATUS_VALUES = [
36
37
  "pending",
37
38
  "provisioning",
@@ -2175,6 +2176,7 @@ var require_websocket_client = __commonJS({
2175
2176
  exports2.EpisodaClient = void 0;
2176
2177
  var ws_1 = __importDefault(require("ws"));
2177
2178
  var https_1 = __importDefault(require("https"));
2179
+ var command_protocol_1 = require_command_protocol();
2178
2180
  var version_1 = require_version();
2179
2181
  var ipv4Agent = new https_1.default.Agent({ family: 4 });
2180
2182
  var MAX_RETRY_DURATION = 6 * 60 * 60 * 1e3;
@@ -2191,6 +2193,7 @@ var require_websocket_client = __commonJS({
2191
2193
  this.autoReconnectEnabled = true;
2192
2194
  this.url = "";
2193
2195
  this.token = "";
2196
+ this.protocolVersion = command_protocol_1.DAEMON_PROTOCOL_VERSION;
2194
2197
  this.isConnected = false;
2195
2198
  this.isDisconnecting = false;
2196
2199
  this.isGracefulShutdown = false;
@@ -2216,11 +2219,15 @@ var require_websocket_client = __commonJS({
2216
2219
  this.osArch = deviceInfo?.osArch;
2217
2220
  this.daemonPid = deviceInfo?.daemonPid;
2218
2221
  this.cliVersion = deviceInfo?.cliVersion;
2222
+ this.protocolVersion = deviceInfo?.protocolVersion ?? command_protocol_1.DAEMON_PROTOCOL_VERSION;
2219
2223
  this.cliPackageName = deviceInfo?.cliPackageName;
2220
2224
  this.capabilities = deviceInfo?.capabilities;
2225
+ this.ptyProviderVersions = deviceInfo?.ptyProviderVersions;
2221
2226
  this.environment = deviceInfo?.environment;
2222
2227
  this.containerId = deviceInfo?.containerId;
2228
+ this.sessionGeneration = void 0;
2223
2229
  this.isDisconnecting = false;
2230
+ this.autoReconnectEnabled = true;
2224
2231
  this.isGracefulShutdown = false;
2225
2232
  this.isIntentionalDisconnect = false;
2226
2233
  this.lastConnectAttemptTime = Date.now();
@@ -2257,8 +2264,10 @@ var require_websocket_client = __commonJS({
2257
2264
  type: "auth",
2258
2265
  token,
2259
2266
  version: this.cliVersion || version_1.VERSION,
2267
+ protocolVersion: this.protocolVersion,
2260
2268
  cliPackageName: this.cliPackageName,
2261
2269
  capabilities: this.capabilities,
2270
+ ptyProviderVersions: this.ptyProviderVersions,
2262
2271
  environment: this.environment,
2263
2272
  machineId,
2264
2273
  containerId: this.containerId,
@@ -2290,6 +2299,7 @@ var require_websocket_client = __commonJS({
2290
2299
  this.ws.on("close", (code, reason) => {
2291
2300
  console.log(`[EpisodaClient] WebSocket closed: ${code} ${reason.toString()}`);
2292
2301
  this.isConnected = false;
2302
+ this.sessionGeneration = void 0;
2293
2303
  const willReconnect = !this.isDisconnecting && this.autoReconnectEnabled;
2294
2304
  this.emit({
2295
2305
  type: "disconnected",
@@ -2351,6 +2361,7 @@ var require_websocket_client = __commonJS({
2351
2361
  this.ws = void 0;
2352
2362
  }
2353
2363
  this.isConnected = false;
2364
+ this.sessionGeneration = void 0;
2354
2365
  }
2355
2366
  /**
2356
2367
  * Register an event handler
@@ -2428,7 +2439,8 @@ var require_websocket_client = __commonJS({
2428
2439
  */
2429
2440
  getStatus() {
2430
2441
  return {
2431
- connected: this.isConnected
2442
+ connected: this.isConnected,
2443
+ sessionGeneration: this.sessionGeneration
2432
2444
  };
2433
2445
  }
2434
2446
  /**
@@ -2470,6 +2482,9 @@ var require_websocket_client = __commonJS({
2470
2482
  * Handle incoming message from server
2471
2483
  */
2472
2484
  handleMessage(message) {
2485
+ if (message.type === "auth_success") {
2486
+ this.sessionGeneration = message.sessionGeneration;
2487
+ }
2473
2488
  if (message.type === "shutdown") {
2474
2489
  console.log("[EpisodaClient] Received graceful shutdown message from server");
2475
2490
  this.isGracefulShutdown = true;
@@ -2487,6 +2502,11 @@ var require_websocket_client = __commonJS({
2487
2502
  this.consecutiveAuthFailures++;
2488
2503
  console.warn(`[EpisodaClient] Auth failure (${this.consecutiveAuthFailures}): ${errorMessage.code}`);
2489
2504
  }
2505
+ if (errorMessage.code === "DAEMON_UPDATE_REQUIRED" || errorMessage.code === "PROTOCOL_MISMATCH") {
2506
+ this.autoReconnectEnabled = false;
2507
+ const errorText = "message" in errorMessage && typeof errorMessage.message === "string" ? errorMessage.message : "Daemon update required";
2508
+ console.error(`[EpisodaClient] ${errorMessage.code}: ${errorText}`);
2509
+ }
2490
2510
  }
2491
2511
  const handlers = this.eventHandlers.get(message.type) || [];
2492
2512
  handlers.forEach((handler) => {
@@ -2616,8 +2636,10 @@ var require_websocket_client = __commonJS({
2616
2636
  osArch: this.osArch,
2617
2637
  daemonPid: this.daemonPid,
2618
2638
  cliVersion: this.cliVersion,
2639
+ protocolVersion: this.protocolVersion,
2619
2640
  cliPackageName: this.cliPackageName,
2620
2641
  capabilities: this.capabilities,
2642
+ ptyProviderVersions: this.ptyProviderVersions,
2621
2643
  environment: this.environment,
2622
2644
  containerId: this.containerId
2623
2645
  }).then(() => {