@4pm/cli 0.2.2 → 0.3.0

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 +22 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3930,7 +3930,7 @@ MCowBQYDK2VwAyEARlfzjaFhe5bhRrMp/ZuH6sVqg/S7f8B1dliuF21iDTw=
3930
3930
  `;
3931
3931
 
3932
3932
  // src/version.ts
3933
- var CLI_VERSION = "0.2.2";
3933
+ var CLI_VERSION = "0.3.0";
3934
3934
 
3935
3935
  // src/core/update.ts
3936
3936
  function compareSemver(a, b) {
@@ -4835,6 +4835,7 @@ async function addProject(payload, onProgress) {
4835
4835
 
4836
4836
  // src/core/ws-client.ts
4837
4837
  var HEARTBEAT_MS = 3e4;
4838
+ var MAX_HASHCODE_INVALID_RETRIES = 5;
4838
4839
  var CLOSE_DRAINING = 4001;
4839
4840
  var OFFLINE_BUFFER_MAX_BYTES = 512 * 1024;
4840
4841
  var WsClient = class {
@@ -4859,16 +4860,32 @@ var WsClient = class {
4859
4860
  * Main lifecycle: connect + reconnect backoff until revoked.
4860
4861
  */
4861
4862
  async run() {
4863
+ let hashcodeInvalidStreak = 0;
4862
4864
  for (let attempt = 0; !this.stopped; attempt++) {
4863
4865
  try {
4864
4866
  await this.connectOnce();
4865
4867
  attempt = 0;
4868
+ hashcodeInvalidStreak = 0;
4866
4869
  } catch (err) {
4867
- if (err instanceof CliApiError && ["HASHCODE_INVALID", "HASHCODE_EXPIRED", "LINK_REVOKED"].includes(err.errorCode)) {
4868
- this.logout(err.errorCode);
4869
- return;
4870
+ if (err instanceof CliApiError) {
4871
+ if (["HASHCODE_EXPIRED", "LINK_REVOKED"].includes(err.errorCode)) {
4872
+ this.logout(err.errorCode);
4873
+ return;
4874
+ }
4875
+ if (err.errorCode === "HASHCODE_INVALID") {
4876
+ if (++hashcodeInvalidStreak > MAX_HASHCODE_INVALID_RETRIES) {
4877
+ this.logout(err.errorCode);
4878
+ return;
4879
+ }
4880
+ console.warn(
4881
+ `Token request rejected (HASHCODE_INVALID) \u2014 retrying (${hashcodeInvalidStreak}/${MAX_HASHCODE_INVALID_RETRIES}).`
4882
+ );
4883
+ } else {
4884
+ console.error(`Connection error: ${err}`);
4885
+ }
4886
+ } else {
4887
+ console.error(`Connection error: ${err}`);
4870
4888
  }
4871
- console.error(`Connection error: ${err}`);
4872
4889
  }
4873
4890
  if (this.stopped) return;
4874
4891
  const wait = backoffJitterMs(Math.min(attempt, 6), 1e3, 6e4);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4pm/cli",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "4PM CLI — drives Claude/Codex CLIs on AI worker machines (Node + TypeScript)",
6
6
  "type": "module",