happy-imou-cloud 2.1.3 → 2.1.5

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 (26) hide show
  1. package/bin/happy-cloud.mjs +1 -1
  2. package/dist/{BaseReasoningProcessor-CPLK0a8y.mjs → BaseReasoningProcessor-CTWoJTb8.mjs} +3 -3
  3. package/dist/{BaseReasoningProcessor-BrcBFCoL.cjs → BaseReasoningProcessor-DsunYoSL.cjs} +3 -3
  4. package/dist/{ProviderSelectionHandler-f7_I3vQa.cjs → ProviderSelectionHandler-BxcgZ5df.cjs} +2 -2
  5. package/dist/{ProviderSelectionHandler-CrXfMTg1.mjs → ProviderSelectionHandler-LiWZjziD.mjs} +2 -2
  6. package/dist/{api-OoiG7XjD.cjs → api-DOn5w7Lv.cjs} +3 -3
  7. package/dist/{api-BGv79x9Q.mjs → api-RxQ4bfJm.mjs} +3 -3
  8. package/dist/{command-FbV44egL.mjs → command-BZ8G4IiN.mjs} +3 -3
  9. package/dist/{command-DAYJSP16.cjs → command-C3XGNSfh.cjs} +3 -3
  10. package/dist/{index-D9lWHpn-.cjs → index-C06zeR85.cjs} +406 -34
  11. package/dist/{index-TRC83Ks9.mjs → index-CQEVJsPp.mjs} +403 -31
  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.mjs +1 -1
  16. package/dist/{persistence-Cmgj3ubQ.mjs → persistence-Bf5FdmEK.mjs} +1 -1
  17. package/dist/{persistence-lN9HV4IZ.cjs → persistence-DuakVvfB.cjs} +1 -1
  18. package/dist/{registerKillSessionHandler-pk4Ohq4Y.cjs → registerKillSessionHandler-BRC1HO05.cjs} +75 -10
  19. package/dist/{registerKillSessionHandler-NZd3xieQ.mjs → registerKillSessionHandler-BuzsaxI2.mjs} +75 -10
  20. package/dist/{runClaude-BP-O6ucu.cjs → runClaude-C8Lx-Xij.cjs} +5 -5
  21. package/dist/{runClaude-7St9-Jci.mjs → runClaude-Cg8x5JOI.mjs} +5 -5
  22. package/dist/{runCodex-BaXi_9BC.mjs → runCodex-e4wK1OuI.mjs} +6 -6
  23. package/dist/{runCodex-BV6kKtTO.cjs → runCodex-rYroXLgt.cjs} +6 -6
  24. package/dist/{runGemini-BiYKqJqO.cjs → runGemini-Bjw2PSMh.cjs} +6 -6
  25. package/dist/{runGemini-ClNqE9N3.mjs → runGemini-Cd1FWJJ_.mjs} +6 -6
  26. package/package.json +2 -2
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
- var api = require('./api-OoiG7XjD.cjs');
5
- var persistence = require('./persistence-lN9HV4IZ.cjs');
4
+ var api = require('./api-DOn5w7Lv.cjs');
5
+ var persistence = require('./persistence-DuakVvfB.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-D9lWHpn-.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-C06zeR85.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-D9lWHpn-.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-C06zeR85.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;
@@ -5891,14 +6185,14 @@ function readPositiveIntegerEnv(name) {
5891
6185
  return value;
5892
6186
  }
5893
6187
  function resolvePostPromptNoUpdatesTimeoutMs(transport) {
5894
- const transportValue = transport.getPostPromptNoUpdatesTimeoutMs?.();
5895
- if (typeof transportValue === "number" && Number.isFinite(transportValue) && transportValue > 0) {
5896
- return Math.trunc(transportValue);
5897
- }
5898
6188
  const envValue = readPositiveIntegerEnv("HAPPY_ACP_POST_PROMPT_NO_UPDATES_TIMEOUT_MS") ?? readPositiveIntegerEnv("HAPPIER_ACP_POST_PROMPT_NO_UPDATES_TIMEOUT_MS");
5899
6189
  if (envValue != null) {
5900
6190
  return envValue;
5901
6191
  }
6192
+ const transportValue = transport.getPostPromptNoUpdatesTimeoutMs?.();
6193
+ if (typeof transportValue === "number" && Number.isFinite(transportValue) && transportValue > 0) {
6194
+ return Math.trunc(transportValue);
6195
+ }
5902
6196
  return DEFAULT_POST_PROMPT_NO_UPDATES_TIMEOUT_MS;
5903
6197
  }
5904
6198
  function getSessionUpdates(params) {
@@ -6187,6 +6481,10 @@ class AcpBackend {
6187
6481
  constructor(options) {
6188
6482
  this.options = options;
6189
6483
  this.transport = options.transportHandler ?? new DefaultTransport(options.agentName);
6484
+ this.sessionPreferences = resolveAcpSessionPreferences({
6485
+ agentName: options.agentName,
6486
+ env: options.env
6487
+ });
6190
6488
  }
6191
6489
  listeners = [];
6192
6490
  process = null;
@@ -6233,6 +6531,8 @@ class AcpBackend {
6233
6531
  sawSessionUpdateSincePrompt = false;
6234
6532
  /** Transport handler for agent-specific behavior */
6235
6533
  transport;
6534
+ sessionPreferences;
6535
+ sessionConfigOptions = null;
6236
6536
  /** Keep a short rolling stderr buffer so startup failures can surface the real cause. */
6237
6537
  recentStderrLines = [];
6238
6538
  recordRecentStderr(text) {
@@ -6248,6 +6548,60 @@ class AcpBackend {
6248
6548
  getRecentStderrExcerpt() {
6249
6549
  return this.recentStderrLines.slice(-6).join("\n");
6250
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
+ }
6251
6605
  clearIdleTimeoutState() {
6252
6606
  if (this.idleTimeout) {
6253
6607
  clearTimeout(this.idleTimeout);
@@ -6821,7 +7175,9 @@ ${recentStderrExcerpt}`);
6821
7175
  }
6822
7176
  );
6823
7177
  this.acpSessionId = sessionResponse.sessionId;
7178
+ this.updateSessionConfigOptions(sessionResponse.configOptions);
6824
7179
  api.logger.debug(`[AcpBackend] Session created: ${this.acpSessionId}`);
7180
+ await this.applySessionConfigPresets();
6825
7181
  this.emitIdleStatus();
6826
7182
  if (initialPrompt) {
6827
7183
  this.sendPrompt(sessionId, initialPrompt).catch((error) => {
@@ -6957,6 +7313,12 @@ ${recentStderrExcerpt}`);
6957
7313
  this.emitUsageTelemetry(update, "acp-usage-update");
6958
7314
  continue;
6959
7315
  }
7316
+ if (sessionUpdateType === "config_option_update") {
7317
+ if (this.syncSessionConfigOptionsFromUpdate(update)) {
7318
+ this.markResponseProgress({ refreshToolTimeouts: false });
7319
+ }
7320
+ continue;
7321
+ }
6960
7322
  if (sessionUpdateType === "task_complete") {
6961
7323
  this.emitUsageTelemetry(update.usage, "acp-session-usage");
6962
7324
  ctx.clearIdleTimeout();
@@ -6972,7 +7334,15 @@ ${recentStderrExcerpt}`);
6972
7334
  this.markResponseProgress();
6973
7335
  }
6974
7336
  const updateTypeStr = sessionUpdateType;
6975
- 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
+ ];
6976
7346
  if (updateTypeStr && !handledTypes.includes(updateTypeStr) && !handledLegacy && !handledPlan && !handledThinking && !handledUsage) {
6977
7347
  api.logger.debug(`[AcpBackend] Unhandled session update type: ${updateTypeStr}`, JSON.stringify(update, null, 2));
6978
7348
  }
@@ -7005,7 +7375,7 @@ ${recentStderrExcerpt}`);
7005
7375
  await this.connection.prompt(promptRequest);
7006
7376
  api.logger.debug("[AcpBackend] Prompt request sent to ACP connection");
7007
7377
  if (this.waitingForResponse && this.activeToolCalls.size === 0 && this.sawSessionUpdateSincePrompt === false) {
7008
- const noUpdatesTimeoutMs = resolvePostPromptNoUpdatesTimeoutMs(this.transport);
7378
+ const noUpdatesTimeoutMs = this.getPostPromptNoUpdatesTimeoutMs();
7009
7379
  this.postPromptCompletionIdleTimeout = setTimeout(() => {
7010
7380
  this.postPromptCompletionIdleTimeout = null;
7011
7381
  if (this.responseCompletionError || !this.waitingForResponse) {
@@ -7050,7 +7420,7 @@ ${recentStderrExcerpt}`);
7050
7420
  * Wait for the response to complete (idle status after all chunks received)
7051
7421
  * Call this after sendPrompt to wait for Gemini to finish responding
7052
7422
  */
7053
- async waitForResponseComplete(timeoutMs = 10 * 6e4) {
7423
+ async waitForResponseComplete(timeoutMs) {
7054
7424
  if (this.responseCompletionError) {
7055
7425
  throw this.responseCompletionError;
7056
7426
  }
@@ -7065,6 +7435,7 @@ ${recentStderrExcerpt}`);
7065
7435
  if (!this.waitingForResponse) {
7066
7436
  return;
7067
7437
  }
7438
+ const effectiveTimeoutMs = timeoutMs ?? resolveAcpResponseWaitTimeoutMs(this.sessionPreferences.timeoutProfile);
7068
7439
  return new Promise((resolve, reject) => {
7069
7440
  this.idleResolver = () => {
7070
7441
  this.idleResolver = null;
@@ -7078,7 +7449,7 @@ ${recentStderrExcerpt}`);
7078
7449
  this.waitingForResponse = false;
7079
7450
  reject(error);
7080
7451
  };
7081
- this.armResponseWaitTimeout(timeoutMs);
7452
+ this.armResponseWaitTimeout(effectiveTimeoutMs);
7082
7453
  });
7083
7454
  }
7084
7455
  /**
@@ -7157,6 +7528,7 @@ ${recentStderrExcerpt}`);
7157
7528
  this.listeners = [];
7158
7529
  this.connection = null;
7159
7530
  this.acpSessionId = null;
7531
+ this.sessionConfigOptions = null;
7160
7532
  this.clearToolCallTracking();
7161
7533
  this.pendingPermissions.clear();
7162
7534
  }
@@ -7893,7 +8265,7 @@ class AbortError extends Error {
7893
8265
  }
7894
8266
  }
7895
8267
 
7896
- 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-D9lWHpn-.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-C06zeR85.cjs', document.baseURI).href)));
7897
8269
  const __dirname$1 = path.join(__filename$1, "..");
7898
8270
  function getGlobalClaudeVersion() {
7899
8271
  try {
@@ -9144,11 +9516,11 @@ var launch = /*#__PURE__*/Object.freeze({
9144
9516
 
9145
9517
  const unifiedProviderExecutors = {
9146
9518
  claude: async (opts) => {
9147
- const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-BP-O6ucu.cjs'); });
9519
+ const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-C8Lx-Xij.cjs'); });
9148
9520
  await runClaude(opts.credentials, opts.claudeOptions ?? {});
9149
9521
  },
9150
9522
  codex: async (opts) => {
9151
- const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-BV6kKtTO.cjs'); });
9523
+ const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-rYroXLgt.cjs'); });
9152
9524
  await runCodex({
9153
9525
  credentials: opts.credentials,
9154
9526
  startedBy: opts.startedBy,
@@ -9157,7 +9529,7 @@ const unifiedProviderExecutors = {
9157
9529
  });
9158
9530
  },
9159
9531
  gemini: async (opts) => {
9160
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-BiYKqJqO.cjs'); });
9532
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-Bjw2PSMh.cjs'); });
9161
9533
  await runGemini({
9162
9534
  credentials: opts.credentials,
9163
9535
  startedBy: opts.startedBy
@@ -9233,7 +9605,7 @@ function shouldRunMainClaudeFlow(opts) {
9233
9605
  return;
9234
9606
  } else if (subcommand === "runtime") {
9235
9607
  if (args[1] === "providers") {
9236
- const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-DAYJSP16.cjs'); });
9608
+ const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-C3XGNSfh.cjs'); });
9237
9609
  console.log(renderRuntimeProviders());
9238
9610
  return;
9239
9611
  }
@@ -9411,8 +9783,8 @@ function shouldRunMainClaudeFlow(opts) {
9411
9783
  const projectId = args[3];
9412
9784
  try {
9413
9785
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
9414
- const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-lN9HV4IZ.cjs'); });
9415
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-OoiG7XjD.cjs'); }).then(function (n) { return n.api; });
9786
+ const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-DuakVvfB.cjs'); });
9787
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-DOn5w7Lv.cjs'); }).then(function (n) { return n.api; });
9416
9788
  let userEmail = void 0;
9417
9789
  try {
9418
9790
  const credentials = await readCredentials2();