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,5 +1,5 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import chalk from 'chalk';
2
- import { l as logger, j as encodeBase64, c as configuration, k as readCredentials, m as ensureSigningCredentials, r as readSettings, u as updateSettings, n as encodeBase64Url, g as delay, o as buildClientHeaders, q as decodeBase64, w as writeCredentialsLegacy, t as writeCredentialsDataKey, v as readDaemonState, x as HAPPY_CLOUD_DAEMON_PORT, y as clearDaemonState, z as packageJson, i as isAuthenticationRequiredError, B as acquireDaemonLock, C as writeDaemonState, A as ApiClient, D as releaseDaemonLock, E as validateProfileForAgent, F as getProfileEnvironmentVariables, G as clearCredentials, I as clearMachineId, M as MessageContentSchema, J as buildSocketAuth, K as encrypt, L as HeadTailPreviewBuffer, N as getLatestDaemonLog } from './api-DZeS3vrX.mjs';
2
+ import { l as logger, j as encodeBase64, c as configuration, k as readCredentials, m as ensureSigningCredentials, r as readSettings, u as updateSettings, n as encodeBase64Url, g as delay, o as buildClientHeaders, q as decodeBase64, w as writeCredentialsLegacy, t as writeCredentialsDataKey, v as readDaemonState, x as HAPPY_CLOUD_DAEMON_PORT, y as clearDaemonState, z as packageJson, i as isAuthenticationRequiredError, B as acquireDaemonLock, C as writeDaemonState, A as ApiClient, D as releaseDaemonLock, E as validateProfileForAgent, F as getProfileEnvironmentVariables, G as clearCredentials, I as clearMachineId, M as MessageContentSchema, J as buildSocketAuth, K as encrypt, L as HeadTailPreviewBuffer, N as getLatestDaemonLog } from './api-DugHuNd4.mjs';
3
3
  import { z } from 'zod';
4
4
  import fs, { writeFile as writeFile$1, rename, unlink as unlink$1 } from 'fs/promises';
5
5
  import os$1, { homedir } from 'os';
@@ -11,7 +11,7 @@ import qrcode from 'qrcode-terminal';
11
11
  import { writeFile, unlink, readdir, readFile, mkdir } from 'node:fs/promises';
12
12
  import { createRequire } from 'node:module';
13
13
  import os, { tmpdir, homedir as homedir$1 } from 'node:os';
14
- import path, { join, resolve as resolve$1, isAbsolute, delimiter, basename, normalize, dirname as dirname$1 } from 'node:path';
14
+ import path, { join, resolve as resolve$1, isAbsolute, delimiter, normalize, dirname as dirname$1, basename } from 'node:path';
15
15
  import open from 'open';
16
16
  import React, { useState } from 'react';
17
17
  import { useInput, Box, Text, render } from 'ink';
@@ -5313,6 +5313,70 @@ function parseAgentSendArgs(args) {
5313
5313
  };
5314
5314
  }
5315
5315
 
5316
+ const defaultDeps = {
5317
+ listDaemonSessions,
5318
+ stopDaemonSession,
5319
+ log: (message) => console.log(message),
5320
+ error: (message) => console.error(message)
5321
+ };
5322
+ function renderSessionCommandHelp() {
5323
+ return [
5324
+ "Usage: hicloud session <command>",
5325
+ "",
5326
+ "Commands:",
5327
+ " list List active sessions tracked by the daemon",
5328
+ " kill <session|pid> Stop a tracked session by session ID or PID"
5329
+ ].join("\n");
5330
+ }
5331
+ async function resolveSessionIdFromTarget(target, deps) {
5332
+ if (!/^\d+$/.test(target)) {
5333
+ return target;
5334
+ }
5335
+ const sessions = await deps.listDaemonSessions();
5336
+ const match = sessions.find((session) => String(session.pid) === target);
5337
+ return match?.happySessionId ?? null;
5338
+ }
5339
+ async function handleSessionCommand(args, deps = defaultDeps) {
5340
+ const subcommand = args[0];
5341
+ if (subcommand === "list") {
5342
+ try {
5343
+ const sessions = await deps.listDaemonSessions();
5344
+ if (sessions.length === 0) {
5345
+ deps.log("No active sessions this daemon is aware of");
5346
+ return 0;
5347
+ }
5348
+ deps.log("Active sessions:");
5349
+ deps.log(JSON.stringify(sessions, null, 2));
5350
+ return 0;
5351
+ } catch {
5352
+ deps.log("No daemon running");
5353
+ return 0;
5354
+ }
5355
+ }
5356
+ if (subcommand === "kill") {
5357
+ const target = args[1];
5358
+ if (!target) {
5359
+ deps.error("Session ID or PID required");
5360
+ return 1;
5361
+ }
5362
+ try {
5363
+ const sessionId = await resolveSessionIdFromTarget(target, deps);
5364
+ if (!sessionId) {
5365
+ deps.error(`No tracked session found for PID ${target}`);
5366
+ return 1;
5367
+ }
5368
+ const success = await deps.stopDaemonSession(sessionId);
5369
+ deps.log(success ? "Session stopped" : "Failed to stop session");
5370
+ return success ? 0 : 1;
5371
+ } catch {
5372
+ deps.error("No daemon running");
5373
+ return 1;
5374
+ }
5375
+ }
5376
+ deps.log(renderSessionCommandHelp());
5377
+ return 0;
5378
+ }
5379
+
5316
5380
  function getProjectPath(workingDirectory, claudeConfigDirOverride) {
5317
5381
  const projectId = resolve$1(workingDirectory).replace(/[^a-zA-Z0-9-]/g, "-");
5318
5382
  const claudeConfigDirRaw = process.env.CLAUDE_CONFIG_DIR ?? "";
@@ -6411,8 +6475,6 @@ const DEFAULT_IDLE_TIMEOUT_MS = 500;
6411
6475
  const DEFAULT_TOOL_CALL_TIMEOUT_MS = 10 * 6e4;
6412
6476
  const DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_HEAD_BYTES = 2e3;
6413
6477
  const DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_TAIL_BYTES = 4e3;
6414
- const CONTENTLESS_FETCH_INPUT_NOTE = "ACP runtime did not provide fetch arguments.";
6415
- const CONTENTLESS_FETCH_RESULT_TEXT = "Fetch completed, but the ACP runtime did not provide structured output.";
6416
6478
  function parseArgsFromContent(content) {
6417
6479
  if (Array.isArray(content)) {
6418
6480
  return { items: content };
@@ -6422,26 +6484,104 @@ function parseArgsFromContent(content) {
6422
6484
  }
6423
6485
  return {};
6424
6486
  }
6425
- function isContentlessFetchTool(toolKind, content, locations) {
6426
- if (toolKind !== "fetch") {
6487
+ function buildToolCallArgs(_toolKind, content, locations) {
6488
+ const args = parseArgsFromContent(content);
6489
+ if (Array.isArray(locations)) {
6490
+ args.locations = locations;
6491
+ }
6492
+ return args;
6493
+ }
6494
+ const MAX_TOOL_OUTPUT_OVERLAP_CHARS = 4096;
6495
+ const MAX_TRACKED_TOOL_OUTPUT_EXACT_CHARS = 16384;
6496
+ const MAX_TRACKED_TOOL_OUTPUT_HEAD_CHARS = 2048;
6497
+ const MAX_TRACKED_TOOL_OUTPUT_TAIL_CHARS = MAX_TOOL_OUTPUT_OVERLAP_CHARS;
6498
+ const MAX_TRACKED_TOOL_OUTPUT_SUFFIX_CHARS = 65536;
6499
+ function findTrailingNewlineTrimmedLength(text) {
6500
+ let trimmedLength = text.length;
6501
+ while (trimmedLength > 0) {
6502
+ const charCode = text.charCodeAt(trimmedLength - 1);
6503
+ if (charCode !== 10 && charCode !== 13) {
6504
+ break;
6505
+ }
6506
+ trimmedLength--;
6507
+ }
6508
+ return trimmedLength;
6509
+ }
6510
+ function sliceSnapshotHead(text, length) {
6511
+ return text.slice(0, Math.min(length, MAX_TRACKED_TOOL_OUTPUT_HEAD_CHARS));
6512
+ }
6513
+ function sliceSnapshotTail(text, length) {
6514
+ const tailLength = Math.min(length, MAX_TRACKED_TOOL_OUTPUT_TAIL_CHARS);
6515
+ return text.slice(Math.max(0, length - tailLength), length);
6516
+ }
6517
+ function sliceSnapshotSuffixWindow(text, length) {
6518
+ const suffixLength = Math.min(length, MAX_TRACKED_TOOL_OUTPUT_SUFFIX_CHARS);
6519
+ return text.slice(Math.max(0, length - suffixLength), length);
6520
+ }
6521
+ function buildToolOutputSnapshot(text) {
6522
+ const length = text.length;
6523
+ const trimmedLength = findTrailingNewlineTrimmedLength(text);
6524
+ return {
6525
+ length,
6526
+ exact: length <= MAX_TRACKED_TOOL_OUTPUT_EXACT_CHARS ? text : void 0,
6527
+ head: sliceSnapshotHead(text, length),
6528
+ tail: sliceSnapshotTail(text, length),
6529
+ suffixWindow: sliceSnapshotSuffixWindow(text, length),
6530
+ trimmedLength,
6531
+ trimmedExact: trimmedLength <= MAX_TRACKED_TOOL_OUTPUT_EXACT_CHARS ? text.slice(0, trimmedLength) : void 0,
6532
+ trimmedHead: sliceSnapshotHead(text, trimmedLength),
6533
+ trimmedTail: sliceSnapshotTail(text, trimmedLength),
6534
+ trimmedSuffixWindow: sliceSnapshotSuffixWindow(text, trimmedLength)
6535
+ };
6536
+ }
6537
+ function snapshotMatchesEdges(next, snapshotLength, snapshotHead, snapshotTail) {
6538
+ if (next.length < snapshotLength) {
6427
6539
  return false;
6428
6540
  }
6429
- if (hasMeaningfulContent(content)) {
6541
+ if (snapshotHead.length > 0 && !next.startsWith(snapshotHead)) {
6430
6542
  return false;
6431
6543
  }
6432
- return !Array.isArray(locations) || locations.length === 0;
6544
+ if (snapshotTail.length === 0) {
6545
+ return true;
6546
+ }
6547
+ const tailStart = snapshotLength - snapshotTail.length;
6548
+ return next.slice(tailStart, tailStart + snapshotTail.length) === snapshotTail;
6433
6549
  }
6434
- function buildToolCallArgs(toolKind, content, locations) {
6435
- const args = parseArgsFromContent(content);
6436
- if (Array.isArray(locations)) {
6437
- args.locations = locations;
6550
+ function snapshotMatchesText(snapshot, next, useTrimmedSnapshot = false) {
6551
+ const snapshotLength = useTrimmedSnapshot ? snapshot.trimmedLength : snapshot.length;
6552
+ if (next.length !== snapshotLength) {
6553
+ return false;
6438
6554
  }
6439
- if (isContentlessFetchTool(toolKind, content, locations)) {
6440
- args.note = CONTENTLESS_FETCH_INPUT_NOTE;
6555
+ const snapshotExact = useTrimmedSnapshot ? snapshot.trimmedExact : snapshot.exact;
6556
+ if (snapshotExact !== void 0) {
6557
+ return next === snapshotExact;
6441
6558
  }
6442
- return args;
6559
+ const snapshotHead = useTrimmedSnapshot ? snapshot.trimmedHead : snapshot.head;
6560
+ const snapshotTail = useTrimmedSnapshot ? snapshot.trimmedTail : snapshot.tail;
6561
+ return snapshotMatchesEdges(next, snapshotLength, snapshotHead, snapshotTail);
6562
+ }
6563
+ function snapshotIsPrefixOfText(snapshot, next, useTrimmedSnapshot = false) {
6564
+ const snapshotLength = useTrimmedSnapshot ? snapshot.trimmedLength : snapshot.length;
6565
+ if (next.length < snapshotLength) {
6566
+ return false;
6567
+ }
6568
+ const snapshotExact = useTrimmedSnapshot ? snapshot.trimmedExact : snapshot.exact;
6569
+ if (snapshotExact !== void 0) {
6570
+ return next.startsWith(snapshotExact);
6571
+ }
6572
+ const snapshotHead = useTrimmedSnapshot ? snapshot.trimmedHead : snapshot.head;
6573
+ const snapshotTail = useTrimmedSnapshot ? snapshot.trimmedTail : snapshot.tail;
6574
+ return snapshotMatchesEdges(next, snapshotLength, snapshotHead, snapshotTail);
6575
+ }
6576
+ function snapshotEndsWithText(snapshot, next) {
6577
+ if (next.length === 0) {
6578
+ return true;
6579
+ }
6580
+ if (snapshot.exact !== void 0) {
6581
+ return snapshot.exact.endsWith(next);
6582
+ }
6583
+ return next.length <= snapshot.suffixWindow.length && snapshot.suffixWindow.endsWith(next);
6443
6584
  }
6444
- const MAX_TOOL_OUTPUT_OVERLAP_CHARS = 4096;
6445
6585
  function findToolOutputOverlap(previous, next) {
6446
6586
  const maxOverlap = Math.min(previous.length, next.length, MAX_TOOL_OUTPUT_OVERLAP_CHARS);
6447
6587
  if (maxOverlap === 0) {
@@ -6460,27 +6600,27 @@ function getToolOutputDelta(previous, next) {
6460
6600
  if (!previous || previous.length === 0) {
6461
6601
  return next;
6462
6602
  }
6463
- if (next === previous || previous.endsWith(next)) {
6603
+ if (snapshotMatchesText(previous, next) || snapshotEndsWithText(previous, next)) {
6464
6604
  return "";
6465
6605
  }
6466
- if (next.startsWith(previous)) {
6606
+ if (snapshotIsPrefixOfText(previous, next)) {
6467
6607
  return next.slice(previous.length);
6468
6608
  }
6469
- const overlap = findToolOutputOverlap(previous, next);
6609
+ const overlapSource = previous.exact ?? previous.tail;
6610
+ const overlap = findToolOutputOverlap(overlapSource, next);
6470
6611
  return overlap > 0 ? next.slice(overlap) : next;
6471
6612
  }
6472
6613
  function shouldReplaceToolOutput(previous, next) {
6473
6614
  if (!previous || previous.length === 0) {
6474
6615
  return false;
6475
6616
  }
6476
- if (next.startsWith(previous)) {
6617
+ if (snapshotIsPrefixOfText(previous, next)) {
6477
6618
  return false;
6478
6619
  }
6479
- const previousWithoutTrailingNewlines = previous.replace(/[\r\n]+$/g, "");
6480
- if (previousWithoutTrailingNewlines.length === previous.length) {
6620
+ if (previous.trimmedLength === previous.length) {
6481
6621
  return false;
6482
6622
  }
6483
- return next.startsWith(previousWithoutTrailingNewlines);
6623
+ return snapshotIsPrefixOfText(previous, next, true);
6484
6624
  }
6485
6625
  function appendToolOutput(existing, next) {
6486
6626
  const shouldReplace = shouldReplaceToolOutput(existing?.lastRawText, next);
@@ -6498,7 +6638,10 @@ function appendToolOutput(existing, next) {
6498
6638
  }
6499
6639
  return {
6500
6640
  preview,
6501
- lastRawText: next,
6641
+ // ACP runtimes sometimes resend the entire cumulative stdout snapshot.
6642
+ // Keep only a bounded summary for dedupe so long tool runs cannot retain
6643
+ // every historical snapshot in memory.
6644
+ lastRawText: buildToolOutputSnapshot(next),
6502
6645
  updateCount: (existing?.updateCount ?? 0) + 1
6503
6646
  };
6504
6647
  }
@@ -6633,15 +6776,8 @@ function mergeStreamedOutputWithResult(content, streamedOutput) {
6633
6776
  }
6634
6777
  return content;
6635
6778
  }
6636
- function buildCompletedToolResult(toolKind, content, streamedOutput) {
6637
- const merged = mergeStreamedOutputWithResult(content, streamedOutput);
6638
- if (toolKind === "fetch" && !hasMeaningfulContent(merged)) {
6639
- return {
6640
- text: CONTENTLESS_FETCH_RESULT_TEXT,
6641
- status: "completed"
6642
- };
6643
- }
6644
- return merged;
6779
+ function buildCompletedToolResult(_toolKind, content, streamedOutput) {
6780
+ return mergeStreamedOutputWithResult(content, streamedOutput);
6645
6781
  }
6646
6782
  function extractErrorDetail(content) {
6647
6783
  if (!content) return void 0;
@@ -6958,12 +7094,11 @@ ${line.slice(-tailChars)}`;
6958
7094
  }
6959
7095
  function createAcpFilteredStdoutReadable(params) {
6960
7096
  const maxMultilineBytes = typeof params.maxMultilineBytes === "number" && Number.isFinite(params.maxMultilineBytes) && params.maxMultilineBytes > 0 ? Math.trunc(params.maxMultilineBytes) : 1e6;
6961
- const decoder = new TextDecoder();
6962
7097
  const encoder = new TextEncoder();
6963
7098
  return new ReadableStream({
6964
7099
  async start(controller) {
6965
7100
  const reader = params.readable.getReader();
6966
- let buffer = "";
7101
+ let buffer = Buffer.alloc(0);
6967
7102
  let multiline = null;
6968
7103
  let discardingOversizedLine = false;
6969
7104
  let controllerErrored = false;
@@ -6976,14 +7111,16 @@ function createAcpFilteredStdoutReadable(params) {
6976
7111
  }
6977
7112
  const filtered = params.transport.filterStdoutLine?.(line);
6978
7113
  if (filtered === void 0) {
6979
- controller.enqueue(encoder.encode(line + "\n"));
7114
+ controller.enqueue(encoder.encode(`${line}
7115
+ `));
6980
7116
  return;
6981
7117
  }
6982
7118
  if (filtered === null) {
6983
7119
  drop("transport_filter_null", line);
6984
7120
  return;
6985
7121
  }
6986
- controller.enqueue(encoder.encode(filtered + "\n"));
7122
+ controller.enqueue(encoder.encode(`${filtered}
7123
+ `));
6987
7124
  };
6988
7125
  const tryFlushMultiline = (candidate) => {
6989
7126
  const trimmed = candidate.trim();
@@ -7004,6 +7141,46 @@ function createAcpFilteredStdoutReadable(params) {
7004
7141
  return false;
7005
7142
  }
7006
7143
  };
7144
+ const consumeLine = (line, lineBytes) => {
7145
+ if (multiline) {
7146
+ const nextBuf = multiline.buf.length > 0 ? `${multiline.buf}
7147
+ ${line}` : line;
7148
+ const nextBytes = multiline.bytes + lineBytes + 1;
7149
+ if (nextBytes > maxMultilineBytes) {
7150
+ drop("multiline_overflow", multiline.buf);
7151
+ multiline = null;
7152
+ if (lineBytes > maxMultilineBytes) {
7153
+ drop("multiline_overflow", line);
7154
+ return;
7155
+ }
7156
+ enqueueLine(line);
7157
+ return;
7158
+ }
7159
+ multiline = { buf: nextBuf, bytes: nextBytes };
7160
+ if (tryFlushMultiline(multiline.buf)) {
7161
+ multiline = null;
7162
+ }
7163
+ return;
7164
+ }
7165
+ if (lineBytes > maxMultilineBytes) {
7166
+ drop("multiline_overflow", line);
7167
+ return;
7168
+ }
7169
+ const trimmed = line.trim();
7170
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
7171
+ try {
7172
+ const parsed = JSON.parse(trimmed);
7173
+ if (typeof parsed === "object" && parsed !== null) {
7174
+ enqueueLine(line);
7175
+ return;
7176
+ }
7177
+ } catch {
7178
+ multiline = { buf: line, bytes: lineBytes };
7179
+ return;
7180
+ }
7181
+ }
7182
+ enqueueLine(line);
7183
+ };
7007
7184
  try {
7008
7185
  while (true) {
7009
7186
  const { value, done } = await reader.read();
@@ -7013,73 +7190,54 @@ function createAcpFilteredStdoutReadable(params) {
7013
7190
  if (!value) {
7014
7191
  continue;
7015
7192
  }
7016
- let decodedChunk = decoder.decode(value, { stream: true });
7193
+ let chunkBuffer = Buffer.from(value);
7017
7194
  if (discardingOversizedLine) {
7018
- const newlineIndex = decodedChunk.indexOf("\n");
7019
- if (newlineIndex === -1) {
7195
+ const newlineIndex2 = chunkBuffer.indexOf(10);
7196
+ if (newlineIndex2 === -1) {
7020
7197
  continue;
7021
7198
  }
7022
- decodedChunk = decodedChunk.slice(newlineIndex + 1);
7199
+ chunkBuffer = chunkBuffer.subarray(newlineIndex2 + 1);
7023
7200
  discardingOversizedLine = false;
7024
7201
  }
7025
- buffer += decodedChunk;
7026
- const lines = buffer.split("\n");
7027
- buffer = lines.pop() || "";
7028
- for (const line of lines) {
7029
- if (multiline) {
7030
- const nextBuf = multiline.buf.length > 0 ? `${multiline.buf}
7031
- ${line}` : line;
7032
- const nextBytes = multiline.bytes + line.length + 1;
7033
- if (nextBytes > maxMultilineBytes) {
7034
- drop("multiline_overflow", multiline.buf);
7035
- multiline = null;
7036
- if (line.length > maxMultilineBytes) {
7037
- drop("multiline_overflow", line);
7038
- continue;
7039
- }
7040
- enqueueLine(line);
7041
- continue;
7042
- }
7043
- multiline = { buf: nextBuf, bytes: nextBytes };
7044
- if (tryFlushMultiline(multiline.buf)) {
7045
- multiline = null;
7046
- }
7047
- continue;
7048
- }
7049
- if (line.length > maxMultilineBytes) {
7050
- drop("multiline_overflow", line);
7051
- continue;
7052
- }
7053
- const trimmed = line.trim();
7054
- if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
7055
- try {
7056
- const parsed = JSON.parse(trimmed);
7057
- if (typeof parsed === "object" && parsed !== null) {
7058
- enqueueLine(line);
7059
- continue;
7060
- }
7061
- } catch {
7062
- multiline = { buf: line, bytes: line.length };
7063
- continue;
7064
- }
7065
- }
7066
- enqueueLine(line);
7202
+ if (chunkBuffer.length === 0) {
7203
+ continue;
7204
+ }
7205
+ buffer = buffer.length === 0 ? chunkBuffer : Buffer.concat([buffer, chunkBuffer]);
7206
+ let newlineIndex = buffer.indexOf(10);
7207
+ while (newlineIndex !== -1) {
7208
+ const rawLine = buffer.subarray(0, newlineIndex);
7209
+ buffer = buffer.subarray(newlineIndex + 1);
7210
+ const lineBuffer = rawLine.at(-1) === 13 ? rawLine.subarray(0, rawLine.length - 1) : rawLine;
7211
+ const line = lineBuffer.toString("utf8");
7212
+ consumeLine(line, lineBuffer.length);
7213
+ newlineIndex = buffer.indexOf(10);
7067
7214
  }
7068
7215
  if (buffer.length > maxMultilineBytes) {
7069
- drop("multiline_overflow", buffer);
7070
- buffer = "";
7216
+ drop("multiline_overflow", buffer.toString("utf8"));
7217
+ buffer = Buffer.alloc(0);
7071
7218
  discardingOversizedLine = true;
7072
7219
  }
7073
7220
  }
7074
- if (multiline) {
7075
- if (!tryFlushMultiline(multiline.buf)) {
7076
- drop("multiline_incomplete", multiline.buf);
7221
+ if (buffer.length > 0) {
7222
+ const trailingLine = buffer.toString("utf8");
7223
+ const pendingMultiline = multiline;
7224
+ if (pendingMultiline) {
7225
+ const nextBuf = pendingMultiline.buf.length > 0 ? `${pendingMultiline.buf}
7226
+ ${trailingLine}` : trailingLine;
7227
+ if (!tryFlushMultiline(nextBuf)) {
7228
+ drop("multiline_incomplete", nextBuf);
7229
+ }
7230
+ multiline = null;
7231
+ } else if (trailingLine.trim()) {
7232
+ drop("multiline_incomplete", trailingLine);
7077
7233
  }
7078
- multiline = null;
7079
7234
  }
7080
- const trailing = buffer.trim();
7081
- if (trailing) {
7082
- drop("multiline_incomplete", buffer);
7235
+ const remainingMultiline = multiline;
7236
+ if (remainingMultiline) {
7237
+ if (!tryFlushMultiline(remainingMultiline.buf)) {
7238
+ drop("multiline_incomplete", remainingMultiline.buf);
7239
+ }
7240
+ multiline = null;
7083
7241
  }
7084
7242
  } catch (error) {
7085
7243
  controllerErrored = true;
@@ -7178,6 +7336,7 @@ const RETRY_CONFIG = {
7178
7336
  maxDelayMs: 5e3
7179
7337
  };
7180
7338
  const DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS = 2 * 6e4;
7339
+ const MAX_DROPPED_STDOUT_LINE_SAMPLES = 5;
7181
7340
  function readPositiveIntegerEnv(name) {
7182
7341
  const raw = typeof process.env[name] === "string" ? process.env[name].trim() : "";
7183
7342
  if (!raw) {
@@ -7273,6 +7432,12 @@ function isSelectionPermissionRequest(params) {
7273
7432
  }
7274
7433
  return !options.every((option) => isApprovalOption(option));
7275
7434
  }
7435
+ function appendDroppedStdoutLineSummary(summary, entry) {
7436
+ summary.count += 1;
7437
+ if (summary.samples.length < MAX_DROPPED_STDOUT_LINE_SAMPLES) {
7438
+ summary.samples.push(entry);
7439
+ }
7440
+ }
7276
7441
  function nodeToWebStreams(stdin, stdout) {
7277
7442
  const writable = new WritableStream({
7278
7443
  write(chunk) {
@@ -7915,19 +8080,22 @@ ${recentStderrExcerpt}`);
7915
8080
  );
7916
8081
  const writable = streams.writable;
7917
8082
  const readable = streams.readable;
7918
- const droppedStdoutLines = [];
8083
+ const droppedStdoutSummary = {
8084
+ count: 0,
8085
+ samples: []
8086
+ };
7919
8087
  const filteredReadable = createAcpFilteredStdoutReadable({
7920
8088
  readable,
7921
8089
  transport: this.transport,
7922
8090
  onDroppedLine: (entry) => {
7923
- droppedStdoutLines.push(entry);
8091
+ appendDroppedStdoutLineSummary(droppedStdoutSummary, entry);
7924
8092
  this.handleDroppedStdoutLine(entry);
7925
8093
  },
7926
8094
  onDone: () => {
7927
- if (droppedStdoutLines.length > 0) {
8095
+ if (droppedStdoutSummary.count > 0) {
7928
8096
  logger.debug(
7929
- `[AcpBackend] Filtered out ${droppedStdoutLines.length} stdout lines from ${this.transport.agentName}`,
7930
- droppedStdoutLines.slice(0, 5)
8097
+ `[AcpBackend] Filtered out ${droppedStdoutSummary.count} stdout lines from ${this.transport.agentName}`,
8098
+ droppedStdoutSummary.samples
7931
8099
  );
7932
8100
  }
7933
8101
  }
@@ -9171,7 +9339,7 @@ function copyCodexHomeEntry(sourcePath, destPath) {
9171
9339
  });
9172
9340
  }
9173
9341
  function normalizePathForComparison(path, platform) {
9174
- const normalizedPath = normalize(path).replace(/[\\/]+$/, "");
9342
+ const normalizedPath = normalize(path).replace(/[\\/]+/g, "/").replace(/\/+$/, "");
9175
9343
  return platform === "win32" ? normalizedPath.toLowerCase() : normalizedPath;
9176
9344
  }
9177
9345
  function isManagedTemporaryCodexHomePath(path, platform) {
@@ -9179,13 +9347,13 @@ function isManagedTemporaryCodexHomePath(path, platform) {
9179
9347
  if (!trimmedPath) {
9180
9348
  return false;
9181
9349
  }
9182
- if (!basename(trimmedPath).startsWith(MANAGED_CODEX_HOME_PREFIX)) {
9350
+ const pathBaseName = trimmedPath.replace(/[\\/]+$/, "").split(/[\\/]/).at(-1) ?? "";
9351
+ if (!pathBaseName.startsWith(MANAGED_CODEX_HOME_PREFIX)) {
9183
9352
  return false;
9184
9353
  }
9185
9354
  const normalizedTempRoot = normalizePathForComparison(tmpdir(), platform);
9186
9355
  const normalizedPath = normalizePathForComparison(trimmedPath, platform);
9187
- const separator = platform === "win32" ? "\\" : "/";
9188
- return normalizedPath.startsWith(`${normalizedTempRoot}${separator}`);
9356
+ return normalizedPath.startsWith(`${normalizedTempRoot}/`);
9189
9357
  }
9190
9358
  function extractSkillDescriptionFromFrontmatter(frontmatter) {
9191
9359
  const lines = frontmatter.split(/\r?\n/);
@@ -9241,25 +9409,7 @@ function shouldSeedCodexSkillEntry(sourcePath) {
9241
9409
  }
9242
9410
  return true;
9243
9411
  }
9244
- function seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir) {
9245
- if (!existsSync(sourceHomeDir)) {
9246
- return;
9247
- }
9248
- for (const fileName of CODEX_HOME_SEED_FILES) {
9249
- try {
9250
- copyCodexHomeEntry(join(sourceHomeDir, fileName), join(isolatedHomeDir, fileName));
9251
- } catch (error) {
9252
- logger.debug(`[codex] Failed to seed CODEX_HOME file ${fileName}`, error);
9253
- }
9254
- }
9255
- for (const dirName of CODEX_HOME_SEED_DIRS) {
9256
- try {
9257
- copyCodexHomeEntry(join(sourceHomeDir, dirName), join(isolatedHomeDir, dirName));
9258
- } catch (error) {
9259
- logger.debug(`[codex] Failed to seed CODEX_HOME directory ${dirName}`, error);
9260
- }
9261
- }
9262
- const sourceSkillsDir = join(sourceHomeDir, "skills");
9412
+ function seedCodexSkillEntries(sourceSkillsDir, isolatedHomeDir, sourceLabel) {
9263
9413
  if (!existsSync(sourceSkillsDir)) {
9264
9414
  return;
9265
9415
  }
@@ -9276,10 +9426,32 @@ function seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir) {
9276
9426
  join(destSkillsDir, entryName)
9277
9427
  );
9278
9428
  } catch (error) {
9279
- logger.debug(`[codex] Failed to seed CODEX_HOME skills entry ${entryName}`, error);
9429
+ logger.debug(`[codex] Failed to seed CODEX_HOME skills entry ${entryName} from ${sourceLabel}`, error);
9280
9430
  }
9281
9431
  }
9282
9432
  }
9433
+ function seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir, bundledSkillsDir) {
9434
+ if (existsSync(sourceHomeDir)) {
9435
+ for (const fileName of CODEX_HOME_SEED_FILES) {
9436
+ try {
9437
+ copyCodexHomeEntry(join(sourceHomeDir, fileName), join(isolatedHomeDir, fileName));
9438
+ } catch (error) {
9439
+ logger.debug(`[codex] Failed to seed CODEX_HOME file ${fileName}`, error);
9440
+ }
9441
+ }
9442
+ for (const dirName of CODEX_HOME_SEED_DIRS) {
9443
+ try {
9444
+ copyCodexHomeEntry(join(sourceHomeDir, dirName), join(isolatedHomeDir, dirName));
9445
+ } catch (error) {
9446
+ logger.debug(`[codex] Failed to seed CODEX_HOME directory ${dirName}`, error);
9447
+ }
9448
+ }
9449
+ }
9450
+ if (bundledSkillsDir) {
9451
+ seedCodexSkillEntries(bundledSkillsDir, isolatedHomeDir, "bundled skills");
9452
+ }
9453
+ seedCodexSkillEntries(join(sourceHomeDir, "skills"), isolatedHomeDir, "source CODEX_HOME");
9454
+ }
9283
9455
  function prepareCodexAcpEnvironment(overrides = {}, options = {}) {
9284
9456
  const env = buildCodexAcpEnv(overrides, options);
9285
9457
  const platform = options.platform ?? process.platform;
@@ -9300,7 +9472,8 @@ function prepareCodexAcpEnvironment(overrides = {}, options = {}) {
9300
9472
  const isolatedHomeDir = tempDirFactory(join(tmpdir(), "happy-codex-home-"));
9301
9473
  mkdirSync$1(isolatedHomeDir, { recursive: true });
9302
9474
  const sourceHomeDir = options.sourceHomeDir ?? join(homedir$1(), ".codex");
9303
- seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir);
9475
+ const bundledSkillsDir = options.bundledSkillsDir ?? join(projectPath(), "skills");
9476
+ seedIsolatedCodexHome(sourceHomeDir, isolatedHomeDir, bundledSkillsDir);
9304
9477
  env.CODEX_HOME = isolatedHomeDir;
9305
9478
  return {
9306
9479
  env,
@@ -10776,14 +10949,14 @@ var launch = /*#__PURE__*/Object.freeze({
10776
10949
  const unifiedProviderExecutors = {
10777
10950
  claude: async (opts) => {
10778
10951
  const claudeOptions = opts.claudeOptions ?? {};
10779
- const { runClaude } = await import('./runClaude-BqN1RhrO.mjs');
10952
+ const { runClaude } = await import('./runClaude-Y84RT6V0.mjs');
10780
10953
  await runClaude(opts.credentials, {
10781
10954
  ...claudeOptions,
10782
10955
  startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
10783
10956
  });
10784
10957
  },
10785
10958
  codex: async (opts) => {
10786
- const { runCodex } = await import('./runCodex-C3htqAO7.mjs');
10959
+ const { runCodex } = await import('./runCodex-D2xIzHke.mjs');
10787
10960
  await runCodex({
10788
10961
  credentials: opts.credentials,
10789
10962
  startedBy: opts.startedBy,
@@ -10792,7 +10965,7 @@ const unifiedProviderExecutors = {
10792
10965
  });
10793
10966
  },
10794
10967
  gemini: async (opts) => {
10795
- const { runGemini } = await import('./runGemini-CH9Cti4U.mjs');
10968
+ const { runGemini } = await import('./runGemini-CAotw19V.mjs');
10796
10969
  await runGemini({
10797
10970
  credentials: opts.credentials,
10798
10971
  startedBy: opts.startedBy
@@ -10875,7 +11048,7 @@ function shouldRunMainClaudeFlow(opts) {
10875
11048
  return;
10876
11049
  } else if (subcommand === "runtime") {
10877
11050
  if (args[1] === "providers") {
10878
- const { renderRuntimeProviders } = await import('./command-B_RdbyPU.mjs');
11051
+ const { renderRuntimeProviders } = await import('./command-DU0KWNsf.mjs');
10879
11052
  console.log(renderRuntimeProviders());
10880
11053
  return;
10881
11054
  }
@@ -10948,6 +11121,12 @@ function shouldRunMainClaudeFlow(opts) {
10948
11121
  process.exit(1);
10949
11122
  }
10950
11123
  return;
11124
+ } else if (subcommand === "session") {
11125
+ const exitCode = await handleSessionCommand(args.slice(1));
11126
+ if (exitCode !== 0) {
11127
+ process.exit(exitCode);
11128
+ }
11129
+ return;
10951
11130
  } else if (subcommand === "codex") {
10952
11131
  try {
10953
11132
  let startedBy = void 0;
@@ -11075,8 +11254,8 @@ function shouldRunMainClaudeFlow(opts) {
11075
11254
  const projectId = args[3];
11076
11255
  try {
11077
11256
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
11078
- const { readCredentials: readCredentials2 } = await import('./api-DZeS3vrX.mjs').then(function (n) { return n.O; });
11079
- const { ApiClient: ApiClient2 } = await import('./api-DZeS3vrX.mjs').then(function (n) { return n.P; });
11257
+ const { readCredentials: readCredentials2 } = await import('./api-DugHuNd4.mjs').then(function (n) { return n.O; });
11258
+ const { ApiClient: ApiClient2 } = await import('./api-DugHuNd4.mjs').then(function (n) { return n.P; });
11080
11259
  let userEmail = void 0;
11081
11260
  try {
11082
11261
  const credentials = await readCredentials2();
@@ -11369,6 +11548,7 @@ ${chalk.bold("Usage:")}
11369
11548
  hicloud gemini Start Gemini mode (ACP)
11370
11549
  hicloud cursor Start Cursor mode (experimental ACP)
11371
11550
  hicloud connect Connect AI vendor API keys
11551
+ hicloud session Manage tracked daemon sessions
11372
11552
  hicloud notify Send push notification
11373
11553
  hicloud daemon Manage background service that allows
11374
11554
  to spawn new sessions away from your computer
@@ -11384,6 +11564,7 @@ ${chalk.bold("Examples:")}
11384
11564
  hicloud --claude-env ANTHROPIC_BASE_URL=http://127.0.0.1:3456
11385
11565
  Use a custom API endpoint (e.g., claude-code-router)
11386
11566
  hicloud auth login --force Authenticate
11567
+ hicloud session list List daemon-tracked sessions
11387
11568
  hicloud doctor Run diagnostics
11388
11569
 
11389
11570
  ${chalk.bold(`${BRAND_CONFIG.name} supports ALL Claude options!`)}