@zonease/happy 0.6.42 → 0.6.44

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 (88) hide show
  1. package/dist/{api-CIE4_cWd.cjs → api-Ct7Z1lwF.cjs} +65 -5
  2. package/dist/{api-Ew6xr81i.mjs → api-D3j3YL3m.mjs} +65 -5
  3. package/dist/{auth-G9fZpVJ2.cjs → auth-B9kOli6i.cjs} +2 -2
  4. package/dist/{auth-BzYevJo2.mjs → auth-C2ZyAGMu.mjs} +4 -4
  5. package/dist/{auth-Q2STUNI-.mjs → auth-DPe89SQx.mjs} +2 -2
  6. package/dist/{auth-Dor79zTL.cjs → auth-W1aK_a-P.cjs} +4 -4
  7. package/dist/{browser-qDIIAL7S.cjs → browser-BPEhi6te.cjs} +1 -1
  8. package/dist/{browser-BI7s-V8E.mjs → browser-Byx5gq-W.mjs} +1 -1
  9. package/dist/{claudeLocal-Db2tDC4X.mjs → claudeLocal-BtxBYzs7.mjs} +1 -1
  10. package/dist/{claudeLocal-f4uBLJaM.cjs → claudeLocal-CcarNVE9.cjs} +1 -1
  11. package/dist/{config-CHjDs8AS.mjs → config-DJLOlgjr.mjs} +1 -1
  12. package/dist/{config-CSBlEik9.cjs → config-Djr2JMWO.cjs} +1 -1
  13. package/dist/{connect-O_nA5BOC.mjs → connect-PrUuHNLU.mjs} +4 -4
  14. package/dist/{connect-CJoTliii.cjs → connect-rcgRx9US.cjs} +4 -4
  15. package/dist/{controlClient-DoS9JqQC.mjs → controlClient-DSiES8Un.mjs} +1 -1
  16. package/dist/{controlClient-CEz_p1zc.cjs → controlClient-FDsMeGVn.cjs} +1 -1
  17. package/dist/{cursorApprovalHook-DRAHfTXU.cjs → cursorApprovalHook-CTJiiPO6.cjs} +29 -11
  18. package/dist/{cursorApprovalHook-B0v1kGa7.mjs → cursorApprovalHook-DGYeNaLe.mjs} +29 -11
  19. package/dist/{cursorApprovalServer-DzY8yJlI.cjs → cursorApprovalServer-C_wqI7wm.cjs} +109 -8
  20. package/dist/{cursorApprovalServer-JjPkdjGR.mjs → cursorApprovalServer-fjPBXSAb.mjs} +109 -10
  21. package/dist/{deviceKeys-B4aqjnE6.mjs → deviceKeys-BYHzWSyg.mjs} +2 -2
  22. package/dist/{deviceKeys-DyUn0bEx.cjs → deviceKeys-DPut1U07.cjs} +2 -2
  23. package/dist/{doctor-DRnft_5-.mjs → doctor-BA28TuMy.mjs} +2 -2
  24. package/dist/{doctor-BJSuVRUZ.cjs → doctor-B_W7odmC.cjs} +2 -2
  25. package/dist/{downloadImage-Cijmufpr.cjs → downloadImage-B7MKUI0u.cjs} +1 -372
  26. package/dist/downloadImage-DKWzC11M.mjs +485 -0
  27. package/dist/{enroll-CysDL6ee.mjs → enroll-Bc3Lke1H.mjs} +3 -3
  28. package/dist/{enroll-C2gunHdt.cjs → enroll-Blqx_Kg8.cjs} +3 -3
  29. package/dist/{evidence-DPutCuUr.mjs → evidence-D8nvQ8pQ.mjs} +1 -1
  30. package/dist/{evidence-DsQ-h-_W.cjs → evidence-jfqT04hc.cjs} +1 -1
  31. package/dist/{formatImageMessage-6aV9YFWr.mjs → formatImageMessage-BFWnadBR.mjs} +1 -1
  32. package/dist/{formatImageMessage-BPK_Ivfe.cjs → formatImageMessage-CZeSzoFO.cjs} +1 -1
  33. package/dist/index.cjs +50 -46
  34. package/dist/index.mjs +50 -46
  35. package/dist/{install-DBg0xQ3g.mjs → install-BvuadnKW.mjs} +1 -1
  36. package/dist/{install-BsTA2tZn.mjs → install-ChK8Eb58.mjs} +2 -2
  37. package/dist/{install-Tyhs6rUp.cjs → install-DFmp8KKp.cjs} +1 -1
  38. package/dist/{install-DlOppA-e.cjs → install-nJv8rYWA.cjs} +2 -2
  39. package/dist/lib.cjs +3 -3
  40. package/dist/lib.d.cts +1 -0
  41. package/dist/lib.d.mts +1 -0
  42. package/dist/lib.mjs +3 -3
  43. package/dist/{loadableToolOutput-DPGTtKJM.cjs → loadableToolOutput-CqMfcEh7.cjs} +2 -2
  44. package/dist/{loadableToolOutput-2dMPAp4N.mjs → loadableToolOutput-D6crYom_.mjs} +2 -2
  45. package/dist/{persistence-D9tMm6bj.mjs → persistence-BXtirP1k.mjs} +1 -1
  46. package/dist/{persistence-BcQmjobZ.cjs → persistence-DOgft4tZ.cjs} +1 -1
  47. package/dist/{push-Dxsugkes.mjs → push-188EjPTP.mjs} +6 -6
  48. package/dist/{push-Cnm6JQMD.cjs → push-DykEVhRR.cjs} +6 -6
  49. package/dist/registerKillSessionHandler-6loIZYD9.mjs +407 -0
  50. package/dist/registerKillSessionHandler-ks8iPY9a.cjs +411 -0
  51. package/dist/{run-CiPWWhXt.cjs → run-DSJ7IIWW.cjs} +10 -8
  52. package/dist/{run-BEflQaQ2.mjs → run-Dp4_De-r.mjs} +10 -8
  53. package/dist/{runClaude-BVXsyCHb.cjs → runClaude-C3be35z0.cjs} +26 -26
  54. package/dist/{runClaude-sPkSqHWY.mjs → runClaude-gj4urJvB.mjs} +21 -21
  55. package/dist/{runCodex-C4rHkIyw.mjs → runCodex-DRZidxNB.mjs} +26 -26
  56. package/dist/{runCodex-BAwhdmSA.cjs → runCodex-p_fToj9T.cjs} +28 -28
  57. package/dist/{runCursor-CD5wC3gA.cjs → runCursor-CJlqkSYR.cjs} +210 -34
  58. package/dist/{runCursor-DiHLWMs8.mjs → runCursor-SFd9G7X_.mjs} +210 -34
  59. package/dist/{runGemini-B-93gOqB.mjs → runGemini-BOsfh6dX.mjs} +17 -17
  60. package/dist/{runGemini-Cto-adir.cjs → runGemini-lxvXq70R.cjs} +19 -19
  61. package/dist/{runOneShot-BfIzE9W4.cjs → runOneShot-BExFkHmA.cjs} +2 -2
  62. package/dist/{runOneShot-DGjlYVhR.mjs → runOneShot-CtzlkF1l.mjs} +2 -2
  63. package/dist/{serve-CqL6NWDr.cjs → serve-Bl1Caf6x.cjs} +6 -6
  64. package/dist/{serve-ttlqF5jn.mjs → serve-DfvSXAD2.mjs} +6 -6
  65. package/dist/{session-BZhGpQUJ.cjs → session--R6FqsxL.cjs} +5 -5
  66. package/dist/{session-Co0REU9e.mjs → session-BSzNJiAb.mjs} +5 -5
  67. package/dist/{sessionKeyCache-BwFUGgMs.cjs → sessionKeyCache-CVkksG68.cjs} +1 -1
  68. package/dist/{sessionKeyCache-pXTjpETo.mjs → sessionKeyCache-DYiCIvYC.mjs} +1 -1
  69. package/dist/{sessionList-fG5uAPzU.cjs → sessionList-C1q9fy5j.cjs} +2 -2
  70. package/dist/{sessionList-DaufR-sA.mjs → sessionList-D3pCseut.mjs} +2 -2
  71. package/dist/{sessionSummary-CjZPt6nr.cjs → sessionSummary-CUZxEBEZ.cjs} +3 -3
  72. package/dist/{sessionSummary-Dv6dPABg.mjs → sessionSummary-WpOlgXe1.mjs} +3 -3
  73. package/dist/{setupOfflineReconnection-DW5il97B.mjs → setupOfflineReconnection-BeWF3SGN.mjs} +5 -3
  74. package/dist/{setupOfflineReconnection-B6coH9QN.cjs → setupOfflineReconnection-CixoiWTS.cjs} +7 -5
  75. package/dist/{spawnHappyCLI-DhUeycct.mjs → spawnHappyCLI-Cyc-69jO.mjs} +1 -1
  76. package/dist/{spawnHappyCLI-Cfu7C1uM.cjs → spawnHappyCLI-hRc7u16s.cjs} +1 -1
  77. package/dist/{ssh-C4YTSHXL.cjs → ssh-B_TYtrys.cjs} +5 -5
  78. package/dist/{ssh-8tPIKk-i.mjs → ssh-BsxAgWgG.mjs} +5 -5
  79. package/dist/{task-DFW-PecP.cjs → task-BInh42e3.cjs} +6 -6
  80. package/dist/{task-CH-oidFy.mjs → task-BS4usaxx.mjs} +6 -6
  81. package/dist/{uninstall-CeioRZNI.mjs → uninstall-BKuDaZKB.mjs} +2 -2
  82. package/dist/{uninstall-yTSL3X6Y.cjs → uninstall-DNFGxNLl.cjs} +2 -2
  83. package/dist/{update-Bju28vNP.cjs → update-B9LoI5l8.cjs} +3 -3
  84. package/dist/{update-Derd2hoX.mjs → update-DC300VOW.mjs} +3 -3
  85. package/package.json +1 -1
  86. package/dist/downloadImage-BpVF7A79.mjs +0 -854
  87. package/dist/gitWorktree-C6jLoaMw.cjs +0 -39
  88. package/dist/gitWorktree-CzJDU2BV.mjs +0 -37
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var axios = require('axios');
4
- var logger = require('./persistence-BcQmjobZ.cjs');
4
+ var logger = require('./persistence-DOgft4tZ.cjs');
5
5
  var node_events = require('node:events');
6
6
  var socket_ioClient = require('socket.io-client');
7
7
  var z = require('zod');
@@ -26,7 +26,7 @@ var tweetnacl = require('tweetnacl');
26
26
  var base64 = require('@stablelib/base64');
27
27
  var node_readline = require('node:readline');
28
28
  var expoServerSdk = require('expo-server-sdk');
29
- var sessionKeyCache = require('./sessionKeyCache-BwFUGgMs.cjs');
29
+ var sessionKeyCache = require('./sessionKeyCache-CVkksG68.cjs');
30
30
  var chalk = require('chalk');
31
31
 
32
32
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -1395,7 +1395,7 @@ function resolveToolsDir() {
1395
1395
  }
1396
1396
  function findToolsDir() {
1397
1397
  try {
1398
- const manifest = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('api-CIE4_cWd.cjs', document.baseURI).href))).resolve(`${toolsPackageName()}/package.json`);
1398
+ const manifest = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('api-Ct7Z1lwF.cjs', document.baseURI).href))).resolve(`${toolsPackageName()}/package.json`);
1399
1399
  return path.dirname(manifest);
1400
1400
  } catch {
1401
1401
  }
@@ -5975,6 +5975,17 @@ async function getCodexSessionPreview(codexSessionId, limit = 10) {
5975
5975
  return messages.slice(-limit);
5976
5976
  }
5977
5977
 
5978
+ function rewriteSessionMetaId(line, newId) {
5979
+ try {
5980
+ const parsed = JSON.parse(line);
5981
+ if (parsed.type !== "session_meta" || !parsed.payload) return line;
5982
+ parsed.payload.session_id = newId;
5983
+ parsed.payload.id = newId;
5984
+ return JSON.stringify(parsed);
5985
+ } catch {
5986
+ return line;
5987
+ }
5988
+ }
5978
5989
  async function forkCodexSession(codexSessionId) {
5979
5990
  return forkAndTruncateCodexSession(codexSessionId);
5980
5991
  }
@@ -5990,7 +6001,10 @@ async function forkAndTruncateCodexSession(codexSessionId, truncateBeforeUuid) {
5990
6001
  const newPath = path.join(dir, `rollout-${dateStr}-${newUUID}.jsonl`);
5991
6002
  try {
5992
6003
  if (!truncateBeforeUuid) {
5993
- await promises.copyFile(originalPath, newPath);
6004
+ const content = await promises.readFile(originalPath, "utf-8");
6005
+ const lines = content.split("\n");
6006
+ const outputLines = lines.map((line, index) => index === 0 ? rewriteSessionMetaId(line, newUUID) : line);
6007
+ await promises.writeFile(newPath, outputLines.join("\n"), "utf-8");
5994
6008
  } else {
5995
6009
  const content = await promises.readFile(originalPath, "utf-8");
5996
6010
  const lines = content.split("\n");
@@ -6017,7 +6031,7 @@ async function forkAndTruncateCodexSession(codexSessionId, truncateBeforeUuid) {
6017
6031
  } catch {
6018
6032
  }
6019
6033
  if (!foundTruncationPoint) {
6020
- outputLines.push(line);
6034
+ outputLines.push(outputLines.length === 0 ? rewriteSessionMetaId(line, newUUID) : line);
6021
6035
  }
6022
6036
  }
6023
6037
  await promises.writeFile(newPath, outputLines.join("\n") + "\n", "utf-8");
@@ -6036,6 +6050,45 @@ async function forkAndTruncateCodexSession(codexSessionId, truncateBeforeUuid) {
6036
6050
  }
6037
6051
  }
6038
6052
 
6053
+ function chatsRoot() {
6054
+ return path.join(os.homedir(), ".cursor", "chats");
6055
+ }
6056
+ async function findChatDirectory(chatId) {
6057
+ const root = chatsRoot();
6058
+ if (!fs.existsSync(root)) return null;
6059
+ let workspaces;
6060
+ try {
6061
+ workspaces = await promises.readdir(root);
6062
+ } catch {
6063
+ return null;
6064
+ }
6065
+ for (const workspace of workspaces) {
6066
+ const candidate = path.join(root, workspace, chatId);
6067
+ try {
6068
+ if ((await promises.stat(candidate)).isDirectory()) return candidate;
6069
+ } catch {
6070
+ }
6071
+ }
6072
+ return null;
6073
+ }
6074
+ async function forkCursorSession(chatId) {
6075
+ const source = await findChatDirectory(chatId);
6076
+ if (!source) {
6077
+ return { success: false, errorMessage: `Cursor chat not found: ${chatId}` };
6078
+ }
6079
+ const newChatId = node_crypto.randomUUID();
6080
+ const destination = path.join(source, "..", newChatId);
6081
+ try {
6082
+ await promises.cp(source, destination, { recursive: true });
6083
+ logger.logger.debug(`[cursor] forked chat ${chatId} \u2192 ${newChatId}`);
6084
+ return { success: true, newChatId };
6085
+ } catch (error) {
6086
+ const message = error instanceof Error ? error.message : String(error);
6087
+ logger.logger.debug(`[cursor] fork failed for ${chatId}: ${message}`);
6088
+ return { success: false, errorMessage: message };
6089
+ }
6090
+ }
6091
+
6039
6092
  class SessionCache {
6040
6093
  data = null;
6041
6094
  loadingPromise = null;
@@ -6606,6 +6659,13 @@ class ApiMachineClient {
6606
6659
  }
6607
6660
  return await forkCodexSession(codexSessionId);
6608
6661
  });
6662
+ this.rpcHandlerManager.registerHandler("cursor-fork-session", async (params) => {
6663
+ const { cursorSessionId } = params || {};
6664
+ if (!cursorSessionId || typeof cursorSessionId !== "string") {
6665
+ throw new Error("cursorSessionId is required");
6666
+ }
6667
+ return await forkCursorSession(cursorSessionId);
6668
+ });
6609
6669
  this.rpcHandlerManager.registerHandler("gemini-list-sessions", async (params) => {
6610
6670
  const offset = typeof params?.offset === "number" && params.offset >= 0 ? Math.floor(params.offset) : 0;
6611
6671
  const limit = typeof params?.limit === "number" && params.limit > 0 ? Math.floor(params.limit) : 50;
@@ -1,5 +1,5 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import axios from 'axios';
2
- import { l as logger, c as configuration, e as encodeBase64, f as encrypt, g as decrypt, h as decodeBase64, i as isDebug, B as encryptLegacy, a as readSettings, C as getRandomBytes, D as libsodiumEncryptForPublicKey } from './persistence-D9tMm6bj.mjs';
2
+ import { l as logger, c as configuration, e as encodeBase64, f as encrypt, g as decrypt, h as decodeBase64, i as isDebug, B as encryptLegacy, a as readSettings, C as getRandomBytes, D as libsodiumEncryptForPublicKey } from './persistence-BXtirP1k.mjs';
3
3
  import { EventEmitter } from 'node:events';
4
4
  import { io } from 'socket.io-client';
5
5
  import { z } from 'zod';
@@ -9,7 +9,7 @@ import { randomUUID, createHash } from 'node:crypto';
9
9
  import fs, { existsSync, readFileSync, writeFileSync, mkdirSync, statSync, readdirSync, mkdtempSync, chmodSync, createReadStream, createWriteStream, unlink as unlink$2, rmdirSync } from 'node:fs';
10
10
  import path, { join, dirname, resolve as resolve$1, basename } from 'node:path';
11
11
  import { spawn, execFile, execSync, execFileSync } from 'node:child_process';
12
- import { readFile, rm, open, writeFile as writeFile$1, rename as rename$1, unlink as unlink$1, stat as stat$1, readdir as readdir$1, copyFile, mkdir as mkdir$1, appendFile as appendFile$1 } from 'node:fs/promises';
12
+ import { readFile, rm, open, writeFile as writeFile$1, rename as rename$1, unlink as unlink$1, stat as stat$1, readdir as readdir$1, copyFile, mkdir as mkdir$1, appendFile as appendFile$1, cp } from 'node:fs/promises';
13
13
  import os, { tmpdir, homedir } from 'node:os';
14
14
  import { promisify } from 'node:util';
15
15
  import { spawn as spawn$1, exec } from 'child_process';
@@ -24,7 +24,7 @@ import tweetnacl from 'tweetnacl';
24
24
  import { encode, decode } from '@stablelib/base64';
25
25
  import { createInterface } from 'node:readline';
26
26
  import { Expo } from 'expo-server-sdk';
27
- import { c as cacheSessionKey } from './sessionKeyCache-pXTjpETo.mjs';
27
+ import { c as cacheSessionKey } from './sessionKeyCache-DYiCIvYC.mjs';
28
28
  import chalk from 'chalk';
29
29
 
30
30
  z.object({
@@ -5972,6 +5972,17 @@ async function getCodexSessionPreview(codexSessionId, limit = 10) {
5972
5972
  return messages.slice(-limit);
5973
5973
  }
5974
5974
 
5975
+ function rewriteSessionMetaId(line, newId) {
5976
+ try {
5977
+ const parsed = JSON.parse(line);
5978
+ if (parsed.type !== "session_meta" || !parsed.payload) return line;
5979
+ parsed.payload.session_id = newId;
5980
+ parsed.payload.id = newId;
5981
+ return JSON.stringify(parsed);
5982
+ } catch {
5983
+ return line;
5984
+ }
5985
+ }
5975
5986
  async function forkCodexSession(codexSessionId) {
5976
5987
  return forkAndTruncateCodexSession(codexSessionId);
5977
5988
  }
@@ -5987,7 +5998,10 @@ async function forkAndTruncateCodexSession(codexSessionId, truncateBeforeUuid) {
5987
5998
  const newPath = join(dir, `rollout-${dateStr}-${newUUID}.jsonl`);
5988
5999
  try {
5989
6000
  if (!truncateBeforeUuid) {
5990
- await copyFile(originalPath, newPath);
6001
+ const content = await readFile(originalPath, "utf-8");
6002
+ const lines = content.split("\n");
6003
+ const outputLines = lines.map((line, index) => index === 0 ? rewriteSessionMetaId(line, newUUID) : line);
6004
+ await writeFile$1(newPath, outputLines.join("\n"), "utf-8");
5991
6005
  } else {
5992
6006
  const content = await readFile(originalPath, "utf-8");
5993
6007
  const lines = content.split("\n");
@@ -6014,7 +6028,7 @@ async function forkAndTruncateCodexSession(codexSessionId, truncateBeforeUuid) {
6014
6028
  } catch {
6015
6029
  }
6016
6030
  if (!foundTruncationPoint) {
6017
- outputLines.push(line);
6031
+ outputLines.push(outputLines.length === 0 ? rewriteSessionMetaId(line, newUUID) : line);
6018
6032
  }
6019
6033
  }
6020
6034
  await writeFile$1(newPath, outputLines.join("\n") + "\n", "utf-8");
@@ -6033,6 +6047,45 @@ async function forkAndTruncateCodexSession(codexSessionId, truncateBeforeUuid) {
6033
6047
  }
6034
6048
  }
6035
6049
 
6050
+ function chatsRoot() {
6051
+ return join(homedir(), ".cursor", "chats");
6052
+ }
6053
+ async function findChatDirectory(chatId) {
6054
+ const root = chatsRoot();
6055
+ if (!existsSync(root)) return null;
6056
+ let workspaces;
6057
+ try {
6058
+ workspaces = await readdir$1(root);
6059
+ } catch {
6060
+ return null;
6061
+ }
6062
+ for (const workspace of workspaces) {
6063
+ const candidate = join(root, workspace, chatId);
6064
+ try {
6065
+ if ((await stat$1(candidate)).isDirectory()) return candidate;
6066
+ } catch {
6067
+ }
6068
+ }
6069
+ return null;
6070
+ }
6071
+ async function forkCursorSession(chatId) {
6072
+ const source = await findChatDirectory(chatId);
6073
+ if (!source) {
6074
+ return { success: false, errorMessage: `Cursor chat not found: ${chatId}` };
6075
+ }
6076
+ const newChatId = randomUUID();
6077
+ const destination = join(source, "..", newChatId);
6078
+ try {
6079
+ await cp(source, destination, { recursive: true });
6080
+ logger.debug(`[cursor] forked chat ${chatId} \u2192 ${newChatId}`);
6081
+ return { success: true, newChatId };
6082
+ } catch (error) {
6083
+ const message = error instanceof Error ? error.message : String(error);
6084
+ logger.debug(`[cursor] fork failed for ${chatId}: ${message}`);
6085
+ return { success: false, errorMessage: message };
6086
+ }
6087
+ }
6088
+
6036
6089
  class SessionCache {
6037
6090
  data = null;
6038
6091
  loadingPromise = null;
@@ -6603,6 +6656,13 @@ class ApiMachineClient {
6603
6656
  }
6604
6657
  return await forkCodexSession(codexSessionId);
6605
6658
  });
6659
+ this.rpcHandlerManager.registerHandler("cursor-fork-session", async (params) => {
6660
+ const { cursorSessionId } = params || {};
6661
+ if (!cursorSessionId || typeof cursorSessionId !== "string") {
6662
+ throw new Error("cursorSessionId is required");
6663
+ }
6664
+ return await forkCursorSession(cursorSessionId);
6665
+ });
6606
6666
  this.rpcHandlerManager.registerHandler("gemini-list-sessions", async (params) => {
6607
6667
  const offset = typeof params?.offset === "number" && params.offset >= 0 ? Math.floor(params.offset) : 0;
6608
6668
  const limit = typeof params?.limit === "number" && params.limit > 0 ? Math.floor(params.limit) : 50;
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var logger = require('./persistence-BcQmjobZ.cjs');
3
+ var logger = require('./persistence-DOgft4tZ.cjs');
4
4
  var node_crypto = require('node:crypto');
5
5
  var tweetnacl = require('tweetnacl');
6
6
  var axios = require('axios');
7
7
  var qrcode = require('qrcode-terminal');
8
8
  var time = require('./time-Bj2HRkKH.cjs');
9
- var browser = require('./browser-qDIIAL7S.cjs');
9
+ var browser = require('./browser-BPEhi6te.cjs');
10
10
  var React = require('react');
11
11
  var ink = require('ink');
12
12
  require('node:fs/promises');
@@ -1,9 +1,9 @@
1
1
  import chalk from 'chalk';
2
- import { r as readCredentials, a as readSettings, c as configuration, l as logger, b as clearCredentials, d as clearMachineId } from './persistence-D9tMm6bj.mjs';
3
- import { authAndSetupMachineIfNeeded } from './auth-Q2STUNI-.mjs';
2
+ import { r as readCredentials, a as readSettings, c as configuration, l as logger, b as clearCredentials, d as clearMachineId } from './persistence-BXtirP1k.mjs';
3
+ import { authAndSetupMachineIfNeeded } from './auth-DPe89SQx.mjs';
4
4
  import { existsSync, rmSync } from 'node:fs';
5
5
  import { createInterface } from 'node:readline';
6
- import { checkIfDaemonRunningAndCleanupStaleState, stopDaemon } from './controlClient-DoS9JqQC.mjs';
6
+ import { checkIfDaemonRunningAndCleanupStaleState, stopDaemon } from './controlClient-DSiES8Un.mjs';
7
7
  import os from 'node:os';
8
8
  import 'node:fs/promises';
9
9
  import 'node:path';
@@ -14,7 +14,7 @@ import 'fs';
14
14
  import 'axios';
15
15
  import 'qrcode-terminal';
16
16
  import './time-DgsBLJA_.mjs';
17
- import './browser-BI7s-V8E.mjs';
17
+ import './browser-Byx5gq-W.mjs';
18
18
  import 'open';
19
19
  import 'react';
20
20
  import 'ink';
@@ -1,10 +1,10 @@
1
- import { e as encodeBase64, c as configuration, l as logger, r as readCredentials, u as updateSettings, i as isDebug, s as encodeBase64Url, h as decodeBase64, t as writeCredentialsLegacy, w as writeCredentialsDataKey } from './persistence-D9tMm6bj.mjs';
1
+ import { e as encodeBase64, c as configuration, l as logger, r as readCredentials, u as updateSettings, i as isDebug, s as encodeBase64Url, h as decodeBase64, t as writeCredentialsLegacy, w as writeCredentialsDataKey } from './persistence-BXtirP1k.mjs';
2
2
  import { randomBytes, randomUUID } from 'node:crypto';
3
3
  import tweetnacl from 'tweetnacl';
4
4
  import axios from 'axios';
5
5
  import qrcode from 'qrcode-terminal';
6
6
  import { d as delay } from './time-DgsBLJA_.mjs';
7
- import { o as openBrowser } from './browser-BI7s-V8E.mjs';
7
+ import { o as openBrowser } from './browser-Byx5gq-W.mjs';
8
8
  import React, { useState } from 'react';
9
9
  import { useInput, Box, Text, render } from 'ink';
10
10
  import 'node:fs/promises';
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
- var logger = require('./persistence-BcQmjobZ.cjs');
5
- var auth = require('./auth-G9fZpVJ2.cjs');
4
+ var logger = require('./persistence-DOgft4tZ.cjs');
5
+ var auth = require('./auth-B9kOli6i.cjs');
6
6
  var fs = require('node:fs');
7
7
  var node_readline = require('node:readline');
8
- var controlClient = require('./controlClient-CEz_p1zc.cjs');
8
+ var controlClient = require('./controlClient-FDsMeGVn.cjs');
9
9
  var os = require('node:os');
10
10
  require('node:fs/promises');
11
11
  require('node:path');
@@ -16,7 +16,7 @@ require('fs');
16
16
  require('axios');
17
17
  require('qrcode-terminal');
18
18
  require('./time-Bj2HRkKH.cjs');
19
- require('./browser-qDIIAL7S.cjs');
19
+ require('./browser-BPEhi6te.cjs');
20
20
  require('open');
21
21
  require('react');
22
22
  require('ink');
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var open = require('open');
4
- var logger = require('./persistence-BcQmjobZ.cjs');
4
+ var logger = require('./persistence-DOgft4tZ.cjs');
5
5
 
6
6
  async function openBrowser(url) {
7
7
  try {
@@ -1,5 +1,5 @@
1
1
  import open from 'open';
2
- import { l as logger } from './persistence-D9tMm6bj.mjs';
2
+ import { l as logger } from './persistence-BXtirP1k.mjs';
3
3
 
4
4
  async function openBrowser(url) {
5
5
  try {
@@ -3,7 +3,7 @@ import { resolve, join } from 'node:path';
3
3
  import { createInterface } from 'node:readline';
4
4
  import { existsSync, readFileSync, readdirSync, statSync, mkdirSync } from 'node:fs';
5
5
  import { randomUUID } from 'node:crypto';
6
- import { l as logger } from './persistence-D9tMm6bj.mjs';
6
+ import { l as logger } from './persistence-BXtirP1k.mjs';
7
7
  import { homedir } from 'node:os';
8
8
  import { p as projectPath } from './projectPath-BTBIMB57.mjs';
9
9
  import { g as getBaseSystemPrompt } from './prompt-BsAZsPbo.mjs';
@@ -5,7 +5,7 @@ var path = require('node:path');
5
5
  var node_readline = require('node:readline');
6
6
  var fs = require('node:fs');
7
7
  var node_crypto = require('node:crypto');
8
- var logger = require('./persistence-BcQmjobZ.cjs');
8
+ var logger = require('./persistence-DOgft4tZ.cjs');
9
9
  var os = require('node:os');
10
10
  var projectPath = require('./projectPath-ChLhdOyt.cjs');
11
11
  var prompt = require('./prompt-BTWDZZO0.cjs');
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import { homedir } from 'os';
4
4
  import { execSync } from 'child_process';
5
- import { l as logger } from './persistence-D9tMm6bj.mjs';
5
+ import { l as logger } from './persistence-BXtirP1k.mjs';
6
6
  import { D as DEFAULT_GEMINI_MODEL, G as GEMINI_MODEL_ENV } from './constants-pmXZGibX.mjs';
7
7
  import 'node:fs/promises';
8
8
  import 'node:fs';
@@ -4,7 +4,7 @@ var fs = require('fs');
4
4
  var path = require('path');
5
5
  var os = require('os');
6
6
  var child_process = require('child_process');
7
- var logger = require('./persistence-BcQmjobZ.cjs');
7
+ var logger = require('./persistence-DOgft4tZ.cjs');
8
8
  var constants = require('./constants-E_UWYTo3.cjs');
9
9
  require('node:fs/promises');
10
10
  require('node:fs');
@@ -2,11 +2,11 @@ import chalk from 'chalk';
2
2
  import { existsSync, mkdirSync, writeFileSync } from 'fs';
3
3
  import { homedir } from 'os';
4
4
  import { join } from 'path';
5
- import { r as readCredentials } from './persistence-D9tMm6bj.mjs';
6
- import { A as ApiClient } from './api-Ew6xr81i.mjs';
5
+ import { r as readCredentials } from './persistence-BXtirP1k.mjs';
6
+ import { A as ApiClient } from './api-D3j3YL3m.mjs';
7
7
  import { createServer } from 'http';
8
8
  import { randomBytes, createHash } from 'crypto';
9
- import { o as openBrowser } from './browser-BI7s-V8E.mjs';
9
+ import { o as openBrowser } from './browser-Byx5gq-W.mjs';
10
10
  import { exec } from 'child_process';
11
11
  import { promisify } from 'util';
12
12
  import 'node:fs/promises';
@@ -32,7 +32,7 @@ import 'ws';
32
32
  import '@stablelib/base64';
33
33
  import 'node:readline';
34
34
  import 'expo-server-sdk';
35
- import './sessionKeyCache-pXTjpETo.mjs';
35
+ import './sessionKeyCache-DYiCIvYC.mjs';
36
36
  import 'open';
37
37
 
38
38
  const CLIENT_ID$2 = "app_EMoamEEZ73f0CkXaXp7hrann";
@@ -4,11 +4,11 @@ var chalk = require('chalk');
4
4
  var fs = require('fs');
5
5
  var os = require('os');
6
6
  var path = require('path');
7
- var logger = require('./persistence-BcQmjobZ.cjs');
8
- var api = require('./api-CIE4_cWd.cjs');
7
+ var logger = require('./persistence-DOgft4tZ.cjs');
8
+ var api = require('./api-Ct7Z1lwF.cjs');
9
9
  var http = require('http');
10
10
  var crypto = require('crypto');
11
- var browser = require('./browser-qDIIAL7S.cjs');
11
+ var browser = require('./browser-BPEhi6te.cjs');
12
12
  var child_process = require('child_process');
13
13
  var util = require('util');
14
14
  require('node:fs/promises');
@@ -34,7 +34,7 @@ require('ws');
34
34
  require('@stablelib/base64');
35
35
  require('node:readline');
36
36
  require('expo-server-sdk');
37
- require('./sessionKeyCache-BwFUGgMs.cjs');
37
+ require('./sessionKeyCache-CVkksG68.cjs');
38
38
  require('open');
39
39
 
40
40
  const CLIENT_ID$2 = "app_EMoamEEZ73f0CkXaXp7hrann";
@@ -1,4 +1,4 @@
1
- import { l as logger, m as readDaemonState, n as clearDaemonState } from './persistence-D9tMm6bj.mjs';
1
+ import { l as logger, m as readDaemonState, n as clearDaemonState } from './persistence-BXtirP1k.mjs';
2
2
  import { p as projectPath } from './projectPath-BTBIMB57.mjs';
3
3
  import { readFileSync } from 'fs';
4
4
  import { join } from 'path';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var logger = require('./persistence-BcQmjobZ.cjs');
3
+ var logger = require('./persistence-DOgft4tZ.cjs');
4
4
  var projectPath = require('./projectPath-ChLhdOyt.cjs');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
@@ -2,12 +2,12 @@
2
2
 
3
3
  var fs = require('node:fs');
4
4
  var path = require('node:path');
5
- var cursorApprovalServer = require('./cursorApprovalServer-DzY8yJlI.cjs');
5
+ var cursorApprovalServer = require('./cursorApprovalServer-C_wqI7wm.cjs');
6
6
  require('node:http');
7
7
  require('node:crypto');
8
8
  require('node:fs/promises');
9
- require('./persistence-BcQmjobZ.cjs');
10
9
  require('node:os');
10
+ require('./persistence-DOgft4tZ.cjs');
11
11
  require('zod');
12
12
  require('tweetnacl');
13
13
  require('chalk');
@@ -33,7 +33,32 @@ function emit(permission, userMessage) {
33
33
  process.stdout.write(`${JSON.stringify(payload)}
34
34
  `);
35
35
  }
36
+ function isStale(pid) {
37
+ if (typeof pid !== "number") return false;
38
+ try {
39
+ process.kill(pid, 0);
40
+ return false;
41
+ } catch {
42
+ return true;
43
+ }
44
+ }
45
+ function readEndpoint(file) {
46
+ if (!fs.existsSync(file)) return null;
47
+ try {
48
+ const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
49
+ if (typeof parsed?.port !== "number" || typeof parsed?.token !== "string") return null;
50
+ if (isStale(parsed.pid)) return null;
51
+ return { port: parsed.port, token: parsed.token };
52
+ } catch {
53
+ }
54
+ return null;
55
+ }
36
56
  function findEndpoint(payload) {
57
+ for (const key of [payload.session_id, payload.conversation_id]) {
58
+ if (typeof key !== "string" || key.length === 0) continue;
59
+ const found = readEndpoint(path.join(cursorApprovalServer.approvalRegistryDir(), `${key}.json`));
60
+ if (found) return found;
61
+ }
37
62
  const candidates = [];
38
63
  if (typeof payload.cwd === "string") candidates.push(payload.cwd);
39
64
  if (Array.isArray(payload.workspace_roots)) {
@@ -44,15 +69,8 @@ function findEndpoint(payload) {
44
69
  if (process.env.CURSOR_PROJECT_DIR) candidates.push(process.env.CURSOR_PROJECT_DIR);
45
70
  candidates.push(process.cwd());
46
71
  for (const dir of candidates) {
47
- const file = path.join(dir, ".cursor", cursorApprovalServer.APPROVAL_ENDPOINT_FILE);
48
- if (!fs.existsSync(file)) continue;
49
- try {
50
- const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
51
- if (typeof parsed?.port === "number" && typeof parsed?.token === "string") {
52
- return { port: parsed.port, token: parsed.token };
53
- }
54
- } catch {
55
- }
72
+ const found = readEndpoint(path.join(dir, ".cursor", cursorApprovalServer.APPROVAL_ENDPOINT_FILE));
73
+ if (found) return found;
56
74
  }
57
75
  return null;
58
76
  }
@@ -1,11 +1,11 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { A as APPROVAL_ENDPOINT_FILE } from './cursorApprovalServer-JjPkdjGR.mjs';
3
+ import { a as approvalRegistryDir, A as APPROVAL_ENDPOINT_FILE } from './cursorApprovalServer-fjPBXSAb.mjs';
4
4
  import 'node:http';
5
5
  import 'node:crypto';
6
6
  import 'node:fs/promises';
7
- import './persistence-D9tMm6bj.mjs';
8
7
  import 'node:os';
8
+ import './persistence-BXtirP1k.mjs';
9
9
  import 'zod';
10
10
  import 'tweetnacl';
11
11
  import 'chalk';
@@ -31,7 +31,32 @@ function emit(permission, userMessage) {
31
31
  process.stdout.write(`${JSON.stringify(payload)}
32
32
  `);
33
33
  }
34
+ function isStale(pid) {
35
+ if (typeof pid !== "number") return false;
36
+ try {
37
+ process.kill(pid, 0);
38
+ return false;
39
+ } catch {
40
+ return true;
41
+ }
42
+ }
43
+ function readEndpoint(file) {
44
+ if (!existsSync(file)) return null;
45
+ try {
46
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
47
+ if (typeof parsed?.port !== "number" || typeof parsed?.token !== "string") return null;
48
+ if (isStale(parsed.pid)) return null;
49
+ return { port: parsed.port, token: parsed.token };
50
+ } catch {
51
+ }
52
+ return null;
53
+ }
34
54
  function findEndpoint(payload) {
55
+ for (const key of [payload.session_id, payload.conversation_id]) {
56
+ if (typeof key !== "string" || key.length === 0) continue;
57
+ const found = readEndpoint(join(approvalRegistryDir(), `${key}.json`));
58
+ if (found) return found;
59
+ }
35
60
  const candidates = [];
36
61
  if (typeof payload.cwd === "string") candidates.push(payload.cwd);
37
62
  if (Array.isArray(payload.workspace_roots)) {
@@ -42,15 +67,8 @@ function findEndpoint(payload) {
42
67
  if (process.env.CURSOR_PROJECT_DIR) candidates.push(process.env.CURSOR_PROJECT_DIR);
43
68
  candidates.push(process.cwd());
44
69
  for (const dir of candidates) {
45
- const file = join(dir, ".cursor", APPROVAL_ENDPOINT_FILE);
46
- if (!existsSync(file)) continue;
47
- try {
48
- const parsed = JSON.parse(readFileSync(file, "utf8"));
49
- if (typeof parsed?.port === "number" && typeof parsed?.token === "string") {
50
- return { port: parsed.port, token: parsed.token };
51
- }
52
- } catch {
53
- }
70
+ const found = readEndpoint(join(dir, ".cursor", APPROVAL_ENDPOINT_FILE));
71
+ if (found) return found;
54
72
  }
55
73
  return null;
56
74
  }