happy-imou-cloud 2.1.57 → 2.1.59

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 (48) hide show
  1. package/dist/{BaseReasoningProcessor-C67V1qL3.cjs → BaseReasoningProcessor-BSlD8znO.cjs} +1 -1
  2. package/dist/{BaseReasoningProcessor-D2Q8Nme5.mjs → BaseReasoningProcessor-CCk42d9N.mjs} +1 -1
  3. package/dist/{ConversationHistory-BBIe2m4P.mjs → ConversationHistory-DK27K3JQ.mjs} +3 -2
  4. package/dist/{ConversationHistory-atrS3PAx.cjs → ConversationHistory-DeQgZhJ6.cjs} +3 -2
  5. package/dist/{ProviderSelectionHandler-Qi2pFTxL.mjs → ProviderSelectionHandler-BOpj_9DE.mjs} +76 -3
  6. package/dist/{ProviderSelectionHandler-h3z4-foa.cjs → ProviderSelectionHandler-D8CA-qU2.cjs} +80 -6
  7. package/dist/{bootstrapManagedProviderSession-RLtyRq0n.cjs → bootstrapManagedProviderSession-CIeuJe8e.cjs} +8 -6
  8. package/dist/{bootstrapManagedProviderSession-AhAYHLGj.mjs → bootstrapManagedProviderSession-CIlq-ugZ.mjs} +5 -3
  9. package/dist/{command-CyzKMQbs.cjs → command-Di3Fzz-y.cjs} +14 -4
  10. package/dist/{command-DRRTqKEA.mjs → command-DwgpAaWb.mjs} +14 -4
  11. package/dist/index-DxN29QWa.cjs +13103 -0
  12. package/dist/index-lyHSYtcT.mjs +13085 -0
  13. package/dist/index.cjs +18 -11
  14. package/dist/index.mjs +18 -11
  15. package/dist/{installFatalProcessHandlers-DyyiLNrG.cjs → installFatalProcessHandlers-1tGjAPvJ.cjs} +1 -1
  16. package/dist/{installFatalProcessHandlers-B99QpyLN.mjs → installFatalProcessHandlers-D8bPk4i9.mjs} +1 -1
  17. package/dist/{launch-DRd9FuLt.mjs → launch-CZph2kt_.mjs} +14 -4
  18. package/dist/{launch-DnWvtpv4.cjs → launch-CtQOCN5k.cjs} +14 -4
  19. package/dist/lib.cjs +14 -4
  20. package/dist/lib.d.cts +3049 -381
  21. package/dist/lib.d.mts +3049 -381
  22. package/dist/lib.mjs +14 -4
  23. package/dist/{runClaude-DOlxK2PO.cjs → runClaude-CeqPnUbU.cjs} +38 -147
  24. package/dist/{runClaude-Df_7_PkI.mjs → runClaude-Xh_udlwO.mjs} +20 -129
  25. package/dist/runCodex-BSKTTl6d.mjs +9021 -0
  26. package/dist/runCodex-Dh9NvwOY.cjs +9026 -0
  27. package/dist/{runCursor-CqElKVpg.mjs → runCursor-2Q3v6cl1.mjs} +22 -13
  28. package/dist/{runCursor-ClUxehsP.cjs → runCursor-DddNgWaI.cjs} +23 -14
  29. package/dist/{runGemini-CmrMnkBU.cjs → runGemini-B_4ILaqM.cjs} +29 -293
  30. package/dist/{runGemini-CVyRbdZg.mjs → runGemini-C2xofHuV.mjs} +23 -287
  31. package/dist/{sessionControl-BovRthCu.mjs → sessionControl-Bmadpvu8.mjs} +68 -242
  32. package/dist/{sessionControl-C1bgV3SZ.cjs → sessionControl-JLtbfkf2.cjs} +67 -245
  33. package/dist/types-CYn-pPZa.cjs +64520 -0
  34. package/dist/types-CotaFNj0.mjs +64350 -0
  35. package/package.json +27 -20
  36. package/scripts/e2e/codex-app-server-goal-smoke.mjs +159 -0
  37. package/scripts/e2e/codex-mcp-memory-summarizer-smoke.mjs +255 -0
  38. package/scripts/e2e/fake-codex-app-server.mjs +267 -0
  39. package/scripts/e2e/local-server-session-roundtrip.mjs +1751 -432
  40. package/scripts/e2e/mcp-stdio-real-server-probe.mjs +189 -0
  41. package/dist/config-BXTUTPxJ.mjs +0 -174
  42. package/dist/config-BqFnXbs0.cjs +0 -184
  43. package/dist/index-BCLSXYQP.mjs +0 -7565
  44. package/dist/index-BoSqCbVr.cjs +0 -7582
  45. package/dist/runCodex-ClqZb2wh.cjs +0 -2307
  46. package/dist/runCodex-DP-67NuP.mjs +0 -2302
  47. package/dist/types-BZeEK90l.mjs +0 -14091
  48. package/dist/types-CcsR2bJq.cjs +0 -14185
package/dist/lib.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { b as ApiClient, c as ApiSessionClient, R as RawJSONLinesSchema, v as configuration, U as logger } from './types-BZeEK90l.mjs';
1
+ export { c as ApiClient, d as ApiSessionClient, p as RawJSONLinesSchema, Q as configuration, aE as logger } from './types-CotaFNj0.mjs';
2
2
  import 'axios';
3
3
  import 'chalk';
4
4
  import 'fs';
@@ -16,12 +16,22 @@ import 'crypto';
16
16
  import 'path';
17
17
  import 'sharp';
18
18
  import 'node:child_process';
19
+ import '@noble/hashes/hmac';
20
+ import '@noble/hashes/sha512';
21
+ import 'base64-js';
22
+ import 'child_process';
23
+ import 'util';
19
24
  import 'cross-spawn';
20
25
  import '@agentclientprotocol/sdk';
21
26
  import 'ps-list';
22
- import 'os';
23
- import 'child_process';
24
27
  import 'url';
25
- import 'node:readline';
28
+ import 'node:util';
29
+ import 'node:stream';
30
+ import 'node:stream/promises';
26
31
  import 'node:url';
32
+ import 'os';
33
+ import 'node:readline';
34
+ import 'fastify';
35
+ import 'fastify-type-provider-zod';
27
36
  import 'expo-server-sdk';
37
+ import 'node:module';
@@ -1,47 +1,52 @@
1
1
  'use strict';
2
2
 
3
3
  var node_crypto = require('node:crypto');
4
- var persistence = require('./types-CcsR2bJq.cjs');
4
+ var persistence = require('./types-CYn-pPZa.cjs');
5
5
  require('cross-spawn');
6
6
  require('@agentclientprotocol/sdk');
7
+ var fs = require('node:fs');
8
+ var fsPromises = require('node:fs/promises');
9
+ var path = require('node:path');
7
10
  require('ps-list');
8
11
  require('fs');
9
12
  require('path');
10
13
  require('os');
11
14
  require('child_process');
12
- var fs$1 = require('node:fs');
13
- var path = require('node:path');
14
15
  var os = require('node:os');
16
+ require('tweetnacl');
17
+ require('@noble/hashes/hmac');
18
+ require('@noble/hashes/sha512');
19
+ require('base64-js');
20
+ var fs$1 = require('fs/promises');
21
+ require('crypto');
15
22
  var node_child_process = require('node:child_process');
16
23
  require('node:readline');
17
- var index = require('./index-BoSqCbVr.cjs');
18
- var promises = require('node:fs/promises');
19
- var fs = require('fs/promises');
20
- require('crypto');
24
+ var index = require('./index-DxN29QWa.cjs');
21
25
  require('chalk');
22
26
  require('node:events');
23
27
  require('axios');
24
- require('tweetnacl');
25
28
  require('open');
26
29
  var React = require('react');
27
30
  var ink = require('ink');
28
- var ProviderSelectionHandler = require('./ProviderSelectionHandler-h3z4-foa.cjs');
31
+ var ProviderSelectionHandler = require('./ProviderSelectionHandler-D8CA-qU2.cjs');
29
32
  require('socket.io-client');
30
33
  require('sharp');
34
+ require('node:stream');
35
+ require('node:stream/promises');
36
+ require('node:url');
37
+ require('node:module');
31
38
  require('expo-server-sdk');
32
- var ConversationHistory = require('./ConversationHistory-atrS3PAx.cjs');
33
- var sessionControl = require('./sessionControl-C1bgV3SZ.cjs');
39
+ var ConversationHistory = require('./ConversationHistory-DeQgZhJ6.cjs');
40
+ var sessionControl = require('./sessionControl-JLtbfkf2.cjs');
34
41
  var node_util = require('node:util');
35
42
  var node_http = require('node:http');
36
43
  require('zod');
44
+ require('util');
37
45
  require('url');
38
- require('node:url');
39
- require('qrcode-terminal');
40
- require('node:module');
41
46
  require('fastify');
42
47
  require('fastify-type-provider-zod');
48
+ require('qrcode-terminal');
43
49
  require('http');
44
- require('util');
45
50
 
46
51
  class Session {
47
52
  path;
@@ -268,76 +273,6 @@ class InvalidateSync {
268
273
  };
269
274
  }
270
275
 
271
- function startFileWatcher(file, onFileChange) {
272
- const abortController = new AbortController();
273
- const parentDir = path.dirname(file);
274
- const targetName = path.basename(file);
275
- void (async () => {
276
- while (true) {
277
- try {
278
- try {
279
- await fs.stat(file);
280
- } catch (e) {
281
- if (abortController.signal.aborted) {
282
- return;
283
- }
284
- if (e?.code === "ENOENT") {
285
- persistence.logger.debug(`[FILE_WATCHER] Waiting for file to exist: ${file}`);
286
- const dirWatcher = fs.watch(parentDir, { persistent: true, signal: abortController.signal });
287
- try {
288
- await fs.stat(file);
289
- } catch (err) {
290
- if (err?.code !== "ENOENT") {
291
- throw err;
292
- }
293
- for await (const event of dirWatcher) {
294
- if (abortController.signal.aborted) {
295
- return;
296
- }
297
- const name = typeof event?.filename === "string" ? String(event.filename) : null;
298
- if (name && name !== targetName) {
299
- continue;
300
- }
301
- try {
302
- await fs.stat(file);
303
- persistence.logger.debug(`[FILE_WATCHER] File appeared: ${file}`);
304
- break;
305
- } catch (nextErr) {
306
- if (nextErr?.code === "ENOENT") {
307
- continue;
308
- }
309
- throw nextErr;
310
- }
311
- }
312
- }
313
- } else {
314
- throw e;
315
- }
316
- }
317
- onFileChange(file);
318
- persistence.logger.debug(`[FILE_WATCHER] Starting watcher for ${file}`);
319
- const watcher = fs.watch(file, { persistent: true, signal: abortController.signal });
320
- for await (const event of watcher) {
321
- if (abortController.signal.aborted) {
322
- return;
323
- }
324
- persistence.logger.debug(`[FILE_WATCHER] File changed: ${file}`);
325
- onFileChange(file);
326
- }
327
- } catch (e) {
328
- if (abortController.signal.aborted) {
329
- return;
330
- }
331
- persistence.logger.debug(`[FILE_WATCHER] Watch error: ${e.message}, restarting watcher in a second`);
332
- await persistence.delay(1e3);
333
- }
334
- }
335
- })();
336
- return () => {
337
- abortController.abort();
338
- };
339
- }
340
-
341
276
  const INTERNAL_CLAUDE_EVENT_TYPES = /* @__PURE__ */ new Set([
342
277
  "file-history-snapshot",
343
278
  "change",
@@ -374,7 +309,7 @@ async function createSessionScanner(opts) {
374
309
  }
375
310
  const filePath = getSessionFilePath(sessionId);
376
311
  try {
377
- await promises.readFile(filePath, "utf-8");
312
+ await fsPromises.readFile(filePath, "utf-8");
378
313
  return;
379
314
  } catch {
380
315
  }
@@ -451,7 +386,7 @@ async function createSessionScanner(opts) {
451
386
  persistence.logger.debug(`[SESSION_SCANNER] Starting watcher for session: ${p}`);
452
387
  watchers.set(p, {
453
388
  filePath: desiredPath,
454
- stop: startFileWatcher(desiredPath, () => {
389
+ stop: ProviderSelectionHandler.startFileWatcher(desiredPath, () => {
455
390
  sync.invalidate();
456
391
  })
457
392
  });
@@ -462,7 +397,7 @@ async function createSessionScanner(opts) {
462
397
  existing.stop();
463
398
  watchers.set(p, {
464
399
  filePath: desiredPath,
465
- stop: startFileWatcher(desiredPath, () => {
400
+ stop: ProviderSelectionHandler.startFileWatcher(desiredPath, () => {
466
401
  sync.invalidate();
467
402
  })
468
403
  });
@@ -555,7 +490,7 @@ async function readSessionLog(sessionFilePath) {
555
490
  persistence.logger.debug(`[SESSION_SCANNER] Reading session file: ${sessionFilePath}`);
556
491
  let file;
557
492
  try {
558
- file = await promises.readFile(sessionFilePath, "utf-8");
493
+ file = await fsPromises.readFile(sessionFilePath, "utf-8");
559
494
  } catch (error) {
560
495
  persistence.logger.debug(`[SESSION_SCANNER] Session file not found: ${sessionFilePath}`);
561
496
  return [];
@@ -695,50 +630,6 @@ async function claudeLocalLauncher(session) {
695
630
  return exitReason || { type: "exit", code: 0 };
696
631
  }
697
632
 
698
- function parseCompact(message) {
699
- const trimmed = message.trim();
700
- if (trimmed === "/compact") {
701
- return {
702
- isCompact: true,
703
- originalMessage: trimmed
704
- };
705
- }
706
- if (trimmed.startsWith("/compact ")) {
707
- return {
708
- isCompact: true,
709
- originalMessage: trimmed
710
- };
711
- }
712
- return {
713
- isCompact: false,
714
- originalMessage: message
715
- };
716
- }
717
- function parseClear(message) {
718
- const trimmed = message.trim();
719
- return {
720
- isClear: trimmed === "/clear"
721
- };
722
- }
723
- function parseSpecialCommand(message) {
724
- const compactResult = parseCompact(message);
725
- if (compactResult.isCompact) {
726
- return {
727
- type: "compact",
728
- originalMessage: compactResult.originalMessage
729
- };
730
- }
731
- const clearResult = parseClear(message);
732
- if (clearResult.isClear) {
733
- return {
734
- type: "clear"
735
- };
736
- }
737
- return {
738
- type: null
739
- };
740
- }
741
-
742
633
  const RemoteModeDisplay = ({ messageBuffer, logPath, onExit, onSwitchToLocal }) => {
743
634
  const [messages, setMessages] = React.useState([]);
744
635
  const [confirmationMode, setConfirmationMode] = React.useState(null);
@@ -871,11 +762,11 @@ function getClaudeSettingsPath() {
871
762
  function readClaudeSettings() {
872
763
  try {
873
764
  const settingsPath = getClaudeSettingsPath();
874
- if (!fs$1.existsSync(settingsPath)) {
765
+ if (!fs.existsSync(settingsPath)) {
875
766
  persistence.logger.debug(`[ClaudeSettings] No Claude settings file found at ${settingsPath}`);
876
767
  return null;
877
768
  }
878
- const settingsContent = fs$1.readFileSync(settingsPath, "utf-8");
769
+ const settingsContent = fs.readFileSync(settingsPath, "utf-8");
879
770
  const settings = JSON.parse(settingsContent);
880
771
  persistence.logger.debug(`[ClaudeSettings] Successfully read Claude settings from ${settingsPath}`);
881
772
  persistence.logger.debug(`[ClaudeSettings] includeCoAuthoredBy: ${settings.includeCoAuthoredBy}`);
@@ -926,7 +817,7 @@ function getToolDescriptor(toolName) {
926
817
  return { edit: false, exitPlan: false };
927
818
  }
928
819
 
929
- class ClaudeAcpPermissionHandler extends sessionControl.BasePermissionHandler {
820
+ class ClaudeAcpPermissionHandler extends persistence.BasePermissionHandler {
930
821
  currentPermissionMode = "default";
931
822
  constructor(session) {
932
823
  super(session);
@@ -1482,7 +1373,7 @@ ${systemPrompt}` : systemPrompt,
1482
1373
  }
1483
1374
  currentModeHash = message.hash;
1484
1375
  readyAlreadySent = false;
1485
- const specialCommand = parseSpecialCommand(message.message);
1376
+ const specialCommand = persistence.parseSpecialCommand(message.message);
1486
1377
  if (specialCommand.type === "clear") {
1487
1378
  await handleClearCommand();
1488
1379
  if (!shouldExit && !pending && session.queue.size() === 0 && !readyAlreadySent) {
@@ -1643,7 +1534,7 @@ async function awaitFileExist(file, timeout = 1e4) {
1643
1534
  const startTime = Date.now();
1644
1535
  while (Date.now() - startTime < timeout) {
1645
1536
  try {
1646
- await fs.access(file);
1537
+ await fs$1.access(file);
1647
1538
  return true;
1648
1539
  } catch (e) {
1649
1540
  await persistence.delay(1e3);
@@ -1686,7 +1577,7 @@ async function claudeRemote(opts) {
1686
1577
  if (!initial) {
1687
1578
  return;
1688
1579
  }
1689
- const specialCommand = parseSpecialCommand(initial.message);
1580
+ const specialCommand = persistence.parseSpecialCommand(initial.message);
1690
1581
  if (specialCommand.type === "clear") {
1691
1582
  if (opts.onCompletionEvent) {
1692
1583
  opts.onCompletionEvent("Context was reset");
@@ -3223,7 +3114,7 @@ async function startHookServer(options) {
3223
3114
 
3224
3115
  function generateHookSettingsFile(port) {
3225
3116
  const hooksDir = path.join(persistence.configuration.happyCloudHomeDir, "tmp", "hooks");
3226
- fs$1.mkdirSync(hooksDir, { recursive: true });
3117
+ fs.mkdirSync(hooksDir, { recursive: true });
3227
3118
  const filename = `session-hook-${process.pid}.json`;
3228
3119
  const filepath = path.join(hooksDir, filename);
3229
3120
  const forwarderScript = path.resolve(persistence.projectPath(), "scripts", "session_hook_forwarder.cjs");
@@ -3243,14 +3134,14 @@ function generateHookSettingsFile(port) {
3243
3134
  ]
3244
3135
  }
3245
3136
  };
3246
- fs$1.writeFileSync(filepath, JSON.stringify(settings, null, 2));
3137
+ fs.writeFileSync(filepath, JSON.stringify(settings, null, 2));
3247
3138
  persistence.logger.debug(`[generateHookSettings] Created hook settings file: ${filepath}`);
3248
3139
  return filepath;
3249
3140
  }
3250
3141
  function cleanupHookSettingsFile(filepath) {
3251
3142
  try {
3252
- if (fs$1.existsSync(filepath)) {
3253
- fs$1.unlinkSync(filepath);
3143
+ if (fs.existsSync(filepath)) {
3144
+ fs.unlinkSync(filepath);
3254
3145
  persistence.logger.debug(`[generateHookSettings] Cleaned up hook settings file: ${filepath}`);
3255
3146
  }
3256
3147
  } catch (error) {
@@ -3271,7 +3162,7 @@ async function runOfflineClaudeLocalFallback(opts) {
3271
3162
  if (!response) {
3272
3163
  throw new Error("Server unavailable");
3273
3164
  }
3274
- await index.publishSessionRegistration(response.id, opts.metadata);
3165
+ await persistence.publishSessionRegistration(response.id, opts.metadata);
3275
3166
  const session = opts.api.sessionSyncClient(response);
3276
3167
  await sessionControl.syncControlledByUserState(session, true);
3277
3168
  const scanner = await createSessionScanner({
@@ -3349,7 +3240,7 @@ function resolveClaudeQueuedMessage(message, currentState) {
3349
3240
  allowedTools,
3350
3241
  disallowedTools
3351
3242
  };
3352
- const specialCommand = parseSpecialCommand(message.content.text);
3243
+ const specialCommand = persistence.parseSpecialCommand(message.content.text);
3353
3244
  const nextState = {
3354
3245
  permissionMode,
3355
3246
  model,
@@ -3442,7 +3333,7 @@ async function runClaude(credentials, options = {}) {
3442
3333
  throw error;
3443
3334
  }
3444
3335
  persistence.logger.debug(`Using machineId: ${machineId}`);
3445
- const { state, metadata } = index.createSessionMetadata({
3336
+ const { state, metadata } = persistence.createSessionMetadata({
3446
3337
  flavor: "claude",
3447
3338
  machineId,
3448
3339
  startedBy: options.startedBy,
@@ -3471,7 +3362,7 @@ async function runClaude(credentials, options = {}) {
3471
3362
  process.exit(0);
3472
3363
  }
3473
3364
  persistence.logger.debug(`Session created: ${response.id}`);
3474
- await index.publishSessionRegistration(response.id, metadata);
3365
+ await persistence.publishSessionRegistration(response.id, metadata);
3475
3366
  extractSDKMetadataAsync(async (sdkMetadata) => {
3476
3367
  persistence.logger.debug("[start] SDK metadata extracted, updating session:", sdkMetadata);
3477
3368
  try {
@@ -1,45 +1,50 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { U as logger, o as backoff, D as delay, R as RawJSONLinesSchema, F as Future, x as createClaudeBackend, K as formatDisplayMessage, ad as truncateDisplayMessage, $ as projectPath, V as mapToClaudeMode, P as PushableAsyncIterable, a0 as query, A as AbortError, e as AsyncLock, v as configuration, ac as startOfflineReconnection, w as connectionState, b as ApiClient, Q as isAuthenticationRequiredError, O as hashObject } from './types-BZeEK90l.mjs';
2
+ import { aE as logger, x as backoff, p as RawJSONLinesSchema, h as Future, B as BasePermissionHandler, aP as parseSpecialCommand, U as createClaudeBackend, ac as formatDisplayMessage, bp as truncateDisplayMessage, a3 as delay, aT as projectPath, aF as mapToClaudeMode, P as PushableAsyncIterable, aV as query, A as AbortError, f as AsyncLock, Q as configuration, bl as startOfflineReconnection, aU as publishSessionRegistration, T as connectionState, c as ApiClient, a0 as createSessionMetadata, aq as isAuthenticationRequiredError, ak as hashObject } from './types-CotaFNj0.mjs';
3
3
  import 'cross-spawn';
4
4
  import '@agentclientprotocol/sdk';
5
+ import { existsSync, readFileSync, mkdirSync, writeFileSync, unlinkSync } from 'node:fs';
6
+ import { readFile } from 'node:fs/promises';
7
+ import { dirname, join, resolve } from 'node:path';
5
8
  import 'ps-list';
6
9
  import 'fs';
7
10
  import 'path';
8
11
  import 'os';
9
12
  import 'child_process';
10
- import { existsSync, readFileSync, mkdirSync, writeFileSync, unlinkSync } from 'node:fs';
11
- import { dirname, basename, join, resolve } from 'node:path';
12
13
  import { homedir } from 'node:os';
14
+ import 'tweetnacl';
15
+ import '@noble/hashes/hmac';
16
+ import '@noble/hashes/sha512';
17
+ import 'base64-js';
18
+ import { access } from 'fs/promises';
19
+ import 'crypto';
13
20
  import { execSync } from 'node:child_process';
14
21
  import 'node:readline';
15
- import { e as getProjectPath, a as claudeLocal, E as ExitCodeError, t as trimIdent, c as claudeCheckSession, j as stopCaffeinate, p as publishSessionRegistration, g as getEnvironmentInfo, d as createSessionMetadata, s as startCaffeinate, b as closeProviderSession } from './index-BCLSXYQP.mjs';
16
- import { readFile } from 'node:fs/promises';
17
- import { stat, watch, access } from 'fs/promises';
18
- import 'crypto';
22
+ import { f as getProjectPath, d as claudeLocal, E as ExitCodeError, t as trimIdent, b as claudeCheckSession, l as stopCaffeinate, g as getEnvironmentInfo, s as startCaffeinate, e as closeProviderSession } from './index-lyHSYtcT.mjs';
19
23
  import 'chalk';
20
24
  import 'node:events';
21
25
  import 'axios';
22
- import 'tweetnacl';
23
26
  import 'open';
24
27
  import React, { useState, useRef, useEffect, useCallback } from 'react';
25
28
  import { useStdout, useInput, Box, Text, render } from 'ink';
26
- import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-Qi2pFTxL.mjs';
29
+ import { c as createKeepAliveController, s as startFileWatcher, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-BOpj_9DE.mjs';
27
30
  import 'socket.io-client';
28
31
  import 'sharp';
32
+ import 'node:stream';
33
+ import 'node:stream/promises';
34
+ import 'node:url';
35
+ import 'node:module';
29
36
  import 'expo-server-sdk';
30
- import { M as MessageBuffer, C as ConversationHistory$1, c as buildTurnResultPushNotification, d as createSessionTranscriptInkRenderer, a as buildReadyPushNotification, l as launchRuntimeHandleWithFactoryResult, b as buildPermissionPushNotification } from './ConversationHistory-BBIe2m4P.mjs';
31
- import { B as BasePermissionHandler, a as BufferedAssistantStreamEmitter, d as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, f as finalizeHappyOrgTurnWithBusinessAck, j as renderTerminalOutputPreview, p as prepareTerminalOutputForForwarding, g as forwardAgentMessageToProviderSession, s as syncControlledByUserState, k as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, c as MissingMachineIdError, M as MessageQueue2, r as registerKillSessionHandler } from './sessionControl-BovRthCu.mjs';
37
+ import { M as MessageBuffer, C as ConversationHistory$1, c as buildTurnResultPushNotification, d as createSessionTranscriptInkRenderer, a as buildReadyPushNotification, l as launchRuntimeHandleWithFactoryResult, b as buildPermissionPushNotification } from './ConversationHistory-DK27K3JQ.mjs';
38
+ import { B as BufferedAssistantStreamEmitter, b as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, f as finalizeHappyOrgTurnWithBusinessAck, d as renderTerminalOutputPreview, p as prepareTerminalOutputForForwarding, c as forwardAgentMessageToProviderSession, s as syncControlledByUserState, g as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, a as MissingMachineIdError, M as MessageQueue2, r as registerKillSessionHandler } from './sessionControl-Bmadpvu8.mjs';
32
39
  import { isDeepStrictEqual } from 'node:util';
33
40
  import { createServer } from 'node:http';
34
41
  import 'zod';
42
+ import 'util';
35
43
  import 'url';
36
- import 'node:url';
37
- import 'qrcode-terminal';
38
- import 'node:module';
39
44
  import 'fastify';
40
45
  import 'fastify-type-provider-zod';
46
+ import 'qrcode-terminal';
41
47
  import 'http';
42
- import 'util';
43
48
 
44
49
  class Session {
45
50
  path;
@@ -266,76 +271,6 @@ class InvalidateSync {
266
271
  };
267
272
  }
268
273
 
269
- function startFileWatcher(file, onFileChange) {
270
- const abortController = new AbortController();
271
- const parentDir = dirname(file);
272
- const targetName = basename(file);
273
- void (async () => {
274
- while (true) {
275
- try {
276
- try {
277
- await stat(file);
278
- } catch (e) {
279
- if (abortController.signal.aborted) {
280
- return;
281
- }
282
- if (e?.code === "ENOENT") {
283
- logger.debug(`[FILE_WATCHER] Waiting for file to exist: ${file}`);
284
- const dirWatcher = watch(parentDir, { persistent: true, signal: abortController.signal });
285
- try {
286
- await stat(file);
287
- } catch (err) {
288
- if (err?.code !== "ENOENT") {
289
- throw err;
290
- }
291
- for await (const event of dirWatcher) {
292
- if (abortController.signal.aborted) {
293
- return;
294
- }
295
- const name = typeof event?.filename === "string" ? String(event.filename) : null;
296
- if (name && name !== targetName) {
297
- continue;
298
- }
299
- try {
300
- await stat(file);
301
- logger.debug(`[FILE_WATCHER] File appeared: ${file}`);
302
- break;
303
- } catch (nextErr) {
304
- if (nextErr?.code === "ENOENT") {
305
- continue;
306
- }
307
- throw nextErr;
308
- }
309
- }
310
- }
311
- } else {
312
- throw e;
313
- }
314
- }
315
- onFileChange(file);
316
- logger.debug(`[FILE_WATCHER] Starting watcher for ${file}`);
317
- const watcher = watch(file, { persistent: true, signal: abortController.signal });
318
- for await (const event of watcher) {
319
- if (abortController.signal.aborted) {
320
- return;
321
- }
322
- logger.debug(`[FILE_WATCHER] File changed: ${file}`);
323
- onFileChange(file);
324
- }
325
- } catch (e) {
326
- if (abortController.signal.aborted) {
327
- return;
328
- }
329
- logger.debug(`[FILE_WATCHER] Watch error: ${e.message}, restarting watcher in a second`);
330
- await delay(1e3);
331
- }
332
- }
333
- })();
334
- return () => {
335
- abortController.abort();
336
- };
337
- }
338
-
339
274
  const INTERNAL_CLAUDE_EVENT_TYPES = /* @__PURE__ */ new Set([
340
275
  "file-history-snapshot",
341
276
  "change",
@@ -693,50 +628,6 @@ async function claudeLocalLauncher(session) {
693
628
  return exitReason || { type: "exit", code: 0 };
694
629
  }
695
630
 
696
- function parseCompact(message) {
697
- const trimmed = message.trim();
698
- if (trimmed === "/compact") {
699
- return {
700
- isCompact: true,
701
- originalMessage: trimmed
702
- };
703
- }
704
- if (trimmed.startsWith("/compact ")) {
705
- return {
706
- isCompact: true,
707
- originalMessage: trimmed
708
- };
709
- }
710
- return {
711
- isCompact: false,
712
- originalMessage: message
713
- };
714
- }
715
- function parseClear(message) {
716
- const trimmed = message.trim();
717
- return {
718
- isClear: trimmed === "/clear"
719
- };
720
- }
721
- function parseSpecialCommand(message) {
722
- const compactResult = parseCompact(message);
723
- if (compactResult.isCompact) {
724
- return {
725
- type: "compact",
726
- originalMessage: compactResult.originalMessage
727
- };
728
- }
729
- const clearResult = parseClear(message);
730
- if (clearResult.isClear) {
731
- return {
732
- type: "clear"
733
- };
734
- }
735
- return {
736
- type: null
737
- };
738
- }
739
-
740
631
  const RemoteModeDisplay = ({ messageBuffer, logPath, onExit, onSwitchToLocal }) => {
741
632
  const [messages, setMessages] = useState([]);
742
633
  const [confirmationMode, setConfirmationMode] = useState(null);