happy-imou-cloud 2.1.24 → 2.1.26

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 (37) hide show
  1. package/bin/happy-cloud.mjs +1 -1
  2. package/compat/acp-sdk-schema/index.d.ts +31 -0
  3. package/compat/acp-sdk-schema/index.js +4 -0
  4. package/compat/acp-sdk-schema/types.gen.d.ts +3761 -0
  5. package/compat/acp-sdk-schema/types.gen.js +2 -2
  6. package/compat/acp-sdk-schema/zod.gen.d.ts +6350 -0
  7. package/compat/acp-sdk-schema/zod.gen.js +883 -383
  8. package/dist/{BaseReasoningProcessor-C12000HQ.cjs → BaseReasoningProcessor-0e-Wwv5i.cjs} +2 -2
  9. package/dist/{BaseReasoningProcessor-BTf3r0UP.mjs → BaseReasoningProcessor-KMtgV6ap.mjs} +2 -2
  10. package/dist/{ProviderSelectionHandler-DXx9hcjB.mjs → ProviderSelectionHandler-CG8ktb5b.mjs} +2 -2
  11. package/dist/{ProviderSelectionHandler-BFdeV3Qi.cjs → ProviderSelectionHandler-CzRyfT1v.cjs} +2 -2
  12. package/dist/{api-DZeS3vrX.mjs → api-DugHuNd4.mjs} +36 -4
  13. package/dist/{api-Baax81ZI.cjs → api-hgzFUi7o.cjs} +36 -4
  14. package/dist/{command-B_RdbyPU.mjs → command-DU0KWNsf.mjs} +2 -2
  15. package/dist/{command-DOZYbypd.cjs → command-Dh8sawXu.cjs} +2 -2
  16. package/dist/{index-DA3m13mn.mjs → index-hj-qbq8Y.mjs} +309 -128
  17. package/dist/{index-BNqCQ-lZ.cjs → index-ythl_OD6.cjs} +313 -132
  18. package/dist/index.cjs +2 -2
  19. package/dist/index.mjs +2 -2
  20. package/dist/lib.cjs +1 -1
  21. package/dist/lib.d.cts +160 -159
  22. package/dist/lib.d.mts +160 -159
  23. package/dist/lib.mjs +1 -1
  24. package/dist/{registerKillSessionHandler-BiG3yHlk.mjs → registerKillSessionHandler-BNzbdofF.mjs} +22 -4
  25. package/dist/{registerKillSessionHandler-BtXtFnRx.cjs → registerKillSessionHandler-Q_rOuCNA.cjs} +22 -4
  26. package/dist/{runClaude-DGV1Dcv4.cjs → runClaude-BUi2fgRI.cjs} +4 -4
  27. package/dist/{runClaude-BqN1RhrO.mjs → runClaude-Y84RT6V0.mjs} +4 -4
  28. package/dist/{runCodex-C3htqAO7.mjs → runCodex-D2xIzHke.mjs} +28 -11
  29. package/dist/{runCodex-DQQkaW3Z.cjs → runCodex-vO3-iZ8E.cjs} +28 -11
  30. package/dist/{runGemini-CH9Cti4U.mjs → runGemini-CAotw19V.mjs} +4 -4
  31. package/dist/{runGemini-CmDSS8Qz.cjs → runGemini-DIKiIVdN.cjs} +4 -4
  32. package/package.json +3 -2
  33. package/scripts/release-smoke.mjs +22 -2
  34. package/skills/happy-cli-testing/SKILL.md +90 -0
  35. package/skills/happy-cli-testing/agents/openai.yaml +4 -0
  36. package/skills/hicloud-problem-investigation/SKILL.md +201 -0
  37. package/skills/hicloud-problem-investigation/agents/openai.yaml +4 -0
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
- var persistence = require('./api-Baax81ZI.cjs');
4
+ var persistence = require('./api-hgzFUi7o.cjs');
5
5
  var z = require('zod');
6
6
  var fs$2 = require('fs/promises');
7
7
  var os$1 = require('os');
@@ -72,7 +72,7 @@ async function openBrowser(url) {
72
72
  }
73
73
  }
74
74
 
75
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BNqCQ-lZ.cjs', document.baseURI).href)));
75
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-ythl_OD6.cjs', document.baseURI).href)));
76
76
  const QRCode = require$1("qrcode-terminal/vendor/QRCode");
77
77
  const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
78
78
  const pendingTempFiles = /* @__PURE__ */ new Set();
@@ -637,7 +637,7 @@ function setupCleanupHandlers() {
637
637
  });
638
638
  }
639
639
 
640
- const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BNqCQ-lZ.cjs', document.baseURI).href))));
640
+ const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-ythl_OD6.cjs', document.baseURI).href))));
641
641
  function projectPath() {
642
642
  const path = path$1.resolve(__dirname$2, "..");
643
643
  return path;
@@ -5335,6 +5335,70 @@ function parseAgentSendArgs(args) {
5335
5335
  };
5336
5336
  }
5337
5337
 
5338
+ const defaultDeps = {
5339
+ listDaemonSessions,
5340
+ stopDaemonSession,
5341
+ log: (message) => console.log(message),
5342
+ error: (message) => console.error(message)
5343
+ };
5344
+ function renderSessionCommandHelp() {
5345
+ return [
5346
+ "Usage: hicloud session <command>",
5347
+ "",
5348
+ "Commands:",
5349
+ " list List active sessions tracked by the daemon",
5350
+ " kill <session|pid> Stop a tracked session by session ID or PID"
5351
+ ].join("\n");
5352
+ }
5353
+ async function resolveSessionIdFromTarget(target, deps) {
5354
+ if (!/^\d+$/.test(target)) {
5355
+ return target;
5356
+ }
5357
+ const sessions = await deps.listDaemonSessions();
5358
+ const match = sessions.find((session) => String(session.pid) === target);
5359
+ return match?.happySessionId ?? null;
5360
+ }
5361
+ async function handleSessionCommand(args, deps = defaultDeps) {
5362
+ const subcommand = args[0];
5363
+ if (subcommand === "list") {
5364
+ try {
5365
+ const sessions = await deps.listDaemonSessions();
5366
+ if (sessions.length === 0) {
5367
+ deps.log("No active sessions this daemon is aware of");
5368
+ return 0;
5369
+ }
5370
+ deps.log("Active sessions:");
5371
+ deps.log(JSON.stringify(sessions, null, 2));
5372
+ return 0;
5373
+ } catch {
5374
+ deps.log("No daemon running");
5375
+ return 0;
5376
+ }
5377
+ }
5378
+ if (subcommand === "kill") {
5379
+ const target = args[1];
5380
+ if (!target) {
5381
+ deps.error("Session ID or PID required");
5382
+ return 1;
5383
+ }
5384
+ try {
5385
+ const sessionId = await resolveSessionIdFromTarget(target, deps);
5386
+ if (!sessionId) {
5387
+ deps.error(`No tracked session found for PID ${target}`);
5388
+ return 1;
5389
+ }
5390
+ const success = await deps.stopDaemonSession(sessionId);
5391
+ deps.log(success ? "Session stopped" : "Failed to stop session");
5392
+ return success ? 0 : 1;
5393
+ } catch {
5394
+ deps.error("No daemon running");
5395
+ return 1;
5396
+ }
5397
+ }
5398
+ deps.log(renderSessionCommandHelp());
5399
+ return 0;
5400
+ }
5401
+
5338
5402
  function getProjectPath(workingDirectory, claudeConfigDirOverride) {
5339
5403
  const projectId = path.resolve(workingDirectory).replace(/[^a-zA-Z0-9-]/g, "-");
5340
5404
  const claudeConfigDirRaw = process.env.CLAUDE_CONFIG_DIR ?? "";
@@ -6433,8 +6497,6 @@ const DEFAULT_IDLE_TIMEOUT_MS = 500;
6433
6497
  const DEFAULT_TOOL_CALL_TIMEOUT_MS = 10 * 6e4;
6434
6498
  const DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_HEAD_BYTES = 2e3;
6435
6499
  const DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_TAIL_BYTES = 4e3;
6436
- const CONTENTLESS_FETCH_INPUT_NOTE = "ACP runtime did not provide fetch arguments.";
6437
- const CONTENTLESS_FETCH_RESULT_TEXT = "Fetch completed, but the ACP runtime did not provide structured output.";
6438
6500
  function parseArgsFromContent(content) {
6439
6501
  if (Array.isArray(content)) {
6440
6502
  return { items: content };
@@ -6444,26 +6506,104 @@ function parseArgsFromContent(content) {
6444
6506
  }
6445
6507
  return {};
6446
6508
  }
6447
- function isContentlessFetchTool(toolKind, content, locations) {
6448
- if (toolKind !== "fetch") {
6509
+ function buildToolCallArgs(_toolKind, content, locations) {
6510
+ const args = parseArgsFromContent(content);
6511
+ if (Array.isArray(locations)) {
6512
+ args.locations = locations;
6513
+ }
6514
+ return args;
6515
+ }
6516
+ const MAX_TOOL_OUTPUT_OVERLAP_CHARS = 4096;
6517
+ const MAX_TRACKED_TOOL_OUTPUT_EXACT_CHARS = 16384;
6518
+ const MAX_TRACKED_TOOL_OUTPUT_HEAD_CHARS = 2048;
6519
+ const MAX_TRACKED_TOOL_OUTPUT_TAIL_CHARS = MAX_TOOL_OUTPUT_OVERLAP_CHARS;
6520
+ const MAX_TRACKED_TOOL_OUTPUT_SUFFIX_CHARS = 65536;
6521
+ function findTrailingNewlineTrimmedLength(text) {
6522
+ let trimmedLength = text.length;
6523
+ while (trimmedLength > 0) {
6524
+ const charCode = text.charCodeAt(trimmedLength - 1);
6525
+ if (charCode !== 10 && charCode !== 13) {
6526
+ break;
6527
+ }
6528
+ trimmedLength--;
6529
+ }
6530
+ return trimmedLength;
6531
+ }
6532
+ function sliceSnapshotHead(text, length) {
6533
+ return text.slice(0, Math.min(length, MAX_TRACKED_TOOL_OUTPUT_HEAD_CHARS));
6534
+ }
6535
+ function sliceSnapshotTail(text, length) {
6536
+ const tailLength = Math.min(length, MAX_TRACKED_TOOL_OUTPUT_TAIL_CHARS);
6537
+ return text.slice(Math.max(0, length - tailLength), length);
6538
+ }
6539
+ function sliceSnapshotSuffixWindow(text, length) {
6540
+ const suffixLength = Math.min(length, MAX_TRACKED_TOOL_OUTPUT_SUFFIX_CHARS);
6541
+ return text.slice(Math.max(0, length - suffixLength), length);
6542
+ }
6543
+ function buildToolOutputSnapshot(text) {
6544
+ const length = text.length;
6545
+ const trimmedLength = findTrailingNewlineTrimmedLength(text);
6546
+ return {
6547
+ length,
6548
+ exact: length <= MAX_TRACKED_TOOL_OUTPUT_EXACT_CHARS ? text : void 0,
6549
+ head: sliceSnapshotHead(text, length),
6550
+ tail: sliceSnapshotTail(text, length),
6551
+ suffixWindow: sliceSnapshotSuffixWindow(text, length),
6552
+ trimmedLength,
6553
+ trimmedExact: trimmedLength <= MAX_TRACKED_TOOL_OUTPUT_EXACT_CHARS ? text.slice(0, trimmedLength) : void 0,
6554
+ trimmedHead: sliceSnapshotHead(text, trimmedLength),
6555
+ trimmedTail: sliceSnapshotTail(text, trimmedLength),
6556
+ trimmedSuffixWindow: sliceSnapshotSuffixWindow(text, trimmedLength)
6557
+ };
6558
+ }
6559
+ function snapshotMatchesEdges(next, snapshotLength, snapshotHead, snapshotTail) {
6560
+ if (next.length < snapshotLength) {
6449
6561
  return false;
6450
6562
  }
6451
- if (hasMeaningfulContent(content)) {
6563
+ if (snapshotHead.length > 0 && !next.startsWith(snapshotHead)) {
6452
6564
  return false;
6453
6565
  }
6454
- return !Array.isArray(locations) || locations.length === 0;
6566
+ if (snapshotTail.length === 0) {
6567
+ return true;
6568
+ }
6569
+ const tailStart = snapshotLength - snapshotTail.length;
6570
+ return next.slice(tailStart, tailStart + snapshotTail.length) === snapshotTail;
6455
6571
  }
6456
- function buildToolCallArgs(toolKind, content, locations) {
6457
- const args = parseArgsFromContent(content);
6458
- if (Array.isArray(locations)) {
6459
- args.locations = locations;
6572
+ function snapshotMatchesText(snapshot, next, useTrimmedSnapshot = false) {
6573
+ const snapshotLength = useTrimmedSnapshot ? snapshot.trimmedLength : snapshot.length;
6574
+ if (next.length !== snapshotLength) {
6575
+ return false;
6460
6576
  }
6461
- if (isContentlessFetchTool(toolKind, content, locations)) {
6462
- args.note = CONTENTLESS_FETCH_INPUT_NOTE;
6577
+ const snapshotExact = useTrimmedSnapshot ? snapshot.trimmedExact : snapshot.exact;
6578
+ if (snapshotExact !== void 0) {
6579
+ return next === snapshotExact;
6463
6580
  }
6464
- return args;
6581
+ const snapshotHead = useTrimmedSnapshot ? snapshot.trimmedHead : snapshot.head;
6582
+ const snapshotTail = useTrimmedSnapshot ? snapshot.trimmedTail : snapshot.tail;
6583
+ return snapshotMatchesEdges(next, snapshotLength, snapshotHead, snapshotTail);
6584
+ }
6585
+ function snapshotIsPrefixOfText(snapshot, next, useTrimmedSnapshot = false) {
6586
+ const snapshotLength = useTrimmedSnapshot ? snapshot.trimmedLength : snapshot.length;
6587
+ if (next.length < snapshotLength) {
6588
+ return false;
6589
+ }
6590
+ const snapshotExact = useTrimmedSnapshot ? snapshot.trimmedExact : snapshot.exact;
6591
+ if (snapshotExact !== void 0) {
6592
+ return next.startsWith(snapshotExact);
6593
+ }
6594
+ const snapshotHead = useTrimmedSnapshot ? snapshot.trimmedHead : snapshot.head;
6595
+ const snapshotTail = useTrimmedSnapshot ? snapshot.trimmedTail : snapshot.tail;
6596
+ return snapshotMatchesEdges(next, snapshotLength, snapshotHead, snapshotTail);
6597
+ }
6598
+ function snapshotEndsWithText(snapshot, next) {
6599
+ if (next.length === 0) {
6600
+ return true;
6601
+ }
6602
+ if (snapshot.exact !== void 0) {
6603
+ return snapshot.exact.endsWith(next);
6604
+ }
6605
+ return next.length <= snapshot.suffixWindow.length && snapshot.suffixWindow.endsWith(next);
6465
6606
  }
6466
- const MAX_TOOL_OUTPUT_OVERLAP_CHARS = 4096;
6467
6607
  function findToolOutputOverlap(previous, next) {
6468
6608
  const maxOverlap = Math.min(previous.length, next.length, MAX_TOOL_OUTPUT_OVERLAP_CHARS);
6469
6609
  if (maxOverlap === 0) {
@@ -6482,27 +6622,27 @@ function getToolOutputDelta(previous, next) {
6482
6622
  if (!previous || previous.length === 0) {
6483
6623
  return next;
6484
6624
  }
6485
- if (next === previous || previous.endsWith(next)) {
6625
+ if (snapshotMatchesText(previous, next) || snapshotEndsWithText(previous, next)) {
6486
6626
  return "";
6487
6627
  }
6488
- if (next.startsWith(previous)) {
6628
+ if (snapshotIsPrefixOfText(previous, next)) {
6489
6629
  return next.slice(previous.length);
6490
6630
  }
6491
- const overlap = findToolOutputOverlap(previous, next);
6631
+ const overlapSource = previous.exact ?? previous.tail;
6632
+ const overlap = findToolOutputOverlap(overlapSource, next);
6492
6633
  return overlap > 0 ? next.slice(overlap) : next;
6493
6634
  }
6494
6635
  function shouldReplaceToolOutput(previous, next) {
6495
6636
  if (!previous || previous.length === 0) {
6496
6637
  return false;
6497
6638
  }
6498
- if (next.startsWith(previous)) {
6639
+ if (snapshotIsPrefixOfText(previous, next)) {
6499
6640
  return false;
6500
6641
  }
6501
- const previousWithoutTrailingNewlines = previous.replace(/[\r\n]+$/g, "");
6502
- if (previousWithoutTrailingNewlines.length === previous.length) {
6642
+ if (previous.trimmedLength === previous.length) {
6503
6643
  return false;
6504
6644
  }
6505
- return next.startsWith(previousWithoutTrailingNewlines);
6645
+ return snapshotIsPrefixOfText(previous, next, true);
6506
6646
  }
6507
6647
  function appendToolOutput(existing, next) {
6508
6648
  const shouldReplace = shouldReplaceToolOutput(existing?.lastRawText, next);
@@ -6520,7 +6660,10 @@ function appendToolOutput(existing, next) {
6520
6660
  }
6521
6661
  return {
6522
6662
  preview,
6523
- lastRawText: next,
6663
+ // ACP runtimes sometimes resend the entire cumulative stdout snapshot.
6664
+ // Keep only a bounded summary for dedupe so long tool runs cannot retain
6665
+ // every historical snapshot in memory.
6666
+ lastRawText: buildToolOutputSnapshot(next),
6524
6667
  updateCount: (existing?.updateCount ?? 0) + 1
6525
6668
  };
6526
6669
  }
@@ -6655,15 +6798,8 @@ function mergeStreamedOutputWithResult(content, streamedOutput) {
6655
6798
  }
6656
6799
  return content;
6657
6800
  }
6658
- function buildCompletedToolResult(toolKind, content, streamedOutput) {
6659
- const merged = mergeStreamedOutputWithResult(content, streamedOutput);
6660
- if (toolKind === "fetch" && !hasMeaningfulContent(merged)) {
6661
- return {
6662
- text: CONTENTLESS_FETCH_RESULT_TEXT,
6663
- status: "completed"
6664
- };
6665
- }
6666
- return merged;
6801
+ function buildCompletedToolResult(_toolKind, content, streamedOutput) {
6802
+ return mergeStreamedOutputWithResult(content, streamedOutput);
6667
6803
  }
6668
6804
  function extractErrorDetail(content) {
6669
6805
  if (!content) return void 0;
@@ -6980,12 +7116,11 @@ ${line.slice(-tailChars)}`;
6980
7116
  }
6981
7117
  function createAcpFilteredStdoutReadable(params) {
6982
7118
  const maxMultilineBytes = typeof params.maxMultilineBytes === "number" && Number.isFinite(params.maxMultilineBytes) && params.maxMultilineBytes > 0 ? Math.trunc(params.maxMultilineBytes) : 1e6;
6983
- const decoder = new TextDecoder();
6984
7119
  const encoder = new TextEncoder();
6985
7120
  return new ReadableStream({
6986
7121
  async start(controller) {
6987
7122
  const reader = params.readable.getReader();
6988
- let buffer = "";
7123
+ let buffer = Buffer.alloc(0);
6989
7124
  let multiline = null;
6990
7125
  let discardingOversizedLine = false;
6991
7126
  let controllerErrored = false;
@@ -6998,14 +7133,16 @@ function createAcpFilteredStdoutReadable(params) {
6998
7133
  }
6999
7134
  const filtered = params.transport.filterStdoutLine?.(line);
7000
7135
  if (filtered === void 0) {
7001
- controller.enqueue(encoder.encode(line + "\n"));
7136
+ controller.enqueue(encoder.encode(`${line}
7137
+ `));
7002
7138
  return;
7003
7139
  }
7004
7140
  if (filtered === null) {
7005
7141
  drop("transport_filter_null", line);
7006
7142
  return;
7007
7143
  }
7008
- controller.enqueue(encoder.encode(filtered + "\n"));
7144
+ controller.enqueue(encoder.encode(`${filtered}
7145
+ `));
7009
7146
  };
7010
7147
  const tryFlushMultiline = (candidate) => {
7011
7148
  const trimmed = candidate.trim();
@@ -7026,6 +7163,46 @@ function createAcpFilteredStdoutReadable(params) {
7026
7163
  return false;
7027
7164
  }
7028
7165
  };
7166
+ const consumeLine = (line, lineBytes) => {
7167
+ if (multiline) {
7168
+ const nextBuf = multiline.buf.length > 0 ? `${multiline.buf}
7169
+ ${line}` : line;
7170
+ const nextBytes = multiline.bytes + lineBytes + 1;
7171
+ if (nextBytes > maxMultilineBytes) {
7172
+ drop("multiline_overflow", multiline.buf);
7173
+ multiline = null;
7174
+ if (lineBytes > maxMultilineBytes) {
7175
+ drop("multiline_overflow", line);
7176
+ return;
7177
+ }
7178
+ enqueueLine(line);
7179
+ return;
7180
+ }
7181
+ multiline = { buf: nextBuf, bytes: nextBytes };
7182
+ if (tryFlushMultiline(multiline.buf)) {
7183
+ multiline = null;
7184
+ }
7185
+ return;
7186
+ }
7187
+ if (lineBytes > maxMultilineBytes) {
7188
+ drop("multiline_overflow", line);
7189
+ return;
7190
+ }
7191
+ const trimmed = line.trim();
7192
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
7193
+ try {
7194
+ const parsed = JSON.parse(trimmed);
7195
+ if (typeof parsed === "object" && parsed !== null) {
7196
+ enqueueLine(line);
7197
+ return;
7198
+ }
7199
+ } catch {
7200
+ multiline = { buf: line, bytes: lineBytes };
7201
+ return;
7202
+ }
7203
+ }
7204
+ enqueueLine(line);
7205
+ };
7029
7206
  try {
7030
7207
  while (true) {
7031
7208
  const { value, done } = await reader.read();
@@ -7035,73 +7212,54 @@ function createAcpFilteredStdoutReadable(params) {
7035
7212
  if (!value) {
7036
7213
  continue;
7037
7214
  }
7038
- let decodedChunk = decoder.decode(value, { stream: true });
7215
+ let chunkBuffer = Buffer.from(value);
7039
7216
  if (discardingOversizedLine) {
7040
- const newlineIndex = decodedChunk.indexOf("\n");
7041
- if (newlineIndex === -1) {
7217
+ const newlineIndex2 = chunkBuffer.indexOf(10);
7218
+ if (newlineIndex2 === -1) {
7042
7219
  continue;
7043
7220
  }
7044
- decodedChunk = decodedChunk.slice(newlineIndex + 1);
7221
+ chunkBuffer = chunkBuffer.subarray(newlineIndex2 + 1);
7045
7222
  discardingOversizedLine = false;
7046
7223
  }
7047
- buffer += decodedChunk;
7048
- const lines = buffer.split("\n");
7049
- buffer = lines.pop() || "";
7050
- for (const line of lines) {
7051
- if (multiline) {
7052
- const nextBuf = multiline.buf.length > 0 ? `${multiline.buf}
7053
- ${line}` : line;
7054
- const nextBytes = multiline.bytes + line.length + 1;
7055
- if (nextBytes > maxMultilineBytes) {
7056
- drop("multiline_overflow", multiline.buf);
7057
- multiline = null;
7058
- if (line.length > maxMultilineBytes) {
7059
- drop("multiline_overflow", line);
7060
- continue;
7061
- }
7062
- enqueueLine(line);
7063
- continue;
7064
- }
7065
- multiline = { buf: nextBuf, bytes: nextBytes };
7066
- if (tryFlushMultiline(multiline.buf)) {
7067
- multiline = null;
7068
- }
7069
- continue;
7070
- }
7071
- if (line.length > maxMultilineBytes) {
7072
- drop("multiline_overflow", line);
7073
- continue;
7074
- }
7075
- const trimmed = line.trim();
7076
- if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
7077
- try {
7078
- const parsed = JSON.parse(trimmed);
7079
- if (typeof parsed === "object" && parsed !== null) {
7080
- enqueueLine(line);
7081
- continue;
7082
- }
7083
- } catch {
7084
- multiline = { buf: line, bytes: line.length };
7085
- continue;
7086
- }
7087
- }
7088
- enqueueLine(line);
7224
+ if (chunkBuffer.length === 0) {
7225
+ continue;
7226
+ }
7227
+ buffer = buffer.length === 0 ? chunkBuffer : Buffer.concat([buffer, chunkBuffer]);
7228
+ let newlineIndex = buffer.indexOf(10);
7229
+ while (newlineIndex !== -1) {
7230
+ const rawLine = buffer.subarray(0, newlineIndex);
7231
+ buffer = buffer.subarray(newlineIndex + 1);
7232
+ const lineBuffer = rawLine.at(-1) === 13 ? rawLine.subarray(0, rawLine.length - 1) : rawLine;
7233
+ const line = lineBuffer.toString("utf8");
7234
+ consumeLine(line, lineBuffer.length);
7235
+ newlineIndex = buffer.indexOf(10);
7089
7236
  }
7090
7237
  if (buffer.length > maxMultilineBytes) {
7091
- drop("multiline_overflow", buffer);
7092
- buffer = "";
7238
+ drop("multiline_overflow", buffer.toString("utf8"));
7239
+ buffer = Buffer.alloc(0);
7093
7240
  discardingOversizedLine = true;
7094
7241
  }
7095
7242
  }
7096
- if (multiline) {
7097
- if (!tryFlushMultiline(multiline.buf)) {
7098
- drop("multiline_incomplete", multiline.buf);
7243
+ if (buffer.length > 0) {
7244
+ const trailingLine = buffer.toString("utf8");
7245
+ const pendingMultiline = multiline;
7246
+ if (pendingMultiline) {
7247
+ const nextBuf = pendingMultiline.buf.length > 0 ? `${pendingMultiline.buf}
7248
+ ${trailingLine}` : trailingLine;
7249
+ if (!tryFlushMultiline(nextBuf)) {
7250
+ drop("multiline_incomplete", nextBuf);
7251
+ }
7252
+ multiline = null;
7253
+ } else if (trailingLine.trim()) {
7254
+ drop("multiline_incomplete", trailingLine);
7099
7255
  }
7100
- multiline = null;
7101
7256
  }
7102
- const trailing = buffer.trim();
7103
- if (trailing) {
7104
- drop("multiline_incomplete", buffer);
7257
+ const remainingMultiline = multiline;
7258
+ if (remainingMultiline) {
7259
+ if (!tryFlushMultiline(remainingMultiline.buf)) {
7260
+ drop("multiline_incomplete", remainingMultiline.buf);
7261
+ }
7262
+ multiline = null;
7105
7263
  }
7106
7264
  } catch (error) {
7107
7265
  controllerErrored = true;
@@ -7200,6 +7358,7 @@ const RETRY_CONFIG = {
7200
7358
  maxDelayMs: 5e3
7201
7359
  };
7202
7360
  const DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS = 2 * 6e4;
7361
+ const MAX_DROPPED_STDOUT_LINE_SAMPLES = 5;
7203
7362
  function readPositiveIntegerEnv(name) {
7204
7363
  const raw = typeof process.env[name] === "string" ? process.env[name].trim() : "";
7205
7364
  if (!raw) {
@@ -7295,6 +7454,12 @@ function isSelectionPermissionRequest(params) {
7295
7454
  }
7296
7455
  return !options.every((option) => isApprovalOption(option));
7297
7456
  }
7457
+ function appendDroppedStdoutLineSummary(summary, entry) {
7458
+ summary.count += 1;
7459
+ if (summary.samples.length < MAX_DROPPED_STDOUT_LINE_SAMPLES) {
7460
+ summary.samples.push(entry);
7461
+ }
7462
+ }
7298
7463
  function nodeToWebStreams(stdin, stdout) {
7299
7464
  const writable = new WritableStream({
7300
7465
  write(chunk) {
@@ -7937,19 +8102,22 @@ ${recentStderrExcerpt}`);
7937
8102
  );
7938
8103
  const writable = streams.writable;
7939
8104
  const readable = streams.readable;
7940
- const droppedStdoutLines = [];
8105
+ const droppedStdoutSummary = {
8106
+ count: 0,
8107
+ samples: []
8108
+ };
7941
8109
  const filteredReadable = createAcpFilteredStdoutReadable({
7942
8110
  readable,
7943
8111
  transport: this.transport,
7944
8112
  onDroppedLine: (entry) => {
7945
- droppedStdoutLines.push(entry);
8113
+ appendDroppedStdoutLineSummary(droppedStdoutSummary, entry);
7946
8114
  this.handleDroppedStdoutLine(entry);
7947
8115
  },
7948
8116
  onDone: () => {
7949
- if (droppedStdoutLines.length > 0) {
8117
+ if (droppedStdoutSummary.count > 0) {
7950
8118
  persistence.logger.debug(
7951
- `[AcpBackend] Filtered out ${droppedStdoutLines.length} stdout lines from ${this.transport.agentName}`,
7952
- droppedStdoutLines.slice(0, 5)
8119
+ `[AcpBackend] Filtered out ${droppedStdoutSummary.count} stdout lines from ${this.transport.agentName}`,
8120
+ droppedStdoutSummary.samples
7953
8121
  );
7954
8122
  }
7955
8123
  }
@@ -9193,21 +9361,21 @@ function copyCodexHomeEntry(sourcePath, destPath) {
9193
9361
  });
9194
9362
  }
9195
9363
  function normalizePathForComparison(path$1, platform) {
9196
- const normalizedPath = path.normalize(path$1).replace(/[\\/]+$/, "");
9364
+ const normalizedPath = path.normalize(path$1).replace(/[\\/]+/g, "/").replace(/\/+$/, "");
9197
9365
  return platform === "win32" ? normalizedPath.toLowerCase() : normalizedPath;
9198
9366
  }
9199
- function isManagedTemporaryCodexHomePath(path$1, platform) {
9200
- const trimmedPath = path$1.trim();
9367
+ function isManagedTemporaryCodexHomePath(path, platform) {
9368
+ const trimmedPath = path.trim();
9201
9369
  if (!trimmedPath) {
9202
9370
  return false;
9203
9371
  }
9204
- if (!path.basename(trimmedPath).startsWith(MANAGED_CODEX_HOME_PREFIX)) {
9372
+ const pathBaseName = trimmedPath.replace(/[\\/]+$/, "").split(/[\\/]/).at(-1) ?? "";
9373
+ if (!pathBaseName.startsWith(MANAGED_CODEX_HOME_PREFIX)) {
9205
9374
  return false;
9206
9375
  }
9207
9376
  const normalizedTempRoot = normalizePathForComparison(os.tmpdir(), platform);
9208
9377
  const normalizedPath = normalizePathForComparison(trimmedPath, platform);
9209
- const separator = platform === "win32" ? "\\" : "/";
9210
- return normalizedPath.startsWith(`${normalizedTempRoot}${separator}`);
9378
+ return normalizedPath.startsWith(`${normalizedTempRoot}/`);
9211
9379
  }
9212
9380
  function extractSkillDescriptionFromFrontmatter(frontmatter) {
9213
9381
  const lines = frontmatter.split(/\r?\n/);
@@ -9263,25 +9431,7 @@ function shouldSeedCodexSkillEntry(sourcePath) {
9263
9431
  }
9264
9432
  return true;
9265
9433
  }
9266
- function seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir) {
9267
- if (!fs.existsSync(sourceHomeDir)) {
9268
- return;
9269
- }
9270
- for (const fileName of CODEX_HOME_SEED_FILES) {
9271
- try {
9272
- copyCodexHomeEntry(path.join(sourceHomeDir, fileName), path.join(isolatedHomeDir, fileName));
9273
- } catch (error) {
9274
- persistence.logger.debug(`[codex] Failed to seed CODEX_HOME file ${fileName}`, error);
9275
- }
9276
- }
9277
- for (const dirName of CODEX_HOME_SEED_DIRS) {
9278
- try {
9279
- copyCodexHomeEntry(path.join(sourceHomeDir, dirName), path.join(isolatedHomeDir, dirName));
9280
- } catch (error) {
9281
- persistence.logger.debug(`[codex] Failed to seed CODEX_HOME directory ${dirName}`, error);
9282
- }
9283
- }
9284
- const sourceSkillsDir = path.join(sourceHomeDir, "skills");
9434
+ function seedCodexSkillEntries(sourceSkillsDir, isolatedHomeDir, sourceLabel) {
9285
9435
  if (!fs.existsSync(sourceSkillsDir)) {
9286
9436
  return;
9287
9437
  }
@@ -9298,10 +9448,32 @@ function seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir) {
9298
9448
  path.join(destSkillsDir, entryName)
9299
9449
  );
9300
9450
  } catch (error) {
9301
- persistence.logger.debug(`[codex] Failed to seed CODEX_HOME skills entry ${entryName}`, error);
9451
+ persistence.logger.debug(`[codex] Failed to seed CODEX_HOME skills entry ${entryName} from ${sourceLabel}`, error);
9302
9452
  }
9303
9453
  }
9304
9454
  }
9455
+ function seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir, bundledSkillsDir) {
9456
+ if (fs.existsSync(sourceHomeDir)) {
9457
+ for (const fileName of CODEX_HOME_SEED_FILES) {
9458
+ try {
9459
+ copyCodexHomeEntry(path.join(sourceHomeDir, fileName), path.join(isolatedHomeDir, fileName));
9460
+ } catch (error) {
9461
+ persistence.logger.debug(`[codex] Failed to seed CODEX_HOME file ${fileName}`, error);
9462
+ }
9463
+ }
9464
+ for (const dirName of CODEX_HOME_SEED_DIRS) {
9465
+ try {
9466
+ copyCodexHomeEntry(path.join(sourceHomeDir, dirName), path.join(isolatedHomeDir, dirName));
9467
+ } catch (error) {
9468
+ persistence.logger.debug(`[codex] Failed to seed CODEX_HOME directory ${dirName}`, error);
9469
+ }
9470
+ }
9471
+ }
9472
+ if (bundledSkillsDir) {
9473
+ seedCodexSkillEntries(bundledSkillsDir, isolatedHomeDir, "bundled skills");
9474
+ }
9475
+ seedCodexSkillEntries(path.join(sourceHomeDir, "skills"), isolatedHomeDir, "source CODEX_HOME");
9476
+ }
9305
9477
  function prepareCodexAcpEnvironment(overrides = {}, options = {}) {
9306
9478
  const env = buildCodexAcpEnv(overrides, options);
9307
9479
  const platform = options.platform ?? process.platform;
@@ -9322,7 +9494,8 @@ function prepareCodexAcpEnvironment(overrides = {}, options = {}) {
9322
9494
  const isolatedHomeDir = tempDirFactory(path.join(os.tmpdir(), "happy-codex-home-"));
9323
9495
  fs.mkdirSync(isolatedHomeDir, { recursive: true });
9324
9496
  const sourceHomeDir = options.sourceHomeDir ?? path.join(os.homedir(), ".codex");
9325
- seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir);
9497
+ const bundledSkillsDir = options.bundledSkillsDir ?? path.join(projectPath(), "skills");
9498
+ seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir, bundledSkillsDir);
9326
9499
  env.CODEX_HOME = isolatedHomeDir;
9327
9500
  return {
9328
9501
  env,
@@ -9479,7 +9652,7 @@ class AbortError extends Error {
9479
9652
  }
9480
9653
  }
9481
9654
 
9482
- const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BNqCQ-lZ.cjs', document.baseURI).href)));
9655
+ const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-ythl_OD6.cjs', document.baseURI).href)));
9483
9656
  const __dirname$1 = path.join(__filename$1, "..");
9484
9657
  function getGlobalClaudeVersion() {
9485
9658
  try {
@@ -10798,14 +10971,14 @@ var launch = /*#__PURE__*/Object.freeze({
10798
10971
  const unifiedProviderExecutors = {
10799
10972
  claude: async (opts) => {
10800
10973
  const claudeOptions = opts.claudeOptions ?? {};
10801
- const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-DGV1Dcv4.cjs'); });
10974
+ const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-BUi2fgRI.cjs'); });
10802
10975
  await runClaude(opts.credentials, {
10803
10976
  ...claudeOptions,
10804
10977
  startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
10805
10978
  });
10806
10979
  },
10807
10980
  codex: async (opts) => {
10808
- const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-DQQkaW3Z.cjs'); });
10981
+ const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-vO3-iZ8E.cjs'); });
10809
10982
  await runCodex({
10810
10983
  credentials: opts.credentials,
10811
10984
  startedBy: opts.startedBy,
@@ -10814,7 +10987,7 @@ const unifiedProviderExecutors = {
10814
10987
  });
10815
10988
  },
10816
10989
  gemini: async (opts) => {
10817
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-CmDSS8Qz.cjs'); });
10990
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-DIKiIVdN.cjs'); });
10818
10991
  await runGemini({
10819
10992
  credentials: opts.credentials,
10820
10993
  startedBy: opts.startedBy
@@ -10897,7 +11070,7 @@ function shouldRunMainClaudeFlow(opts) {
10897
11070
  return;
10898
11071
  } else if (subcommand === "runtime") {
10899
11072
  if (args[1] === "providers") {
10900
- const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-DOZYbypd.cjs'); });
11073
+ const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-Dh8sawXu.cjs'); });
10901
11074
  console.log(renderRuntimeProviders());
10902
11075
  return;
10903
11076
  }
@@ -10970,6 +11143,12 @@ function shouldRunMainClaudeFlow(opts) {
10970
11143
  process.exit(1);
10971
11144
  }
10972
11145
  return;
11146
+ } else if (subcommand === "session") {
11147
+ const exitCode = await handleSessionCommand(args.slice(1));
11148
+ if (exitCode !== 0) {
11149
+ process.exit(exitCode);
11150
+ }
11151
+ return;
10973
11152
  } else if (subcommand === "codex") {
10974
11153
  try {
10975
11154
  let startedBy = void 0;
@@ -11097,8 +11276,8 @@ function shouldRunMainClaudeFlow(opts) {
11097
11276
  const projectId = args[3];
11098
11277
  try {
11099
11278
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
11100
- const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-Baax81ZI.cjs'); }).then(function (n) { return n.persistence; });
11101
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-Baax81ZI.cjs'); }).then(function (n) { return n.api; });
11279
+ const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-hgzFUi7o.cjs'); }).then(function (n) { return n.persistence; });
11280
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-hgzFUi7o.cjs'); }).then(function (n) { return n.api; });
11102
11281
  let userEmail = void 0;
11103
11282
  try {
11104
11283
  const credentials = await readCredentials2();
@@ -11391,6 +11570,7 @@ ${chalk.bold("Usage:")}
11391
11570
  hicloud gemini Start Gemini mode (ACP)
11392
11571
  hicloud cursor Start Cursor mode (experimental ACP)
11393
11572
  hicloud connect Connect AI vendor API keys
11573
+ hicloud session Manage tracked daemon sessions
11394
11574
  hicloud notify Send push notification
11395
11575
  hicloud daemon Manage background service that allows
11396
11576
  to spawn new sessions away from your computer
@@ -11406,6 +11586,7 @@ ${chalk.bold("Examples:")}
11406
11586
  hicloud --claude-env ANTHROPIC_BASE_URL=http://127.0.0.1:3456
11407
11587
  Use a custom API endpoint (e.g., claude-code-router)
11408
11588
  hicloud auth login --force Authenticate
11589
+ hicloud session list List daemon-tracked sessions
11409
11590
  hicloud doctor Run diagnostics
11410
11591
 
11411
11592
  ${chalk.bold(`${BRAND_CONFIG.name} supports ALL Claude options!`)}