happy-imou-cloud 2.1.2 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/bin/happy-cloud.mjs +39 -39
  2. package/dist/{BaseReasoningProcessor-CzvqwxuY.cjs → BaseReasoningProcessor-DgdsExMH.cjs} +3 -3
  3. package/dist/{BaseReasoningProcessor-BaOWkVcu.mjs → BaseReasoningProcessor-lTsZVuAU.mjs} +3 -3
  4. package/dist/{ProviderSelectionHandler-wwbfeK_s.cjs → ProviderSelectionHandler-Bavm9TDG.cjs} +2 -2
  5. package/dist/{ProviderSelectionHandler-Q8pl7e-d.mjs → ProviderSelectionHandler-CGTnB7ba.mjs} +2 -2
  6. package/dist/{api-DZimmN4C.cjs → api-B6ESNpGB.cjs} +3 -3
  7. package/dist/{api-Cxifhw5r.mjs → api-l8X03rs-.mjs} +3 -3
  8. package/dist/{command-B6LM3Nml.mjs → command-BVCkEMtp.mjs} +3 -3
  9. package/dist/{command-RcCJI1jl.cjs → command-DPLKOzMr.cjs} +3 -3
  10. package/dist/{index-Cuvs0lFS.cjs → index-D1BP-fEm.cjs} +438 -38
  11. package/dist/{index-Des7I5WX.mjs → index-D72RMo5Z.mjs} +435 -35
  12. package/dist/index.cjs +3 -3
  13. package/dist/index.mjs +3 -3
  14. package/dist/lib.cjs +1 -1
  15. package/dist/lib.d.cts +81 -82
  16. package/dist/lib.d.mts +81 -82
  17. package/dist/lib.mjs +1 -1
  18. package/dist/{persistence-6d4U4Sh8.mjs → persistence-CyFjFOlN.mjs} +1 -1
  19. package/dist/{persistence-C8-MtdQK.cjs → persistence-EDmI-c8T.cjs} +1 -1
  20. package/dist/{registerKillSessionHandler-BapPCRmp.cjs → registerKillSessionHandler-71xCO8e_.cjs} +6 -5
  21. package/dist/{registerKillSessionHandler-BFBkz_XT.mjs → registerKillSessionHandler-DAVhkb-l.mjs} +6 -5
  22. package/dist/{runClaude-CPV5Uap2.mjs → runClaude-BRhQLKjh.mjs} +5 -5
  23. package/dist/{runClaude-DVnqKa1q.cjs → runClaude-DjnTGJGC.cjs} +5 -5
  24. package/dist/{runCodex-Bzsp8gFO.cjs → runCodex-BHq7Rnq7.cjs} +6 -6
  25. package/dist/{runCodex-CwtLSTMJ.mjs → runCodex-DUs_jBE-.mjs} +6 -6
  26. package/dist/{runGemini-6Dwyk_Km.cjs → runGemini-hkZeOnA_.cjs} +6 -6
  27. package/dist/{runGemini-Bmoxehlh.mjs → runGemini-pmvBZ6qU.mjs} +6 -6
  28. package/package.json +3 -3
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
- var api = require('./api-DZimmN4C.cjs');
5
- var persistence = require('./persistence-C8-MtdQK.cjs');
4
+ var api = require('./api-B6ESNpGB.cjs');
5
+ var persistence = require('./persistence-EDmI-c8T.cjs');
6
6
  var z = require('zod');
7
7
  var fs$2 = require('fs/promises');
8
8
  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-Cuvs0lFS.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-D1BP-fEm.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();
@@ -695,7 +695,7 @@ function setupCleanupHandlers() {
695
695
  });
696
696
  }
697
697
 
698
- 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-Cuvs0lFS.cjs', document.baseURI).href))));
698
+ 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-D1BP-fEm.cjs', document.baseURI).href))));
699
699
  function projectPath() {
700
700
  const path = path$1.resolve(__dirname$2, "..");
701
701
  return path;
@@ -4864,6 +4864,296 @@ function truncateDisplayMessage(value, maxLength) {
4864
4864
  return `${formatted.substring(0, maxLength)}...`;
4865
4865
  }
4866
4866
 
4867
+ const DEFAULT_RESPONSE_WAIT_TIMEOUT_MS = 10 * 6e4;
4868
+ const DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS$1 = 2 * 6e4;
4869
+ const TIMEOUT_FAST_WORDS = ["fast", "quick", "low", "minimal", "light", "shallow", "short", "economy"];
4870
+ const TIMEOUT_BALANCED_WORDS = ["balanced", "medium", "normal", "default", "standard", "auto"];
4871
+ const TIMEOUT_DEEP_WORDS = ["deep", "high", "max", "maximum", "extended", "long", "intense", "thorough"];
4872
+ const CACHE_OFF_WORDS = ["off", "none", "disabled", "disable", "false"];
4873
+ const CACHE_DEFAULT_WORDS = ["default", "auto", "balanced", "standard", "normal"];
4874
+ const CACHE_AGGRESSIVE_WORDS = ["aggressive", "enabled", "enable", "on", "high", "max", "maximum", "full", "always"];
4875
+ const TIMEOUT_OPTION_HINTS = ["timeout", "latency", "speed", "effort", "thought", "thinking", "reasoning", "reason", "depth"];
4876
+ const CACHE_OPTION_HINTS = ["cache", "caching", "cached", "reuse", "replay"];
4877
+ function normalizeAgentKey(agentName) {
4878
+ return agentName.replace(/[^a-z0-9]+/gi, "_").replace(/^_+|_+$/g, "").toUpperCase();
4879
+ }
4880
+ function readEnvValue(env, names) {
4881
+ for (const name of names) {
4882
+ const raw = env[name]?.trim();
4883
+ if (raw) {
4884
+ return raw;
4885
+ }
4886
+ }
4887
+ return null;
4888
+ }
4889
+ function readTimeoutProfile(agentName, env) {
4890
+ const agentKey = normalizeAgentKey(agentName);
4891
+ const raw = readEnvValue(env, [
4892
+ `HAPPY_${agentKey}_ACP_TIMEOUT_PROFILE`,
4893
+ `HAPPIER_${agentKey}_ACP_TIMEOUT_PROFILE`,
4894
+ "HAPPY_ACP_TIMEOUT_PROFILE",
4895
+ "HAPPIER_ACP_TIMEOUT_PROFILE"
4896
+ ])?.toLowerCase();
4897
+ if (!raw) {
4898
+ return { value: "balanced", source: "default" };
4899
+ }
4900
+ if (["fast", "quick", "low", "minimal", "light", "shallow"].includes(raw)) {
4901
+ return { value: "fast", source: "env" };
4902
+ }
4903
+ if (["deep", "high", "max", "maximum", "extended", "long", "thorough"].includes(raw)) {
4904
+ return { value: "deep", source: "env" };
4905
+ }
4906
+ return { value: "balanced", source: "env" };
4907
+ }
4908
+ function readCachePolicy(agentName, env) {
4909
+ const agentKey = normalizeAgentKey(agentName);
4910
+ const raw = readEnvValue(env, [
4911
+ `HAPPY_${agentKey}_ACP_CACHE_POLICY`,
4912
+ `HAPPIER_${agentKey}_ACP_CACHE_POLICY`,
4913
+ "HAPPY_ACP_CACHE_POLICY",
4914
+ "HAPPIER_ACP_CACHE_POLICY"
4915
+ ])?.toLowerCase();
4916
+ if (!raw) {
4917
+ return { value: "default", source: "default" };
4918
+ }
4919
+ if (["off", "none", "disabled", "disable", "false"].includes(raw)) {
4920
+ return { value: "off", source: "env" };
4921
+ }
4922
+ if (["aggressive", "enabled", "enable", "on", "high", "max", "maximum", "full", "always"].includes(raw)) {
4923
+ return { value: "aggressive", source: "env" };
4924
+ }
4925
+ return { value: "default", source: "env" };
4926
+ }
4927
+ function normalizeText(value) {
4928
+ return (value ?? "").toLowerCase();
4929
+ }
4930
+ function tokenize(...parts) {
4931
+ return parts.map((part) => normalizeText(part)).join(" ").split(/[^a-z0-9]+/g).filter(Boolean);
4932
+ }
4933
+ function includesAny(tokens, expected) {
4934
+ return expected.some((candidate) => tokens.includes(candidate));
4935
+ }
4936
+ function isSelectSessionConfigOption(option) {
4937
+ return option.type === "select";
4938
+ }
4939
+ function isBooleanSessionConfigOption(option) {
4940
+ return option.type === "boolean";
4941
+ }
4942
+ function flattenSelectOptions(options) {
4943
+ const flattened = [];
4944
+ for (const option of options) {
4945
+ if (Array.isArray(option.options)) {
4946
+ flattened.push(...option.options);
4947
+ continue;
4948
+ }
4949
+ flattened.push(option);
4950
+ }
4951
+ return flattened;
4952
+ }
4953
+ function classifyConfigOption(option) {
4954
+ const tokens = tokenize(option.id, option.name, option.description, option.category);
4955
+ if (option.category === "thought_level" || includesAny(tokens, TIMEOUT_OPTION_HINTS)) {
4956
+ return "timeout";
4957
+ }
4958
+ if (includesAny(tokens, CACHE_OPTION_HINTS)) {
4959
+ return "cache";
4960
+ }
4961
+ return null;
4962
+ }
4963
+ function scoreTimeoutChoice(option, profile, currentValue) {
4964
+ const tokens = tokenize(option.value, option.name, option.description);
4965
+ let score = 0;
4966
+ if (profile === "fast" && includesAny(tokens, TIMEOUT_FAST_WORDS)) {
4967
+ score += 4;
4968
+ }
4969
+ if (profile === "balanced" && includesAny(tokens, TIMEOUT_BALANCED_WORDS)) {
4970
+ score += 4;
4971
+ }
4972
+ if (profile === "deep" && includesAny(tokens, TIMEOUT_DEEP_WORDS)) {
4973
+ score += 4;
4974
+ }
4975
+ if (profile === "balanced" && option.value === currentValue) {
4976
+ score += 2;
4977
+ }
4978
+ return score;
4979
+ }
4980
+ function scoreCacheChoice(option, policy, currentValue) {
4981
+ const tokens = tokenize(option.value, option.name, option.description);
4982
+ let score = 0;
4983
+ if (policy === "off" && includesAny(tokens, CACHE_OFF_WORDS)) {
4984
+ score += 4;
4985
+ }
4986
+ if (policy === "default" && includesAny(tokens, CACHE_DEFAULT_WORDS)) {
4987
+ score += 4;
4988
+ }
4989
+ if (policy === "aggressive" && includesAny(tokens, CACHE_AGGRESSIVE_WORDS)) {
4990
+ score += 4;
4991
+ }
4992
+ if (policy === "default" && option.value === currentValue) {
4993
+ score += 2;
4994
+ }
4995
+ return score;
4996
+ }
4997
+ function chooseTimeoutValue(option, profile) {
4998
+ if (!isSelectSessionConfigOption(option)) {
4999
+ return null;
5000
+ }
5001
+ const candidates = flattenSelectOptions(option.options);
5002
+ let best = null;
5003
+ for (const candidate of candidates) {
5004
+ const score = scoreTimeoutChoice(candidate, profile, option.currentValue);
5005
+ if (score <= 0) {
5006
+ continue;
5007
+ }
5008
+ if (!best || score > best.score) {
5009
+ best = { value: candidate.value, score };
5010
+ }
5011
+ }
5012
+ return best?.value ?? null;
5013
+ }
5014
+ function chooseCacheValue(option, policy) {
5015
+ if (isBooleanSessionConfigOption(option)) {
5016
+ if (policy === "off") {
5017
+ return false;
5018
+ }
5019
+ if (policy === "aggressive") {
5020
+ return true;
5021
+ }
5022
+ return null;
5023
+ }
5024
+ if (!isSelectSessionConfigOption(option)) {
5025
+ return null;
5026
+ }
5027
+ const candidates = flattenSelectOptions(option.options);
5028
+ let best = null;
5029
+ for (const candidate of candidates) {
5030
+ const score = scoreCacheChoice(candidate, policy, option.currentValue);
5031
+ if (score <= 0) {
5032
+ continue;
5033
+ }
5034
+ if (!best || score > best.score) {
5035
+ best = { value: candidate.value, score };
5036
+ }
5037
+ }
5038
+ return best?.value ?? null;
5039
+ }
5040
+ function buildSetSessionConfigOptionRequest(options) {
5041
+ if (typeof options.value === "boolean") {
5042
+ return {
5043
+ sessionId: options.sessionId,
5044
+ configId: options.configId,
5045
+ type: "boolean",
5046
+ value: options.value
5047
+ };
5048
+ }
5049
+ return {
5050
+ sessionId: options.sessionId,
5051
+ configId: options.configId,
5052
+ value: options.value
5053
+ };
5054
+ }
5055
+ function resolveAcpSessionPreferences(options) {
5056
+ const mergedEnv = {
5057
+ ...process.env,
5058
+ ...options.env ?? {}
5059
+ };
5060
+ const timeout = readTimeoutProfile(options.agentName, mergedEnv);
5061
+ const cache = readCachePolicy(options.agentName, mergedEnv);
5062
+ return {
5063
+ agentName: options.agentName,
5064
+ timeoutProfile: timeout.value,
5065
+ timeoutSource: timeout.source,
5066
+ cachePolicy: cache.value,
5067
+ cacheSource: cache.source
5068
+ };
5069
+ }
5070
+ function scaleAcpTimeoutMs(baseMs, kind, profile) {
5071
+ if (profile === "balanced") {
5072
+ return baseMs;
5073
+ }
5074
+ const multipliers = profile === "fast" ? {
5075
+ init: 0.75,
5076
+ tool: 0.75,
5077
+ investigation: 0.75,
5078
+ think: 0.5,
5079
+ execute: 0.75
5080
+ } : {
5081
+ init: 1.5,
5082
+ tool: 1.5,
5083
+ investigation: 1.5,
5084
+ think: 2,
5085
+ execute: 1.5
5086
+ };
5087
+ const minimums = {
5088
+ init: 15e3,
5089
+ tool: 6e4,
5090
+ investigation: 5 * 6e4,
5091
+ think: 15e3,
5092
+ execute: 2 * 6e4
5093
+ };
5094
+ return Math.max(minimums[kind], Math.round(baseMs * multipliers[kind]));
5095
+ }
5096
+ function resolveAcpResponseWaitTimeoutMs(profile) {
5097
+ if (profile === "fast") {
5098
+ return 5 * 6e4;
5099
+ }
5100
+ if (profile === "deep") {
5101
+ return 20 * 6e4;
5102
+ }
5103
+ return DEFAULT_RESPONSE_WAIT_TIMEOUT_MS;
5104
+ }
5105
+ function resolveAcpPostPromptNoUpdatesTimeoutMs(baseMs, profile) {
5106
+ if (profile === "fast") {
5107
+ return Math.max(3e4, Math.min(baseMs, 45e3));
5108
+ }
5109
+ if (profile === "deep") {
5110
+ return Math.max(baseMs, 4 * 6e4);
5111
+ }
5112
+ return baseMs || DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS$1;
5113
+ }
5114
+ function buildAcpSessionConfigPresetPlan(options) {
5115
+ const plan = [];
5116
+ for (const option of options.configOptions ?? []) {
5117
+ const kind = classifyConfigOption(option);
5118
+ if (kind === "timeout" && options.preferences.timeoutSource === "env") {
5119
+ const targetValue = chooseTimeoutValue(option, options.preferences.timeoutProfile);
5120
+ if (targetValue && targetValue !== option.currentValue) {
5121
+ plan.push({
5122
+ kind,
5123
+ optionId: option.id,
5124
+ optionName: option.name,
5125
+ currentValue: option.currentValue,
5126
+ targetValue,
5127
+ request: buildSetSessionConfigOptionRequest({
5128
+ sessionId: options.sessionId,
5129
+ configId: option.id,
5130
+ value: targetValue
5131
+ })
5132
+ });
5133
+ }
5134
+ continue;
5135
+ }
5136
+ if (kind === "cache" && options.preferences.cacheSource === "env") {
5137
+ const targetValue = chooseCacheValue(option, options.preferences.cachePolicy);
5138
+ if (targetValue && targetValue !== option.currentValue) {
5139
+ plan.push({
5140
+ kind,
5141
+ optionId: option.id,
5142
+ optionName: option.name,
5143
+ currentValue: option.currentValue,
5144
+ targetValue,
5145
+ request: buildSetSessionConfigOptionRequest({
5146
+ sessionId: options.sessionId,
5147
+ configId: option.id,
5148
+ value: targetValue
5149
+ })
5150
+ });
5151
+ }
5152
+ }
5153
+ }
5154
+ return plan;
5155
+ }
5156
+
4867
5157
  const DEFAULT_TIMEOUTS = {
4868
5158
  /** Default initialization timeout: 60 seconds */
4869
5159
  init: 6e4,
@@ -4877,11 +5167,14 @@ class DefaultTransport {
4877
5167
  constructor(agentName = "generic-acp") {
4878
5168
  this.agentName = agentName;
4879
5169
  }
5170
+ getTimeoutProfile() {
5171
+ return resolveAcpSessionPreferences({ agentName: this.agentName }).timeoutProfile;
5172
+ }
4880
5173
  /**
4881
5174
  * Default init timeout: 60 seconds
4882
5175
  */
4883
5176
  getInitTimeout() {
4884
- return DEFAULT_TIMEOUTS.init;
5177
+ return scaleAcpTimeoutMs(DEFAULT_TIMEOUTS.init, "init", this.getTimeoutProfile());
4885
5178
  }
4886
5179
  getInitDelayMs() {
4887
5180
  return 0;
@@ -4930,9 +5223,9 @@ class DefaultTransport {
4930
5223
  */
4931
5224
  getToolCallTimeout(_toolCallId, toolKind) {
4932
5225
  if (toolKind === "think") {
4933
- return DEFAULT_TIMEOUTS.think;
5226
+ return scaleAcpTimeoutMs(DEFAULT_TIMEOUTS.think, "think", this.getTimeoutProfile());
4934
5227
  }
4935
- return DEFAULT_TIMEOUTS.toolCall;
5228
+ return scaleAcpTimeoutMs(DEFAULT_TIMEOUTS.toolCall, "tool", this.getTimeoutProfile());
4936
5229
  }
4937
5230
  /**
4938
5231
  * Default: no tool name extraction (return null)
@@ -4947,7 +5240,7 @@ class DefaultTransport {
4947
5240
  return toolName;
4948
5241
  }
4949
5242
  getPostPromptNoUpdatesTimeoutMs() {
4950
- return 2 * 6e4;
5243
+ return resolveAcpPostPromptNoUpdatesTimeoutMs(2 * 6e4, this.getTimeoutProfile());
4951
5244
  }
4952
5245
  }
4953
5246
 
@@ -4984,11 +5277,14 @@ const AVAILABLE_MODELS = [
4984
5277
  ];
4985
5278
  class GeminiTransport {
4986
5279
  agentName = "gemini";
5280
+ getTimeoutProfile() {
5281
+ return resolveAcpSessionPreferences({ agentName: this.agentName }).timeoutProfile;
5282
+ }
4987
5283
  /**
4988
5284
  * Gemini CLI needs 2 minutes for first start (model download, warm-up)
4989
5285
  */
4990
5286
  getInitTimeout() {
4991
- return GEMINI_TIMEOUTS.init;
5287
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.init, "init", this.getTimeoutProfile());
4992
5288
  }
4993
5289
  getInitDelayMs() {
4994
5290
  return GEMINI_TIMEOUTS.initDelay;
@@ -5071,12 +5367,12 @@ class GeminiTransport {
5071
5367
  */
5072
5368
  getToolCallTimeout(toolCallId, toolKind) {
5073
5369
  if (this.isInvestigationTool(toolCallId, toolKind)) {
5074
- return GEMINI_TIMEOUTS.investigation;
5370
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.investigation, "investigation", this.getTimeoutProfile());
5075
5371
  }
5076
5372
  if (toolKind === "think") {
5077
- return GEMINI_TIMEOUTS.think;
5373
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.think, "think", this.getTimeoutProfile());
5078
5374
  }
5079
- return GEMINI_TIMEOUTS.toolCall;
5375
+ return scaleAcpTimeoutMs(GEMINI_TIMEOUTS.toolCall, "tool", this.getTimeoutProfile());
5080
5376
  }
5081
5377
  /**
5082
5378
  * Get idle detection timeout
@@ -5170,22 +5466,20 @@ function readPositiveIntegerEnv$1(name) {
5170
5466
  }
5171
5467
  return value;
5172
5468
  }
5173
- function resolveCodexExecuteTimeoutMs() {
5174
- return readPositiveIntegerEnv$1("HAPPY_CODEX_EXECUTE_TIMEOUT_MS") ?? readPositiveIntegerEnv$1("HAPPIER_CODEX_EXECUTE_TIMEOUT_MS") ?? DEFAULT_CODEX_EXECUTE_TIMEOUT_MS;
5175
- }
5176
5469
  class CodexTransport extends DefaultTransport {
5177
5470
  constructor() {
5178
5471
  super("codex");
5179
5472
  }
5180
5473
  getInitTimeout() {
5181
- return 3e4;
5474
+ return scaleAcpTimeoutMs(3e4, "init", this.getTimeoutProfile());
5182
5475
  }
5183
5476
  getIdleTimeout() {
5184
5477
  return 800;
5185
5478
  }
5186
5479
  getToolCallTimeout(toolCallId, toolKind) {
5187
5480
  if (toolKind === "execute") {
5188
- return resolveCodexExecuteTimeoutMs();
5481
+ const explicit = readPositiveIntegerEnv$1("HAPPY_CODEX_EXECUTE_TIMEOUT_MS") ?? readPositiveIntegerEnv$1("HAPPIER_CODEX_EXECUTE_TIMEOUT_MS");
5482
+ return explicit ?? scaleAcpTimeoutMs(DEFAULT_CODEX_EXECUTE_TIMEOUT_MS, "execute", this.getTimeoutProfile());
5189
5483
  }
5190
5484
  return super.getToolCallTimeout(toolCallId, toolKind);
5191
5485
  }
@@ -5197,7 +5491,7 @@ class ClaudeTransport extends DefaultTransport {
5197
5491
  super("claude");
5198
5492
  }
5199
5493
  getInitTimeout() {
5200
- return 15e3;
5494
+ return scaleAcpTimeoutMs(15e3, "init", this.getTimeoutProfile());
5201
5495
  }
5202
5496
  getIdleTimeout() {
5203
5497
  return 600;
@@ -5210,7 +5504,7 @@ class CursorTransport extends DefaultTransport {
5210
5504
  super("cursor");
5211
5505
  }
5212
5506
  getInitTimeout() {
5213
- return 2e4;
5507
+ return scaleAcpTimeoutMs(2e4, "init", this.getTimeoutProfile());
5214
5508
  }
5215
5509
  getIdleTimeout() {
5216
5510
  return 700;
@@ -5357,6 +5651,9 @@ function extractToolOutputChunk(content) {
5357
5651
  const formatted = formatDisplayMessage(content);
5358
5652
  return formatted.length > 0 ? formatted : null;
5359
5653
  }
5654
+ function hasVisibleToolCallProgress(content) {
5655
+ return extractToolOutputChunk(content) !== null;
5656
+ }
5360
5657
  function mergeStreamedOutputWithResult(content, streamedOutput) {
5361
5658
  if (!streamedOutput || streamedOutput.length === 0) {
5362
5659
  return content;
@@ -5888,14 +6185,14 @@ function readPositiveIntegerEnv(name) {
5888
6185
  return value;
5889
6186
  }
5890
6187
  function resolvePostPromptNoUpdatesTimeoutMs(transport) {
5891
- const transportValue = transport.getPostPromptNoUpdatesTimeoutMs?.();
5892
- if (typeof transportValue === "number" && Number.isFinite(transportValue) && transportValue > 0) {
5893
- return Math.trunc(transportValue);
5894
- }
5895
6188
  const envValue = readPositiveIntegerEnv("HAPPY_ACP_POST_PROMPT_NO_UPDATES_TIMEOUT_MS") ?? readPositiveIntegerEnv("HAPPIER_ACP_POST_PROMPT_NO_UPDATES_TIMEOUT_MS");
5896
6189
  if (envValue != null) {
5897
6190
  return envValue;
5898
6191
  }
6192
+ const transportValue = transport.getPostPromptNoUpdatesTimeoutMs?.();
6193
+ if (typeof transportValue === "number" && Number.isFinite(transportValue) && transportValue > 0) {
6194
+ return Math.trunc(transportValue);
6195
+ }
5899
6196
  return DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS;
5900
6197
  }
5901
6198
  function getSessionUpdates(params) {
@@ -5912,6 +6209,15 @@ function getSessionUpdates(params) {
5912
6209
  function asNonNegativeFiniteNumber(value) {
5913
6210
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
5914
6211
  }
6212
+ function shouldRefreshProgressForToolCallUpdate(update, wasToolCallActive, isToolCallActive) {
6213
+ if (!wasToolCallActive && isToolCallActive) {
6214
+ return true;
6215
+ }
6216
+ if (update.status === "completed" || update.status === "failed" || update.status === "cancelled") {
6217
+ return true;
6218
+ }
6219
+ return hasVisibleToolCallProgress(update.content);
6220
+ }
5915
6221
  function extractUsageTokens(record) {
5916
6222
  const used = asNonNegativeFiniteNumber(record.used);
5917
6223
  const size = asNonNegativeFiniteNumber(record.size);
@@ -6175,6 +6481,10 @@ class AcpBackend {
6175
6481
  constructor(options) {
6176
6482
  this.options = options;
6177
6483
  this.transport = options.transportHandler ?? new DefaultTransport(options.agentName);
6484
+ this.sessionPreferences = resolveAcpSessionPreferences({
6485
+ agentName: options.agentName,
6486
+ env: options.env
6487
+ });
6178
6488
  }
6179
6489
  listeners = [];
6180
6490
  process = null;
@@ -6221,6 +6531,8 @@ class AcpBackend {
6221
6531
  sawSessionUpdateSincePrompt = false;
6222
6532
  /** Transport handler for agent-specific behavior */
6223
6533
  transport;
6534
+ sessionPreferences;
6535
+ sessionConfigOptions = null;
6224
6536
  /** Keep a short rolling stderr buffer so startup failures can surface the real cause. */
6225
6537
  recentStderrLines = [];
6226
6538
  recordRecentStderr(text) {
@@ -6236,6 +6548,60 @@ class AcpBackend {
6236
6548
  getRecentStderrExcerpt() {
6237
6549
  return this.recentStderrLines.slice(-6).join("\n");
6238
6550
  }
6551
+ updateSessionConfigOptions(configOptions) {
6552
+ this.sessionConfigOptions = Array.isArray(configOptions) ? configOptions : null;
6553
+ }
6554
+ syncSessionConfigOptionsFromUpdate(update) {
6555
+ const configOptions = update.configOptions;
6556
+ if (!Array.isArray(configOptions)) {
6557
+ return false;
6558
+ }
6559
+ this.updateSessionConfigOptions(configOptions);
6560
+ return true;
6561
+ }
6562
+ async applySessionConfigPresets() {
6563
+ if (!this.connection || !this.acpSessionId) {
6564
+ return;
6565
+ }
6566
+ const presetPlan = buildAcpSessionConfigPresetPlan({
6567
+ sessionId: this.acpSessionId,
6568
+ configOptions: this.sessionConfigOptions,
6569
+ preferences: this.sessionPreferences
6570
+ });
6571
+ if (presetPlan.length === 0) {
6572
+ return;
6573
+ }
6574
+ api.logger.debug(
6575
+ `[AcpBackend] Applying ${presetPlan.length} ACP session config preset(s) for ${this.sessionPreferences.agentName}`
6576
+ );
6577
+ for (const preset of presetPlan) {
6578
+ try {
6579
+ api.logger.debug(
6580
+ `[AcpBackend] Setting ACP session config ${preset.optionId} from ${String(preset.currentValue)} to ${String(preset.targetValue)}`
6581
+ );
6582
+ const response = await this.connection.setSessionConfigOption(preset.request);
6583
+ this.updateSessionConfigOptions(response.configOptions);
6584
+ } catch (error) {
6585
+ api.logger.warn(
6586
+ `[AcpBackend] Failed to apply ACP session config preset ${preset.optionId}:`,
6587
+ error
6588
+ );
6589
+ }
6590
+ }
6591
+ }
6592
+ getPostPromptNoUpdatesTimeoutMs() {
6593
+ const explicitTimeout = readPositiveIntegerEnv("HAPPY_ACP_POST_PROMPT_NO_UPDATES_TIMEOUT_MS") ?? readPositiveIntegerEnv("HAPPIER_ACP_POST_PROMPT_NO_UPDATES_TIMEOUT_MS");
6594
+ if (explicitTimeout != null) {
6595
+ return explicitTimeout;
6596
+ }
6597
+ if (this.sessionPreferences.timeoutSource === "env") {
6598
+ return resolveAcpPostPromptNoUpdatesTimeoutMs(
6599
+ DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS,
6600
+ this.sessionPreferences.timeoutProfile
6601
+ );
6602
+ }
6603
+ return resolvePostPromptNoUpdatesTimeoutMs(this.transport);
6604
+ }
6239
6605
  clearIdleTimeoutState() {
6240
6606
  if (this.idleTimeout) {
6241
6607
  clearTimeout(this.idleTimeout);
@@ -6809,7 +7175,9 @@ ${recentStderrExcerpt}`);
6809
7175
  }
6810
7176
  );
6811
7177
  this.acpSessionId = sessionResponse.sessionId;
7178
+ this.updateSessionConfigOptions(sessionResponse.configOptions);
6812
7179
  api.logger.debug(`[AcpBackend] Session created: ${this.acpSessionId}`);
7180
+ await this.applySessionConfigPresets();
6813
7181
  this.emitIdleStatus();
6814
7182
  if (initialPrompt) {
6815
7183
  this.sendPrompt(sessionId, initialPrompt).catch((error) => {
@@ -6897,7 +7265,6 @@ ${recentStderrExcerpt}`);
6897
7265
  this.clearPostPromptCompletionIdleTimeout();
6898
7266
  for (const update of updates) {
6899
7267
  const sessionUpdateType = update.sessionUpdate;
6900
- this.markResponseProgress();
6901
7268
  if (sessionUpdateType !== "agent_message_chunk" && sessionUpdateType !== "tool_call_update") {
6902
7269
  api.logger.debug(`[AcpBackend] Received session update: ${sessionUpdateType}`, JSON.stringify({
6903
7270
  sessionUpdate: sessionUpdateType,
@@ -6909,8 +7276,12 @@ ${recentStderrExcerpt}`);
6909
7276
  }, null, 2));
6910
7277
  }
6911
7278
  const ctx = this.createHandlerContext();
7279
+ const toolCallId = update.toolCallId;
7280
+ const wasToolCallActive = typeof toolCallId === "string" && this.activeToolCalls.has(toolCallId);
6912
7281
  if (sessionUpdateType === "agent_message_chunk") {
6913
- handleAgentMessageChunk(update, ctx);
7282
+ if (handleAgentMessageChunk(update, ctx).handled) {
7283
+ this.markResponseProgress();
7284
+ }
6914
7285
  continue;
6915
7286
  }
6916
7287
  if (sessionUpdateType === "tool_call_update") {
@@ -6918,20 +7289,36 @@ ${recentStderrExcerpt}`);
6918
7289
  if (result.toolCallCountSincePrompt !== void 0) {
6919
7290
  this.toolCallCountSincePrompt = result.toolCallCountSincePrompt;
6920
7291
  }
7292
+ const isToolCallActive = typeof toolCallId === "string" && this.activeToolCalls.has(toolCallId);
7293
+ if (shouldRefreshProgressForToolCallUpdate(update, wasToolCallActive, isToolCallActive)) {
7294
+ this.markResponseProgress();
7295
+ }
6921
7296
  continue;
6922
7297
  }
6923
7298
  if (sessionUpdateType === "agent_thought_chunk") {
6924
- handleAgentThoughtChunk(update, ctx);
7299
+ if (handleAgentThoughtChunk(update, ctx).handled) {
7300
+ this.markResponseProgress();
7301
+ }
6925
7302
  continue;
6926
7303
  }
6927
7304
  if (sessionUpdateType === "tool_call") {
6928
- handleToolCall(update, ctx);
7305
+ const result = handleToolCall(update, ctx);
7306
+ const isToolCallActive = typeof toolCallId === "string" && this.activeToolCalls.has(toolCallId);
7307
+ if (result.handled && !wasToolCallActive && isToolCallActive) {
7308
+ this.markResponseProgress();
7309
+ }
6929
7310
  continue;
6930
7311
  }
6931
7312
  if (sessionUpdateType === "usage_update") {
6932
7313
  this.emitUsageTelemetry(update, "acp-usage-update");
6933
7314
  continue;
6934
7315
  }
7316
+ if (sessionUpdateType === "config_option_update") {
7317
+ if (this.syncSessionConfigOptionsFromUpdate(update)) {
7318
+ this.markResponseProgress({ refreshToolTimeouts: false });
7319
+ }
7320
+ continue;
7321
+ }
6935
7322
  if (sessionUpdateType === "task_complete") {
6936
7323
  this.emitUsageTelemetry(update.usage, "acp-session-usage");
6937
7324
  ctx.clearIdleTimeout();
@@ -6943,8 +7330,19 @@ ${recentStderrExcerpt}`);
6943
7330
  const handledPlan = handlePlanUpdate(update, ctx).handled;
6944
7331
  const handledThinking = handleThinkingUpdate(update, ctx).handled;
6945
7332
  const handledUsage = this.emitUsageTelemetry(update.usage, "acp-session-usage");
7333
+ if (handledLegacy || handledPlan || handledThinking) {
7334
+ this.markResponseProgress();
7335
+ }
6946
7336
  const updateTypeStr = sessionUpdateType;
6947
- const handledTypes = ["agent_message_chunk", "tool_call_update", "agent_thought_chunk", "tool_call", "usage_update", "task_complete"];
7337
+ const handledTypes = [
7338
+ "agent_message_chunk",
7339
+ "tool_call_update",
7340
+ "agent_thought_chunk",
7341
+ "tool_call",
7342
+ "usage_update",
7343
+ "config_option_update",
7344
+ "task_complete"
7345
+ ];
6948
7346
  if (updateTypeStr && !handledTypes.includes(updateTypeStr) && !handledLegacy && !handledPlan && !handledThinking && !handledUsage) {
6949
7347
  api.logger.debug(`[AcpBackend] Unhandled session update type: ${updateTypeStr}`, JSON.stringify(update, null, 2));
6950
7348
  }
@@ -6977,7 +7375,7 @@ ${recentStderrExcerpt}`);
6977
7375
  await this.connection.prompt(promptRequest);
6978
7376
  api.logger.debug("[AcpBackend] Prompt request sent to ACP connection");
6979
7377
  if (this.waitingForResponse && this.activeToolCalls.size === 0 && this.sawSessionUpdateSincePrompt === false) {
6980
- const noUpdatesTimeoutMs = resolvePostPromptNoUpdatesTimeoutMs(this.transport);
7378
+ const noUpdatesTimeoutMs = this.getPostPromptNoUpdatesTimeoutMs();
6981
7379
  this.postPromptCompletionIdleTimeout = setTimeout(() => {
6982
7380
  this.postPromptCompletionIdleTimeout = null;
6983
7381
  if (this.responseCompletionError || !this.waitingForResponse) {
@@ -7022,7 +7420,7 @@ ${recentStderrExcerpt}`);
7022
7420
  * Wait for the response to complete (idle status after all chunks received)
7023
7421
  * Call this after sendPrompt to wait for Gemini to finish responding
7024
7422
  */
7025
- async waitForResponseComplete(timeoutMs = 10 * 6e4) {
7423
+ async waitForResponseComplete(timeoutMs) {
7026
7424
  if (this.responseCompletionError) {
7027
7425
  throw this.responseCompletionError;
7028
7426
  }
@@ -7037,6 +7435,7 @@ ${recentStderrExcerpt}`);
7037
7435
  if (!this.waitingForResponse) {
7038
7436
  return;
7039
7437
  }
7438
+ const effectiveTimeoutMs = timeoutMs ?? resolveAcpResponseWaitTimeoutMs(this.sessionPreferences.timeoutProfile);
7040
7439
  return new Promise((resolve, reject) => {
7041
7440
  this.idleResolver = () => {
7042
7441
  this.idleResolver = null;
@@ -7050,7 +7449,7 @@ ${recentStderrExcerpt}`);
7050
7449
  this.waitingForResponse = false;
7051
7450
  reject(error);
7052
7451
  };
7053
- this.armResponseWaitTimeout(timeoutMs);
7452
+ this.armResponseWaitTimeout(effectiveTimeoutMs);
7054
7453
  });
7055
7454
  }
7056
7455
  /**
@@ -7129,6 +7528,7 @@ ${recentStderrExcerpt}`);
7129
7528
  this.listeners = [];
7130
7529
  this.connection = null;
7131
7530
  this.acpSessionId = null;
7531
+ this.sessionConfigOptions = null;
7132
7532
  this.clearToolCallTracking();
7133
7533
  this.pendingPermissions.clear();
7134
7534
  }
@@ -7865,7 +8265,7 @@ class AbortError extends Error {
7865
8265
  }
7866
8266
  }
7867
8267
 
7868
- 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-Cuvs0lFS.cjs', document.baseURI).href)));
8268
+ 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-D1BP-fEm.cjs', document.baseURI).href)));
7869
8269
  const __dirname$1 = path.join(__filename$1, "..");
7870
8270
  function getGlobalClaudeVersion() {
7871
8271
  try {
@@ -9116,11 +9516,11 @@ var launch = /*#__PURE__*/Object.freeze({
9116
9516
 
9117
9517
  const unifiedProviderExecutors = {
9118
9518
  claude: async (opts) => {
9119
- const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-DVnqKa1q.cjs'); });
9519
+ const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-DjnTGJGC.cjs'); });
9120
9520
  await runClaude(opts.credentials, opts.claudeOptions ?? {});
9121
9521
  },
9122
9522
  codex: async (opts) => {
9123
- const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-Bzsp8gFO.cjs'); });
9523
+ const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-BHq7Rnq7.cjs'); });
9124
9524
  await runCodex({
9125
9525
  credentials: opts.credentials,
9126
9526
  startedBy: opts.startedBy,
@@ -9129,7 +9529,7 @@ const unifiedProviderExecutors = {
9129
9529
  });
9130
9530
  },
9131
9531
  gemini: async (opts) => {
9132
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-6Dwyk_Km.cjs'); });
9532
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-hkZeOnA_.cjs'); });
9133
9533
  await runGemini({
9134
9534
  credentials: opts.credentials,
9135
9535
  startedBy: opts.startedBy
@@ -9205,7 +9605,7 @@ function shouldRunMainClaudeFlow(opts) {
9205
9605
  return;
9206
9606
  } else if (subcommand === "runtime") {
9207
9607
  if (args[1] === "providers") {
9208
- const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-RcCJI1jl.cjs'); });
9608
+ const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-DPLKOzMr.cjs'); });
9209
9609
  console.log(renderRuntimeProviders());
9210
9610
  return;
9211
9611
  }
@@ -9383,8 +9783,8 @@ function shouldRunMainClaudeFlow(opts) {
9383
9783
  const projectId = args[3];
9384
9784
  try {
9385
9785
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
9386
- const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-C8-MtdQK.cjs'); });
9387
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-DZimmN4C.cjs'); }).then(function (n) { return n.api; });
9786
+ const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-EDmI-c8T.cjs'); });
9787
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-B6ESNpGB.cjs'); }).then(function (n) { return n.api; });
9388
9788
  let userEmail = void 0;
9389
9789
  try {
9390
9790
  const credentials = await readCredentials2();