happy-imou-cloud 2.0.2 → 2.0.4
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/{BaseReasoningProcessor-B6tJ_eL5.cjs → BaseReasoningProcessor-DEEfNi5Y.cjs} +4 -4
- package/dist/{BaseReasoningProcessor-D8VhEbs2.mjs → BaseReasoningProcessor-Di1yEMMv.mjs} +2 -2
- package/dist/{api-MYhAGPLn.mjs → api-CIHTNilH.mjs} +2 -2
- package/dist/{api-D2Njw9Im.cjs → api-CyJG1mr6.cjs} +43 -43
- package/dist/{command-nmK6O-ab.mjs → command-BERqmFB0.mjs} +3 -3
- package/dist/{command-CVldr51S.cjs → command-CPlJKXDn.cjs} +3 -3
- package/dist/{index-Bg-YziG2.cjs → index-1zlH6s7a.cjs} +313 -118
- package/dist/{index-B97L7qLD.mjs → index-vNYxNqVZ.mjs} +226 -31
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-D_2GkJAO.cjs → persistence-BeFVx6kI.cjs} +28 -28
- package/dist/{persistence-Dkm7rm8k.mjs → persistence-sLEqV8vk.mjs} +1 -1
- package/dist/{registerKillSessionHandler-BAXmJQRt.cjs → registerKillSessionHandler-CCxqGFjZ.cjs} +2 -2
- package/dist/{registerKillSessionHandler-5GbrO0FM.mjs → registerKillSessionHandler-uVHqIC4h.mjs} +2 -2
- package/dist/{runClaude-Cii3R2Fv.mjs → runClaude-Dl9nIRIg.mjs} +25 -5
- package/dist/{runClaude-B-GNEkKg.cjs → runClaude-Dz-PCSvb.cjs} +53 -33
- package/dist/{runCodex-CPHyGwj9.cjs → runCodex-BtZplK1R.cjs} +275 -408
- package/dist/{runCodex-C--ZwAhl.mjs → runCodex-DgKKw3IU.mjs} +273 -409
- package/dist/{runGemini-CQp7Nuzn.mjs → runGemini-CM1v3I24.mjs} +10 -8
- package/dist/{runGemini-DaDz1bzQ.cjs → runGemini-DUyH311Z.cjs} +10 -8
- package/package.json +1 -1
- package/dist/future-Dq4Ha1Dn.cjs +0 -24
- package/dist/future-xRdLl3vf.mjs +0 -22
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var promises = require('node:fs/promises');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var api = require('./api-
|
|
4
|
+
var node_fs = require('node:fs');
|
|
5
|
+
var node_path = require('node:path');
|
|
6
|
+
var api = require('./api-CyJG1mr6.cjs');
|
|
7
7
|
var z = require('zod');
|
|
8
8
|
require('axios');
|
|
9
9
|
require('chalk');
|
|
@@ -169,7 +169,7 @@ function migrateSettings(raw, fromVersion) {
|
|
|
169
169
|
return migrated;
|
|
170
170
|
}
|
|
171
171
|
async function readSettings() {
|
|
172
|
-
if (!
|
|
172
|
+
if (!node_fs.existsSync(api.configuration.settingsFile)) {
|
|
173
173
|
return { ...defaultSettings };
|
|
174
174
|
}
|
|
175
175
|
try {
|
|
@@ -212,7 +212,7 @@ async function updateSettings(updater) {
|
|
|
212
212
|
const tmpFile = `${api.configuration.settingsFile}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
213
213
|
let fileHandle;
|
|
214
214
|
let attempts = 0;
|
|
215
|
-
if (!
|
|
215
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
216
216
|
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
217
217
|
}
|
|
218
218
|
async function removeFileWithRetry(path) {
|
|
@@ -233,7 +233,7 @@ async function updateSettings(updater) {
|
|
|
233
233
|
}
|
|
234
234
|
while (attempts < MAX_LOCK_ATTEMPTS) {
|
|
235
235
|
try {
|
|
236
|
-
fileHandle = await promises.open(lockFile,
|
|
236
|
+
fileHandle = await promises.open(lockFile, node_fs.constants.O_CREAT | node_fs.constants.O_EXCL | node_fs.constants.O_WRONLY);
|
|
237
237
|
break;
|
|
238
238
|
} catch (err) {
|
|
239
239
|
if (LOCK_CONTENTION_CODES.has(err?.code)) {
|
|
@@ -258,14 +258,14 @@ async function updateSettings(updater) {
|
|
|
258
258
|
try {
|
|
259
259
|
const current = await readSettings() || { ...defaultSettings };
|
|
260
260
|
const updated = await updater(current);
|
|
261
|
-
if (!
|
|
261
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
262
262
|
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
263
263
|
}
|
|
264
264
|
await promises.writeFile(tmpFile, JSON.stringify(updated, null, 2));
|
|
265
265
|
await promises.rename(tmpFile, api.configuration.settingsFile);
|
|
266
266
|
return updated;
|
|
267
267
|
} finally {
|
|
268
|
-
if (
|
|
268
|
+
if (node_fs.existsSync(tmpFile)) {
|
|
269
269
|
await removeFileWithRetry(tmpFile).catch(() => {
|
|
270
270
|
});
|
|
271
271
|
}
|
|
@@ -291,7 +291,7 @@ const credentialsSchema = z__namespace.object({
|
|
|
291
291
|
}).nullish()
|
|
292
292
|
});
|
|
293
293
|
async function readCredentials() {
|
|
294
|
-
if (!
|
|
294
|
+
if (!node_fs.existsSync(api.configuration.privateKeyFile)) {
|
|
295
295
|
return null;
|
|
296
296
|
}
|
|
297
297
|
try {
|
|
@@ -323,7 +323,7 @@ async function readCredentials() {
|
|
|
323
323
|
return null;
|
|
324
324
|
}
|
|
325
325
|
async function writeCredentialsLegacy(credentials) {
|
|
326
|
-
if (!
|
|
326
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
327
327
|
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
328
328
|
}
|
|
329
329
|
await promises.writeFile(api.configuration.privateKeyFile, JSON.stringify({
|
|
@@ -333,7 +333,7 @@ async function writeCredentialsLegacy(credentials) {
|
|
|
333
333
|
}, null, 2));
|
|
334
334
|
}
|
|
335
335
|
async function writeCredentialsDataKey(credentials) {
|
|
336
|
-
if (!
|
|
336
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
337
337
|
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
338
338
|
}
|
|
339
339
|
await promises.writeFile(api.configuration.privateKeyFile, JSON.stringify({
|
|
@@ -343,7 +343,7 @@ async function writeCredentialsDataKey(credentials) {
|
|
|
343
343
|
}, null, 2));
|
|
344
344
|
}
|
|
345
345
|
async function clearCredentials() {
|
|
346
|
-
if (
|
|
346
|
+
if (node_fs.existsSync(api.configuration.privateKeyFile)) {
|
|
347
347
|
await promises.unlink(api.configuration.privateKeyFile);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
@@ -355,7 +355,7 @@ async function clearMachineId() {
|
|
|
355
355
|
}
|
|
356
356
|
async function readDaemonState() {
|
|
357
357
|
try {
|
|
358
|
-
if (!
|
|
358
|
+
if (!node_fs.existsSync(api.configuration.daemonStateFile)) {
|
|
359
359
|
return null;
|
|
360
360
|
}
|
|
361
361
|
const content = await promises.readFile(api.configuration.daemonStateFile, "utf-8");
|
|
@@ -366,13 +366,13 @@ async function readDaemonState() {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
function writeDaemonState(state) {
|
|
369
|
-
|
|
369
|
+
node_fs.writeFileSync(api.configuration.daemonStateFile, JSON.stringify(state, null, 2), "utf-8");
|
|
370
370
|
}
|
|
371
371
|
async function clearDaemonState() {
|
|
372
|
-
if (
|
|
372
|
+
if (node_fs.existsSync(api.configuration.daemonStateFile)) {
|
|
373
373
|
await promises.unlink(api.configuration.daemonStateFile);
|
|
374
374
|
}
|
|
375
|
-
if (
|
|
375
|
+
if (node_fs.existsSync(api.configuration.daemonLockFile)) {
|
|
376
376
|
try {
|
|
377
377
|
await promises.unlink(api.configuration.daemonLockFile);
|
|
378
378
|
} catch {
|
|
@@ -381,7 +381,7 @@ async function clearDaemonState() {
|
|
|
381
381
|
}
|
|
382
382
|
async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
383
383
|
const lockFileName = `daemon.lock.${process.pid}.${Date.now()}`;
|
|
384
|
-
const lockFile =
|
|
384
|
+
const lockFile = node_path.join(node_path.dirname(api.configuration.daemonLockFile), lockFileName);
|
|
385
385
|
api.logger.debug(`[ACQUIRE LOCK] Attempting to acquire lock: ${lockFile}`);
|
|
386
386
|
api.logger.debug(`[ACQUIRE LOCK] Platform: ${process.platform}, PID: ${process.pid}`);
|
|
387
387
|
const isPidAlive = (pid) => {
|
|
@@ -394,8 +394,8 @@ async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
|
394
394
|
};
|
|
395
395
|
const readLockPid = () => {
|
|
396
396
|
try {
|
|
397
|
-
if (
|
|
398
|
-
const content =
|
|
397
|
+
if (node_fs.existsSync(lockFile)) {
|
|
398
|
+
const content = node_fs.readFileSync(lockFile, "utf-8").trim();
|
|
399
399
|
const pid = parseInt(content, 10);
|
|
400
400
|
if (!isNaN(pid) && pid > 0) {
|
|
401
401
|
return pid;
|
|
@@ -406,7 +406,7 @@ async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
|
406
406
|
return null;
|
|
407
407
|
};
|
|
408
408
|
const writeLockPid = (pid) => {
|
|
409
|
-
|
|
409
|
+
node_fs.writeFileSync(lockFile, String(pid), "utf-8");
|
|
410
410
|
};
|
|
411
411
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
412
412
|
api.logger.debug(`[ACQUIRE LOCK] Attempt ${attempt}/${maxAttempts}`);
|
|
@@ -423,9 +423,9 @@ async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
|
423
423
|
api.logger.debug(`[ACQUIRE LOCK] No existing lock file`);
|
|
424
424
|
}
|
|
425
425
|
try {
|
|
426
|
-
if (
|
|
426
|
+
if (node_fs.existsSync(lockFile)) {
|
|
427
427
|
try {
|
|
428
|
-
|
|
428
|
+
node_fs.unlinkSync(lockFile);
|
|
429
429
|
api.logger.debug(`[ACQUIRE LOCK] Removed existing lock file`);
|
|
430
430
|
} catch (unlinkError) {
|
|
431
431
|
api.logger.debug(`[ACQUIRE LOCK] Could not remove lock file, trying anyway`);
|
|
@@ -472,17 +472,17 @@ async function releaseDaemonLock(lockHandle) {
|
|
|
472
472
|
} catch {
|
|
473
473
|
}
|
|
474
474
|
try {
|
|
475
|
-
if (
|
|
476
|
-
|
|
475
|
+
if (node_fs.existsSync(api.configuration.daemonLockFile)) {
|
|
476
|
+
node_fs.unlinkSync(api.configuration.daemonLockFile);
|
|
477
477
|
api.logger.debug(`[RELEASE LOCK] Released daemon lock`);
|
|
478
478
|
}
|
|
479
|
-
const lockDir =
|
|
479
|
+
const lockDir = node_path.dirname(api.configuration.daemonLockFile);
|
|
480
480
|
try {
|
|
481
|
-
const files =
|
|
481
|
+
const files = node_fs.readdirSync(lockDir);
|
|
482
482
|
for (const file of files) {
|
|
483
483
|
if (file.startsWith("daemon.lock.") && file.includes(`.${process.pid}.`)) {
|
|
484
|
-
const lockPath =
|
|
485
|
-
|
|
484
|
+
const lockPath = node_path.join(lockDir, file);
|
|
485
|
+
node_fs.unlinkSync(lockPath);
|
|
486
486
|
api.logger.debug(`[RELEASE LOCK] Released lock: ${file}`);
|
|
487
487
|
}
|
|
488
488
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, unlink, mkdir, open, stat, writeFile, rename } from 'node:fs/promises';
|
|
2
2
|
import { existsSync, unlinkSync, writeFileSync, readdirSync, readFileSync, constants } from 'node:fs';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
|
-
import { c as configuration, l as logger, e as encodeBase64 } from './api-
|
|
4
|
+
import { c as configuration, l as logger, e as encodeBase64 } from './api-CIHTNilH.mjs';
|
|
5
5
|
import * as z from 'zod';
|
|
6
6
|
import 'axios';
|
|
7
7
|
import 'chalk';
|
package/dist/{registerKillSessionHandler-BAXmJQRt.cjs → registerKillSessionHandler-CCxqGFjZ.cjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var api = require('./api-
|
|
3
|
+
var index = require('./index-1zlH6s7a.cjs');
|
|
4
|
+
var api = require('./api-CyJG1mr6.cjs');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
require('axios');
|
|
7
7
|
require('node:events');
|
package/dist/{registerKillSessionHandler-5GbrO0FM.mjs → registerKillSessionHandler-uVHqIC4h.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as formatDisplayMessage } from './index-
|
|
2
|
-
import { l as logger } from './api-
|
|
1
|
+
import { f as formatDisplayMessage } from './index-vNYxNqVZ.mjs';
|
|
2
|
+
import { l as logger } from './api-CIHTNilH.mjs';
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import 'node:events';
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import os, { homedir } from 'node:os';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import { l as logger, d as backoff, f as delay, g as AsyncLock, c as configuration, b as connectionState, A as ApiClient, p as packageJson, i as isAuthenticationRequiredError, s as startOfflineReconnection } from './api-
|
|
4
|
-
import { e as getProjectPath, h as claudeLocal, E as ExitCodeError, j as isBun, k as trimIdent, l as claudeCheckSession, p as projectPath, m as getEnvironmentInfo, i as initialMachineMetadata, b as stopCaffeinate, n as notifyDaemonSessionStarted, o as startCaffeinate } from './index-
|
|
5
|
-
import { F as Future } from './future-xRdLl3vf.mjs';
|
|
3
|
+
import { l as logger, d as backoff, f as delay, g as AsyncLock, c as configuration, b as connectionState, A as ApiClient, p as packageJson, i as isAuthenticationRequiredError, s as startOfflineReconnection } from './api-CIHTNilH.mjs';
|
|
4
|
+
import { e as getProjectPath, h as claudeLocal, E as ExitCodeError, j as isBun, k as trimIdent, l as claudeCheckSession, p as projectPath, m as getEnvironmentInfo, i as initialMachineMetadata, b as stopCaffeinate, n as notifyDaemonSessionStarted, o as startCaffeinate } from './index-vNYxNqVZ.mjs';
|
|
6
5
|
import { R as RawJSONLinesSchema } from './types-CiliQpqS.mjs';
|
|
7
6
|
import { dirname, basename, join, resolve } from 'node:path';
|
|
8
7
|
import { readFile } from 'node:fs/promises';
|
|
9
8
|
import { stat, watch, access } from 'fs/promises';
|
|
10
9
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
11
|
-
import { a as MessageBuffer, M as MessageQueue2, h as hashObject, r as registerKillSessionHandler } from './registerKillSessionHandler-
|
|
10
|
+
import { a as MessageBuffer, M as MessageQueue2, h as hashObject, r as registerKillSessionHandler } from './registerKillSessionHandler-uVHqIC4h.mjs';
|
|
12
11
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
13
12
|
import { execSync, spawn } from 'node:child_process';
|
|
14
13
|
import { createInterface } from 'node:readline';
|
|
@@ -21,7 +20,7 @@ import 'tweetnacl';
|
|
|
21
20
|
import 'expo-server-sdk';
|
|
22
21
|
import 'chalk';
|
|
23
22
|
import { isDeepStrictEqual } from 'node:util';
|
|
24
|
-
import { readSettings } from './persistence-
|
|
23
|
+
import { readSettings } from './persistence-sLEqV8vk.mjs';
|
|
25
24
|
import { createServer } from 'node:http';
|
|
26
25
|
import 'fs';
|
|
27
26
|
import 'zod';
|
|
@@ -199,6 +198,27 @@ class Session {
|
|
|
199
198
|
};
|
|
200
199
|
}
|
|
201
200
|
|
|
201
|
+
class Future {
|
|
202
|
+
_resolve;
|
|
203
|
+
_reject;
|
|
204
|
+
_promise;
|
|
205
|
+
constructor() {
|
|
206
|
+
this._promise = new Promise((resolve, reject) => {
|
|
207
|
+
this._resolve = resolve;
|
|
208
|
+
this._reject = reject;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
resolve(value) {
|
|
212
|
+
this._resolve(value);
|
|
213
|
+
}
|
|
214
|
+
reject(reason) {
|
|
215
|
+
this._reject(reason);
|
|
216
|
+
}
|
|
217
|
+
get promise() {
|
|
218
|
+
return this._promise;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
202
222
|
class InvalidateSync {
|
|
203
223
|
_invalidated = false;
|
|
204
224
|
_invalidatedDouble = false;
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var os = require('node:os');
|
|
4
4
|
var node_crypto = require('node:crypto');
|
|
5
|
-
var api = require('./api-
|
|
6
|
-
var index = require('./index-
|
|
7
|
-
var future = require('./future-Dq4Ha1Dn.cjs');
|
|
5
|
+
var api = require('./api-CyJG1mr6.cjs');
|
|
6
|
+
var index = require('./index-1zlH6s7a.cjs');
|
|
8
7
|
var types = require('./types-DVk3crez.cjs');
|
|
9
|
-
var
|
|
8
|
+
var node_path = require('node:path');
|
|
10
9
|
var promises = require('node:fs/promises');
|
|
11
10
|
var fs = require('fs/promises');
|
|
12
11
|
var ink = require('ink');
|
|
13
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
12
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-CCxqGFjZ.cjs');
|
|
14
13
|
var React = require('react');
|
|
15
14
|
var node_child_process = require('node:child_process');
|
|
16
15
|
var node_readline = require('node:readline');
|
|
17
|
-
var
|
|
16
|
+
var node_fs = require('node:fs');
|
|
18
17
|
var node_url = require('node:url');
|
|
19
18
|
require('axios');
|
|
20
19
|
require('node:events');
|
|
@@ -23,7 +22,7 @@ require('tweetnacl');
|
|
|
23
22
|
require('expo-server-sdk');
|
|
24
23
|
require('chalk');
|
|
25
24
|
var node_util = require('node:util');
|
|
26
|
-
var persistence = require('./persistence-
|
|
25
|
+
var persistence = require('./persistence-BeFVx6kI.cjs');
|
|
27
26
|
var node_http = require('node:http');
|
|
28
27
|
require('fs');
|
|
29
28
|
require('zod');
|
|
@@ -202,6 +201,27 @@ class Session {
|
|
|
202
201
|
};
|
|
203
202
|
}
|
|
204
203
|
|
|
204
|
+
class Future {
|
|
205
|
+
_resolve;
|
|
206
|
+
_reject;
|
|
207
|
+
_promise;
|
|
208
|
+
constructor() {
|
|
209
|
+
this._promise = new Promise((resolve, reject) => {
|
|
210
|
+
this._resolve = resolve;
|
|
211
|
+
this._reject = reject;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
resolve(value) {
|
|
215
|
+
this._resolve(value);
|
|
216
|
+
}
|
|
217
|
+
reject(reason) {
|
|
218
|
+
this._reject(reason);
|
|
219
|
+
}
|
|
220
|
+
get promise() {
|
|
221
|
+
return this._promise;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
205
225
|
class InvalidateSync {
|
|
206
226
|
_invalidated = false;
|
|
207
227
|
_invalidatedDouble = false;
|
|
@@ -270,8 +290,8 @@ class InvalidateSync {
|
|
|
270
290
|
|
|
271
291
|
function startFileWatcher(file, onFileChange) {
|
|
272
292
|
const abortController = new AbortController();
|
|
273
|
-
const parentDir =
|
|
274
|
-
const targetName =
|
|
293
|
+
const parentDir = node_path.dirname(file);
|
|
294
|
+
const targetName = node_path.basename(file);
|
|
275
295
|
void (async () => {
|
|
276
296
|
while (true) {
|
|
277
297
|
try {
|
|
@@ -355,7 +375,7 @@ async function createSessionScanner(opts) {
|
|
|
355
375
|
}
|
|
356
376
|
function getSessionFilePath(sessionId) {
|
|
357
377
|
const override = sessionFileOverrides.get(sessionId);
|
|
358
|
-
return override ??
|
|
378
|
+
return override ?? node_path.join(effectiveProjectDir(), `${sessionId}.jsonl`);
|
|
359
379
|
}
|
|
360
380
|
function scheduleTranscriptMissingWarning(sessionId) {
|
|
361
381
|
if (!opts.onTranscriptMissing) {
|
|
@@ -395,7 +415,7 @@ async function createSessionScanner(opts) {
|
|
|
395
415
|
if (opts.sessionId && typeof opts.transcriptPath === "string" && opts.transcriptPath.trim()) {
|
|
396
416
|
const transcriptPath = opts.transcriptPath.trim();
|
|
397
417
|
sessionFileOverrides.set(opts.sessionId, transcriptPath);
|
|
398
|
-
projectDirOverride =
|
|
418
|
+
projectDirOverride = node_path.dirname(transcriptPath);
|
|
399
419
|
}
|
|
400
420
|
if (opts.sessionId) {
|
|
401
421
|
let messages = await readSessionLog(getSessionFilePath(opts.sessionId));
|
|
@@ -498,7 +518,7 @@ async function createSessionScanner(opts) {
|
|
|
498
518
|
sessionFileOverrides.set(sessionId, transcriptPath);
|
|
499
519
|
didUpdatePaths = true;
|
|
500
520
|
}
|
|
501
|
-
const nextProjectDir =
|
|
521
|
+
const nextProjectDir = node_path.dirname(transcriptPath);
|
|
502
522
|
if (projectDirOverride !== nextProjectDir) {
|
|
503
523
|
projectDirOverride = nextProjectDir;
|
|
504
524
|
didUpdatePaths = true;
|
|
@@ -610,7 +630,7 @@ async function claudeLocalLauncher(session) {
|
|
|
610
630
|
session.addSessionFoundCallback(scannerSessionCallback);
|
|
611
631
|
let exitReason = null;
|
|
612
632
|
const processAbortController = new AbortController();
|
|
613
|
-
let exutFuture = new
|
|
633
|
+
let exutFuture = new Future();
|
|
614
634
|
try {
|
|
615
635
|
async function abort() {
|
|
616
636
|
if (!processAbortController.signal.aborted) {
|
|
@@ -917,8 +937,8 @@ class AbortError extends Error {
|
|
|
917
937
|
}
|
|
918
938
|
}
|
|
919
939
|
|
|
920
|
-
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('runClaude-
|
|
921
|
-
const __dirname$1 =
|
|
940
|
+
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('runClaude-Dz-PCSvb.cjs', document.baseURI).href)));
|
|
941
|
+
const __dirname$1 = node_path.join(__filename$1, "..");
|
|
922
942
|
function getGlobalClaudeVersion() {
|
|
923
943
|
try {
|
|
924
944
|
const cleanEnv = getCleanEnv();
|
|
@@ -982,7 +1002,7 @@ function findGlobalClaudePath() {
|
|
|
982
1002
|
cwd: homeDir,
|
|
983
1003
|
env: cleanEnv
|
|
984
1004
|
}).trim();
|
|
985
|
-
if (result &&
|
|
1005
|
+
if (result && node_fs.existsSync(result)) {
|
|
986
1006
|
api.logger.debug(`[Claude SDK] Found global claude path via which: ${result}`);
|
|
987
1007
|
return result;
|
|
988
1008
|
}
|
|
@@ -992,7 +1012,7 @@ function findGlobalClaudePath() {
|
|
|
992
1012
|
return null;
|
|
993
1013
|
}
|
|
994
1014
|
function getDefaultClaudeCodePath() {
|
|
995
|
-
const nodeModulesPath =
|
|
1015
|
+
const nodeModulesPath = node_path.join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
|
|
996
1016
|
if (process.env.HAPPY_CLAUDE_PATH) {
|
|
997
1017
|
api.logger.debug(`[Claude SDK] Using HAPPY_CLAUDE_PATH: ${process.env.HAPPY_CLAUDE_PATH}`);
|
|
998
1018
|
return process.env.HAPPY_CLAUDE_PATH;
|
|
@@ -1281,7 +1301,7 @@ function query(config) {
|
|
|
1281
1301
|
}
|
|
1282
1302
|
const isJsFile = pathToClaudeCodeExecutable.endsWith(".js") || pathToClaudeCodeExecutable.endsWith(".cjs");
|
|
1283
1303
|
const isCommandOnly = pathToClaudeCodeExecutable === "claude";
|
|
1284
|
-
if (!isCommandOnly && !
|
|
1304
|
+
if (!isCommandOnly && !node_fs.existsSync(pathToClaudeCodeExecutable)) {
|
|
1285
1305
|
throw new ReferenceError(`Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`);
|
|
1286
1306
|
}
|
|
1287
1307
|
const spawnCommand = isJsFile ? executable : pathToClaudeCodeExecutable;
|
|
@@ -1538,17 +1558,17 @@ async function awaitFileExist(file, timeout = 1e4) {
|
|
|
1538
1558
|
}
|
|
1539
1559
|
|
|
1540
1560
|
function getClaudeSettingsPath() {
|
|
1541
|
-
const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
1542
|
-
return
|
|
1561
|
+
const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR || node_path.join(os.homedir(), ".claude");
|
|
1562
|
+
return node_path.join(claudeConfigDir, "settings.json");
|
|
1543
1563
|
}
|
|
1544
1564
|
function readClaudeSettings() {
|
|
1545
1565
|
try {
|
|
1546
1566
|
const settingsPath = getClaudeSettingsPath();
|
|
1547
|
-
if (!
|
|
1567
|
+
if (!node_fs.existsSync(settingsPath)) {
|
|
1548
1568
|
api.logger.debug(`[ClaudeSettings] No Claude settings file found at ${settingsPath}`);
|
|
1549
1569
|
return null;
|
|
1550
1570
|
}
|
|
1551
|
-
const settingsContent =
|
|
1571
|
+
const settingsContent = node_fs.readFileSync(settingsPath, "utf-8");
|
|
1552
1572
|
const settings = JSON.parse(settingsContent);
|
|
1553
1573
|
api.logger.debug(`[ClaudeSettings] Successfully read Claude settings from ${settingsPath}`);
|
|
1554
1574
|
api.logger.debug(`[ClaudeSettings] includeCoAuthoredBy: ${settings.includeCoAuthoredBy}`);
|
|
@@ -1657,7 +1677,7 @@ async function claudeRemote(opts) {
|
|
|
1657
1677
|
executable: opts.jsRuntime ?? "node",
|
|
1658
1678
|
abort: opts.signal,
|
|
1659
1679
|
pathToClaudeCodeExecutable: (() => {
|
|
1660
|
-
return
|
|
1680
|
+
return node_path.resolve(node_path.join(index.projectPath(), "scripts", "claude_remote_launcher.cjs"));
|
|
1661
1681
|
})(),
|
|
1662
1682
|
settingsPath: opts.hookSettingsPath
|
|
1663
1683
|
};
|
|
@@ -1693,7 +1713,7 @@ async function claudeRemote(opts) {
|
|
|
1693
1713
|
updateThinking(true);
|
|
1694
1714
|
const systemInit = message;
|
|
1695
1715
|
if (systemInit.session_id) {
|
|
1696
|
-
const transcriptPath = opts.transcriptPath && opts.sessionId === systemInit.session_id ? opts.transcriptPath :
|
|
1716
|
+
const transcriptPath = opts.transcriptPath && opts.sessionId === systemInit.session_id ? opts.transcriptPath : node_path.join(index.getProjectPath(opts.path), `${systemInit.session_id}.jsonl`);
|
|
1697
1717
|
api.logger.debug(`[claudeRemote] Waiting for session file to be written to disk: ${transcriptPath}`);
|
|
1698
1718
|
const found = await awaitFileExist(transcriptPath);
|
|
1699
1719
|
api.logger.debug(`[claudeRemote] Session file found: ${systemInit.session_id} ${found}`);
|
|
@@ -2807,7 +2827,7 @@ async function claudeRemoteLauncher(session) {
|
|
|
2807
2827
|
previousSessionId = session.sessionId;
|
|
2808
2828
|
const controller = new AbortController();
|
|
2809
2829
|
abortController = controller;
|
|
2810
|
-
abortFuture = new
|
|
2830
|
+
abortFuture = new Future();
|
|
2811
2831
|
let modeHash = null;
|
|
2812
2832
|
let mode = null;
|
|
2813
2833
|
try {
|
|
@@ -3095,11 +3115,11 @@ async function startHookServer(options) {
|
|
|
3095
3115
|
}
|
|
3096
3116
|
|
|
3097
3117
|
function generateHookSettingsFile(port) {
|
|
3098
|
-
const hooksDir =
|
|
3099
|
-
|
|
3118
|
+
const hooksDir = node_path.join(api.configuration.happyCloudHomeDir, "tmp", "hooks");
|
|
3119
|
+
node_fs.mkdirSync(hooksDir, { recursive: true });
|
|
3100
3120
|
const filename = `session-hook-${process.pid}.json`;
|
|
3101
|
-
const filepath =
|
|
3102
|
-
const forwarderScript =
|
|
3121
|
+
const filepath = node_path.join(hooksDir, filename);
|
|
3122
|
+
const forwarderScript = node_path.resolve(index.projectPath(), "scripts", "session_hook_forwarder.cjs");
|
|
3103
3123
|
const hookCommand = `node "${forwarderScript}" ${port}`;
|
|
3104
3124
|
const settings = {
|
|
3105
3125
|
hooks: {
|
|
@@ -3116,14 +3136,14 @@ function generateHookSettingsFile(port) {
|
|
|
3116
3136
|
]
|
|
3117
3137
|
}
|
|
3118
3138
|
};
|
|
3119
|
-
|
|
3139
|
+
node_fs.writeFileSync(filepath, JSON.stringify(settings, null, 2));
|
|
3120
3140
|
api.logger.debug(`[generateHookSettings] Created hook settings file: ${filepath}`);
|
|
3121
3141
|
return filepath;
|
|
3122
3142
|
}
|
|
3123
3143
|
function cleanupHookSettingsFile(filepath) {
|
|
3124
3144
|
try {
|
|
3125
|
-
if (
|
|
3126
|
-
|
|
3145
|
+
if (node_fs.existsSync(filepath)) {
|
|
3146
|
+
node_fs.unlinkSync(filepath);
|
|
3127
3147
|
api.logger.debug(`[generateHookSettings] Cleaned up hook settings file: ${filepath}`);
|
|
3128
3148
|
}
|
|
3129
3149
|
} catch (error) {
|
|
@@ -3164,7 +3184,7 @@ async function runClaude(credentials, options = {}) {
|
|
|
3164
3184
|
homeDir: os.homedir(),
|
|
3165
3185
|
happyHomeDir: api.configuration.happyCloudHomeDir,
|
|
3166
3186
|
happyLibDir: index.projectPath(),
|
|
3167
|
-
happyToolsDir:
|
|
3187
|
+
happyToolsDir: node_path.resolve(index.projectPath(), "tools", "unpacked"),
|
|
3168
3188
|
startedFromDaemon: options.startedBy === "daemon",
|
|
3169
3189
|
hostPid: process.pid,
|
|
3170
3190
|
startedBy: options.startedBy || "terminal",
|