episoda 0.2.68 → 0.2.70

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.
@@ -2337,12 +2337,18 @@ var require_websocket_client = __commonJS({
2337
2337
  /**
2338
2338
  * EP701: Emit a client-side event to registered handlers
2339
2339
  * Used for events like 'disconnected' that originate from the client, not server
2340
+ * EP1095: Fixed to handle async handlers - catches both sync errors and promise rejections
2340
2341
  */
2341
2342
  emit(event) {
2342
2343
  const handlers = this.eventHandlers.get(event.type) || [];
2343
2344
  handlers.forEach((handler) => {
2344
2345
  try {
2345
- handler(event);
2346
+ const result = handler(event);
2347
+ if (result && typeof result === "object" && "catch" in result && typeof result.catch === "function") {
2348
+ result.catch((error) => {
2349
+ console.error(`[EpisodaClient] Async handler error for ${event.type}:`, error);
2350
+ });
2351
+ }
2346
2352
  } catch (error) {
2347
2353
  console.error(`[EpisodaClient] Handler error for ${event.type}:`, error);
2348
2354
  }
@@ -2369,7 +2375,12 @@ var require_websocket_client = __commonJS({
2369
2375
  const handlers = this.eventHandlers.get(message.type) || [];
2370
2376
  handlers.forEach((handler) => {
2371
2377
  try {
2372
- handler(message);
2378
+ const result = handler(message);
2379
+ if (result && typeof result === "object" && "catch" in result && typeof result.catch === "function") {
2380
+ result.catch((error) => {
2381
+ console.error(`[EpisodaClient] Async handler error for ${message.type}:`, error);
2382
+ });
2383
+ }
2373
2384
  } catch (error) {
2374
2385
  console.error(`[EpisodaClient] Handler error for ${message.type}:`, error);
2375
2386
  }
@@ -2730,7 +2741,7 @@ var require_package = __commonJS({
2730
2741
  "package.json"(exports2, module2) {
2731
2742
  module2.exports = {
2732
2743
  name: "episoda",
2733
- version: "0.2.68",
2744
+ version: "0.2.70",
2734
2745
  description: "CLI tool for Episoda local development workflow orchestration",
2735
2746
  main: "dist/index.js",
2736
2747
  types: "dist/index.d.ts",
@@ -8903,20 +8914,24 @@ var Daemon = class _Daemon {
8903
8914
  client.updateToken(tokenMsg.accessToken);
8904
8915
  });
8905
8916
  client.on("machine_uuid_update", async (message) => {
8906
- const uuidMsg = message;
8907
- if (uuidMsg.machineUuid) {
8908
- this.machineUuid = uuidMsg.machineUuid;
8909
- console.log(`[Daemon] EP1095: Machine UUID updated: ${this.machineUuid}`);
8910
- await this.cacheMachineUuid(uuidMsg.machineUuid);
8911
- this.syncMachineProjectPath(projectId, projectPath).catch((err) => {
8912
- console.warn("[Daemon] EP1095: Deferred project path sync failed:", err.message);
8913
- });
8914
- const connection2 = this.connections.get(projectPath);
8915
- if (connection2) {
8916
- this.reconcileWorktrees(projectId, projectPath, connection2.client).catch((err) => {
8917
- console.warn("[Daemon] EP1095: Deferred reconciliation failed:", err.message);
8917
+ try {
8918
+ const uuidMsg = message;
8919
+ if (uuidMsg.machineUuid) {
8920
+ this.machineUuid = uuidMsg.machineUuid;
8921
+ console.log(`[Daemon] EP1095: Machine UUID updated: ${this.machineUuid}`);
8922
+ await this.cacheMachineUuid(uuidMsg.machineUuid);
8923
+ this.syncMachineProjectPath(projectId, projectPath).catch((err) => {
8924
+ console.warn("[Daemon] EP1095: Deferred project path sync failed:", err.message);
8918
8925
  });
8926
+ const connection2 = this.connections.get(projectPath);
8927
+ if (connection2) {
8928
+ this.reconcileWorktrees(projectId, projectPath, connection2.client).catch((err) => {
8929
+ console.warn("[Daemon] EP1095: Deferred reconciliation failed:", err.message);
8930
+ });
8931
+ }
8919
8932
  }
8933
+ } catch (error) {
8934
+ console.error("[Daemon] EP1095: Error handling machine_uuid_update:", error instanceof Error ? error.message : error);
8920
8935
  }
8921
8936
  });
8922
8937
  client.on("disconnected", (event) => {