chatroom-cli 1.0.83 → 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 -48
  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
  }
@@ -10878,10 +10948,19 @@ async function waitForTask(chatroomId, options) {
10878
10948
  console.error(`❌ Invalid chatroom ID format: ID must contain only alphanumeric characters and underscores`);
10879
10949
  process.exit(1);
10880
10950
  }
10881
- const chatroom = await client2.query(api.chatrooms.get, {
10882
- sessionId,
10883
- chatroomId
10884
- });
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
+ }
10885
10964
  if (!chatroom) {
10886
10965
  console.error(`❌ Chatroom ${chatroomId} not found or access denied`);
10887
10966
  process.exit(1);
@@ -11300,47 +11379,6 @@ var init_task_started2 = __esm(() => {
11300
11379
  init_client2();
11301
11380
  });
11302
11381
 
11303
- // src/utils/error-formatting.ts
11304
- function formatError(message, suggestions) {
11305
- console.error(`❌ ${message}`);
11306
- if (suggestions && suggestions.length > 0) {
11307
- console.error("");
11308
- suggestions.forEach((suggestion) => {
11309
- console.error(`\uD83D\uDCA1 ${suggestion}`);
11310
- });
11311
- }
11312
- }
11313
- function formatValidationError(field, value, expected) {
11314
- formatError(`Invalid ${field}`, [`Got: ${value}`, `Expected: ${expected}`]);
11315
- }
11316
- function formatFileError(operation, filePath, reason) {
11317
- const message = `Cannot ${operation} file: ${filePath}`;
11318
- if (reason) {
11319
- formatError(message, [`Reason: ${reason}`]);
11320
- } else {
11321
- console.error(`❌ ${message}`);
11322
- }
11323
- }
11324
- function formatAuthError(currentUrl, otherUrls) {
11325
- console.error(`❌ Not authenticated${currentUrl ? ` for: ${currentUrl}` : ""}`);
11326
- if (otherUrls && otherUrls.length > 0) {
11327
- console.error(`
11328
- \uD83D\uDCA1 You have sessions for other environments:`);
11329
- for (const url of otherUrls) {
11330
- console.error(` • ${url}`);
11331
- }
11332
- console.error(`
11333
- To use a different environment, set CHATROOM_CONVEX_URL:`);
11334
- console.error(` CHATROOM_CONVEX_URL=${otherUrls[0]} chatroom <command>`);
11335
- console.error(`
11336
- Or to authenticate for the current environment:`);
11337
- }
11338
- console.error(` chatroom auth login`);
11339
- }
11340
- function formatChatroomIdError(chatroomId) {
11341
- formatValidationError("chatroom ID format", `ID must be 20-40 characters (got ${chatroomId?.length || 0})`, "20-40 character string");
11342
- }
11343
-
11344
11382
  // src/commands/task-complete.ts
11345
11383
  var exports_task_complete = {};
11346
11384
  __export(exports_task_complete, {
@@ -13386,7 +13424,11 @@ Run any chatroom command first to register this machine,`);
13386
13424
  connected: true
13387
13425
  });
13388
13426
  } catch (error) {
13389
- 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
+ }
13390
13432
  releaseLock();
13391
13433
  process.exit(1);
13392
13434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatroom-cli",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
4
4
  "description": "CLI for multi-agent chatroom collaboration",
5
5
  "type": "module",
6
6
  "bin": {