chatroom-cli 1.0.82 → 1.0.84

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.
Files changed (2) hide show
  1. package/dist/index.js +90 -49
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9617,6 +9617,67 @@ var init_api3 = __esm(() => {
9617
9617
  init_api2();
9618
9618
  });
9619
9619
 
9620
+ // src/utils/error-formatting.ts
9621
+ function formatError(message, suggestions) {
9622
+ console.error(`❌ ${message}`);
9623
+ if (suggestions && suggestions.length > 0) {
9624
+ console.error("");
9625
+ suggestions.forEach((suggestion) => {
9626
+ console.error(`\uD83D\uDCA1 ${suggestion}`);
9627
+ });
9628
+ }
9629
+ }
9630
+ function formatValidationError(field, value, expected) {
9631
+ formatError(`Invalid ${field}`, [`Got: ${value}`, `Expected: ${expected}`]);
9632
+ }
9633
+ function formatFileError(operation, filePath, reason) {
9634
+ const message = `Cannot ${operation} file: ${filePath}`;
9635
+ if (reason) {
9636
+ formatError(message, [`Reason: ${reason}`]);
9637
+ } else {
9638
+ console.error(`❌ ${message}`);
9639
+ }
9640
+ }
9641
+ function formatAuthError(currentUrl, otherUrls) {
9642
+ console.error(`❌ Not authenticated${currentUrl ? ` for: ${currentUrl}` : ""}`);
9643
+ if (otherUrls && otherUrls.length > 0) {
9644
+ console.error(`
9645
+ \uD83D\uDCA1 You have sessions for other environments:`);
9646
+ for (const url of otherUrls) {
9647
+ console.error(` • ${url}`);
9648
+ }
9649
+ console.error(`
9650
+ To use a different environment, set CHATROOM_CONVEX_URL:`);
9651
+ console.error(` CHATROOM_CONVEX_URL=${otherUrls[0]} chatroom <command>`);
9652
+ console.error(`
9653
+ Or to authenticate for the current environment:`);
9654
+ }
9655
+ console.error(` chatroom auth login`);
9656
+ }
9657
+ function formatChatroomIdError(chatroomId) {
9658
+ formatValidationError("chatroom ID format", `ID must be 20-40 characters (got ${chatroomId?.length || 0})`, "20-40 character string");
9659
+ }
9660
+ function isNetworkError(error) {
9661
+ const msg = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
9662
+ const code2 = error?.code;
9663
+ return msg.includes("fetch failed") || msg.includes("failed to fetch") || msg.includes("econnrefused") || msg.includes("enotfound") || msg.includes("etimedout") || msg.includes("network") || msg.includes("connection refused") || msg.includes("socket hang up") || msg.includes("dns") || code2 === "ECONNREFUSED" || code2 === "ENOTFOUND" || code2 === "ETIMEDOUT" || code2 === "ECONNRESET";
9664
+ }
9665
+ function formatConnectivityError(error, backendUrl) {
9666
+ const err = error instanceof Error ? error : new Error(String(error));
9667
+ console.error(`
9668
+ ❌ Could not reach the backend${backendUrl ? ` at ${backendUrl}` : ""}`);
9669
+ console.error(` ${err.message}`);
9670
+ console.error(`
9671
+ Your session may still be valid. Please check:`);
9672
+ console.error(` • Network connectivity`);
9673
+ console.error(` • Whether the backend service is running`);
9674
+ if (backendUrl) {
9675
+ console.error(` • CHATROOM_CONVEX_URL is correct (currently: ${backendUrl})`);
9676
+ }
9677
+ console.error(`
9678
+ Try again once the backend is reachable.`);
9679
+ }
9680
+
9620
9681
  // src/infrastructure/auth/middleware.ts
9621
9682
  var exports_middleware = {};
9622
9683
  __export(exports_middleware, {
@@ -9677,12 +9738,18 @@ async function requireAuth() {
9677
9738
  userName: validation.userName
9678
9739
  };
9679
9740
  } catch (error) {
9741
+ if (isNetworkError(error)) {
9742
+ formatConnectivityError(error, getConvexUrl());
9743
+ process.exit(1);
9744
+ }
9680
9745
  const err = error;
9681
9746
  console.error(`
9682
9747
  ❌ Error: Could not validate session`);
9683
9748
  console.error(` ${err.message}`);
9684
9749
  console.error(`
9685
- Please check your connection and try again.`);
9750
+ Please re-authenticate:`);
9751
+ console.error(` $ chatroom auth login
9752
+ `);
9686
9753
  process.exit(1);
9687
9754
  }
9688
9755
  }
@@ -9707,7 +9774,10 @@ async function checkAuth() {
9707
9774
  userId: validation.userId,
9708
9775
  userName: validation.userName
9709
9776
  };
9710
- } catch {
9777
+ } catch (error) {
9778
+ if (isNetworkError(error)) {
9779
+ throw error;
9780
+ }
9711
9781
  return null;
9712
9782
  }
9713
9783
  }
@@ -10061,7 +10131,6 @@ function ensureMachineRegistered() {
10061
10131
  config.availableHarnesses = detectAvailableHarnesses();
10062
10132
  config.harnessVersions = detectHarnessVersions(config.availableHarnesses);
10063
10133
  config.lastSyncedAt = now;
10064
- config.hostname = hostname2();
10065
10134
  saveMachineConfig(config);
10066
10135
  }
10067
10136
  return {
@@ -10879,10 +10948,19 @@ async function waitForTask(chatroomId, options) {
10879
10948
  console.error(`❌ Invalid chatroom ID format: ID must contain only alphanumeric characters and underscores`);
10880
10949
  process.exit(1);
10881
10950
  }
10882
- const chatroom = await client2.query(api.chatrooms.get, {
10883
- sessionId,
10884
- chatroomId
10885
- });
10951
+ let chatroom;
10952
+ try {
10953
+ chatroom = await client2.query(api.chatrooms.get, {
10954
+ sessionId,
10955
+ chatroomId
10956
+ });
10957
+ } catch (error) {
10958
+ if (isNetworkError(error)) {
10959
+ formatConnectivityError(error, convexUrl);
10960
+ process.exit(1);
10961
+ }
10962
+ throw error;
10963
+ }
10886
10964
  if (!chatroom) {
10887
10965
  console.error(`❌ Chatroom ${chatroomId} not found or access denied`);
10888
10966
  process.exit(1);
@@ -11301,47 +11379,6 @@ var init_task_started2 = __esm(() => {
11301
11379
  init_client2();
11302
11380
  });
11303
11381
 
11304
- // src/utils/error-formatting.ts
11305
- function formatError(message, suggestions) {
11306
- console.error(`❌ ${message}`);
11307
- if (suggestions && suggestions.length > 0) {
11308
- console.error("");
11309
- suggestions.forEach((suggestion) => {
11310
- console.error(`\uD83D\uDCA1 ${suggestion}`);
11311
- });
11312
- }
11313
- }
11314
- function formatValidationError(field, value, expected) {
11315
- formatError(`Invalid ${field}`, [`Got: ${value}`, `Expected: ${expected}`]);
11316
- }
11317
- function formatFileError(operation, filePath, reason) {
11318
- const message = `Cannot ${operation} file: ${filePath}`;
11319
- if (reason) {
11320
- formatError(message, [`Reason: ${reason}`]);
11321
- } else {
11322
- console.error(`❌ ${message}`);
11323
- }
11324
- }
11325
- function formatAuthError(currentUrl, otherUrls) {
11326
- console.error(`❌ Not authenticated${currentUrl ? ` for: ${currentUrl}` : ""}`);
11327
- if (otherUrls && otherUrls.length > 0) {
11328
- console.error(`
11329
- \uD83D\uDCA1 You have sessions for other environments:`);
11330
- for (const url of otherUrls) {
11331
- console.error(` • ${url}`);
11332
- }
11333
- console.error(`
11334
- To use a different environment, set CHATROOM_CONVEX_URL:`);
11335
- console.error(` CHATROOM_CONVEX_URL=${otherUrls[0]} chatroom <command>`);
11336
- console.error(`
11337
- Or to authenticate for the current environment:`);
11338
- }
11339
- console.error(` chatroom auth login`);
11340
- }
11341
- function formatChatroomIdError(chatroomId) {
11342
- formatValidationError("chatroom ID format", `ID must be 20-40 characters (got ${chatroomId?.length || 0})`, "20-40 character string");
11343
- }
11344
-
11345
11382
  // src/commands/task-complete.ts
11346
11383
  var exports_task_complete = {};
11347
11384
  __export(exports_task_complete, {
@@ -13387,7 +13424,11 @@ Run any chatroom command first to register this machine,`);
13387
13424
  connected: true
13388
13425
  });
13389
13426
  } catch (error) {
13390
- console.error(`❌ Failed to update daemon status: ${error.message}`);
13427
+ if (isNetworkError(error)) {
13428
+ formatConnectivityError(error, convexUrl);
13429
+ } else {
13430
+ console.error(`❌ Failed to update daemon status: ${error.message}`);
13431
+ }
13391
13432
  releaseLock();
13392
13433
  process.exit(1);
13393
13434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatroom-cli",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "description": "CLI for multi-agent chatroom collaboration",
5
5
  "type": "module",
6
6
  "bin": {