happy-imou-cloud 2.0.1 → 2.0.3
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-DQE2l7Xu.mjs → BaseReasoningProcessor-B37yOHxo.mjs} +2 -2
- package/dist/{BaseReasoningProcessor-01KqA3Kz.cjs → BaseReasoningProcessor-_wxlqKB8.cjs} +4 -4
- package/dist/{api-B8v4tczT.cjs → api-D9dIR956.cjs} +97 -44
- package/dist/{api-B5Ui8Fw0.mjs → api-DpQIC-DJ.mjs} +56 -3
- package/dist/{command-D8yNlaDo.cjs → command-CdXv1zNF.cjs} +3 -3
- package/dist/{command-BfIuJmeo.mjs → command-DRqrBuHM.mjs} +3 -3
- package/dist/{index-BByhFIIq.mjs → index-CriPm_z9.mjs} +15 -17
- package/dist/{index-BOqJ9hwi.cjs → index-LYPXVO_L.cjs} +98 -100
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +6 -0
- package/dist/lib.d.mts +6 -0
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-CzpZpiL3.mjs → persistence-CqgPgbzN.mjs} +29 -7
- package/dist/{persistence-C33AMdtv.cjs → persistence-PzKU0QCa.cjs} +54 -32
- package/dist/{registerKillSessionHandler-BkzQulD9.cjs → registerKillSessionHandler-BDBPoQSA.cjs} +2 -2
- package/dist/{registerKillSessionHandler-BtSK7IOa.mjs → registerKillSessionHandler-C3M_-4Zg.mjs} +2 -2
- package/dist/{runClaude-C_WLfM6c.mjs → runClaude-D6Pdkevn.mjs} +250 -46
- package/dist/{runClaude-CNVufgZb.cjs → runClaude-IeRSC5qX.cjs} +270 -66
- package/dist/{runCodex-8eWjTPJr.mjs → runCodex-CsfUU1Wb.mjs} +216 -401
- package/dist/{runCodex-Dzy8anlX.cjs → runCodex-WRmgSK6L.cjs} +216 -401
- package/dist/{runGemini-nbr0mm-S.mjs → runGemini-CrH3dQ0Y.mjs} +5 -5
- package/dist/{runGemini-CgsVKP7m.cjs → runGemini-qBh6zs5G.cjs} +5 -5
- package/package.json +1 -2
- package/dist/future-Dq4Ha1Dn.cjs +0 -24
- package/dist/future-xRdLl3vf.mjs +0 -22
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readFile, unlink, open, stat,
|
|
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-DpQIC-DJ.mjs';
|
|
5
5
|
import * as z from 'zod';
|
|
6
6
|
import 'axios';
|
|
7
7
|
import 'chalk';
|
|
@@ -185,16 +185,37 @@ async function updateSettings(updater) {
|
|
|
185
185
|
const LOCK_RETRY_INTERVAL_MS = 100;
|
|
186
186
|
const MAX_LOCK_ATTEMPTS = 50;
|
|
187
187
|
const STALE_LOCK_TIMEOUT_MS = 1e4;
|
|
188
|
+
const LOCK_CONTENTION_CODES = /* @__PURE__ */ new Set(["EEXIST", "EPERM", "EACCES", "EBUSY"]);
|
|
189
|
+
const LOCK_RELEASE_RETRYABLE_CODES = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
188
190
|
const lockFile = configuration.settingsFile + ".lock";
|
|
189
|
-
const tmpFile = `${configuration.settingsFile}.${process.pid}.${Date.now()}.tmp`;
|
|
191
|
+
const tmpFile = `${configuration.settingsFile}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
190
192
|
let fileHandle;
|
|
191
193
|
let attempts = 0;
|
|
194
|
+
if (!existsSync(configuration.happyCloudHomeDir)) {
|
|
195
|
+
await mkdir(configuration.happyCloudHomeDir, { recursive: true });
|
|
196
|
+
}
|
|
197
|
+
async function removeFileWithRetry(path) {
|
|
198
|
+
for (let attempt = 1; attempt <= 20; attempt++) {
|
|
199
|
+
try {
|
|
200
|
+
await unlink(path);
|
|
201
|
+
return;
|
|
202
|
+
} catch (err) {
|
|
203
|
+
if (err?.code === "ENOENT") {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (!LOCK_RELEASE_RETRYABLE_CODES.has(err?.code) || attempt === 20) {
|
|
207
|
+
throw err;
|
|
208
|
+
}
|
|
209
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
192
213
|
while (attempts < MAX_LOCK_ATTEMPTS) {
|
|
193
214
|
try {
|
|
194
215
|
fileHandle = await open(lockFile, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY);
|
|
195
216
|
break;
|
|
196
217
|
} catch (err) {
|
|
197
|
-
if (err
|
|
218
|
+
if (LOCK_CONTENTION_CODES.has(err?.code)) {
|
|
198
219
|
attempts++;
|
|
199
220
|
await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_INTERVAL_MS));
|
|
200
221
|
try {
|
|
@@ -224,11 +245,12 @@ async function updateSettings(updater) {
|
|
|
224
245
|
return updated;
|
|
225
246
|
} finally {
|
|
226
247
|
if (existsSync(tmpFile)) {
|
|
227
|
-
await
|
|
248
|
+
await removeFileWithRetry(tmpFile).catch(() => {
|
|
228
249
|
});
|
|
229
250
|
}
|
|
230
|
-
await fileHandle.close()
|
|
231
|
-
|
|
251
|
+
await fileHandle.close().catch(() => {
|
|
252
|
+
});
|
|
253
|
+
await removeFileWithRetry(lockFile).catch(() => {
|
|
232
254
|
});
|
|
233
255
|
}
|
|
234
256
|
}
|
|
@@ -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-D9dIR956.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 {
|
|
@@ -206,16 +206,37 @@ async function updateSettings(updater) {
|
|
|
206
206
|
const LOCK_RETRY_INTERVAL_MS = 100;
|
|
207
207
|
const MAX_LOCK_ATTEMPTS = 50;
|
|
208
208
|
const STALE_LOCK_TIMEOUT_MS = 1e4;
|
|
209
|
+
const LOCK_CONTENTION_CODES = /* @__PURE__ */ new Set(["EEXIST", "EPERM", "EACCES", "EBUSY"]);
|
|
210
|
+
const LOCK_RELEASE_RETRYABLE_CODES = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
209
211
|
const lockFile = api.configuration.settingsFile + ".lock";
|
|
210
|
-
const tmpFile = `${api.configuration.settingsFile}.${process.pid}.${Date.now()}.tmp`;
|
|
212
|
+
const tmpFile = `${api.configuration.settingsFile}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
211
213
|
let fileHandle;
|
|
212
214
|
let attempts = 0;
|
|
215
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
216
|
+
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
217
|
+
}
|
|
218
|
+
async function removeFileWithRetry(path) {
|
|
219
|
+
for (let attempt = 1; attempt <= 20; attempt++) {
|
|
220
|
+
try {
|
|
221
|
+
await promises.unlink(path);
|
|
222
|
+
return;
|
|
223
|
+
} catch (err) {
|
|
224
|
+
if (err?.code === "ENOENT") {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (!LOCK_RELEASE_RETRYABLE_CODES.has(err?.code) || attempt === 20) {
|
|
228
|
+
throw err;
|
|
229
|
+
}
|
|
230
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
213
234
|
while (attempts < MAX_LOCK_ATTEMPTS) {
|
|
214
235
|
try {
|
|
215
|
-
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);
|
|
216
237
|
break;
|
|
217
238
|
} catch (err) {
|
|
218
|
-
if (err
|
|
239
|
+
if (LOCK_CONTENTION_CODES.has(err?.code)) {
|
|
219
240
|
attempts++;
|
|
220
241
|
await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_INTERVAL_MS));
|
|
221
242
|
try {
|
|
@@ -237,19 +258,20 @@ async function updateSettings(updater) {
|
|
|
237
258
|
try {
|
|
238
259
|
const current = await readSettings() || { ...defaultSettings };
|
|
239
260
|
const updated = await updater(current);
|
|
240
|
-
if (!
|
|
261
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
241
262
|
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
242
263
|
}
|
|
243
264
|
await promises.writeFile(tmpFile, JSON.stringify(updated, null, 2));
|
|
244
265
|
await promises.rename(tmpFile, api.configuration.settingsFile);
|
|
245
266
|
return updated;
|
|
246
267
|
} finally {
|
|
247
|
-
if (
|
|
248
|
-
await
|
|
268
|
+
if (node_fs.existsSync(tmpFile)) {
|
|
269
|
+
await removeFileWithRetry(tmpFile).catch(() => {
|
|
249
270
|
});
|
|
250
271
|
}
|
|
251
|
-
await fileHandle.close()
|
|
252
|
-
|
|
272
|
+
await fileHandle.close().catch(() => {
|
|
273
|
+
});
|
|
274
|
+
await removeFileWithRetry(lockFile).catch(() => {
|
|
253
275
|
});
|
|
254
276
|
}
|
|
255
277
|
}
|
|
@@ -269,7 +291,7 @@ const credentialsSchema = z__namespace.object({
|
|
|
269
291
|
}).nullish()
|
|
270
292
|
});
|
|
271
293
|
async function readCredentials() {
|
|
272
|
-
if (!
|
|
294
|
+
if (!node_fs.existsSync(api.configuration.privateKeyFile)) {
|
|
273
295
|
return null;
|
|
274
296
|
}
|
|
275
297
|
try {
|
|
@@ -301,7 +323,7 @@ async function readCredentials() {
|
|
|
301
323
|
return null;
|
|
302
324
|
}
|
|
303
325
|
async function writeCredentialsLegacy(credentials) {
|
|
304
|
-
if (!
|
|
326
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
305
327
|
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
306
328
|
}
|
|
307
329
|
await promises.writeFile(api.configuration.privateKeyFile, JSON.stringify({
|
|
@@ -311,7 +333,7 @@ async function writeCredentialsLegacy(credentials) {
|
|
|
311
333
|
}, null, 2));
|
|
312
334
|
}
|
|
313
335
|
async function writeCredentialsDataKey(credentials) {
|
|
314
|
-
if (!
|
|
336
|
+
if (!node_fs.existsSync(api.configuration.happyCloudHomeDir)) {
|
|
315
337
|
await promises.mkdir(api.configuration.happyCloudHomeDir, { recursive: true });
|
|
316
338
|
}
|
|
317
339
|
await promises.writeFile(api.configuration.privateKeyFile, JSON.stringify({
|
|
@@ -321,7 +343,7 @@ async function writeCredentialsDataKey(credentials) {
|
|
|
321
343
|
}, null, 2));
|
|
322
344
|
}
|
|
323
345
|
async function clearCredentials() {
|
|
324
|
-
if (
|
|
346
|
+
if (node_fs.existsSync(api.configuration.privateKeyFile)) {
|
|
325
347
|
await promises.unlink(api.configuration.privateKeyFile);
|
|
326
348
|
}
|
|
327
349
|
}
|
|
@@ -333,7 +355,7 @@ async function clearMachineId() {
|
|
|
333
355
|
}
|
|
334
356
|
async function readDaemonState() {
|
|
335
357
|
try {
|
|
336
|
-
if (!
|
|
358
|
+
if (!node_fs.existsSync(api.configuration.daemonStateFile)) {
|
|
337
359
|
return null;
|
|
338
360
|
}
|
|
339
361
|
const content = await promises.readFile(api.configuration.daemonStateFile, "utf-8");
|
|
@@ -344,13 +366,13 @@ async function readDaemonState() {
|
|
|
344
366
|
}
|
|
345
367
|
}
|
|
346
368
|
function writeDaemonState(state) {
|
|
347
|
-
|
|
369
|
+
node_fs.writeFileSync(api.configuration.daemonStateFile, JSON.stringify(state, null, 2), "utf-8");
|
|
348
370
|
}
|
|
349
371
|
async function clearDaemonState() {
|
|
350
|
-
if (
|
|
372
|
+
if (node_fs.existsSync(api.configuration.daemonStateFile)) {
|
|
351
373
|
await promises.unlink(api.configuration.daemonStateFile);
|
|
352
374
|
}
|
|
353
|
-
if (
|
|
375
|
+
if (node_fs.existsSync(api.configuration.daemonLockFile)) {
|
|
354
376
|
try {
|
|
355
377
|
await promises.unlink(api.configuration.daemonLockFile);
|
|
356
378
|
} catch {
|
|
@@ -359,7 +381,7 @@ async function clearDaemonState() {
|
|
|
359
381
|
}
|
|
360
382
|
async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
361
383
|
const lockFileName = `daemon.lock.${process.pid}.${Date.now()}`;
|
|
362
|
-
const lockFile =
|
|
384
|
+
const lockFile = node_path.join(node_path.dirname(api.configuration.daemonLockFile), lockFileName);
|
|
363
385
|
api.logger.debug(`[ACQUIRE LOCK] Attempting to acquire lock: ${lockFile}`);
|
|
364
386
|
api.logger.debug(`[ACQUIRE LOCK] Platform: ${process.platform}, PID: ${process.pid}`);
|
|
365
387
|
const isPidAlive = (pid) => {
|
|
@@ -372,8 +394,8 @@ async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
|
372
394
|
};
|
|
373
395
|
const readLockPid = () => {
|
|
374
396
|
try {
|
|
375
|
-
if (
|
|
376
|
-
const content =
|
|
397
|
+
if (node_fs.existsSync(lockFile)) {
|
|
398
|
+
const content = node_fs.readFileSync(lockFile, "utf-8").trim();
|
|
377
399
|
const pid = parseInt(content, 10);
|
|
378
400
|
if (!isNaN(pid) && pid > 0) {
|
|
379
401
|
return pid;
|
|
@@ -384,7 +406,7 @@ async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
|
384
406
|
return null;
|
|
385
407
|
};
|
|
386
408
|
const writeLockPid = (pid) => {
|
|
387
|
-
|
|
409
|
+
node_fs.writeFileSync(lockFile, String(pid), "utf-8");
|
|
388
410
|
};
|
|
389
411
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
390
412
|
api.logger.debug(`[ACQUIRE LOCK] Attempt ${attempt}/${maxAttempts}`);
|
|
@@ -401,9 +423,9 @@ async function acquireDaemonLock(maxAttempts = 3, delayIncrementMs = 1e3) {
|
|
|
401
423
|
api.logger.debug(`[ACQUIRE LOCK] No existing lock file`);
|
|
402
424
|
}
|
|
403
425
|
try {
|
|
404
|
-
if (
|
|
426
|
+
if (node_fs.existsSync(lockFile)) {
|
|
405
427
|
try {
|
|
406
|
-
|
|
428
|
+
node_fs.unlinkSync(lockFile);
|
|
407
429
|
api.logger.debug(`[ACQUIRE LOCK] Removed existing lock file`);
|
|
408
430
|
} catch (unlinkError) {
|
|
409
431
|
api.logger.debug(`[ACQUIRE LOCK] Could not remove lock file, trying anyway`);
|
|
@@ -450,17 +472,17 @@ async function releaseDaemonLock(lockHandle) {
|
|
|
450
472
|
} catch {
|
|
451
473
|
}
|
|
452
474
|
try {
|
|
453
|
-
if (
|
|
454
|
-
|
|
475
|
+
if (node_fs.existsSync(api.configuration.daemonLockFile)) {
|
|
476
|
+
node_fs.unlinkSync(api.configuration.daemonLockFile);
|
|
455
477
|
api.logger.debug(`[RELEASE LOCK] Released daemon lock`);
|
|
456
478
|
}
|
|
457
|
-
const lockDir =
|
|
479
|
+
const lockDir = node_path.dirname(api.configuration.daemonLockFile);
|
|
458
480
|
try {
|
|
459
|
-
const files =
|
|
481
|
+
const files = node_fs.readdirSync(lockDir);
|
|
460
482
|
for (const file of files) {
|
|
461
483
|
if (file.startsWith("daemon.lock.") && file.includes(`.${process.pid}.`)) {
|
|
462
|
-
const lockPath =
|
|
463
|
-
|
|
484
|
+
const lockPath = node_path.join(lockDir, file);
|
|
485
|
+
node_fs.unlinkSync(lockPath);
|
|
464
486
|
api.logger.debug(`[RELEASE LOCK] Released lock: ${file}`);
|
|
465
487
|
}
|
|
466
488
|
}
|
package/dist/{registerKillSessionHandler-BkzQulD9.cjs → registerKillSessionHandler-BDBPoQSA.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-LYPXVO_L.cjs');
|
|
4
|
+
var api = require('./api-D9dIR956.cjs');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
require('axios');
|
|
7
7
|
require('node:events');
|
package/dist/{registerKillSessionHandler-BtSK7IOa.mjs → registerKillSessionHandler-C3M_-4Zg.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-CriPm_z9.mjs';
|
|
2
|
+
import { l as logger } from './api-DpQIC-DJ.mjs';
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import 'node:events';
|