@zonease/happy 0.6.54 → 0.6.56
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.
- package/dist/{api-DLk8tzQQ.mjs → api-9wvM_aF-.mjs} +79 -67
- package/dist/{api-Da8DnAgp.cjs → api-BGc484qf.cjs} +73 -61
- package/dist/{auth-3eHy-NiL.cjs → auth-B6vskzfm.cjs} +2 -2
- package/dist/{auth-Dn64MNXy.mjs → auth-BnEa31tI.mjs} +2 -2
- package/dist/{auth-DHyEz32d.cjs → auth-CPfJalJM.cjs} +4 -4
- package/dist/{auth-l0Gi002V.mjs → auth-DqAM-lIh.mjs} +4 -4
- package/dist/{browser-DmSfJ05Z.mjs → browser-CkQP96Zi.mjs} +1 -1
- package/dist/{browser-Cw-H2Ma5.cjs → browser-CnxzD1lA.cjs} +1 -1
- package/dist/{claudeLocal-B0Y7CBFV.mjs → claudeLocal-B5uxtoit.mjs} +1 -1
- package/dist/{claudeLocal-DNLVyOkk.cjs → claudeLocal-CV4fT0Gg.cjs} +1 -1
- package/dist/{config-CPzuub8l.mjs → config-C9hdBdfj.mjs} +1 -1
- package/dist/{config-B1dECrwV.cjs → config-C__p7EWC.cjs} +1 -1
- package/dist/{connect-C7dp_WX0.mjs → connect-BeORCRXq.mjs} +5 -5
- package/dist/{connect-CcqT6Eg4.cjs → connect-DQjpjfYn.cjs} +5 -5
- package/dist/{controlClient-4irLqjPn.cjs → controlClient-DWBW6jRF.cjs} +4 -4
- package/dist/{controlClient-DESWXp4N.mjs → controlClient-VY0CGL8k.mjs} +4 -4
- package/dist/{cursorApprovalHook-BDYPCM1A.cjs → cursorApprovalHook-BuDSRM-6.cjs} +2 -2
- package/dist/{cursorApprovalHook-BX5PlCLv.mjs → cursorApprovalHook-D_8btpsY.mjs} +2 -2
- package/dist/{cursorApprovalServer-BZyv6LZR.mjs → cursorApprovalServer-BOUd2-Fg.mjs} +1 -1
- package/dist/{cursorApprovalServer-gH0pwRGq.cjs → cursorApprovalServer-j9RphnEG.cjs} +1 -1
- package/dist/{deviceKeys-BekDRny4.mjs → deviceKeys-DvfaTff3.mjs} +2 -2
- package/dist/{deviceKeys-CDTA_iqA.cjs → deviceKeys-c_sN01Mm.cjs} +2 -2
- package/dist/{doctor-BCqchQlg.cjs → doctor-CD46A-_Y.cjs} +2 -2
- package/dist/{doctor-CFDWT__E.mjs → doctor-DQtQbfG-.mjs} +2 -2
- package/dist/{downloadImage-Bv0iPThm.mjs → downloadImage-B6A4x8Jw.mjs} +1 -1
- package/dist/{downloadImage-oDAqiRug.cjs → downloadImage-DGdHCFi3.cjs} +1 -1
- package/dist/{enroll-BEZ5llpQ.mjs → enroll-CyHWNKNt.mjs} +3 -3
- package/dist/{enroll-BS_DDdDI.cjs → enroll-D9CEuRI_.cjs} +3 -3
- package/dist/{evidence-DUqAB-YC.mjs → evidence-BuYebdrN.mjs} +1 -1
- package/dist/{evidence-DNxlL47R.cjs → evidence-CCrpzsTA.cjs} +1 -1
- package/dist/{formatImageMessage-DNrnXT9b.mjs → formatImageMessage-5qaaT_Wq.mjs} +1 -1
- package/dist/{formatImageMessage-9IXAYb2e.cjs → formatImageMessage-DttKW75w.cjs} +1 -1
- package/dist/index.cjs +49 -47
- package/dist/index.mjs +49 -47
- package/dist/{install-DRJM6rAH.mjs → install-1Y6dAcMp.mjs} +1 -1
- package/dist/{install-B8BRcKro.cjs → install-B0hT_tLv.cjs} +2 -2
- package/dist/{install-qidTS2aZ.cjs → install-C4cwObCN.cjs} +1 -1
- package/dist/{install-PoZjcS6c.mjs → install-eIXFuZbC.mjs} +2 -2
- package/dist/lib.cjs +6 -6
- package/dist/lib.mjs +6 -6
- package/dist/{loadableToolOutput-BlVR2izz.mjs → loadableToolOutput-BKDTnyoF.mjs} +2 -2
- package/dist/{loadableToolOutput-Dee4IYX-.cjs → loadableToolOutput-Cb-18__b.cjs} +2 -2
- package/dist/{persistence-CXOGgoCo.cjs → persistence-CNXsXPLm.cjs} +1 -1
- package/dist/{persistence-DSUgpkhC.mjs → persistence-IdEuIeMz.mjs} +1 -1
- package/dist/{push-CISsRYtP.cjs → push-XL6Sb0Vw.cjs} +6 -6
- package/dist/{push-BAhpKKZi.mjs → push-tXs96IyG.mjs} +6 -6
- package/dist/{registerKillSessionHandler-DYhs41SE.cjs → registerKillSessionHandler-D9tmPdw5.cjs} +3 -3
- package/dist/{registerKillSessionHandler-Due-xxRL.mjs → registerKillSessionHandler-vF5c8YZF.mjs} +3 -3
- package/dist/{run-DOdseFir.cjs → run-BKfeeheJ.cjs} +16 -10
- package/dist/{run-CnaW5CvS.mjs → run-BvpCwXkt.mjs} +16 -10
- package/dist/{runClaude-DZMQllwE.mjs → runClaude-BiVqZQOm.mjs} +15 -15
- package/dist/{runClaude-Bdg1uZQB.cjs → runClaude-DDsG7eMR.cjs} +16 -16
- package/dist/{runCodex-Btsu2b6-.cjs → runCodex-Bh519-dW.cjs} +15 -15
- package/dist/{runCodex-DBZcVBP-.mjs → runCodex-C-8SvnpP.mjs} +15 -15
- package/dist/{runCursor-BGoe6glt.mjs → runCursor-3AFNF0y2.mjs} +16 -16
- package/dist/{runCursor-BoqAa3cX.cjs → runCursor-CYbvOqUa.cjs} +16 -16
- package/dist/{runGemini-CrPFkfeE.mjs → runGemini-Dh2JRfOJ.mjs} +19 -19
- package/dist/{runGemini-PlEnK1qg.cjs → runGemini-ExHXGZBY.cjs} +19 -19
- package/dist/{runOneShot-Ck0pDOnK.cjs → runOneShot-CEVKtkx_.cjs} +2 -2
- package/dist/{runOneShot-CtcdFR7C.mjs → runOneShot-CVcw-K0_.mjs} +2 -2
- package/dist/{serve-CmDwh71O.mjs → serve-C4dOQ0jP.mjs} +6 -6
- package/dist/{serve-Dw2TAf7J.cjs → serve-D0IhhySV.cjs} +6 -6
- package/dist/{session-lvats2oo.mjs → session-CwMxRPXS.mjs} +5 -5
- package/dist/{session-cgCKfQlj.cjs → session-DK9eudJT.cjs} +5 -5
- package/dist/{sessionKeyCache-WsWILYqW.mjs → sessionKeyCache-DDzTs7E5.mjs} +1 -1
- package/dist/{sessionKeyCache-BcHYqqvh.cjs → sessionKeyCache-JjjYAxdf.cjs} +1 -1
- package/dist/{sessionList-CZe1CUNV.cjs → sessionList-DZmmAP3q.cjs} +2 -2
- package/dist/{sessionList-rWjYFvKo.mjs → sessionList-IYAtPIev.mjs} +2 -2
- package/dist/{sessionSummary-DHMo6gQp.mjs → sessionSummary-CQQyTHRC.mjs} +3 -3
- package/dist/{sessionSummary-B2alrCw2.cjs → sessionSummary-CsIfkyZA.cjs} +3 -3
- package/dist/{setupOfflineReconnection-Bgr2zrFL.mjs → setupOfflineReconnection-C1yzDMt6.mjs} +3 -3
- package/dist/{setupOfflineReconnection-CDKLObwx.cjs → setupOfflineReconnection-DwtIEUeJ.cjs} +3 -3
- package/dist/{spawnHappyCLI-DMHDwhaj.cjs → spawnHappyCLI-BbMkZhMk.cjs} +1 -1
- package/dist/{spawnHappyCLI-D395WmG6.mjs → spawnHappyCLI-DlTg87jS.mjs} +1 -1
- package/dist/{ssh-DY2t_lUb.cjs → ssh-D31o750w.cjs} +40 -28
- package/dist/{ssh-D4Tm8kgg.mjs → ssh-DSVjanff.mjs} +40 -28
- package/dist/{task-CwUcMY2G.cjs → task--Apxd9oF.cjs} +6 -6
- package/dist/{task-5ZowiuIL.mjs → task-D9ZjWCcw.mjs} +6 -6
- package/dist/{uninstall-rxjrCBV0.mjs → uninstall-Bo2uaLRP.mjs} +2 -2
- package/dist/{uninstall-B8pTaKP5.cjs → uninstall-CZJcoC06.cjs} +2 -2
- package/dist/{update-DP570X8n.mjs → update-BiV4YqG3.mjs} +3 -3
- package/dist/{update-DwU5c4md.cjs → update-D-bTjP2k.cjs} +3 -3
- package/package.json +1 -1
|
@@ -1,20 +1,21 @@
|
|
|
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-
|
|
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-IdEuIeMz.mjs';
|
|
3
3
|
import { EventEmitter } from 'node:events';
|
|
4
4
|
import { io } from 'socket.io-client';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import './index-7P6T8CE4.mjs';
|
|
7
7
|
import { b as backoff, e as exponentialBackoffDelay } from './time-DgsBLJA_.mjs';
|
|
8
8
|
import { randomUUID, createHash } from 'node:crypto';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import path, { dirname, join, resolve as resolve$1, basename } from 'node:path';
|
|
10
|
+
import fs, { existsSync, createReadStream, statSync, readdirSync, mkdtempSync, writeFileSync, chmodSync, createWriteStream, unlink as unlink$2, rmdirSync } from 'node:fs';
|
|
11
|
+
import { mkdir, appendFile, readFile, rm, open, writeFile as writeFile$1, rename as rename$1, unlink as unlink$1, stat as stat$1, readdir as readdir$1, copyFile, cp } from 'node:fs/promises';
|
|
12
|
+
import { createInterface } from 'node:readline';
|
|
11
13
|
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, cp } from 'node:fs/promises';
|
|
13
14
|
import os, { tmpdir, homedir } from 'node:os';
|
|
14
15
|
import { promisify } from 'node:util';
|
|
15
16
|
import { spawn as spawn$1, exec } from 'child_process';
|
|
16
17
|
import { promisify as promisify$1 } from 'util';
|
|
17
|
-
import { readFile as readFile$1, writeFile, mkdir, rm as rm$1, stat, appendFile, rename, lstat, unlink, readdir } from 'fs/promises';
|
|
18
|
+
import { readFile as readFile$1, writeFile, mkdir as mkdir$1, rm as rm$1, stat, appendFile as appendFile$1, rename, lstat, unlink, readdir } from 'fs/promises';
|
|
18
19
|
import { resolve, join as join$1, dirname as dirname$1, sep } from 'path';
|
|
19
20
|
import { p as projectPath } from './projectPath-BTBIMB57.mjs';
|
|
20
21
|
import { createRequire } from 'node:module';
|
|
@@ -22,9 +23,8 @@ import WebSocket from 'ws';
|
|
|
22
23
|
import { randomUUID as randomUUID$1 } from 'crypto';
|
|
23
24
|
import tweetnacl from 'tweetnacl';
|
|
24
25
|
import { encode, decode } from '@stablelib/base64';
|
|
25
|
-
import { createInterface } from 'node:readline';
|
|
26
26
|
import { Expo } from 'expo-server-sdk';
|
|
27
|
-
import { c as cacheSessionKey } from './sessionKeyCache-
|
|
27
|
+
import { c as cacheSessionKey } from './sessionKeyCache-DDzTs7E5.mjs';
|
|
28
28
|
import chalk from 'chalk';
|
|
29
29
|
|
|
30
30
|
z.object({
|
|
@@ -232,41 +232,70 @@ class InvalidateSync {
|
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
const
|
|
236
|
-
function
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
235
|
+
const pendingAppends = /* @__PURE__ */ new Map();
|
|
236
|
+
async function appendJsonLines(filePath, records) {
|
|
237
|
+
const data = records.map((record) => `${JSON.stringify(record)}
|
|
238
|
+
`).join("");
|
|
239
|
+
const previous = pendingAppends.get(filePath) ?? Promise.resolve();
|
|
240
|
+
const current = previous.then(async () => {
|
|
241
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
242
|
+
await appendFile(filePath, data, "utf-8");
|
|
243
|
+
});
|
|
244
|
+
const settled = current.catch(() => {
|
|
245
|
+
});
|
|
246
|
+
pendingAppends.set(filePath, settled);
|
|
247
|
+
void settled.then(() => {
|
|
248
|
+
if (pendingAppends.get(filePath) === settled) pendingAppends.delete(filePath);
|
|
249
|
+
});
|
|
250
|
+
return current;
|
|
243
251
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
252
|
+
async function findJsonLine(filePath, needle, match) {
|
|
253
|
+
await pendingAppends.get(filePath);
|
|
254
|
+
if (!existsSync(filePath)) return null;
|
|
255
|
+
const fileStream = createReadStream(filePath, { encoding: "utf8" });
|
|
256
|
+
const rl = createInterface({
|
|
257
|
+
input: fileStream,
|
|
258
|
+
crlfDelay: Infinity
|
|
259
|
+
});
|
|
246
260
|
try {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
let existing = [];
|
|
250
|
-
if (existsSync(filePath)) {
|
|
261
|
+
for await (const line of rl) {
|
|
262
|
+
if (!line.includes(needle)) continue;
|
|
251
263
|
try {
|
|
252
|
-
|
|
264
|
+
const record = JSON.parse(line);
|
|
265
|
+
if (match(record)) return record;
|
|
253
266
|
} catch {
|
|
254
|
-
existing = [];
|
|
255
267
|
}
|
|
256
268
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
logger.warn(`[DiffStore] Failed to save diff records:`, error);
|
|
269
|
+
return null;
|
|
270
|
+
} finally {
|
|
271
|
+
rl.close();
|
|
272
|
+
fileStream.destroy();
|
|
262
273
|
}
|
|
263
274
|
}
|
|
264
|
-
function
|
|
275
|
+
async function findInJsonArrayFile(filePath, match) {
|
|
276
|
+
if (!existsSync(filePath)) return null;
|
|
277
|
+
const records = JSON.parse(await readFile(filePath, "utf-8"));
|
|
278
|
+
return records.find(match) ?? null;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const diffsDir = join(configuration.happyHomeDir, "diffs");
|
|
282
|
+
function getFilePath$1(sessionId) {
|
|
283
|
+
return join(diffsDir, `${sessionId}.jsonl`);
|
|
284
|
+
}
|
|
285
|
+
function getLegacyFilePath$1(sessionId) {
|
|
286
|
+
return join(diffsDir, `${sessionId}.json`);
|
|
287
|
+
}
|
|
288
|
+
function saveDiffRecords(sessionId, records) {
|
|
289
|
+
if (records.length === 0) return;
|
|
290
|
+
appendJsonLines(getFilePath$1(sessionId), records).then(
|
|
291
|
+
() => logger.debug(`[DiffStore] Saved ${records.length} record(s) for session ${sessionId}`),
|
|
292
|
+
(error) => logger.warn(`[DiffStore] Failed to save diff records:`, error)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
async function getDiffDetail(sessionId, callId, filePath) {
|
|
265
296
|
try {
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
const records = JSON.parse(readFileSync(file, "utf-8"));
|
|
269
|
-
const record = records.find((r) => r.callId === callId && r.filePath === filePath);
|
|
297
|
+
const match = (r) => r.callId === callId && r.filePath === filePath;
|
|
298
|
+
const record = await findJsonLine(getFilePath$1(sessionId), JSON.stringify(callId), match) ?? await findInJsonArrayFile(getLegacyFilePath$1(sessionId), match);
|
|
270
299
|
if (!record) return null;
|
|
271
300
|
return { diff: record.diff, additions: record.additions, deletions: record.deletions };
|
|
272
301
|
} catch (error) {
|
|
@@ -276,39 +305,22 @@ function getDiffDetail(sessionId, callId, filePath) {
|
|
|
276
305
|
}
|
|
277
306
|
|
|
278
307
|
const toolOutputsDir = join(configuration.happyHomeDir, "tool-outputs");
|
|
279
|
-
function ensureToolOutputsDir() {
|
|
280
|
-
if (!existsSync(toolOutputsDir)) {
|
|
281
|
-
mkdirSync(toolOutputsDir, { recursive: true });
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
308
|
function getFilePath(sessionId) {
|
|
309
|
+
return join(toolOutputsDir, `${sessionId}.jsonl`);
|
|
310
|
+
}
|
|
311
|
+
function getLegacyFilePath(sessionId) {
|
|
285
312
|
return join(toolOutputsDir, `${sessionId}.json`);
|
|
286
313
|
}
|
|
287
314
|
function saveToolOutputRecord(sessionId, record) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (existsSync(filePath)) {
|
|
293
|
-
try {
|
|
294
|
-
existing = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
295
|
-
} catch {
|
|
296
|
-
existing = [];
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
existing.push(record);
|
|
300
|
-
writeFileSync(filePath, JSON.stringify(existing), "utf-8");
|
|
301
|
-
logger.debug(`[ToolOutputStore] Saved output for ${record.toolName} (${record.callId}) in session ${sessionId}`);
|
|
302
|
-
} catch (error) {
|
|
303
|
-
logger.warn("[ToolOutputStore] Failed to save tool output record:", error);
|
|
304
|
-
}
|
|
315
|
+
appendJsonLines(getFilePath(sessionId), [record]).then(
|
|
316
|
+
() => logger.debug(`[ToolOutputStore] Saved output for ${record.toolName} (${record.callId}) in session ${sessionId}`),
|
|
317
|
+
(error) => logger.warn("[ToolOutputStore] Failed to save tool output record:", error)
|
|
318
|
+
);
|
|
305
319
|
}
|
|
306
|
-
function getToolOutputRecord(sessionId, callId) {
|
|
320
|
+
async function getToolOutputRecord(sessionId, callId) {
|
|
307
321
|
try {
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
const records = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
311
|
-
return records.find((record) => record.callId === callId) || null;
|
|
322
|
+
const match = (record) => record.callId === callId;
|
|
323
|
+
return await findJsonLine(getFilePath(sessionId), JSON.stringify(callId), match) ?? await findInJsonArrayFile(getLegacyFilePath(sessionId), match);
|
|
312
324
|
} catch (error) {
|
|
313
325
|
logger.warn("[ToolOutputStore] Failed to get tool output record:", error);
|
|
314
326
|
return null;
|
|
@@ -1846,7 +1858,7 @@ function registerCommonHandlers(rpcHandlerManager, workingDirectory, sessionId)
|
|
|
1846
1858
|
return { success: false, error: `Path '${paths.absolutePath}' is on the system write deny-list` };
|
|
1847
1859
|
}
|
|
1848
1860
|
try {
|
|
1849
|
-
await mkdir(paths.directory, { recursive: true });
|
|
1861
|
+
await mkdir$1(paths.directory, { recursive: true });
|
|
1850
1862
|
await rm$1(paths.tempAbsolutePath, { force: true });
|
|
1851
1863
|
await rm$1(paths.absolutePath, { force: true });
|
|
1852
1864
|
await writeFile(paths.tempAbsolutePath, Buffer.alloc(0));
|
|
@@ -1883,7 +1895,7 @@ function registerCommonHandlers(rpcHandlerManager, workingDirectory, sessionId)
|
|
|
1883
1895
|
if (currentSize + chunk.length > MAX_SESSION_UPLOAD_FILE_BYTES) {
|
|
1884
1896
|
return { success: false, error: "File exceeds 100MB limit" };
|
|
1885
1897
|
}
|
|
1886
|
-
await appendFile(paths.tempAbsolutePath, chunk);
|
|
1898
|
+
await appendFile$1(paths.tempAbsolutePath, chunk);
|
|
1887
1899
|
return {
|
|
1888
1900
|
success: true,
|
|
1889
1901
|
relativePath: paths.relativePath,
|
|
@@ -2080,7 +2092,7 @@ function registerCommonHandlers(rpcHandlerManager, workingDirectory, sessionId)
|
|
|
2080
2092
|
return { success: false, error: `Path '${absPath}' is on the system write deny-list` };
|
|
2081
2093
|
}
|
|
2082
2094
|
try {
|
|
2083
|
-
await mkdir(absPath);
|
|
2095
|
+
await mkdir$1(absPath);
|
|
2084
2096
|
logger.info("[createDirectory] path=%s ok=%s", absPath, true);
|
|
2085
2097
|
return { success: true };
|
|
2086
2098
|
} catch (error) {
|
|
@@ -2244,7 +2256,7 @@ function registerCommonHandlers(rpcHandlerManager, workingDirectory, sessionId)
|
|
|
2244
2256
|
if (sessionId) {
|
|
2245
2257
|
rpcHandlerManager.registerHandler("getDiffDetail", async (data) => {
|
|
2246
2258
|
logger.debug("getDiffDetail request:", data.callId, data.filePath);
|
|
2247
|
-
const result = getDiffDetail(sessionId, data.callId, data.filePath);
|
|
2259
|
+
const result = await getDiffDetail(sessionId, data.callId, data.filePath);
|
|
2248
2260
|
if (!result) {
|
|
2249
2261
|
return { success: false, error: "not_found" };
|
|
2250
2262
|
}
|
|
@@ -2257,7 +2269,7 @@ function registerCommonHandlers(rpcHandlerManager, workingDirectory, sessionId)
|
|
|
2257
2269
|
});
|
|
2258
2270
|
rpcHandlerManager.registerHandler("getToolOutput", async (data) => {
|
|
2259
2271
|
logger.debug("getToolOutput request:", data.callId);
|
|
2260
|
-
const record = getToolOutputRecord(sessionId, data.callId);
|
|
2272
|
+
const record = await getToolOutputRecord(sessionId, data.callId);
|
|
2261
2273
|
if (!record) {
|
|
2262
2274
|
return { success: false, error: "not_found" };
|
|
2263
2275
|
}
|
|
@@ -5261,7 +5273,7 @@ class GeminiSessionWriter {
|
|
|
5261
5273
|
}
|
|
5262
5274
|
async init(meta) {
|
|
5263
5275
|
try {
|
|
5264
|
-
await mkdir
|
|
5276
|
+
await mkdir(getGeminiSessionsDir(), { recursive: true });
|
|
5265
5277
|
this.appendLine({
|
|
5266
5278
|
type: "meta",
|
|
5267
5279
|
key: "sessionStart",
|
|
@@ -5328,7 +5340,7 @@ class GeminiSessionWriter {
|
|
|
5328
5340
|
* Errors are logged but never thrown — persistence is best-effort.
|
|
5329
5341
|
*/
|
|
5330
5342
|
appendLine(line) {
|
|
5331
|
-
this.writePromise = this.writePromise.then(() => appendFile
|
|
5343
|
+
this.writePromise = this.writePromise.then(() => appendFile(this.filePath, JSON.stringify(line) + "\n", "utf-8")).catch((error) => {
|
|
5332
5344
|
logger.debug(`[GeminiSessionWriter] Write failed:`, error);
|
|
5333
5345
|
});
|
|
5334
5346
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
|
-
var logger = require('./persistence-
|
|
4
|
+
var logger = require('./persistence-CNXsXPLm.cjs');
|
|
5
5
|
var node_events = require('node:events');
|
|
6
6
|
var socket_ioClient = require('socket.io-client');
|
|
7
7
|
var z = require('zod');
|
|
8
8
|
require('./index-DBev4hhV.cjs');
|
|
9
9
|
var time = require('./time-Bj2HRkKH.cjs');
|
|
10
10
|
var node_crypto = require('node:crypto');
|
|
11
|
-
var fs = require('node:fs');
|
|
12
11
|
var path = require('node:path');
|
|
13
|
-
var
|
|
12
|
+
var fs = require('node:fs');
|
|
14
13
|
var promises = require('node:fs/promises');
|
|
14
|
+
var node_readline = require('node:readline');
|
|
15
|
+
var node_child_process = require('node:child_process');
|
|
15
16
|
var os = require('node:os');
|
|
16
17
|
var node_util = require('node:util');
|
|
17
18
|
var child_process = require('child_process');
|
|
@@ -24,9 +25,8 @@ var WebSocket = require('ws');
|
|
|
24
25
|
var crypto = require('crypto');
|
|
25
26
|
var tweetnacl = require('tweetnacl');
|
|
26
27
|
var base64 = require('@stablelib/base64');
|
|
27
|
-
var node_readline = require('node:readline');
|
|
28
28
|
var expoServerSdk = require('expo-server-sdk');
|
|
29
|
-
var sessionKeyCache = require('./sessionKeyCache-
|
|
29
|
+
var sessionKeyCache = require('./sessionKeyCache-JjjYAxdf.cjs');
|
|
30
30
|
var chalk = require('chalk');
|
|
31
31
|
|
|
32
32
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -235,41 +235,70 @@ class InvalidateSync {
|
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
const
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
238
|
+
const pendingAppends = /* @__PURE__ */ new Map();
|
|
239
|
+
async function appendJsonLines(filePath, records) {
|
|
240
|
+
const data = records.map((record) => `${JSON.stringify(record)}
|
|
241
|
+
`).join("");
|
|
242
|
+
const previous = pendingAppends.get(filePath) ?? Promise.resolve();
|
|
243
|
+
const current = previous.then(async () => {
|
|
244
|
+
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
245
|
+
await promises.appendFile(filePath, data, "utf-8");
|
|
246
|
+
});
|
|
247
|
+
const settled = current.catch(() => {
|
|
248
|
+
});
|
|
249
|
+
pendingAppends.set(filePath, settled);
|
|
250
|
+
void settled.then(() => {
|
|
251
|
+
if (pendingAppends.get(filePath) === settled) pendingAppends.delete(filePath);
|
|
252
|
+
});
|
|
253
|
+
return current;
|
|
246
254
|
}
|
|
247
|
-
function
|
|
248
|
-
|
|
255
|
+
async function findJsonLine(filePath, needle, match) {
|
|
256
|
+
await pendingAppends.get(filePath);
|
|
257
|
+
if (!fs.existsSync(filePath)) return null;
|
|
258
|
+
const fileStream = fs.createReadStream(filePath, { encoding: "utf8" });
|
|
259
|
+
const rl = node_readline.createInterface({
|
|
260
|
+
input: fileStream,
|
|
261
|
+
crlfDelay: Infinity
|
|
262
|
+
});
|
|
249
263
|
try {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
let existing = [];
|
|
253
|
-
if (fs.existsSync(filePath)) {
|
|
264
|
+
for await (const line of rl) {
|
|
265
|
+
if (!line.includes(needle)) continue;
|
|
254
266
|
try {
|
|
255
|
-
|
|
267
|
+
const record = JSON.parse(line);
|
|
268
|
+
if (match(record)) return record;
|
|
256
269
|
} catch {
|
|
257
|
-
existing = [];
|
|
258
270
|
}
|
|
259
271
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
logger.logger.warn(`[DiffStore] Failed to save diff records:`, error);
|
|
272
|
+
return null;
|
|
273
|
+
} finally {
|
|
274
|
+
rl.close();
|
|
275
|
+
fileStream.destroy();
|
|
265
276
|
}
|
|
266
277
|
}
|
|
267
|
-
function
|
|
278
|
+
async function findInJsonArrayFile(filePath, match) {
|
|
279
|
+
if (!fs.existsSync(filePath)) return null;
|
|
280
|
+
const records = JSON.parse(await promises.readFile(filePath, "utf-8"));
|
|
281
|
+
return records.find(match) ?? null;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const diffsDir = path.join(logger.configuration.happyHomeDir, "diffs");
|
|
285
|
+
function getFilePath$1(sessionId) {
|
|
286
|
+
return path.join(diffsDir, `${sessionId}.jsonl`);
|
|
287
|
+
}
|
|
288
|
+
function getLegacyFilePath$1(sessionId) {
|
|
289
|
+
return path.join(diffsDir, `${sessionId}.json`);
|
|
290
|
+
}
|
|
291
|
+
function saveDiffRecords(sessionId, records) {
|
|
292
|
+
if (records.length === 0) return;
|
|
293
|
+
appendJsonLines(getFilePath$1(sessionId), records).then(
|
|
294
|
+
() => logger.logger.debug(`[DiffStore] Saved ${records.length} record(s) for session ${sessionId}`),
|
|
295
|
+
(error) => logger.logger.warn(`[DiffStore] Failed to save diff records:`, error)
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
async function getDiffDetail(sessionId, callId, filePath) {
|
|
268
299
|
try {
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
const records = JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
272
|
-
const record = records.find((r) => r.callId === callId && r.filePath === filePath);
|
|
300
|
+
const match = (r) => r.callId === callId && r.filePath === filePath;
|
|
301
|
+
const record = await findJsonLine(getFilePath$1(sessionId), JSON.stringify(callId), match) ?? await findInJsonArrayFile(getLegacyFilePath$1(sessionId), match);
|
|
273
302
|
if (!record) return null;
|
|
274
303
|
return { diff: record.diff, additions: record.additions, deletions: record.deletions };
|
|
275
304
|
} catch (error) {
|
|
@@ -279,39 +308,22 @@ function getDiffDetail(sessionId, callId, filePath) {
|
|
|
279
308
|
}
|
|
280
309
|
|
|
281
310
|
const toolOutputsDir = path.join(logger.configuration.happyHomeDir, "tool-outputs");
|
|
282
|
-
function ensureToolOutputsDir() {
|
|
283
|
-
if (!fs.existsSync(toolOutputsDir)) {
|
|
284
|
-
fs.mkdirSync(toolOutputsDir, { recursive: true });
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
311
|
function getFilePath(sessionId) {
|
|
312
|
+
return path.join(toolOutputsDir, `${sessionId}.jsonl`);
|
|
313
|
+
}
|
|
314
|
+
function getLegacyFilePath(sessionId) {
|
|
288
315
|
return path.join(toolOutputsDir, `${sessionId}.json`);
|
|
289
316
|
}
|
|
290
317
|
function saveToolOutputRecord(sessionId, record) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (fs.existsSync(filePath)) {
|
|
296
|
-
try {
|
|
297
|
-
existing = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
298
|
-
} catch {
|
|
299
|
-
existing = [];
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
existing.push(record);
|
|
303
|
-
fs.writeFileSync(filePath, JSON.stringify(existing), "utf-8");
|
|
304
|
-
logger.logger.debug(`[ToolOutputStore] Saved output for ${record.toolName} (${record.callId}) in session ${sessionId}`);
|
|
305
|
-
} catch (error) {
|
|
306
|
-
logger.logger.warn("[ToolOutputStore] Failed to save tool output record:", error);
|
|
307
|
-
}
|
|
318
|
+
appendJsonLines(getFilePath(sessionId), [record]).then(
|
|
319
|
+
() => logger.logger.debug(`[ToolOutputStore] Saved output for ${record.toolName} (${record.callId}) in session ${sessionId}`),
|
|
320
|
+
(error) => logger.logger.warn("[ToolOutputStore] Failed to save tool output record:", error)
|
|
321
|
+
);
|
|
308
322
|
}
|
|
309
|
-
function getToolOutputRecord(sessionId, callId) {
|
|
323
|
+
async function getToolOutputRecord(sessionId, callId) {
|
|
310
324
|
try {
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
const records = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
314
|
-
return records.find((record) => record.callId === callId) || null;
|
|
325
|
+
const match = (record) => record.callId === callId;
|
|
326
|
+
return await findJsonLine(getFilePath(sessionId), JSON.stringify(callId), match) ?? await findInJsonArrayFile(getLegacyFilePath(sessionId), match);
|
|
315
327
|
} catch (error) {
|
|
316
328
|
logger.logger.warn("[ToolOutputStore] Failed to get tool output record:", error);
|
|
317
329
|
return null;
|
|
@@ -1395,7 +1407,7 @@ function resolveToolsDir() {
|
|
|
1395
1407
|
}
|
|
1396
1408
|
function findToolsDir() {
|
|
1397
1409
|
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-
|
|
1410
|
+
const manifest = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('api-BGc484qf.cjs', document.baseURI).href))).resolve(`${toolsPackageName()}/package.json`);
|
|
1399
1411
|
return path.dirname(manifest);
|
|
1400
1412
|
} catch {
|
|
1401
1413
|
}
|
|
@@ -2247,7 +2259,7 @@ function registerCommonHandlers(rpcHandlerManager, workingDirectory, sessionId)
|
|
|
2247
2259
|
if (sessionId) {
|
|
2248
2260
|
rpcHandlerManager.registerHandler("getDiffDetail", async (data) => {
|
|
2249
2261
|
logger.logger.debug("getDiffDetail request:", data.callId, data.filePath);
|
|
2250
|
-
const result = getDiffDetail(sessionId, data.callId, data.filePath);
|
|
2262
|
+
const result = await getDiffDetail(sessionId, data.callId, data.filePath);
|
|
2251
2263
|
if (!result) {
|
|
2252
2264
|
return { success: false, error: "not_found" };
|
|
2253
2265
|
}
|
|
@@ -2260,7 +2272,7 @@ function registerCommonHandlers(rpcHandlerManager, workingDirectory, sessionId)
|
|
|
2260
2272
|
});
|
|
2261
2273
|
rpcHandlerManager.registerHandler("getToolOutput", async (data) => {
|
|
2262
2274
|
logger.logger.debug("getToolOutput request:", data.callId);
|
|
2263
|
-
const record = getToolOutputRecord(sessionId, data.callId);
|
|
2275
|
+
const record = await getToolOutputRecord(sessionId, data.callId);
|
|
2264
2276
|
if (!record) {
|
|
2265
2277
|
return { success: false, error: "not_found" };
|
|
2266
2278
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var logger = require('./persistence-
|
|
3
|
+
var logger = require('./persistence-CNXsXPLm.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-
|
|
9
|
+
var browser = require('./browser-CnxzD1lA.cjs');
|
|
10
10
|
var React = require('react');
|
|
11
11
|
var ink = require('ink');
|
|
12
12
|
require('node:fs/promises');
|
|
@@ -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-
|
|
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-IdEuIeMz.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-
|
|
7
|
+
import { o as openBrowser } from './browser-CkQP96Zi.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-
|
|
5
|
-
var auth = require('./auth-
|
|
4
|
+
var logger = require('./persistence-CNXsXPLm.cjs');
|
|
5
|
+
var auth = require('./auth-B6vskzfm.cjs');
|
|
6
6
|
var fs = require('node:fs');
|
|
7
7
|
var node_readline = require('node:readline');
|
|
8
|
-
var controlClient = require('./controlClient-
|
|
8
|
+
var controlClient = require('./controlClient-DWBW6jRF.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-
|
|
19
|
+
require('./browser-CnxzD1lA.cjs');
|
|
20
20
|
require('open');
|
|
21
21
|
require('react');
|
|
22
22
|
require('ink');
|
|
@@ -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-
|
|
3
|
-
import { authAndSetupMachineIfNeeded } from './auth-
|
|
2
|
+
import { r as readCredentials, a as readSettings, c as configuration, l as logger, b as clearCredentials, d as clearMachineId } from './persistence-IdEuIeMz.mjs';
|
|
3
|
+
import { authAndSetupMachineIfNeeded } from './auth-BnEa31tI.mjs';
|
|
4
4
|
import { existsSync, rmSync } from 'node:fs';
|
|
5
5
|
import { createInterface } from 'node:readline';
|
|
6
|
-
import { checkIfDaemonRunningAndCleanupStaleState, stopDaemon } from './controlClient-
|
|
6
|
+
import { checkIfDaemonRunningAndCleanupStaleState, stopDaemon } from './controlClient-VY0CGL8k.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-
|
|
17
|
+
import './browser-CkQP96Zi.mjs';
|
|
18
18
|
import 'open';
|
|
19
19
|
import 'react';
|
|
20
20
|
import 'ink';
|
|
@@ -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-
|
|
6
|
+
import { l as logger } from './persistence-IdEuIeMz.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-
|
|
8
|
+
var logger = require('./persistence-CNXsXPLm.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-
|
|
5
|
+
import { l as logger } from './persistence-IdEuIeMz.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-
|
|
7
|
+
var logger = require('./persistence-CNXsXPLm.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-
|
|
6
|
-
import { A as ApiClient } from './api-
|
|
5
|
+
import { r as readCredentials } from './persistence-IdEuIeMz.mjs';
|
|
6
|
+
import { A as ApiClient } from './api-9wvM_aF-.mjs';
|
|
7
7
|
import { createServer } from 'http';
|
|
8
8
|
import { randomBytes, createHash } from 'crypto';
|
|
9
|
-
import { o as openBrowser } from './browser-
|
|
9
|
+
import { o as openBrowser } from './browser-CkQP96Zi.mjs';
|
|
10
10
|
import { exec } from 'child_process';
|
|
11
11
|
import { promisify } from 'util';
|
|
12
12
|
import 'node:fs/promises';
|
|
@@ -22,6 +22,7 @@ import 'socket.io-client';
|
|
|
22
22
|
import './index-7P6T8CE4.mjs';
|
|
23
23
|
import '@paralleldrive/cuid2';
|
|
24
24
|
import './time-DgsBLJA_.mjs';
|
|
25
|
+
import 'node:readline';
|
|
25
26
|
import 'node:child_process';
|
|
26
27
|
import 'node:util';
|
|
27
28
|
import 'fs/promises';
|
|
@@ -30,9 +31,8 @@ import 'url';
|
|
|
30
31
|
import 'node:module';
|
|
31
32
|
import 'ws';
|
|
32
33
|
import '@stablelib/base64';
|
|
33
|
-
import 'node:readline';
|
|
34
34
|
import 'expo-server-sdk';
|
|
35
|
-
import './sessionKeyCache-
|
|
35
|
+
import './sessionKeyCache-DDzTs7E5.mjs';
|
|
36
36
|
import 'open';
|
|
37
37
|
|
|
38
38
|
const CLIENT_ID$2 = "app_EMoamEEZ73f0CkXaXp7hrann";
|