autohand-cli 0.7.3 → 0.7.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.
package/dist/index.cjs CHANGED
@@ -24,7 +24,7 @@ var _chunkLUKMRIKJcjs = require('./chunk-LUKMRIKJ.cjs');
24
24
  require('./chunk-JHGIWNHL.cjs');
25
25
 
26
26
 
27
- var _chunkHXAAED4Wcjs = require('./chunk-HXAAED4W.cjs');
27
+ var _chunkHYTYXN2Gcjs = require('./chunk-HYTYXN2G.cjs');
28
28
 
29
29
 
30
30
  var _chunkOTS4YFSZcjs = require('./chunk-OTS4YFSZ.cjs');
@@ -41,13 +41,13 @@ var _chunkC3IFF3EHcjs = require('./chunk-C3IFF3EH.cjs');
41
41
 
42
42
 
43
43
 
44
- var _chunk7EIL6P6Qcjs = require('./chunk-7EIL6P6Q.cjs');
44
+ var _chunkXJZYEURAcjs = require('./chunk-XJZYEURA.cjs');
45
45
 
46
46
 
47
- var _chunkFEI2GPAWcjs = require('./chunk-FEI2GPAW.cjs');
47
+ var _chunk2E2COWKBcjs = require('./chunk-2E2COWKB.cjs');
48
48
 
49
49
 
50
- var _chunkU43RFUBRcjs = require('./chunk-U43RFUBR.cjs');
50
+ var _chunk536VWSZKcjs = require('./chunk-536VWSZK.cjs');
51
51
 
52
52
 
53
53
  var _chunkREPKBECDcjs = require('./chunk-REPKBECD.cjs');
@@ -59,7 +59,7 @@ var _chunkREPKBECDcjs = require('./chunk-REPKBECD.cjs');
59
59
 
60
60
 
61
61
 
62
- var _chunkSXUZ3CX3cjs = require('./chunk-SXUZ3CX3.cjs');
62
+ var _chunkQMVTT55Ycjs = require('./chunk-QMVTT55Y.cjs');
63
63
 
64
64
 
65
65
  var _chunkB5N5UAMOcjs = require('./chunk-B5N5UAMO.cjs');
@@ -1988,6 +1988,128 @@ var OpenRouterProvider = class {
1988
1988
  }
1989
1989
  };
1990
1990
 
1991
+ // src/utils/platform.ts
1992
+ function isAppleSilicon() {
1993
+ return process.platform === "darwin" && process.arch === "arm64";
1994
+ }
1995
+ function isMLXSupported() {
1996
+ return isAppleSilicon();
1997
+ }
1998
+
1999
+ // src/providers/MLXProvider.ts
2000
+ var MLXProvider = class {
2001
+ constructor(config) {
2002
+ const port = config.port || 8080;
2003
+ this.baseUrl = config.baseUrl || `http://localhost:${port}`;
2004
+ this.model = config.model || "mlx-model";
2005
+ }
2006
+ getName() {
2007
+ return "mlx";
2008
+ }
2009
+ setModel(model) {
2010
+ this.model = model;
2011
+ }
2012
+ async listModels() {
2013
+ if (!isMLXSupported()) {
2014
+ return [];
2015
+ }
2016
+ try {
2017
+ const response = await fetch(`${this.baseUrl}/v1/models`);
2018
+ if (!response.ok) {
2019
+ return this.model ? [this.model] : [];
2020
+ }
2021
+ const data = await response.json();
2022
+ return _nullishCoalesce(_optionalChain([data, 'access', _42 => _42.data, 'optionalAccess', _43 => _43.map, 'call', _44 => _44((m) => m.id)]), () => ( (this.model ? [this.model] : [])));
2023
+ } catch (e23) {
2024
+ return this.model ? [this.model] : [];
2025
+ }
2026
+ }
2027
+ async isAvailable() {
2028
+ if (!isMLXSupported()) {
2029
+ return false;
2030
+ }
2031
+ try {
2032
+ const response = await fetch(`${this.baseUrl}/v1/models`);
2033
+ return response.ok;
2034
+ } catch (e24) {
2035
+ return false;
2036
+ }
2037
+ }
2038
+ async complete(request) {
2039
+ if (!isMLXSupported()) {
2040
+ throw new Error("MLX is only supported on macOS with Apple Silicon");
2041
+ }
2042
+ const body = {
2043
+ model: request.model || this.model,
2044
+ messages: request.messages.map((msg) => {
2045
+ const mapped = {
2046
+ role: msg.role,
2047
+ content: msg.content
2048
+ };
2049
+ if (msg.name) mapped.name = msg.name;
2050
+ if (msg.role === "tool" && msg.tool_call_id) mapped.tool_call_id = msg.tool_call_id;
2051
+ if (msg.role === "assistant" && msg.tool_calls) mapped.tool_calls = msg.tool_calls;
2052
+ return mapped;
2053
+ }),
2054
+ temperature: _nullishCoalesce(request.temperature, () => ( 0.7)),
2055
+ max_tokens: _nullishCoalesce(request.maxTokens, () => ( 4096)),
2056
+ stream: false
2057
+ };
2058
+ if (request.tools && request.tools.length > 0) {
2059
+ body.tools = request.tools.map((tool) => ({
2060
+ type: "function",
2061
+ function: {
2062
+ name: tool.name,
2063
+ description: tool.description,
2064
+ parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
2065
+ }
2066
+ }));
2067
+ }
2068
+ const response = await fetch(`${this.baseUrl}/v1/chat/completions`, {
2069
+ method: "POST",
2070
+ headers: {
2071
+ "Content-Type": "application/json"
2072
+ },
2073
+ body: JSON.stringify(body),
2074
+ signal: request.signal
2075
+ });
2076
+ if (!response.ok) {
2077
+ throw new Error(`MLX API error: ${response.status} ${response.statusText}`);
2078
+ }
2079
+ const data = await response.json();
2080
+ const choice = data.choices[0];
2081
+ let toolCalls;
2082
+ if (_optionalChain([choice, 'optionalAccess', _45 => _45.message, 'access', _46 => _46.tool_calls, 'optionalAccess', _47 => _47.length])) {
2083
+ toolCalls = choice.message.tool_calls.map((tc) => ({
2084
+ id: tc.id,
2085
+ type: "function",
2086
+ function: {
2087
+ name: tc.function.name,
2088
+ arguments: tc.function.arguments
2089
+ }
2090
+ }));
2091
+ }
2092
+ let usage;
2093
+ if (data.usage) {
2094
+ usage = {
2095
+ promptTokens: data.usage.prompt_tokens,
2096
+ completionTokens: data.usage.completion_tokens,
2097
+ totalTokens: data.usage.total_tokens
2098
+ };
2099
+ }
2100
+ const finishReason = _optionalChain([toolCalls, 'optionalAccess', _48 => _48.length]) ? "tool_calls" : _optionalChain([choice, 'optionalAccess', _49 => _49.finish_reason]) === "stop" || _optionalChain([choice, 'optionalAccess', _50 => _50.finish_reason]) === "length" || _optionalChain([choice, 'optionalAccess', _51 => _51.finish_reason]) === "content_filter" ? choice.finish_reason : "stop";
2101
+ return {
2102
+ id: data.id || `mlx-${Date.now()}`,
2103
+ created: data.created || Math.floor(Date.now() / 1e3),
2104
+ content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess', _52 => _52.message, 'access', _53 => _53.content]), () => ( "")),
2105
+ toolCalls,
2106
+ finishReason,
2107
+ usage,
2108
+ raw: data
2109
+ };
2110
+ }
2111
+ };
2112
+
1991
2113
  // src/providers/ProviderFactory.ts
1992
2114
  var ProviderNotConfiguredError = class extends Error {
1993
2115
  constructor(providerName) {
@@ -2039,6 +2161,11 @@ var ProviderFactory = class {
2039
2161
  return new UnconfiguredProvider("llamacpp");
2040
2162
  }
2041
2163
  return new LlamaCppProvider(config.llamacpp);
2164
+ case "mlx":
2165
+ if (!config.mlx) {
2166
+ return new UnconfiguredProvider("mlx");
2167
+ }
2168
+ return new MLXProvider(config.mlx);
2042
2169
  case "openrouter":
2043
2170
  default:
2044
2171
  if (!config.openrouter) {
@@ -2048,16 +2175,24 @@ var ProviderFactory = class {
2048
2175
  }
2049
2176
  }
2050
2177
  /**
2051
- * Get all available provider names
2178
+ * Get all available provider names.
2179
+ * MLX is only included on Apple Silicon (macOS + arm64).
2052
2180
  */
2053
2181
  static getProviderNames() {
2054
- return ["openrouter", "ollama", "openai", "llamacpp"];
2182
+ const providers = ["openrouter", "ollama", "openai", "llamacpp"];
2183
+ if (isMLXSupported()) {
2184
+ providers.push("mlx");
2185
+ }
2186
+ return providers;
2055
2187
  }
2056
2188
  /**
2057
- * Check if a provider name is valid
2189
+ * Check if a provider name is valid.
2190
+ * Note: This checks if the name is a valid provider type, not if it's available on this platform.
2191
+ * MLX is always a valid provider name, but may not be available on non-Apple Silicon systems.
2058
2192
  */
2059
2193
  static isValidProvider(name) {
2060
- return this.getProviderNames().includes(name);
2194
+ const allProviders = ["openrouter", "ollama", "openai", "llamacpp", "mlx"];
2195
+ return allProviders.includes(name);
2061
2196
  }
2062
2197
  };
2063
2198
 
@@ -2215,7 +2350,7 @@ var MentionPreview = class {
2215
2350
  }
2216
2351
  return;
2217
2352
  }
2218
- if ((_optionalChain([key, 'optionalAccess', _42 => _42.name]) === "down" || _optionalChain([key, 'optionalAccess', _43 => _43.name]) === "up") && this.mode && this.lastSuggestions.length) {
2353
+ if ((_optionalChain([key, 'optionalAccess', _54 => _54.name]) === "down" || _optionalChain([key, 'optionalAccess', _55 => _55.name]) === "up") && this.mode && this.lastSuggestions.length) {
2219
2354
  const delta = key.name === "down" ? 1 : -1;
2220
2355
  const length = this.lastSuggestions.length;
2221
2356
  this.activeIndex = (this.activeIndex + delta + length) % length;
@@ -2261,7 +2396,7 @@ var MentionPreview = class {
2261
2396
  return /@([A-Za-z0-9_./\\-]*)$/.exec(beforeCursor);
2262
2397
  }
2263
2398
  isTabKey(key) {
2264
- return _optionalChain([key, 'optionalAccess', _44 => _44.name]) === "tab" || _optionalChain([key, 'optionalAccess', _45 => _45.sequence]) === " ";
2399
+ return _optionalChain([key, 'optionalAccess', _56 => _56.name]) === "tab" || _optionalChain([key, 'optionalAccess', _57 => _57.sequence]) === " ";
2265
2400
  }
2266
2401
  filterSlash(seed) {
2267
2402
  const normalized = seed.toLowerCase();
@@ -2495,7 +2630,7 @@ function parseBase64DataUrl(dataUrl) {
2495
2630
  try {
2496
2631
  const data = Buffer.from(base64Data, "base64");
2497
2632
  return { mimeType, data };
2498
- } catch (e23) {
2633
+ } catch (e25) {
2499
2634
  return void 0;
2500
2635
  }
2501
2636
  }
@@ -2624,7 +2759,7 @@ async function promptOnce(options) {
2624
2759
  \u{1F4F7} Loaded image: ${filePath} -> [Image #${id}]
2625
2760
  `));
2626
2761
  }
2627
- } catch (e24) {
2762
+ } catch (e26) {
2628
2763
  }
2629
2764
  }
2630
2765
  }
@@ -2664,7 +2799,7 @@ async function promptOnce(options) {
2664
2799
  \u{1F4F7} Loaded image: ${filePath} -> [Image #${id}]
2665
2800
  `));
2666
2801
  }
2667
- } catch (e25) {
2802
+ } catch (e27) {
2668
2803
  }
2669
2804
  }
2670
2805
  }
@@ -2684,7 +2819,7 @@ async function promptOnce(options) {
2684
2819
  \u{1F4F7} Loaded image: ${filePath} -> [Image #${id}]
2685
2820
  `));
2686
2821
  }
2687
- } catch (e26) {
2822
+ } catch (e28) {
2688
2823
  }
2689
2824
  }
2690
2825
  }
@@ -2720,14 +2855,14 @@ async function promptOnce(options) {
2720
2855
  }
2721
2856
  };
2722
2857
  const handleKeypress = (_str, key) => {
2723
- if (_optionalChain([key, 'optionalAccess', _46 => _46.name]) === "return" && (key.shift || key.meta)) {
2858
+ if (_optionalChain([key, 'optionalAccess', _58 => _58.name]) === "return" && (key.shift || key.meta)) {
2724
2859
  const currentMarkers = countNewlineMarkers(rl.line || "");
2725
2860
  if (currentMarkers < MAX_NEWLINES) {
2726
2861
  insertAtCursor(NEWLINE_MARKER);
2727
2862
  }
2728
2863
  return;
2729
2864
  }
2730
- if (_optionalChain([key, 'optionalAccess', _47 => _47.name]) === "c" && key.ctrl) {
2865
+ if (_optionalChain([key, 'optionalAccess', _59 => _59.name]) === "c" && key.ctrl) {
2731
2866
  const currentInput = rl.line || "";
2732
2867
  if (currentInput.length > 0) {
2733
2868
  mentionPreview.reset();
@@ -2920,7 +3055,7 @@ var GIT_SAFETY = {
2920
3055
  };
2921
3056
  function getCurrentBranch(cwd) {
2922
3057
  const result = _child_process.spawnSync.call(void 0, "git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd, encoding: "utf8" });
2923
- return _optionalChain([result, 'access', _48 => _48.stdout, 'optionalAccess', _49 => _49.trim, 'call', _50 => _50()]) || "";
3058
+ return _optionalChain([result, 'access', _60 => _60.stdout, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()]) || "";
2924
3059
  }
2925
3060
  function getCommitsAhead(cwd, remote = "origin", branch) {
2926
3061
  const currentBranch = branch || getCurrentBranch(cwd);
@@ -2929,7 +3064,7 @@ function getCommitsAhead(cwd, remote = "origin", branch) {
2929
3064
  cwd,
2930
3065
  encoding: "utf8"
2931
3066
  });
2932
- return parseInt(_optionalChain([result, 'access', _51 => _51.stdout, 'optionalAccess', _52 => _52.trim, 'call', _53 => _53()]) || "0", 10) || 0;
3067
+ return parseInt(_optionalChain([result, 'access', _63 => _63.stdout, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || "0", 10) || 0;
2933
3068
  }
2934
3069
  function applyGitPatch(cwd, patch) {
2935
3070
  const result = _child_process.spawnSync.call(void 0, "git", ["apply", "-"], {
@@ -2977,7 +3112,7 @@ function gitDiffRange(cwd, options = {}) {
2977
3112
  if (options.range) {
2978
3113
  args.push(options.range);
2979
3114
  }
2980
- if (_optionalChain([options, 'access', _54 => _54.paths, 'optionalAccess', _55 => _55.length])) {
3115
+ if (_optionalChain([options, 'access', _66 => _66.paths, 'optionalAccess', _67 => _67.length])) {
2981
3116
  args.push("--", ...options.paths);
2982
3117
  }
2983
3118
  const result = _child_process.spawnSync.call(void 0, "git", args, { cwd, encoding: "utf8" });
@@ -3276,7 +3411,7 @@ function getAutoCommitInfo(cwd) {
3276
3411
  diffSummary: ""
3277
3412
  };
3278
3413
  }
3279
- const changes = _optionalChain([statusResult, 'access', _56 => _56.stdout, 'optionalAccess', _57 => _57.trim, 'call', _58 => _58(), 'access', _59 => _59.split, 'call', _60 => _60("\n"), 'access', _61 => _61.filter, 'call', _62 => _62(Boolean)]) || [];
3414
+ const changes = _optionalChain([statusResult, 'access', _68 => _68.stdout, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70(), 'access', _71 => _71.split, 'call', _72 => _72("\n"), 'access', _73 => _73.filter, 'call', _74 => _74(Boolean)]) || [];
3280
3415
  if (changes.length === 0) {
3281
3416
  return {
3282
3417
  canCommit: false,
@@ -3304,7 +3439,7 @@ function getAutoCommitInfo(cwd) {
3304
3439
  }
3305
3440
  }
3306
3441
  const diffStatResult = _child_process.spawnSync.call(void 0, "git", ["diff", "--stat", "HEAD"], { cwd, encoding: "utf8" });
3307
- const diffSummary = _optionalChain([diffStatResult, 'access', _63 => _63.stdout, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || "";
3442
+ const diffSummary = _optionalChain([diffStatResult, 'access', _75 => _75.stdout, 'optionalAccess', _76 => _76.trim, 'call', _77 => _77()]) || "";
3308
3443
  const suggestedMessage = generateCommitMessage(added, modified, deleted, renamed);
3309
3444
  return {
3310
3445
  canCommit: true,
@@ -3359,7 +3494,7 @@ function generateCommitMessage(added, modified, deleted, renamed) {
3359
3494
  }
3360
3495
  function executeAutoCommit(cwd, message, stageAll = true) {
3361
3496
  const statusResult = _child_process.spawnSync.call(void 0, "git", ["status", "--porcelain"], { cwd, encoding: "utf8" });
3362
- const changes = _optionalChain([statusResult, 'access', _66 => _66.stdout, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68(), 'access', _69 => _69.split, 'call', _70 => _70("\n"), 'access', _71 => _71.filter, 'call', _72 => _72(Boolean)]) || [];
3497
+ const changes = _optionalChain([statusResult, 'access', _78 => _78.stdout, 'optionalAccess', _79 => _79.trim, 'call', _80 => _80(), 'access', _81 => _81.split, 'call', _82 => _82("\n"), 'access', _83 => _83.filter, 'call', _84 => _84(Boolean)]) || [];
3363
3498
  if (stageAll) {
3364
3499
  const addResult = _child_process.spawnSync.call(void 0, "git", ["add", "-A"], { cwd, encoding: "utf8" });
3365
3500
  if (addResult.status !== 0) {
@@ -3379,7 +3514,7 @@ function executeAutoCommit(cwd, message, stageAll = true) {
3379
3514
  };
3380
3515
  }
3381
3516
  const hashResult = _child_process.spawnSync.call(void 0, "git", ["rev-parse", "--short", "HEAD"], { cwd, encoding: "utf8" });
3382
- const commitHash = _optionalChain([hashResult, 'access', _73 => _73.stdout, 'optionalAccess', _74 => _74.trim, 'call', _75 => _75()]);
3517
+ const commitHash = _optionalChain([hashResult, 'access', _85 => _85.stdout, 'optionalAccess', _86 => _86.trim, 'call', _87 => _87()]);
3383
3518
  return {
3384
3519
  success: true,
3385
3520
  message: `Committed ${changes.length} file(s): ${commitHash}`,
@@ -3617,15 +3752,15 @@ var ToolFilter = class {
3617
3752
  this.policy = {
3618
3753
  ...basePolicy,
3619
3754
  ...customPolicy,
3620
- allowedCategories: _nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _76 => _76.allowedCategories]), () => ( basePolicy.allowedCategories)),
3755
+ allowedCategories: _nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _88 => _88.allowedCategories]), () => ( basePolicy.allowedCategories)),
3621
3756
  blockedTools: [
3622
3757
  ..._nullishCoalesce(basePolicy.blockedTools, () => ( [])),
3623
- ..._nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _77 => _77.blockedTools]), () => ( []))
3758
+ ..._nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _89 => _89.blockedTools]), () => ( []))
3624
3759
  ],
3625
- allowedTools: _optionalChain([customPolicy, 'optionalAccess', _78 => _78.allowedTools]),
3760
+ allowedTools: _optionalChain([customPolicy, 'optionalAccess', _90 => _90.allowedTools]),
3626
3761
  requireApprovalFor: [
3627
3762
  ..._nullishCoalesce(basePolicy.requireApprovalFor, () => ( [])),
3628
- ..._nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _79 => _79.requireApprovalFor]), () => ( []))
3763
+ ..._nullishCoalesce(_optionalChain([customPolicy, 'optionalAccess', _91 => _91.requireApprovalFor]), () => ( []))
3629
3764
  ]
3630
3765
  };
3631
3766
  }
@@ -3636,7 +3771,7 @@ var ToolFilter = class {
3636
3771
  if (this.policy.allowedTools && this.policy.allowedTools.length > 0) {
3637
3772
  return this.policy.allowedTools.includes(toolName);
3638
3773
  }
3639
- if (_optionalChain([this, 'access', _80 => _80.policy, 'access', _81 => _81.blockedTools, 'optionalAccess', _82 => _82.includes, 'call', _83 => _83(toolName)])) {
3774
+ if (_optionalChain([this, 'access', _92 => _92.policy, 'access', _93 => _93.blockedTools, 'optionalAccess', _94 => _94.includes, 'call', _95 => _95(toolName)])) {
3640
3775
  return false;
3641
3776
  }
3642
3777
  const category = getToolCategory(toolName);
@@ -3646,7 +3781,7 @@ var ToolFilter = class {
3646
3781
  * Check if a tool requires approval (beyond its default setting)
3647
3782
  */
3648
3783
  requiresApproval(toolName, defaultRequiresApproval) {
3649
- if (_optionalChain([this, 'access', _84 => _84.policy, 'access', _85 => _85.requireApprovalFor, 'optionalAccess', _86 => _86.includes, 'call', _87 => _87(toolName)])) {
3784
+ if (_optionalChain([this, 'access', _96 => _96.policy, 'access', _97 => _97.requireApprovalFor, 'optionalAccess', _98 => _98.includes, 'call', _99 => _99(toolName)])) {
3650
3785
  return true;
3651
3786
  }
3652
3787
  return _nullishCoalesce(defaultRequiresApproval, () => ( false));
@@ -3820,15 +3955,15 @@ var SLASH_COMMANDS = [
3820
3955
  _chunkM7RVTUWEcjs.metadata,
3821
3956
  _chunkJBKP2CLAcjs.metadata,
3822
3957
  _chunkC3IFF3EHcjs.metadata,
3823
- _chunk7EIL6P6Qcjs.metadata,
3824
- _chunkFEI2GPAWcjs.metadata,
3825
- _chunkU43RFUBRcjs.metadata,
3958
+ _chunkXJZYEURAcjs.metadata,
3959
+ _chunk2E2COWKBcjs.metadata,
3960
+ _chunk536VWSZKcjs.metadata,
3826
3961
  _chunkB5N5UAMOcjs.metadata,
3827
3962
  _chunk3L76MLO5cjs.metadata,
3828
3963
  _chunkCT2VTDPQcjs.metadata,
3829
3964
  _chunkCT2VTDPQcjs.installMetadata,
3830
3965
  _chunkLUKMRIKJcjs.metadata,
3831
- _chunkHXAAED4Wcjs.metadata,
3966
+ _chunkHYTYXN2Gcjs.metadata,
3832
3967
  _chunkOTS4YFSZcjs.metadata
3833
3968
  ];
3834
3969
 
@@ -4874,9 +5009,9 @@ var ToolManager = class _ToolManager {
4874
5009
  continue;
4875
5010
  }
4876
5011
  const definition = this.definitions.get(call.tool);
4877
- const requiresApproval = this.toolFilter.requiresApproval(call.tool, _optionalChain([definition, 'optionalAccess', _88 => _88.requiresApproval]));
5012
+ const requiresApproval = this.toolFilter.requiresApproval(call.tool, _optionalChain([definition, 'optionalAccess', _100 => _100.requiresApproval]));
4878
5013
  if (requiresApproval) {
4879
- let message = _nullishCoalesce(_optionalChain([definition, 'optionalAccess', _89 => _89.approvalMessage]), () => ( `Allow tool ${call.tool}?`));
5014
+ let message = _nullishCoalesce(_optionalChain([definition, 'optionalAccess', _101 => _101.approvalMessage]), () => ( `Allow tool ${call.tool}?`));
4880
5015
  let permContext = { tool: call.tool };
4881
5016
  if (call.tool === "run_command" && call.args) {
4882
5017
  const cmd = String(call.args.command || "");
@@ -4886,15 +5021,15 @@ var ToolManager = class _ToolManager {
4886
5021
  message = `Run this command${dir}?
4887
5022
  $ ${fullCommand}`;
4888
5023
  permContext.command = fullCommand;
4889
- } else if (call.tool === "delete_path" && _optionalChain([call, 'access', _90 => _90.args, 'optionalAccess', _91 => _91.path])) {
5024
+ } else if (call.tool === "delete_path" && _optionalChain([call, 'access', _102 => _102.args, 'optionalAccess', _103 => _103.path])) {
4890
5025
  message = `Delete this path?
4891
5026
  ${call.args.path}`;
4892
5027
  permContext.path = String(call.args.path);
4893
- } else if (call.tool === "write_file" && _optionalChain([call, 'access', _92 => _92.args, 'optionalAccess', _93 => _93.path])) {
5028
+ } else if (call.tool === "write_file" && _optionalChain([call, 'access', _104 => _104.args, 'optionalAccess', _105 => _105.path])) {
4894
5029
  message = `Write to this file?
4895
5030
  ${call.args.path}`;
4896
5031
  permContext.path = String(call.args.path);
4897
- } else if (call.tool === "multi_file_edit" && _optionalChain([call, 'access', _94 => _94.args, 'optionalAccess', _95 => _95.file_path])) {
5032
+ } else if (call.tool === "multi_file_edit" && _optionalChain([call, 'access', _106 => _106.args, 'optionalAccess', _107 => _107.file_path])) {
4898
5033
  const editCount = Array.isArray(call.args.edits) ? call.args.edits.length : 0;
4899
5034
  message = `Edit this file (${editCount} change${editCount === 1 ? "" : "s"})?
4900
5035
  ${call.args.file_path}`;
@@ -5422,8 +5557,8 @@ function tokenize(code, language) {
5422
5557
  return tokens;
5423
5558
  }
5424
5559
  function colorToken(token) {
5425
- if (_chunkSXUZ3CX3cjs.isThemeInitialized.call(void 0, )) {
5426
- const theme = _chunkSXUZ3CX3cjs.getTheme.call(void 0, );
5560
+ if (_chunkQMVTT55Ycjs.isThemeInitialized.call(void 0, )) {
5561
+ const theme = _chunkQMVTT55Ycjs.getTheme.call(void 0, );
5427
5562
  switch (token.type) {
5428
5563
  case "keyword":
5429
5564
  return theme.fg("syntaxKeyword", token.value);
@@ -5545,15 +5680,15 @@ function runCommand(cmd, args, cwd, options = {}) {
5545
5680
  child.kill("SIGTERM");
5546
5681
  }, options.timeout);
5547
5682
  }
5548
- _optionalChain([child, 'access', _96 => _96.stdout, 'optionalAccess', _97 => _97.on, 'call', _98 => _98("data", (chunk) => {
5683
+ _optionalChain([child, 'access', _108 => _108.stdout, 'optionalAccess', _109 => _109.on, 'call', _110 => _110("data", (chunk) => {
5549
5684
  const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
5550
5685
  stdout += text;
5551
- _optionalChain([options, 'access', _99 => _99.onStdout, 'optionalCall', _100 => _100(text)]);
5686
+ _optionalChain([options, 'access', _111 => _111.onStdout, 'optionalCall', _112 => _112(text)]);
5552
5687
  })]);
5553
- _optionalChain([child, 'access', _101 => _101.stderr, 'optionalAccess', _102 => _102.on, 'call', _103 => _103("data", (chunk) => {
5688
+ _optionalChain([child, 'access', _113 => _113.stderr, 'optionalAccess', _114 => _114.on, 'call', _115 => _115("data", (chunk) => {
5554
5689
  const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
5555
5690
  stderr += text;
5556
- _optionalChain([options, 'access', _104 => _104.onStderr, 'optionalCall', _105 => _105(text)]);
5691
+ _optionalChain([options, 'access', _116 => _116.onStderr, 'optionalCall', _117 => _117(text)]);
5557
5692
  })]);
5558
5693
  child.once("error", (error) => {
5559
5694
  if (timeoutId) clearTimeout(timeoutId);
@@ -5608,7 +5743,7 @@ async function listDirectoryTree(root, options = {}) {
5608
5743
  if (stats.isDirectory() && currentDepth < depth) {
5609
5744
  await walk(full, `${prefix} `, currentDepth + 1);
5610
5745
  }
5611
- } catch (e27) {
5746
+ } catch (e29) {
5612
5747
  continue;
5613
5748
  }
5614
5749
  if (result.length >= maxEntries) {
@@ -5767,7 +5902,7 @@ var WorktreeManager = class {
5767
5902
  if (result.status !== 0) {
5768
5903
  throw new Error(result.stderr || "Failed to create worktree");
5769
5904
  }
5770
- if (_optionalChain([template, 'optionalAccess', _106 => _106.setupCommands]) && options.runSetup !== false) {
5905
+ if (_optionalChain([template, 'optionalAccess', _118 => _118.setupCommands]) && options.runSetup !== false) {
5771
5906
  for (const cmd of template.setupCommands) {
5772
5907
  await this.runInWorktree(worktreePath, cmd);
5773
5908
  }
@@ -5781,7 +5916,7 @@ var WorktreeManager = class {
5781
5916
  const absolutePath = path17.default.isAbsolute(worktreePath) ? worktreePath : path17.default.resolve(this.repoRoot, worktreePath);
5782
5917
  const worktrees = this.list();
5783
5918
  const wt = worktrees.find((w) => w.path === absolutePath);
5784
- const branchToDelete = _optionalChain([wt, 'optionalAccess', _107 => _107.branch]);
5919
+ const branchToDelete = _optionalChain([wt, 'optionalAccess', _119 => _119.branch]);
5785
5920
  const args = ["worktree", "remove"];
5786
5921
  if (options.force) {
5787
5922
  args.push("--force");
@@ -5834,7 +5969,7 @@ var WorktreeManager = class {
5834
5969
  try {
5835
5970
  await this.remove(wt.path, { force: true, deleteBranch: options.removeMerged });
5836
5971
  removed.push(wt.path);
5837
- } catch (e28) {
5972
+ } catch (e30) {
5838
5973
  }
5839
5974
  }
5840
5975
  _child_process.spawnSync.call(void 0, "git", ["worktree", "prune"], { cwd: this.repoRoot });
@@ -5911,7 +6046,7 @@ var WorktreeManager = class {
5911
6046
  } catch (error) {
5912
6047
  try {
5913
6048
  await this.runInWorktree(wt.path, `git ${strategy} --abort`);
5914
- } catch (e29) {
6049
+ } catch (e31) {
5915
6050
  }
5916
6051
  failed.push(`${wt.path}: ${error.message}`);
5917
6052
  }
@@ -6264,7 +6399,7 @@ async function fetchUrl(url, options = {}) {
6264
6399
  try {
6265
6400
  const json = JSON.parse(content);
6266
6401
  return JSON.stringify(json, null, 2).slice(0, maxLength);
6267
- } catch (e30) {
6402
+ } catch (e32) {
6268
6403
  }
6269
6404
  }
6270
6405
  const text = htmlToText(content);
@@ -6284,11 +6419,11 @@ async function getNpmInfo(packageName, version) {
6284
6419
  version: data.version,
6285
6420
  description: data.description || "",
6286
6421
  homepage: data.homepage,
6287
- repository: typeof data.repository === "string" ? data.repository : _optionalChain([data, 'access', _108 => _108.repository, 'optionalAccess', _109 => _109.url]),
6422
+ repository: typeof data.repository === "string" ? data.repository : _optionalChain([data, 'access', _120 => _120.repository, 'optionalAccess', _121 => _121.url]),
6288
6423
  license: data.license,
6289
6424
  dependencies: data.dependencies,
6290
6425
  keywords: data.keywords,
6291
- authors: _optionalChain([data, 'access', _110 => _110.maintainers, 'optionalAccess', _111 => _111.map, 'call', _112 => _112((m) => m.name || m.email)])
6426
+ authors: _optionalChain([data, 'access', _122 => _122.maintainers, 'optionalAccess', _123 => _123.map, 'call', _124 => _124((m) => m.name || m.email)])
6292
6427
  };
6293
6428
  } catch (error) {
6294
6429
  throw new Error(`Failed to get npm info for ${packageName}: ${error instanceof Error ? error.message : String(error)}`);
@@ -6306,14 +6441,14 @@ async function getPyPIInfo(packageName, version) {
6306
6441
  version: info.version,
6307
6442
  description: info.summary || "",
6308
6443
  homepage: info.home_page || info.project_url,
6309
- repository: _optionalChain([info, 'access', _113 => _113.project_urls, 'optionalAccess', _114 => _114.Repository]) || _optionalChain([info, 'access', _115 => _115.project_urls, 'optionalAccess', _116 => _116.Source]),
6444
+ repository: _optionalChain([info, 'access', _125 => _125.project_urls, 'optionalAccess', _126 => _126.Repository]) || _optionalChain([info, 'access', _127 => _127.project_urls, 'optionalAccess', _128 => _128.Source]),
6310
6445
  license: info.license,
6311
- dependencies: _optionalChain([info, 'access', _117 => _117.requires_dist, 'optionalAccess', _118 => _118.reduce, 'call', _119 => _119((acc, dep) => {
6446
+ dependencies: _optionalChain([info, 'access', _129 => _129.requires_dist, 'optionalAccess', _130 => _130.reduce, 'call', _131 => _131((acc, dep) => {
6312
6447
  const [name] = dep.split(/[<>=!;\s]/);
6313
6448
  acc[name] = dep;
6314
6449
  return acc;
6315
6450
  }, {})]),
6316
- keywords: _optionalChain([info, 'access', _120 => _120.keywords, 'optionalAccess', _121 => _121.split, 'call', _122 => _122(","), 'access', _123 => _123.map, 'call', _124 => _124((k) => k.trim()), 'access', _125 => _125.filter, 'call', _126 => _126(Boolean)]),
6451
+ keywords: _optionalChain([info, 'access', _132 => _132.keywords, 'optionalAccess', _133 => _133.split, 'call', _134 => _134(","), 'access', _135 => _135.map, 'call', _136 => _136((k) => k.trim()), 'access', _137 => _137.filter, 'call', _138 => _138(Boolean)]),
6317
6452
  authors: info.author ? [info.author] : []
6318
6453
  };
6319
6454
  } catch (error) {
@@ -6326,17 +6461,17 @@ async function getCargoInfo(packageName, version) {
6326
6461
  const content = await simpleFetch(url, { timeout: 1e4 });
6327
6462
  const data = JSON.parse(content);
6328
6463
  const crate = data.crate;
6329
- const ver = version ? _optionalChain([data, 'access', _127 => _127.versions, 'optionalAccess', _128 => _128.find, 'call', _129 => _129((v) => v.num === version)]) : _optionalChain([data, 'access', _130 => _130.versions, 'optionalAccess', _131 => _131[0]]);
6464
+ const ver = version ? _optionalChain([data, 'access', _139 => _139.versions, 'optionalAccess', _140 => _140.find, 'call', _141 => _141((v) => v.num === version)]) : _optionalChain([data, 'access', _142 => _142.versions, 'optionalAccess', _143 => _143[0]]);
6330
6465
  return {
6331
6466
  registry: "crates",
6332
6467
  name: crate.name,
6333
- version: _optionalChain([ver, 'optionalAccess', _132 => _132.num]) || crate.newest_version,
6468
+ version: _optionalChain([ver, 'optionalAccess', _144 => _144.num]) || crate.newest_version,
6334
6469
  description: crate.description || "",
6335
6470
  homepage: crate.homepage,
6336
6471
  repository: crate.repository,
6337
- license: _optionalChain([ver, 'optionalAccess', _133 => _133.license]),
6472
+ license: _optionalChain([ver, 'optionalAccess', _145 => _145.license]),
6338
6473
  keywords: crate.keywords,
6339
- authors: _optionalChain([ver, 'optionalAccess', _134 => _134.published_by, 'optionalAccess', _135 => _135.name]) ? [ver.published_by.name] : []
6474
+ authors: _optionalChain([ver, 'optionalAccess', _146 => _146.published_by, 'optionalAccess', _147 => _147.name]) ? [ver.published_by.name] : []
6340
6475
  };
6341
6476
  } catch (error) {
6342
6477
  throw new Error(`Failed to get Cargo info for ${packageName}: ${error instanceof Error ? error.message : String(error)}`);
@@ -6355,7 +6490,7 @@ async function getRubyGemsInfo(packageName, version) {
6355
6490
  description: gem.info || gem.summary || "",
6356
6491
  homepage: gem.homepage_uri,
6357
6492
  repository: gem.source_code_uri,
6358
- license: _optionalChain([gem, 'access', _136 => _136.licenses, 'optionalAccess', _137 => _137[0]]),
6493
+ license: _optionalChain([gem, 'access', _148 => _148.licenses, 'optionalAccess', _149 => _149[0]]),
6359
6494
  keywords: [],
6360
6495
  authors: gem.authors ? [gem.authors] : []
6361
6496
  };
@@ -6446,10 +6581,10 @@ function formatPackageInfo(info) {
6446
6581
  if (info.license) {
6447
6582
  lines.push(`License: ${info.license}`);
6448
6583
  }
6449
- if (_optionalChain([info, 'access', _138 => _138.keywords, 'optionalAccess', _139 => _139.length])) {
6584
+ if (_optionalChain([info, 'access', _150 => _150.keywords, 'optionalAccess', _151 => _151.length])) {
6450
6585
  lines.push(`Keywords: ${info.keywords.join(", ")}`);
6451
6586
  }
6452
- if (_optionalChain([info, 'access', _140 => _140.authors, 'optionalAccess', _141 => _141.length])) {
6587
+ if (_optionalChain([info, 'access', _152 => _152.authors, 'optionalAccess', _153 => _153.length])) {
6453
6588
  lines.push(`Authors: ${info.authors.join(", ")}`);
6454
6589
  }
6455
6590
  if (info.dependencies && Object.keys(info.dependencies).length > 0) {
@@ -6555,10 +6690,10 @@ var ToolsRegistry = class {
6555
6690
  if (this.isValidMetaTool(data)) {
6556
6691
  this.metaToolCache.set(data.name, data);
6557
6692
  }
6558
- } catch (e31) {
6693
+ } catch (e33) {
6559
6694
  }
6560
6695
  }
6561
- } catch (e32) {
6696
+ } catch (e34) {
6562
6697
  }
6563
6698
  }
6564
6699
  isValidMetaTool(candidate) {
@@ -6907,7 +7042,7 @@ var ActionExecutor = class _ActionExecutor {
6907
7042
  return {};
6908
7043
  }
6909
7044
  const hookResponse = await this.onPermissionRequest(context);
6910
- if (!_optionalChain([hookResponse, 'optionalAccess', _142 => _142.decision])) {
7045
+ if (!_optionalChain([hookResponse, 'optionalAccess', _154 => _154.decision])) {
6911
7046
  return {};
6912
7047
  }
6913
7048
  switch (hookResponse.decision) {
@@ -7046,7 +7181,7 @@ var ActionExecutor = class _ActionExecutor {
7046
7181
  this.showDiff(oldContent, newContent, action.path);
7047
7182
  }
7048
7183
  await this.files.writeFile(action.path, newContent);
7049
- _optionalChain([this, 'access', _143 => _143.onFileModified, 'optionalCall', _144 => _144()]);
7184
+ _optionalChain([this, 'access', _155 => _155.onFileModified, 'optionalCall', _156 => _156()]);
7050
7185
  return exists ? `Updated ${action.path}` : `Created ${action.path}`;
7051
7186
  }
7052
7187
  case "append_file": {
@@ -7060,7 +7195,7 @@ var ActionExecutor = class _ActionExecutor {
7060
7195
  \u{1F4DD} ${action.path}:`));
7061
7196
  this.showDiff(oldContent, newContent, action.path);
7062
7197
  await this.files.appendFile(action.path, addition);
7063
- _optionalChain([this, 'access', _145 => _145.onFileModified, 'optionalCall', _146 => _146()]);
7198
+ _optionalChain([this, 'access', _157 => _157.onFileModified, 'optionalCall', _158 => _158()]);
7064
7199
  return `Appended to ${action.path}`;
7065
7200
  }
7066
7201
  case "apply_patch": {
@@ -7078,7 +7213,7 @@ var ActionExecutor = class _ActionExecutor {
7078
7213
  await this.files.applyPatch(action.path, patch);
7079
7214
  const newContent = await this.files.readFile(action.path);
7080
7215
  this.showDiff(oldContent, newContent, action.path);
7081
- _optionalChain([this, 'access', _147 => _147.onFileModified, 'optionalCall', _148 => _148()]);
7216
+ _optionalChain([this, 'access', _159 => _159.onFileModified, 'optionalCall', _160 => _160()]);
7082
7217
  return `Patched ${action.path}`;
7083
7218
  }
7084
7219
  case "tools_registry": {
@@ -7169,7 +7304,7 @@ ${hit.snippet}`).join("\n\n");
7169
7304
  \u{1F504} ${action.path}:`));
7170
7305
  this.showDiff(content, result, action.path);
7171
7306
  await this.files.writeFile(action.path, result);
7172
- _optionalChain([this, 'access', _149 => _149.onFileModified, 'optionalCall', _150 => _150()]);
7307
+ _optionalChain([this, 'access', _161 => _161.onFileModified, 'optionalCall', _162 => _162()]);
7173
7308
  }
7174
7309
  return `Updated ${action.path}`;
7175
7310
  }
@@ -7185,15 +7320,15 @@ ${hit.snippet}`).join("\n\n");
7185
7320
  return 'Error: run_command requires a "command" argument (string)';
7186
7321
  }
7187
7322
  const shouldStreamOutput = Boolean(
7188
- this.onToolOutput && _optionalChain([context, 'optionalAccess', _151 => _151.toolCallId]) && !action.background && process.env.AUTOHAND_STREAM_TOOL_OUTPUT === "1"
7323
+ this.onToolOutput && _optionalChain([context, 'optionalAccess', _163 => _163.toolCallId]) && !action.background && process.env.AUTOHAND_STREAM_TOOL_OUTPUT === "1"
7189
7324
  );
7190
7325
  const emitOutput = (stream, data) => {
7191
7326
  if (!shouldStreamOutput) {
7192
7327
  return;
7193
7328
  }
7194
- _optionalChain([this, 'access', _152 => _152.onToolOutput, 'optionalCall', _153 => _153({
7329
+ _optionalChain([this, 'access', _164 => _164.onToolOutput, 'optionalCall', _165 => _165({
7195
7330
  tool: action.type,
7196
- toolCallId: _optionalChain([context, 'optionalAccess', _154 => _154.toolCallId]),
7331
+ toolCallId: _optionalChain([context, 'optionalAccess', _166 => _166.toolCallId]),
7197
7332
  stream,
7198
7333
  data
7199
7334
  })]);
@@ -7658,7 +7793,7 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
7658
7793
  if (oldContent !== newContent) {
7659
7794
  this.showDiff(oldContent, newContent, action.file_path);
7660
7795
  await this.files.writeFile(action.file_path, newContent);
7661
- _optionalChain([this, 'access', _155 => _155.onFileModified, 'optionalCall', _156 => _156()]);
7796
+ _optionalChain([this, 'access', _167 => _167.onFileModified, 'optionalCall', _168 => _168()]);
7662
7797
  }
7663
7798
  return `Applied ${action.edits.length} edit(s) to ${action.file_path}`;
7664
7799
  }
@@ -7673,7 +7808,7 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
7673
7808
  const content = await this.files.readFile(todoPath);
7674
7809
  const parsed = JSON.parse(content);
7675
7810
  existingTodos = Array.isArray(parsed) ? parsed : [];
7676
- } catch (e33) {
7811
+ } catch (e35) {
7677
7812
  }
7678
7813
  const todoMap = new Map(existingTodos.map((t) => [t.id, t]));
7679
7814
  for (const task of action.tasks) {
@@ -7850,7 +7985,7 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
7850
7985
  * Identifies imports, classes, functions, and key sections with line numbers.
7851
7986
  */
7852
7987
  extractFileOutline(lines, filePath) {
7853
- const ext = _optionalChain([filePath, 'access', _157 => _157.split, 'call', _158 => _158("."), 'access', _159 => _159.pop, 'call', _160 => _160(), 'optionalAccess', _161 => _161.toLowerCase, 'call', _162 => _162()]) || "";
7988
+ const ext = _optionalChain([filePath, 'access', _169 => _169.split, 'call', _170 => _170("."), 'access', _171 => _171.pop, 'call', _172 => _172(), 'optionalAccess', _173 => _173.toLowerCase, 'call', _174 => _174()]) || "";
7854
7989
  const outline = [];
7855
7990
  const patterns = {
7856
7991
  ts: [
@@ -7937,7 +8072,7 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
7937
8072
  if (!target) {
7938
8073
  return;
7939
8074
  }
7940
- _optionalChain([this, 'access', _163 => _163.logExploration, 'optionalCall', _164 => _164({ kind, target })]);
8075
+ _optionalChain([this, 'access', _175 => _175.logExploration, 'optionalCall', _176 => _176({ kind, target })]);
7941
8076
  }
7942
8077
  async executeCustomCommand(action) {
7943
8078
  const existing = await loadCustomCommand(action.name);
@@ -8118,8 +8253,8 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
8118
8253
  * Colorize raw git diff output with green for additions and red for removals
8119
8254
  */
8120
8255
  colorizeGitDiff(diffOutput) {
8121
- const useTheme = _chunkSXUZ3CX3cjs.isThemeInitialized.call(void 0, );
8122
- const theme = useTheme ? _chunkSXUZ3CX3cjs.getTheme.call(void 0, ) : null;
8256
+ const useTheme = _chunkQMVTT55Ycjs.isThemeInitialized.call(void 0, );
8257
+ const theme = useTheme ? _chunkQMVTT55Ycjs.getTheme.call(void 0, ) : null;
8123
8258
  if (!diffOutput || diffOutput === "No diff") {
8124
8259
  return theme ? theme.fg("muted", "No changes") : _chalk2.default.gray("No changes");
8125
8260
  }
@@ -8128,12 +8263,12 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
8128
8263
  const colorizedLines = [];
8129
8264
  let additions = 0;
8130
8265
  let deletions = 0;
8131
- const addedColor = _optionalChain([theme, 'optionalAccess', _165 => _165.getColor, 'call', _166 => _166("diffAdded")]) || "#4caf50";
8132
- const removedColor = _optionalChain([theme, 'optionalAccess', _167 => _167.getColor, 'call', _168 => _168("diffRemoved")]) || "#f44336";
8133
- const contextColor = _optionalChain([theme, 'optionalAccess', _169 => _169.getColor, 'call', _170 => _170("diffContext")]) || "#9e9e9e";
8134
- const accentColor = _optionalChain([theme, 'optionalAccess', _171 => _171.getColor, 'call', _172 => _172("accent")]) || "#00bcd4";
8135
- const addedRgb = _chunkSXUZ3CX3cjs.hexToRgb.call(void 0, addedColor);
8136
- const removedRgb = _chunkSXUZ3CX3cjs.hexToRgb.call(void 0, removedColor);
8266
+ const addedColor = _optionalChain([theme, 'optionalAccess', _177 => _177.getColor, 'call', _178 => _178("diffAdded")]) || "#4caf50";
8267
+ const removedColor = _optionalChain([theme, 'optionalAccess', _179 => _179.getColor, 'call', _180 => _180("diffRemoved")]) || "#f44336";
8268
+ const contextColor = _optionalChain([theme, 'optionalAccess', _181 => _181.getColor, 'call', _182 => _182("diffContext")]) || "#9e9e9e";
8269
+ const accentColor = _optionalChain([theme, 'optionalAccess', _183 => _183.getColor, 'call', _184 => _184("accent")]) || "#00bcd4";
8270
+ const addedRgb = _chunkQMVTT55Ycjs.hexToRgb.call(void 0, addedColor);
8271
+ const removedRgb = _chunkQMVTT55Ycjs.hexToRgb.call(void 0, removedColor);
8137
8272
  const addBgR = addedRgb ? Math.floor(addedRgb.r * 0.15) : 30;
8138
8273
  const addBgG = addedRgb ? Math.floor(addedRgb.g * 0.2) : 50;
8139
8274
  const addBgB = addedRgb ? Math.floor(addedRgb.b * 0.15) : 30;
@@ -8202,8 +8337,8 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
8202
8337
  const contextLines = 3;
8203
8338
  const lang = filePath ? detectLanguage(filePath) : "text";
8204
8339
  const shouldHighlight = lang !== "text";
8205
- const useTheme = _chunkSXUZ3CX3cjs.isThemeInitialized.call(void 0, );
8206
- const theme = useTheme ? _chunkSXUZ3CX3cjs.getTheme.call(void 0, ) : null;
8340
+ const useTheme = _chunkQMVTT55Ycjs.isThemeInitialized.call(void 0, );
8341
+ const theme = useTheme ? _chunkQMVTT55Ycjs.getTheme.call(void 0, ) : null;
8207
8342
  let additions = 0;
8208
8343
  let deletions = 0;
8209
8344
  for (const part of diff) {
@@ -8300,7 +8435,7 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
8300
8435
  const removedColor = theme.getColor("diffRemoved");
8301
8436
  const contextColor = theme.getColor("diffContext");
8302
8437
  if (change.type === "add") {
8303
- const addedRgb = _chunkSXUZ3CX3cjs.hexToRgb.call(void 0, addedColor);
8438
+ const addedRgb = _chunkQMVTT55Ycjs.hexToRgb.call(void 0, addedColor);
8304
8439
  const bgR = addedRgb ? Math.floor(addedRgb.r * 0.15) : 30;
8305
8440
  const bgG = addedRgb ? Math.floor(addedRgb.g * 0.2) : 50;
8306
8441
  const bgB = addedRgb ? Math.floor(addedRgb.b * 0.15) : 30;
@@ -8308,7 +8443,7 @@ ${result.removed.map((p) => ` - ${p}`).join("\n")}`;
8308
8443
  const content = _chalk2.default.bgRgb(bgR, bgG, bgB)(` ${highlighted} `.padEnd(Math.max(termWidth - 10, change.line.length + 2)));
8309
8444
  console.log(prefix + content);
8310
8445
  } else if (change.type === "remove") {
8311
- const removedRgb = _chunkSXUZ3CX3cjs.hexToRgb.call(void 0, removedColor);
8446
+ const removedRgb = _chunkQMVTT55Ycjs.hexToRgb.call(void 0, removedColor);
8312
8447
  const bgR = removedRgb ? Math.floor(removedRgb.r * 0.25) : 60;
8313
8448
  const bgG = removedRgb ? Math.floor(removedRgb.g * 0.15) : 30;
8314
8449
  const bgB = removedRgb ? Math.floor(removedRgb.b * 0.15) : 30;
@@ -8458,15 +8593,15 @@ var SlashCommandHandler = class {
8458
8593
  return null;
8459
8594
  }
8460
8595
  case "/status": {
8461
- const { status } = await Promise.resolve().then(() => _interopRequireWildcard(require("./status-RSWACM74.cjs")));
8596
+ const { status } = await Promise.resolve().then(() => _interopRequireWildcard(require("./status-U5NH6SYY.cjs")));
8462
8597
  return status(this.ctx);
8463
8598
  }
8464
8599
  case "/login": {
8465
- const { login } = await Promise.resolve().then(() => _interopRequireWildcard(require("./login-HUH3CEWL.cjs")));
8600
+ const { login } = await Promise.resolve().then(() => _interopRequireWildcard(require("./login-QNJ5C42G.cjs")));
8466
8601
  return login({ config: this.ctx.config });
8467
8602
  }
8468
8603
  case "/logout": {
8469
- const { logout } = await Promise.resolve().then(() => _interopRequireWildcard(require("./logout-3V3SH7OL.cjs")));
8604
+ const { logout } = await Promise.resolve().then(() => _interopRequireWildcard(require("./logout-MVUP7GPU.cjs")));
8470
8605
  return logout({ config: this.ctx.config });
8471
8606
  }
8472
8607
  case "/permissions": {
@@ -8514,7 +8649,7 @@ var SlashCommandHandler = class {
8514
8649
  });
8515
8650
  }
8516
8651
  case "/theme": {
8517
- const { theme } = await Promise.resolve().then(() => _interopRequireWildcard(require("./theme-LIF3RD3A.cjs")));
8652
+ const { theme } = await Promise.resolve().then(() => _interopRequireWildcard(require("./theme-CVY6MVEK.cjs")));
8518
8653
  if (!this.ctx.config) {
8519
8654
  console.log(_chalk2.default.yellow("Config not available for theme selection."));
8520
8655
  return null;
@@ -8855,8 +8990,8 @@ var SubAgent = class {
8855
8990
  * Format a tool definition as a signature string
8856
8991
  */
8857
8992
  formatToolSignature(def) {
8858
- const params = _optionalChain([def, 'access', _173 => _173.parameters, 'optionalAccess', _174 => _174.properties]) ? Object.entries(def.parameters.properties).map(([name, prop]) => {
8859
- const required = _optionalChain([def, 'access', _175 => _175.parameters, 'optionalAccess', _176 => _176.required, 'optionalAccess', _177 => _177.includes, 'call', _178 => _178(name)]) ? "" : "?";
8993
+ const params = _optionalChain([def, 'access', _185 => _185.parameters, 'optionalAccess', _186 => _186.properties]) ? Object.entries(def.parameters.properties).map(([name, prop]) => {
8994
+ const required = _optionalChain([def, 'access', _187 => _187.parameters, 'optionalAccess', _188 => _188.required, 'optionalAccess', _189 => _189.includes, 'call', _190 => _190(name)]) ? "" : "?";
8860
8995
  return `${name}${required}: ${prop.type}`;
8861
8996
  }).join(", ") : "";
8862
8997
  return `- ${def.name}(${params}): ${def.description}`;
@@ -8876,7 +9011,7 @@ var SubAgent = class {
8876
9011
  toolChoice: tools.length > 0 ? "auto" : void 0
8877
9012
  });
8878
9013
  const payload = this.parseResponse(completion);
8879
- if (_optionalChain([completion, 'access', _179 => _179.toolCalls, 'optionalAccess', _180 => _180.length])) {
9014
+ if (_optionalChain([completion, 'access', _191 => _191.toolCalls, 'optionalAccess', _192 => _192.length])) {
8880
9015
  this.conversation.addMessage({
8881
9016
  role: "assistant",
8882
9017
  content: completion.content || ""
@@ -8891,13 +9026,13 @@ var SubAgent = class {
8891
9026
  const results = await this.toolManager.execute(payload.toolCalls);
8892
9027
  for (let j = 0; j < results.length; j++) {
8893
9028
  const result = results[j];
8894
- const toolCall = _optionalChain([completion, 'access', _181 => _181.toolCalls, 'optionalAccess', _182 => _182[j]]);
9029
+ const toolCall = _optionalChain([completion, 'access', _193 => _193.toolCalls, 'optionalAccess', _194 => _194[j]]);
8895
9030
  const content = result.success ? _nullishCoalesce(result.output, () => ( "(no output)")) : _nullishCoalesce(result.error, () => ( "Tool failed"));
8896
9031
  this.conversation.addMessage({
8897
9032
  role: "tool",
8898
9033
  name: result.tool,
8899
9034
  content,
8900
- tool_call_id: _optionalChain([toolCall, 'optionalAccess', _183 => _183.id])
9035
+ tool_call_id: _optionalChain([toolCall, 'optionalAccess', _195 => _195.id])
8901
9036
  });
8902
9037
  if (!result.success) {
8903
9038
  console.log(_chalk2.default.red(`[${this.name}] Tool ${result.tool} failed: ${content}`));
@@ -8932,7 +9067,7 @@ var SubAgent = class {
8932
9067
  safeParseJson(json) {
8933
9068
  try {
8934
9069
  return JSON.parse(json);
8935
- } catch (e34) {
9070
+ } catch (e36) {
8936
9071
  return {};
8937
9072
  }
8938
9073
  }
@@ -8957,7 +9092,7 @@ var SubAgent = class {
8957
9092
  return { finalResponse: contentValue };
8958
9093
  }
8959
9094
  return { finalResponse: raw.trim() };
8960
- } catch (e35) {
9095
+ } catch (e37) {
8961
9096
  return { finalResponse: raw.trim() };
8962
9097
  }
8963
9098
  }
@@ -9158,7 +9293,7 @@ var ErrorLogger = class {
9158
9293
  used: totalMem - freeMem
9159
9294
  },
9160
9295
  cpu: {
9161
- model: _optionalChain([cpus, 'access', _184 => _184[0], 'optionalAccess', _185 => _185.model]) || "Unknown",
9296
+ model: _optionalChain([cpus, 'access', _196 => _196[0], 'optionalAccess', _197 => _197.model]) || "Unknown",
9162
9297
  cores: cpus.length
9163
9298
  },
9164
9299
  hostname: _os2.default.hostname(),
@@ -9174,12 +9309,12 @@ var ErrorLogger = class {
9174
9309
  const entries = content.split("\n---\n").filter((entry) => entry.trim()).map((entry) => {
9175
9310
  try {
9176
9311
  return JSON.parse(entry);
9177
- } catch (e36) {
9312
+ } catch (e38) {
9178
9313
  return null;
9179
9314
  }
9180
9315
  }).filter((entry) => entry !== null);
9181
9316
  return entries.slice(-count);
9182
- } catch (e37) {
9317
+ } catch (e39) {
9183
9318
  return [];
9184
9319
  }
9185
9320
  }
@@ -9203,8 +9338,7 @@ var DEFAULT_CONFIG = {
9203
9338
  timeout: 5e3,
9204
9339
  maxRetries: 3,
9205
9340
  offlineQueue: true,
9206
- cliVersion: "0.1.0",
9207
- companySecret: ""
9341
+ cliVersion: _chunkXJZYEURAcjs.package_default.version
9208
9342
  };
9209
9343
  var FeedbackApiClient = class {
9210
9344
  constructor(configOverrides) {
@@ -9226,13 +9360,13 @@ var FeedbackApiClient = class {
9226
9360
  this.deviceId = (await _fsextra2.default.readFile(this.deviceIdPath, "utf8")).trim();
9227
9361
  return this.deviceId;
9228
9362
  }
9229
- } catch (e38) {
9363
+ } catch (e40) {
9230
9364
  }
9231
9365
  this.deviceId = `anon_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
9232
9366
  try {
9233
9367
  await _fsextra2.default.ensureDir(path17.default.dirname(this.deviceIdPath));
9234
9368
  await _fsextra2.default.writeFile(this.deviceIdPath, this.deviceId);
9235
- } catch (e39) {
9369
+ } catch (e41) {
9236
9370
  }
9237
9371
  return this.deviceId;
9238
9372
  }
@@ -9280,18 +9414,18 @@ var FeedbackApiClient = class {
9280
9414
  }
9281
9415
  /**
9282
9416
  * Send feedback to API endpoint
9417
+ * No authentication required - endpoint is rate-limited instead
9283
9418
  */
9284
9419
  async sendToApi(submission) {
9285
9420
  const controller = new AbortController();
9286
9421
  const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
9287
- const authToken = `${submission.deviceId}.${this.config.companySecret}`;
9288
9422
  try {
9289
9423
  const response = await fetch(`${this.config.baseUrl}/v1/feedback`, {
9290
9424
  method: "POST",
9291
9425
  headers: {
9292
9426
  "Content-Type": "application/json",
9293
- "Authorization": `Bearer ${authToken}`,
9294
- "X-CLI-Version": this.config.cliVersion
9427
+ "X-CLI-Version": this.config.cliVersion,
9428
+ "X-Device-ID": submission.deviceId
9295
9429
  },
9296
9430
  body: JSON.stringify(submission),
9297
9431
  signal: controller.signal
@@ -9332,7 +9466,7 @@ var FeedbackApiClient = class {
9332
9466
  }
9333
9467
  await _fsextra2.default.ensureDir(path17.default.dirname(this.queuePath));
9334
9468
  await _fsextra2.default.writeJson(this.queuePath, queue, { spaces: 2 });
9335
- } catch (e40) {
9469
+ } catch (e42) {
9336
9470
  }
9337
9471
  }
9338
9472
  /**
@@ -9362,7 +9496,7 @@ var FeedbackApiClient = class {
9362
9496
  remaining.push(item);
9363
9497
  failed++;
9364
9498
  }
9365
- } catch (e41) {
9499
+ } catch (e43) {
9366
9500
  item.attempts++;
9367
9501
  item.lastAttempt = (/* @__PURE__ */ new Date()).toISOString();
9368
9502
  remaining.push(item);
@@ -9374,7 +9508,7 @@ var FeedbackApiClient = class {
9374
9508
  } else {
9375
9509
  await _fsextra2.default.remove(this.queuePath);
9376
9510
  }
9377
- } catch (e42) {
9511
+ } catch (e44) {
9378
9512
  }
9379
9513
  return { sent, failed };
9380
9514
  }
@@ -9389,9 +9523,9 @@ var FeedbackApiClient = class {
9389
9523
  const queue = await _fsextra2.default.readJson(this.queuePath);
9390
9524
  return {
9391
9525
  pending: queue.length,
9392
- oldestItem: _optionalChain([queue, 'access', _186 => _186[0], 'optionalAccess', _187 => _187.lastAttempt]) || null
9526
+ oldestItem: _optionalChain([queue, 'access', _198 => _198[0], 'optionalAccess', _199 => _199.lastAttempt]) || null
9393
9527
  };
9394
- } catch (e43) {
9528
+ } catch (e45) {
9395
9529
  return { pending: 0, oldestItem: null };
9396
9530
  }
9397
9531
  }
@@ -9409,7 +9543,7 @@ var FeedbackApiClient = class {
9409
9543
  });
9410
9544
  clearTimeout(timeoutId);
9411
9545
  return response.ok;
9412
- } catch (e44) {
9546
+ } catch (e46) {
9413
9547
  return false;
9414
9548
  }
9415
9549
  }
@@ -9468,7 +9602,7 @@ var FeedbackManager = class {
9468
9602
  if (_fsextra2.default.existsSync(this.statePath)) {
9469
9603
  return _fsextra2.default.readJsonSync(this.statePath);
9470
9604
  }
9471
- } catch (e45) {
9605
+ } catch (e47) {
9472
9606
  }
9473
9607
  return {
9474
9608
  lastPromptedAt: null,
@@ -9485,7 +9619,7 @@ var FeedbackManager = class {
9485
9619
  try {
9486
9620
  _fsextra2.default.ensureDirSync(this.stateDir);
9487
9621
  _fsextra2.default.writeJsonSync(this.statePath, this.state, { spaces: 2 });
9488
- } catch (e46) {
9622
+ } catch (e48) {
9489
9623
  }
9490
9624
  }
9491
9625
  async saveFeedbackResponse(response) {
@@ -9497,12 +9631,12 @@ var FeedbackManager = class {
9497
9631
  }
9498
9632
  responses.push(response);
9499
9633
  _fsextra2.default.writeJsonSync(this.responsesPath, responses, { spaces: 2 });
9500
- } catch (e47) {
9634
+ } catch (e49) {
9501
9635
  }
9502
9636
  if (this.config.sendToApi) {
9503
9637
  try {
9504
9638
  await this.apiClient.submit(response);
9505
- } catch (e48) {
9639
+ } catch (e50) {
9506
9640
  }
9507
9641
  }
9508
9642
  }
@@ -9599,7 +9733,7 @@ var FeedbackManager = class {
9599
9733
  try {
9600
9734
  return await _enquirer2.default.prompt(config);
9601
9735
  } catch (error) {
9602
- if (_optionalChain([error, 'optionalAccess', _188 => _188.code]) === "ERR_USE_AFTER_CLOSE") {
9736
+ if (_optionalChain([error, 'optionalAccess', _200 => _200.code]) === "ERR_USE_AFTER_CLOSE") {
9603
9737
  return null;
9604
9738
  }
9605
9739
  throw error;
@@ -9640,7 +9774,7 @@ var FeedbackManager = class {
9640
9774
  name: "reason",
9641
9775
  message: "What do you like most about Autohand? (optional, press Enter to skip)"
9642
9776
  });
9643
- reason = _optionalChain([followUp, 'optionalAccess', _189 => _189.reason]) || void 0;
9777
+ reason = _optionalChain([followUp, 'optionalAccess', _201 => _201.reason]) || void 0;
9644
9778
  if (followUp) {
9645
9779
  const recResult = await safePrompt({
9646
9780
  type: "confirm",
@@ -9648,7 +9782,7 @@ var FeedbackManager = class {
9648
9782
  message: "Would you recommend Autohand to a colleague?",
9649
9783
  initial: true
9650
9784
  });
9651
- recommend = _optionalChain([recResult, 'optionalAccess', _190 => _190.recommend]);
9785
+ recommend = _optionalChain([recResult, 'optionalAccess', _202 => _202.recommend]);
9652
9786
  }
9653
9787
  } else {
9654
9788
  const followUp = await safePrompt({
@@ -9656,7 +9790,7 @@ var FeedbackManager = class {
9656
9790
  name: "improvement",
9657
9791
  message: "What could we do better? (optional, press Enter to skip)"
9658
9792
  });
9659
- improvement = _optionalChain([followUp, 'optionalAccess', _191 => _191.improvement]) || void 0;
9793
+ improvement = _optionalChain([followUp, 'optionalAccess', _203 => _203.improvement]) || void 0;
9660
9794
  }
9661
9795
  const response = {
9662
9796
  npsScore,
@@ -9683,7 +9817,7 @@ var FeedbackManager = class {
9683
9817
  console.log();
9684
9818
  return true;
9685
9819
  } catch (error) {
9686
- if (_optionalChain([error, 'optionalAccess', _192 => _192.code]) === "ERR_USE_AFTER_CLOSE") {
9820
+ if (_optionalChain([error, 'optionalAccess', _204 => _204.code]) === "ERR_USE_AFTER_CLOSE") {
9687
9821
  return false;
9688
9822
  }
9689
9823
  this.state.dismissed++;
@@ -9765,7 +9899,7 @@ var FeedbackManager = class {
9765
9899
  if (_fsextra2.default.existsSync(this.responsesPath)) {
9766
9900
  return _fsextra2.default.readJsonSync(this.responsesPath);
9767
9901
  }
9768
- } catch (e49) {
9902
+ } catch (e51) {
9769
9903
  }
9770
9904
  return [];
9771
9905
  }
@@ -9816,7 +9950,7 @@ var TelemetryClient = class {
9816
9950
  const id = _crypto2.default.randomUUID();
9817
9951
  _fsextra2.default.writeFileSync(DEVICE_ID_FILE, id);
9818
9952
  return id;
9819
- } catch (e50) {
9953
+ } catch (e52) {
9820
9954
  return _crypto2.default.randomUUID();
9821
9955
  }
9822
9956
  }
@@ -9830,7 +9964,7 @@ var TelemetryClient = class {
9830
9964
  const data = _fsextra2.default.readFileSync(QUEUE_FILE, "utf8");
9831
9965
  this.queue = JSON.parse(data);
9832
9966
  }
9833
- } catch (e51) {
9967
+ } catch (e53) {
9834
9968
  this.queue = [];
9835
9969
  }
9836
9970
  }
@@ -9841,7 +9975,7 @@ var TelemetryClient = class {
9841
9975
  try {
9842
9976
  _fsextra2.default.ensureDirSync(TELEMETRY_DIR);
9843
9977
  _fsextra2.default.writeFileSync(QUEUE_FILE, JSON.stringify(this.queue, null, 2));
9844
- } catch (e52) {
9978
+ } catch (e54) {
9845
9979
  }
9846
9980
  }
9847
9981
  /**
@@ -9884,7 +10018,7 @@ var TelemetryClient = class {
9884
10018
  });
9885
10019
  clearTimeout(timeout);
9886
10020
  return response.ok;
9887
- } catch (e53) {
10021
+ } catch (e55) {
9888
10022
  return false;
9889
10023
  }
9890
10024
  }
@@ -9934,7 +10068,7 @@ var TelemetryClient = class {
9934
10068
  headers: {
9935
10069
  "Content-Type": "application/json",
9936
10070
  "Authorization": `Bearer ${authToken}`,
9937
- "X-CLI-Version": _optionalChain([eventsToSend, 'access', _193 => _193[0], 'optionalAccess', _194 => _194.cliVersion]) || "unknown"
10071
+ "X-CLI-Version": _optionalChain([eventsToSend, 'access', _205 => _205[0], 'optionalAccess', _206 => _206.cliVersion]) || "unknown"
9938
10072
  },
9939
10073
  body: JSON.stringify({ events: eventsToSend })
9940
10074
  });
@@ -9946,7 +10080,7 @@ var TelemetryClient = class {
9946
10080
  } else {
9947
10081
  failed = eventsToSend.length;
9948
10082
  }
9949
- } catch (e54) {
10083
+ } catch (e56) {
9950
10084
  failed = eventsToSend.length;
9951
10085
  await new Promise((resolve) => setTimeout(resolve, 1e3 * (attempt + 1)));
9952
10086
  }
@@ -10001,7 +10135,7 @@ var TelemetryClient = class {
10001
10135
  }
10002
10136
  _fsextra2.default.writeFileSync(syncQueueFile, JSON.stringify(syncQueue, null, 2));
10003
10137
  return { success: false, error: "Offline - queued for sync" };
10004
- } catch (e55) {
10138
+ } catch (e57) {
10005
10139
  return { success: false, error: "Failed to queue session" };
10006
10140
  }
10007
10141
  }
@@ -10059,7 +10193,7 @@ var TelemetryClient = class {
10059
10193
  _fsextra2.default.removeSync(syncQueueFile);
10060
10194
  }
10061
10195
  return { synced, failed };
10062
- } catch (e56) {
10196
+ } catch (e58) {
10063
10197
  return { synced: 0, failed: 0 };
10064
10198
  }
10065
10199
  }
@@ -10105,7 +10239,7 @@ var TelemetryManager = class {
10105
10239
  */
10106
10240
  getSystemInfo() {
10107
10241
  return {
10108
- cliVersion: _chunk7EIL6P6Qcjs.package_default.version,
10242
+ cliVersion: _chunkXJZYEURAcjs.package_default.version,
10109
10243
  platform: process.platform,
10110
10244
  osVersion: _os2.default.release(),
10111
10245
  nodeVersion: process.version,
@@ -10181,7 +10315,7 @@ var TelemetryManager = class {
10181
10315
  */
10182
10316
  async trackError(data) {
10183
10317
  this.errorsCount++;
10184
- const sanitizedStack = _optionalChain([data, 'access', _195 => _195.stack, 'optionalAccess', _196 => _196.replace, 'call', _197 => _197(/\/Users\/[^/]+/g, "/Users/***"), 'access', _198 => _198.replace, 'call', _199 => _199(/\/home\/[^/]+/g, "/home/***"), 'access', _200 => _200.replace, 'call', _201 => _201(/C:\\Users\\[^\\]+/g, "C:\\Users\\***")]);
10318
+ const sanitizedStack = _optionalChain([data, 'access', _207 => _207.stack, 'optionalAccess', _208 => _208.replace, 'call', _209 => _209(/\/Users\/[^/]+/g, "/Users/***"), 'access', _210 => _210.replace, 'call', _211 => _211(/\/home\/[^/]+/g, "/home/***"), 'access', _212 => _212.replace, 'call', _213 => _213(/C:\\Users\\[^\\]+/g, "C:\\Users\\***")]);
10185
10319
  await this.trackEvent("error", {
10186
10320
  type: data.type,
10187
10321
  message: data.message,
@@ -10195,7 +10329,7 @@ var TelemetryManager = class {
10195
10329
  */
10196
10330
  async trackSessionFailureBug(data) {
10197
10331
  this.errorsCount++;
10198
- const sanitizedStack = _optionalChain([data, 'access', _202 => _202.error, 'access', _203 => _203.stack, 'optionalAccess', _204 => _204.replace, 'call', _205 => _205(/\/Users\/[^/]+/g, "/Users/***"), 'access', _206 => _206.replace, 'call', _207 => _207(/\/home\/[^/]+/g, "/home/***"), 'access', _208 => _208.replace, 'call', _209 => _209(/C:\\Users\\[^\\]+/g, "C:\\Users\\***")]);
10332
+ const sanitizedStack = _optionalChain([data, 'access', _214 => _214.error, 'access', _215 => _215.stack, 'optionalAccess', _216 => _216.replace, 'call', _217 => _217(/\/Users\/[^/]+/g, "/Users/***"), 'access', _218 => _218.replace, 'call', _219 => _219(/\/home\/[^/]+/g, "/home/***"), 'access', _220 => _220.replace, 'call', _221 => _221(/C:\\Users\\[^\\]+/g, "C:\\Users\\***")]);
10199
10333
  const bugData = {
10200
10334
  type: "BUG:session_failure",
10201
10335
  errorMessage: data.error.message,
@@ -10273,10 +10407,10 @@ var TelemetryManager = class {
10273
10407
  metadata: {
10274
10408
  model: this.currentModel || void 0,
10275
10409
  provider: this.currentProvider || void 0,
10276
- totalTokens: _optionalChain([data, 'access', _210 => _210.metadata, 'optionalAccess', _211 => _211.totalTokens]),
10277
- startTime: _optionalChain([this, 'access', _212 => _212.sessionStartTime, 'optionalAccess', _213 => _213.toISOString, 'call', _214 => _214()]),
10410
+ totalTokens: _optionalChain([data, 'access', _222 => _222.metadata, 'optionalAccess', _223 => _223.totalTokens]),
10411
+ startTime: _optionalChain([this, 'access', _224 => _224.sessionStartTime, 'optionalAccess', _225 => _225.toISOString, 'call', _226 => _226()]),
10278
10412
  endTime: (/* @__PURE__ */ new Date()).toISOString(),
10279
- workspaceRoot: _optionalChain([data, 'access', _215 => _215.metadata, 'optionalAccess', _216 => _216.workspaceRoot])
10413
+ workspaceRoot: _optionalChain([data, 'access', _227 => _227.metadata, 'optionalAccess', _228 => _228.workspaceRoot])
10280
10414
  }
10281
10415
  });
10282
10416
  }
@@ -10355,7 +10489,7 @@ var CommunitySkillsClient = class {
10355
10489
  if (_fsextra2.default.existsSync(deviceIdPath)) {
10356
10490
  return _fsextra2.default.readFileSync(deviceIdPath, "utf-8").trim();
10357
10491
  }
10358
- } catch (e57) {
10492
+ } catch (e59) {
10359
10493
  }
10360
10494
  return `anon_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
10361
10495
  }
@@ -10370,7 +10504,7 @@ var CommunitySkillsClient = class {
10370
10504
  if (_fsextra2.default.existsSync(queuePath)) {
10371
10505
  this.queue = _fsextra2.default.readJsonSync(queuePath);
10372
10506
  }
10373
- } catch (e58) {
10507
+ } catch (e60) {
10374
10508
  this.queue = [];
10375
10509
  }
10376
10510
  }
@@ -10381,7 +10515,7 @@ var CommunitySkillsClient = class {
10381
10515
  try {
10382
10516
  _fsextra2.default.ensureDirSync(this.queueDir);
10383
10517
  _fsextra2.default.writeJsonSync(path17.default.join(this.queueDir, "queue.json"), this.queue);
10384
- } catch (e59) {
10518
+ } catch (e61) {
10385
10519
  }
10386
10520
  }
10387
10521
  /**
@@ -10439,34 +10573,34 @@ var CommunitySkillsClient = class {
10439
10573
  */
10440
10574
  async listSkills(filters) {
10441
10575
  const params = new URLSearchParams();
10442
- if (_optionalChain([filters, 'optionalAccess', _217 => _217.languages, 'optionalAccess', _218 => _218.length])) {
10576
+ if (_optionalChain([filters, 'optionalAccess', _229 => _229.languages, 'optionalAccess', _230 => _230.length])) {
10443
10577
  params.set("languages", filters.languages.join(","));
10444
10578
  }
10445
- if (_optionalChain([filters, 'optionalAccess', _219 => _219.frameworks, 'optionalAccess', _220 => _220.length])) {
10579
+ if (_optionalChain([filters, 'optionalAccess', _231 => _231.frameworks, 'optionalAccess', _232 => _232.length])) {
10446
10580
  params.set("frameworks", filters.frameworks.join(","));
10447
10581
  }
10448
- if (_optionalChain([filters, 'optionalAccess', _221 => _221.patterns, 'optionalAccess', _222 => _222.length])) {
10582
+ if (_optionalChain([filters, 'optionalAccess', _233 => _233.patterns, 'optionalAccess', _234 => _234.length])) {
10449
10583
  params.set("patterns", filters.patterns.join(","));
10450
10584
  }
10451
- if (_optionalChain([filters, 'optionalAccess', _223 => _223.search])) {
10585
+ if (_optionalChain([filters, 'optionalAccess', _235 => _235.search])) {
10452
10586
  params.set("search", filters.search);
10453
10587
  }
10454
- if (_optionalChain([filters, 'optionalAccess', _224 => _224.curated])) {
10588
+ if (_optionalChain([filters, 'optionalAccess', _236 => _236.curated])) {
10455
10589
  params.set("curated", "true");
10456
10590
  }
10457
- if (_optionalChain([filters, 'optionalAccess', _225 => _225.featured])) {
10591
+ if (_optionalChain([filters, 'optionalAccess', _237 => _237.featured])) {
10458
10592
  params.set("featured", "true");
10459
10593
  }
10460
- if (_optionalChain([filters, 'optionalAccess', _226 => _226.limit])) {
10594
+ if (_optionalChain([filters, 'optionalAccess', _238 => _238.limit])) {
10461
10595
  params.set("limit", String(filters.limit));
10462
10596
  }
10463
- if (_optionalChain([filters, 'optionalAccess', _227 => _227.offset])) {
10597
+ if (_optionalChain([filters, 'optionalAccess', _239 => _239.offset])) {
10464
10598
  params.set("offset", String(filters.offset));
10465
10599
  }
10466
10600
  const query = params.toString();
10467
10601
  const endpoint = `/v1/community-skills${query ? `?${query}` : ""}`;
10468
10602
  const result = await this.request(endpoint);
10469
- return result.ok ? _optionalChain([result, 'access', _228 => _228.data, 'optionalAccess', _229 => _229.skills]) || [] : [];
10603
+ return result.ok ? _optionalChain([result, 'access', _240 => _240.data, 'optionalAccess', _241 => _241.skills]) || [] : [];
10470
10604
  }
10471
10605
  /**
10472
10606
  * Download a skill by name
@@ -10475,7 +10609,7 @@ var CommunitySkillsClient = class {
10475
10609
  const result = await this.request(
10476
10610
  `/v1/community-skills/${encodeURIComponent(name)}/download`
10477
10611
  );
10478
- if (result.ok && _optionalChain([result, 'access', _230 => _230.data, 'optionalAccess', _231 => _231.skill])) {
10612
+ if (result.ok && _optionalChain([result, 'access', _242 => _242.data, 'optionalAccess', _243 => _243.skill])) {
10479
10613
  return { success: true, skill: result.data.skill };
10480
10614
  }
10481
10615
  return { success: false, error: result.error || "Failed to download skill" };
@@ -10497,7 +10631,7 @@ var CommunitySkillsClient = class {
10497
10631
  const query = params.toString();
10498
10632
  const endpoint = `/v1/community-skills/suggestions${query ? `?${query}` : ""}`;
10499
10633
  const result = await this.request(endpoint);
10500
- return result.ok ? _optionalChain([result, 'access', _232 => _232.data, 'optionalAccess', _233 => _233.suggestions]) || [] : [];
10634
+ return result.ok ? _optionalChain([result, 'access', _244 => _244.data, 'optionalAccess', _245 => _245.suggestions]) || [] : [];
10501
10635
  }
10502
10636
  /**
10503
10637
  * Submit a skill for community review
@@ -10507,17 +10641,17 @@ var CommunitySkillsClient = class {
10507
10641
  method: "POST",
10508
10642
  body: JSON.stringify(skill)
10509
10643
  });
10510
- if (result.ok && _optionalChain([result, 'access', _234 => _234.data, 'optionalAccess', _235 => _235.success])) {
10644
+ if (result.ok && _optionalChain([result, 'access', _246 => _246.data, 'optionalAccess', _247 => _247.success])) {
10511
10645
  return {
10512
10646
  success: true,
10513
10647
  id: result.data.id,
10514
10648
  pending: result.data.pending
10515
10649
  };
10516
10650
  }
10517
- if (!result.ok && _optionalChain([result, 'access', _236 => _236.error, 'optionalAccess', _237 => _237.includes, 'call', _238 => _238("fetch")])) {
10651
+ if (!result.ok && _optionalChain([result, 'access', _248 => _248.error, 'optionalAccess', _249 => _249.includes, 'call', _250 => _250("fetch")])) {
10518
10652
  this.addToQueue("submit", skill);
10519
10653
  }
10520
- return { success: false, error: result.error || _optionalChain([result, 'access', _239 => _239.data, 'optionalAccess', _240 => _240.error]) };
10654
+ return { success: false, error: result.error || _optionalChain([result, 'access', _251 => _251.data, 'optionalAccess', _252 => _252.error]) };
10521
10655
  }
10522
10656
  // ============ Backup Operations ============
10523
10657
  /**
@@ -10534,7 +10668,7 @@ var CommunitySkillsClient = class {
10534
10668
  })
10535
10669
  }
10536
10670
  );
10537
- if (result.ok && _optionalChain([result, 'access', _241 => _241.data, 'optionalAccess', _242 => _242.backed])) {
10671
+ if (result.ok && _optionalChain([result, 'access', _253 => _253.data, 'optionalAccess', _254 => _254.backed])) {
10538
10672
  return true;
10539
10673
  }
10540
10674
  this.addToQueue("backup", skill);
@@ -10556,8 +10690,8 @@ var CommunitySkillsClient = class {
10556
10690
  });
10557
10691
  if (result.ok) {
10558
10692
  return {
10559
- backed: _optionalChain([result, 'access', _243 => _243.data, 'optionalAccess', _244 => _244.backed]) || 0,
10560
- failed: _optionalChain([result, 'access', _245 => _245.data, 'optionalAccess', _246 => _246.skipped]) || 0
10693
+ backed: _optionalChain([result, 'access', _255 => _255.data, 'optionalAccess', _256 => _256.backed]) || 0,
10694
+ failed: _optionalChain([result, 'access', _257 => _257.data, 'optionalAccess', _258 => _258.skipped]) || 0
10561
10695
  };
10562
10696
  }
10563
10697
  for (const skill of skills) {
@@ -10572,7 +10706,7 @@ var CommunitySkillsClient = class {
10572
10706
  const result = await this.request(
10573
10707
  `/v1/skills-backup/${encodeURIComponent(this.deviceId)}`
10574
10708
  );
10575
- return result.ok ? _optionalChain([result, 'access', _247 => _247.data, 'optionalAccess', _248 => _248.backups]) || [] : [];
10709
+ return result.ok ? _optionalChain([result, 'access', _259 => _259.data, 'optionalAccess', _260 => _260.backups]) || [] : [];
10576
10710
  }
10577
10711
  /**
10578
10712
  * Restore skills from backup
@@ -10630,7 +10764,7 @@ var CommunitySkillsClient = class {
10630
10764
  })
10631
10765
  }
10632
10766
  );
10633
- success = result.ok && (_optionalChain([result, 'access', _249 => _249.data, 'optionalAccess', _250 => _250.backed]) || 0) > 0;
10767
+ success = result.ok && (_optionalChain([result, 'access', _261 => _261.data, 'optionalAccess', _262 => _262.backed]) || 0) > 0;
10634
10768
  } else if (op.type === "submit") {
10635
10769
  const result = await this.request(
10636
10770
  "/v1/community-skills",
@@ -10639,7 +10773,7 @@ var CommunitySkillsClient = class {
10639
10773
  body: JSON.stringify(op.payload)
10640
10774
  }
10641
10775
  );
10642
- success = result.ok && _optionalChain([result, 'access', _251 => _251.data, 'optionalAccess', _252 => _252.success]) === true;
10776
+ success = result.ok && _optionalChain([result, 'access', _263 => _263.data, 'optionalAccess', _264 => _264.success]) === true;
10643
10777
  }
10644
10778
  if (success) {
10645
10779
  sent++;
@@ -10827,7 +10961,7 @@ var PersistentInput = class extends _events2.default {
10827
10961
  if (!this.isActive || this.isPaused) {
10828
10962
  return;
10829
10963
  }
10830
- if (_optionalChain([key, 'optionalAccess', _253 => _253.name]) === "return" || _optionalChain([key, 'optionalAccess', _254 => _254.name]) === "enter") {
10964
+ if (_optionalChain([key, 'optionalAccess', _265 => _265.name]) === "return" || _optionalChain([key, 'optionalAccess', _266 => _266.name]) === "enter") {
10831
10965
  if (this.currentInput.trim()) {
10832
10966
  this.addToQueue(this.currentInput.trim());
10833
10967
  this.currentInput = "";
@@ -10837,7 +10971,7 @@ var PersistentInput = class extends _events2.default {
10837
10971
  }
10838
10972
  return;
10839
10973
  }
10840
- if (_optionalChain([key, 'optionalAccess', _255 => _255.name]) === "backspace") {
10974
+ if (_optionalChain([key, 'optionalAccess', _267 => _267.name]) === "backspace") {
10841
10975
  if (this.currentInput.length > 0) {
10842
10976
  this.currentInput = this.currentInput.slice(0, -1);
10843
10977
  if (!this.silentMode) {
@@ -10846,15 +10980,15 @@ var PersistentInput = class extends _events2.default {
10846
10980
  }
10847
10981
  return;
10848
10982
  }
10849
- if (_optionalChain([key, 'optionalAccess', _256 => _256.name]) === "escape") {
10983
+ if (_optionalChain([key, 'optionalAccess', _268 => _268.name]) === "escape") {
10850
10984
  this.emit("escape");
10851
10985
  return;
10852
10986
  }
10853
- if (_optionalChain([key, 'optionalAccess', _257 => _257.name]) === "c" && key.ctrl) {
10987
+ if (_optionalChain([key, 'optionalAccess', _269 => _269.name]) === "c" && key.ctrl) {
10854
10988
  this.emit("ctrl-c");
10855
10989
  return;
10856
10990
  }
10857
- if (_optionalChain([key, 'optionalAccess', _258 => _258.ctrl]) || _optionalChain([key, 'optionalAccess', _259 => _259.meta])) {
10991
+ if (_optionalChain([key, 'optionalAccess', _270 => _270.ctrl]) || _optionalChain([key, 'optionalAccess', _271 => _271.meta])) {
10858
10992
  return;
10859
10993
  }
10860
10994
  if (_str) {
@@ -11084,7 +11218,7 @@ function formatToolOutputForDisplay(options) {
11084
11218
  const { tool, content, charLimit, filePath, command, commandArgs } = options;
11085
11219
  const totalChars = content.length;
11086
11220
  if (tool === "run_command" && command) {
11087
- const fullCommand = _optionalChain([commandArgs, 'optionalAccess', _260 => _260.length]) ? `${command} ${commandArgs.join(" ")}` : command;
11221
+ const fullCommand = _optionalChain([commandArgs, 'optionalAccess', _272 => _272.length]) ? `${command} ${commandArgs.join(" ")}` : command;
11088
11222
  const outputLines = content ? content.split("\n").length : 0;
11089
11223
  const truncatedContent = charLimit > 0 && totalChars > charLimit ? `${content.slice(0, charLimit)}
11090
11224
  ... (${totalChars} chars)` : content;
@@ -11232,14 +11366,14 @@ async function confirm(message, context) {
11232
11366
  message: "Enter alternative action (or empty to cancel)"
11233
11367
  });
11234
11368
  const altAnswer = await inputPrompt.run();
11235
- if (_optionalChain([altAnswer, 'optionalAccess', _261 => _261.trim, 'call', _262 => _262()])) {
11369
+ if (_optionalChain([altAnswer, 'optionalAccess', _273 => _273.trim, 'call', _274 => _274()])) {
11236
11370
  confirm.lastAlternative = altAnswer.trim();
11237
11371
  return "alternative";
11238
11372
  }
11239
11373
  return false;
11240
11374
  }
11241
11375
  return false;
11242
- } catch (e60) {
11376
+ } catch (e62) {
11243
11377
  return false;
11244
11378
  }
11245
11379
  }
@@ -11478,8 +11612,8 @@ var IntentDetector = class {
11478
11612
  */
11479
11613
  formatDisplay(result) {
11480
11614
  const { intent, keywords } = result;
11481
- const useTheme = _chunkSXUZ3CX3cjs.isThemeInitialized.call(void 0, );
11482
- const theme = useTheme ? _chunkSXUZ3CX3cjs.getTheme.call(void 0, ) : null;
11615
+ const useTheme = _chunkQMVTT55Ycjs.isThemeInitialized.call(void 0, );
11616
+ const theme = useTheme ? _chunkQMVTT55Ycjs.getTheme.call(void 0, ) : null;
11483
11617
  const accent = (text) => theme ? theme.fg("accent", text) : text;
11484
11618
  const warning = (text) => theme ? theme.fg("warning", text) : text;
11485
11619
  const muted = (text) => theme ? theme.fg("muted", text) : text;
@@ -11570,12 +11704,12 @@ var EnvironmentBootstrap = class {
11570
11704
  * @returns Bootstrap result with all steps
11571
11705
  */
11572
11706
  async run(workspaceRoot, options) {
11573
- if (!_optionalChain([options, 'optionalAccess', _263 => _263.force]) && this.isCacheValid()) {
11707
+ if (!_optionalChain([options, 'optionalAccess', _275 => _275.force]) && this.isCacheValid()) {
11574
11708
  return this.lastResult;
11575
11709
  }
11576
11710
  const startTime = Date.now();
11577
11711
  const steps = [];
11578
- if (!_optionalChain([options, 'optionalAccess', _264 => _264.skipGitSync])) {
11712
+ if (!_optionalChain([options, 'optionalAccess', _276 => _276.skipGitSync])) {
11579
11713
  steps.push(await this.gitSync(workspaceRoot));
11580
11714
  }
11581
11715
  const pm = await this.detectPackageManager(workspaceRoot);
@@ -11586,7 +11720,7 @@ var EnvironmentBootstrap = class {
11586
11720
  detail: `Detected: ${pm}`
11587
11721
  });
11588
11722
  }
11589
- if (pm && !_optionalChain([options, 'optionalAccess', _265 => _265.skipInstall])) {
11723
+ if (pm && !_optionalChain([options, 'optionalAccess', _277 => _277.skipInstall])) {
11590
11724
  steps.push(await this.installDependencies(workspaceRoot, pm));
11591
11725
  }
11592
11726
  steps.push(await this.validateToolchain(workspaceRoot));
@@ -11622,7 +11756,7 @@ var EnvironmentBootstrap = class {
11622
11756
  }
11623
11757
  }
11624
11758
  return "npm";
11625
- } catch (e61) {
11759
+ } catch (e63) {
11626
11760
  return null;
11627
11761
  }
11628
11762
  }
@@ -11660,7 +11794,7 @@ var EnvironmentBootstrap = class {
11660
11794
  try {
11661
11795
  await execAsync("git pull --ff-only", { cwd: root, timeout: 6e4 });
11662
11796
  step.detail = "Pulled latest changes";
11663
- } catch (e62) {
11797
+ } catch (e64) {
11664
11798
  step.detail = "Behind remote (pull failed, may need manual merge)";
11665
11799
  }
11666
11800
  } else if (statusOutput.includes("Your branch is ahead")) {
@@ -11769,8 +11903,8 @@ var EnvironmentBootstrap = class {
11769
11903
  * @returns Formatted string for terminal display
11770
11904
  */
11771
11905
  formatDisplay(result) {
11772
- const useTheme = _chunkSXUZ3CX3cjs.isThemeInitialized.call(void 0, );
11773
- const theme = useTheme ? _chunkSXUZ3CX3cjs.getTheme.call(void 0, ) : null;
11906
+ const useTheme = _chunkQMVTT55Ycjs.isThemeInitialized.call(void 0, );
11907
+ const theme = useTheme ? _chunkQMVTT55Ycjs.getTheme.call(void 0, ) : null;
11774
11908
  const accent = (text) => theme ? theme.fg("accent", text) : text;
11775
11909
  const success = (text) => theme ? theme.fg("success", text) : text;
11776
11910
  const error = (text) => theme ? theme.fg("error", text) : text;
@@ -11845,28 +11979,28 @@ var CodeQualityPipeline = class {
11845
11979
  const startTime = Date.now();
11846
11980
  const scripts = await this.detectScripts(workspaceRoot);
11847
11981
  const checks = [];
11848
- if (_optionalChain([options, 'optionalAccess', _266 => _266.autoFix]) && scripts.lint) {
11982
+ if (_optionalChain([options, 'optionalAccess', _278 => _278.autoFix]) && scripts.lint) {
11849
11983
  await this.runAutoFix(workspaceRoot, scripts.lint);
11850
11984
  }
11851
11985
  const parallelChecks = [];
11852
- if (scripts.lint && !_optionalChain([options, 'optionalAccess', _267 => _267.skipLint])) {
11986
+ if (scripts.lint && !_optionalChain([options, 'optionalAccess', _279 => _279.skipLint])) {
11853
11987
  parallelChecks.push(this.runCheck(workspaceRoot, "lint", "Lint", scripts.lint));
11854
11988
  }
11855
- if (scripts.typecheck && !_optionalChain([options, 'optionalAccess', _268 => _268.skipTypecheck])) {
11989
+ if (scripts.typecheck && !_optionalChain([options, 'optionalAccess', _280 => _280.skipTypecheck])) {
11856
11990
  parallelChecks.push(this.runCheck(workspaceRoot, "typecheck", "Types", scripts.typecheck));
11857
11991
  }
11858
11992
  if (parallelChecks.length > 0) {
11859
11993
  const parallelResults = await Promise.all(parallelChecks);
11860
11994
  checks.push(...parallelResults);
11861
11995
  }
11862
- if (scripts.test && !_optionalChain([options, 'optionalAccess', _269 => _269.skipTest])) {
11996
+ if (scripts.test && !_optionalChain([options, 'optionalAccess', _281 => _281.skipTest])) {
11863
11997
  let testCmd = scripts.test;
11864
- if (_optionalChain([options, 'optionalAccess', _270 => _270.testFilter])) {
11998
+ if (_optionalChain([options, 'optionalAccess', _282 => _282.testFilter])) {
11865
11999
  testCmd = `${scripts.test} --grep "${options.testFilter}"`;
11866
12000
  }
11867
12001
  checks.push(await this.runCheck(workspaceRoot, "test", "Tests", testCmd));
11868
12002
  }
11869
- if (scripts.build && !_optionalChain([options, 'optionalAccess', _271 => _271.skipBuild])) {
12003
+ if (scripts.build && !_optionalChain([options, 'optionalAccess', _283 => _283.skipBuild])) {
11870
12004
  checks.push(await this.runCheck(workspaceRoot, "build", "Build", scripts.build));
11871
12005
  }
11872
12006
  const passed = checks.every((c) => c.status === "passed" || c.status === "skipped");
@@ -11896,7 +12030,7 @@ var CodeQualityPipeline = class {
11896
12030
  test: this.findScript(scripts, this.scriptPatterns.test),
11897
12031
  build: this.findScript(scripts, this.scriptPatterns.build)
11898
12032
  };
11899
- } catch (e63) {
12033
+ } catch (e65) {
11900
12034
  return {};
11901
12035
  }
11902
12036
  }
@@ -11961,7 +12095,7 @@ var CodeQualityPipeline = class {
11961
12095
  try {
11962
12096
  await execAsync2(`npm run ${fixScript}`, { cwd: root, timeout: 6e4 });
11963
12097
  return;
11964
- } catch (e64) {
12098
+ } catch (e66) {
11965
12099
  }
11966
12100
  }
11967
12101
  }
@@ -12076,8 +12210,8 @@ var AutohandAgent = class {
12076
12210
  this.searchQueries = [];
12077
12211
  this.sessionRetryCount = 0;
12078
12212
  const initialProvider = _nullishCoalesce(runtime.config.provider, () => ( "openrouter"));
12079
- const providerSettings = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, runtime.config, initialProvider);
12080
- const model = _nullishCoalesce(_nullishCoalesce(runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _272 => _272.model]))), () => ( "unconfigured"));
12213
+ const providerSettings = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, runtime.config, initialProvider);
12214
+ const model = _nullishCoalesce(_nullishCoalesce(runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _284 => _284.model]))), () => ( "unconfigured"));
12081
12215
  this.contextWindow = getContextWindow(model);
12082
12216
  this.ignoreFilter = new GitIgnoreParser(runtime.workspaceRoot, []);
12083
12217
  this.conversation = ConversationManager.getInstance();
@@ -12092,7 +12226,7 @@ var AutohandAgent = class {
12092
12226
  workspaceRoot: runtime.workspaceRoot,
12093
12227
  onPersist: async (settings) => {
12094
12228
  runtime.config.permissions = settings;
12095
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, runtime.config);
12229
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, runtime.config);
12096
12230
  }
12097
12231
  });
12098
12232
  this.permissionManager.initLocalSettings().catch(() => {
@@ -12102,7 +12236,7 @@ var AutohandAgent = class {
12102
12236
  workspaceRoot: runtime.workspaceRoot,
12103
12237
  onPersist: async () => {
12104
12238
  runtime.config.hooks = this.hookManager.getSettings();
12105
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, runtime.config);
12239
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, runtime.config);
12106
12240
  },
12107
12241
  onHookOutput: (result) => {
12108
12242
  if (result.stdout && !result.response) {
@@ -12121,7 +12255,7 @@ var AutohandAgent = class {
12121
12255
  onExploration: (entry) => this.recordExploration(entry),
12122
12256
  onToolOutput: (chunk) => this.handleToolOutput(chunk),
12123
12257
  toolsRegistry: this.toolsRegistry,
12124
- getRegisteredTools: () => _nullishCoalesce(_optionalChain([this, 'access', _273 => _273.toolManager, 'optionalAccess', _274 => _274.listDefinitions, 'call', _275 => _275()]), () => ( [])),
12258
+ getRegisteredTools: () => _nullishCoalesce(_optionalChain([this, 'access', _285 => _285.toolManager, 'optionalAccess', _286 => _286.listDefinitions, 'call', _287 => _287()]), () => ( [])),
12125
12259
  memoryManager: this.memoryManager,
12126
12260
  permissionManager: this.permissionManager,
12127
12261
  onFileModified: () => this.markFilesModified(),
@@ -12133,7 +12267,7 @@ var AutohandAgent = class {
12133
12267
  permissionType: "tool_approval"
12134
12268
  });
12135
12269
  for (const result of results) {
12136
- if (_optionalChain([result, 'access', _276 => _276.response, 'optionalAccess', _277 => _277.decision])) {
12270
+ if (_optionalChain([result, 'access', _288 => _288.response, 'optionalAccess', _289 => _289.decision])) {
12137
12271
  return {
12138
12272
  decision: result.response.decision,
12139
12273
  reason: result.response.reason,
@@ -12160,17 +12294,20 @@ var AutohandAgent = class {
12160
12294
  });
12161
12295
  }
12162
12296
  });
12163
- this.errorLogger = new ErrorLogger(_chunk7EIL6P6Qcjs.package_default.version);
12164
- this.feedbackManager = new FeedbackManager();
12297
+ this.errorLogger = new ErrorLogger(_chunkXJZYEURAcjs.package_default.version);
12298
+ this.feedbackManager = new FeedbackManager({
12299
+ apiBaseUrl: _optionalChain([runtime, 'access', _290 => _290.config, 'access', _291 => _291.api, 'optionalAccess', _292 => _292.baseUrl]) || "https://api.autohand.ai",
12300
+ cliVersion: _chunkXJZYEURAcjs.package_default.version
12301
+ });
12165
12302
  this.skillsRegistry = new (0, _chunkCVYEUA3Dcjs.SkillsRegistry)(_chunkXTHHDIBGcjs.AUTOHAND_PATHS.skills);
12166
12303
  this.telemetryManager = new TelemetryManager({
12167
- enabled: _optionalChain([runtime, 'access', _278 => _278.config, 'access', _279 => _279.telemetry, 'optionalAccess', _280 => _280.enabled]) === true,
12168
- apiBaseUrl: _optionalChain([runtime, 'access', _281 => _281.config, 'access', _282 => _282.telemetry, 'optionalAccess', _283 => _283.apiBaseUrl]) || "https://api.autohand.ai",
12169
- enableSessionSync: _optionalChain([runtime, 'access', _284 => _284.config, 'access', _285 => _285.telemetry, 'optionalAccess', _286 => _286.enableSessionSync]) === true
12304
+ enabled: _optionalChain([runtime, 'access', _293 => _293.config, 'access', _294 => _294.telemetry, 'optionalAccess', _295 => _295.enabled]) === true,
12305
+ apiBaseUrl: _optionalChain([runtime, 'access', _296 => _296.config, 'access', _297 => _297.telemetry, 'optionalAccess', _298 => _298.apiBaseUrl]) || "https://api.autohand.ai",
12306
+ enableSessionSync: _optionalChain([runtime, 'access', _299 => _299.config, 'access', _300 => _300.telemetry, 'optionalAccess', _301 => _301.enableSessionSync]) === true
12170
12307
  });
12171
12308
  const communitySettings = _nullishCoalesce(runtime.config.communitySkills, () => ( {}));
12172
12309
  this.communityClient = new CommunitySkillsClient({
12173
- apiBaseUrl: _optionalChain([runtime, 'access', _287 => _287.config, 'access', _288 => _288.api, 'optionalAccess', _289 => _289.baseUrl]) || "https://api.autohand.ai",
12310
+ apiBaseUrl: _optionalChain([runtime, 'access', _302 => _302.config, 'access', _303 => _303.api, 'optionalAccess', _304 => _304.baseUrl]) || "https://api.autohand.ai",
12174
12311
  enabled: communitySettings.enabled !== false
12175
12312
  });
12176
12313
  this.skillsRegistry.setTelemetryManager(this.telemetryManager);
@@ -12264,7 +12401,7 @@ var AutohandAgent = class {
12264
12401
  });
12265
12402
  this.sessionManager = new (0, _chunkUPR5PKX4cjs.SessionManager)();
12266
12403
  this.projectManager = new ProjectManager();
12267
- this.useInkRenderer = _optionalChain([runtime, 'access', _290 => _290.config, 'access', _291 => _291.ui, 'optionalAccess', _292 => _292.useInkRenderer]) === true;
12404
+ this.useInkRenderer = _optionalChain([runtime, 'access', _305 => _305.config, 'access', _306 => _306.ui, 'optionalAccess', _307 => _307.useInkRenderer]) === true;
12268
12405
  this.persistentInput = createPersistentInput({
12269
12406
  maxQueueSize: 10,
12270
12407
  silentMode: true
@@ -12313,8 +12450,8 @@ var AutohandAgent = class {
12313
12450
  await this.hookManager.initialize();
12314
12451
  await this.resetConversationContext();
12315
12452
  this.feedbackManager.startSession();
12316
- const providerSettings = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
12317
- const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _293 => _293.model]))), () => ( "unconfigured"));
12453
+ const providerSettings = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
12454
+ const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _308 => _308.model]))), () => ( "unconfigured"));
12318
12455
  await this.sessionManager.createSession(this.runtime.workspaceRoot, model);
12319
12456
  const session = this.sessionManager.getCurrentSession();
12320
12457
  if (session) {
@@ -12325,7 +12462,7 @@ var AutohandAgent = class {
12325
12462
  );
12326
12463
  }
12327
12464
  await this.hookManager.executeHooks("session-start", {
12328
- sessionId: _optionalChain([session, 'optionalAccess', _294 => _294.metadata, 'access', _295 => _295.sessionId]),
12465
+ sessionId: _optionalChain([session, 'optionalAccess', _309 => _309.metadata, 'access', _310 => _310.sessionId]),
12329
12466
  sessionType: "startup"
12330
12467
  });
12331
12468
  await this.runInteractiveLoop();
@@ -12341,8 +12478,8 @@ var AutohandAgent = class {
12341
12478
  await this.skillsRegistry.setWorkspace(this.runtime.workspaceRoot);
12342
12479
  await this.hookManager.initialize();
12343
12480
  await this.resetConversationContext();
12344
- const providerSettings = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
12345
- const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _296 => _296.model]))), () => ( "unconfigured"));
12481
+ const providerSettings = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
12482
+ const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _311 => _311.model]))), () => ( "unconfigured"));
12346
12483
  await this.sessionManager.createSession(this.runtime.workspaceRoot, model);
12347
12484
  const session = this.sessionManager.getCurrentSession();
12348
12485
  if (session) {
@@ -12353,7 +12490,7 @@ var AutohandAgent = class {
12353
12490
  );
12354
12491
  }
12355
12492
  await this.hookManager.executeHooks("session-start", {
12356
- sessionId: _optionalChain([session, 'optionalAccess', _297 => _297.metadata, 'access', _298 => _298.sessionId]),
12493
+ sessionId: _optionalChain([session, 'optionalAccess', _312 => _312.metadata, 'access', _313 => _313.sessionId]),
12357
12494
  sessionType: "startup"
12358
12495
  });
12359
12496
  }
@@ -12364,18 +12501,18 @@ var AutohandAgent = class {
12364
12501
  const turnDuration = Date.now() - turnStartTime;
12365
12502
  const session = this.sessionManager.getCurrentSession();
12366
12503
  await this.hookManager.executeHooks("stop", {
12367
- sessionId: _optionalChain([session, 'optionalAccess', _299 => _299.metadata, 'access', _300 => _300.sessionId]),
12504
+ sessionId: _optionalChain([session, 'optionalAccess', _314 => _314.metadata, 'access', _315 => _315.sessionId]),
12368
12505
  turnDuration,
12369
12506
  tokensUsed: this.sessionTokensUsed
12370
12507
  });
12371
- if (_optionalChain([this, 'access', _301 => _301.runtime, 'access', _302 => _302.config, 'access', _303 => _303.ui, 'optionalAccess', _304 => _304.terminalBell]) !== false) {
12508
+ if (_optionalChain([this, 'access', _316 => _316.runtime, 'access', _317 => _317.config, 'access', _318 => _318.ui, 'optionalAccess', _319 => _319.terminalBell]) !== false) {
12372
12509
  process.stdout.write("\x07");
12373
12510
  }
12374
12511
  if (this.runtime.options.autoCommit) {
12375
12512
  await this.performAutoCommit();
12376
12513
  }
12377
12514
  await this.hookManager.executeHooks("session-end", {
12378
- sessionId: _optionalChain([session, 'optionalAccess', _305 => _305.metadata, 'access', _306 => _306.sessionId]),
12515
+ sessionId: _optionalChain([session, 'optionalAccess', _320 => _320.metadata, 'access', _321 => _321.sessionId]),
12379
12516
  sessionEndReason: "exit",
12380
12517
  duration: Date.now() - this.sessionStartedAt
12381
12518
  });
@@ -12449,7 +12586,7 @@ If lint or tests fail, report the issues but do NOT commit.`;
12449
12586
  id: tc.id,
12450
12587
  type: "function",
12451
12588
  function: {
12452
- name: tc.tool || _optionalChain([tc, 'access', _307 => _307.function, 'optionalAccess', _308 => _308.name]) || "unknown",
12589
+ name: tc.tool || _optionalChain([tc, 'access', _322 => _322.function, 'optionalAccess', _323 => _323.name]) || "unknown",
12453
12590
  arguments: typeof tc.args === "string" ? tc.args : JSON.stringify(tc.args || {})
12454
12591
  }
12455
12592
  }));
@@ -12480,8 +12617,8 @@ If lint or tests fail, report the issues but do NOT commit.`;
12480
12617
  message: error.message,
12481
12618
  context: "resumeSession"
12482
12619
  });
12483
- const providerSettings = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
12484
- const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _309 => _309.model]))), () => ( "unconfigured"));
12620
+ const providerSettings = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
12621
+ const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _324 => _324.model]))), () => ( "unconfigured"));
12485
12622
  await this.sessionManager.createSession(this.runtime.workspaceRoot, model);
12486
12623
  await this.runInteractiveLoop();
12487
12624
  }
@@ -12500,7 +12637,7 @@ If lint or tests fail, report the issues but do NOT commit.`;
12500
12637
  console.log(_chalk2.default.gray(` ${remaining} more request(s) queued`));
12501
12638
  }
12502
12639
  }
12503
- } else if (_optionalChain([this, 'access', _310 => _310.inkRenderer, 'optionalAccess', _311 => _311.hasQueuedInstructions, 'call', _312 => _312()])) {
12640
+ } else if (_optionalChain([this, 'access', _325 => _325.inkRenderer, 'optionalAccess', _326 => _326.hasQueuedInstructions, 'call', _327 => _327()])) {
12504
12641
  instruction = _nullishCoalesce(this.inkRenderer.dequeueInstruction(), () => ( null));
12505
12642
  if (instruction) {
12506
12643
  console.log(_chalk2.default.cyan(`
@@ -12532,7 +12669,7 @@ If lint or tests fail, report the issues but do NOT commit.`;
12532
12669
  const trigger = this.feedbackManager.shouldPrompt({ sessionEnding: true });
12533
12670
  if (trigger) {
12534
12671
  const session2 = this.sessionManager.getCurrentSession();
12535
- await this.feedbackManager.promptForFeedback(trigger, _optionalChain([session2, 'optionalAccess', _313 => _313.metadata, 'access', _314 => _314.sessionId]));
12672
+ await this.feedbackManager.promptForFeedback(trigger, _optionalChain([session2, 'optionalAccess', _328 => _328.metadata, 'access', _329 => _329.sessionId]));
12536
12673
  }
12537
12674
  await this.closeSession();
12538
12675
  return;
@@ -12549,11 +12686,11 @@ If lint or tests fail, report the issues but do NOT commit.`;
12549
12686
  const turnDuration = Date.now() - turnStartTime;
12550
12687
  const session = this.sessionManager.getCurrentSession();
12551
12688
  await this.hookManager.executeHooks("stop", {
12552
- sessionId: _optionalChain([session, 'optionalAccess', _315 => _315.metadata, 'access', _316 => _316.sessionId]),
12689
+ sessionId: _optionalChain([session, 'optionalAccess', _330 => _330.metadata, 'access', _331 => _331.sessionId]),
12553
12690
  turnDuration,
12554
12691
  tokensUsed: this.sessionTokensUsed
12555
12692
  });
12556
- if (_optionalChain([this, 'access', _317 => _317.runtime, 'access', _318 => _318.config, 'access', _319 => _319.ui, 'optionalAccess', _320 => _320.terminalBell]) !== false) {
12693
+ if (_optionalChain([this, 'access', _332 => _332.runtime, 'access', _333 => _333.config, 'access', _334 => _334.ui, 'optionalAccess', _335 => _335.terminalBell]) !== false) {
12557
12694
  process.stdout.write("\x07");
12558
12695
  }
12559
12696
  this.feedbackManager.recordInteraction();
@@ -12567,13 +12704,13 @@ If lint or tests fail, report the issues but do NOT commit.`;
12567
12704
  if (feedbackTrigger === "gratitude") {
12568
12705
  await this.feedbackManager.quickRating();
12569
12706
  } else {
12570
- await this.feedbackManager.promptForFeedback(feedbackTrigger, _optionalChain([session2, 'optionalAccess', _321 => _321.metadata, 'access', _322 => _322.sessionId]));
12707
+ await this.feedbackManager.promptForFeedback(feedbackTrigger, _optionalChain([session2, 'optionalAccess', _336 => _336.metadata, 'access', _337 => _337.sessionId]));
12571
12708
  }
12572
12709
  }
12573
12710
  console.log();
12574
12711
  } catch (error) {
12575
12712
  const errorObj = error;
12576
- const isCancel = errorObj.name === "ExitPromptError" || errorObj.isCanceled || _optionalChain([errorObj, 'access', _323 => _323.message, 'optionalAccess', _324 => _324.includes, 'call', _325 => _325("canceled")]) || _optionalChain([errorObj, 'access', _326 => _326.message, 'optionalAccess', _327 => _327.includes, 'call', _328 => _328("User force closed")]) || !errorObj.message;
12713
+ const isCancel = errorObj.name === "ExitPromptError" || errorObj.isCanceled || _optionalChain([errorObj, 'access', _338 => _338.message, 'optionalAccess', _339 => _339.includes, 'call', _340 => _340("canceled")]) || _optionalChain([errorObj, 'access', _341 => _341.message, 'optionalAccess', _342 => _342.includes, 'call', _343 => _343("User force closed")]) || !errorObj.message;
12577
12714
  if (isCancel) {
12578
12715
  continue;
12579
12716
  }
@@ -12730,7 +12867,7 @@ If lint or tests fail, report the issues but do NOT commit.`;
12730
12867
  let entries;
12731
12868
  try {
12732
12869
  entries = await _fsextra2.default.readdir(current);
12733
- } catch (e65) {
12870
+ } catch (e67) {
12734
12871
  return;
12735
12872
  }
12736
12873
  for (const entry of entries) {
@@ -12746,7 +12883,7 @@ If lint or tests fail, report the issues but do NOT commit.`;
12746
12883
  } else if (stats.isFile()) {
12747
12884
  acc.push(rel);
12748
12885
  }
12749
- } catch (e66) {
12886
+ } catch (e68) {
12750
12887
  continue;
12751
12888
  }
12752
12889
  }
@@ -12785,14 +12922,15 @@ If lint or tests fail, report the issues but do NOT commit.`;
12785
12922
  }
12786
12923
  async promptModelSelection() {
12787
12924
  try {
12788
- const allProviders = ["openrouter", "ollama", "llamacpp", "openai"];
12925
+ const allProviders = ProviderFactory.getProviderNames();
12789
12926
  const providerChoices = allProviders.map((name) => {
12790
12927
  const isConfigured = this.isProviderConfigured(name);
12791
12928
  const indicator = isConfigured ? _chalk2.default.green("\u25CF") : _chalk2.default.red("\u25CB");
12792
12929
  const current = name === this.activeProvider ? _chalk2.default.cyan(" (current)") : "";
12930
+ const siliconNote = name === "mlx" ? _chalk2.default.gray(" (Apple Silicon)") : "";
12793
12931
  return {
12794
12932
  name,
12795
- message: `${indicator} ${name}${current}`,
12933
+ message: `${indicator} ${name}${current}${siliconNote}`,
12796
12934
  value: name
12797
12935
  };
12798
12936
  });
@@ -12814,7 +12952,7 @@ ${selectedProvider} is not configured yet. Let's set it up!
12814
12952
  }
12815
12953
  await this.changeProviderModel(selectedProvider);
12816
12954
  } catch (error) {
12817
- if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _329 => _329.message, 'optionalAccess', _330 => _330.includes, 'call', _331 => _331("canceled")])) {
12955
+ if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _344 => _344.message, 'optionalAccess', _345 => _345.includes, 'call', _346 => _346("canceled")])) {
12818
12956
  console.log(_chalk2.default.gray("\nConfiguration cancelled."));
12819
12957
  return;
12820
12958
  }
@@ -12843,6 +12981,9 @@ ${selectedProvider} is not configured yet. Let's set it up!
12843
12981
  case "openai":
12844
12982
  await this.configureOpenAI();
12845
12983
  break;
12984
+ case "mlx":
12985
+ await this.configureMLX();
12986
+ break;
12846
12987
  }
12847
12988
  }
12848
12989
  async configureOpenRouter() {
@@ -12869,11 +13010,11 @@ ${selectedProvider} is not configured yet. Let's set it up!
12869
13010
  };
12870
13011
  this.runtime.config.provider = "openrouter";
12871
13012
  this.runtime.options.model = answers.model;
12872
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, this.runtime.config);
13013
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, this.runtime.config);
12873
13014
  this.resetLlmClient("openrouter", answers.model);
12874
13015
  console.log(_chalk2.default.green("\n\u2713 OpenRouter configured successfully!"));
12875
13016
  } catch (error) {
12876
- if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _332 => _332.message, 'optionalAccess', _333 => _333.includes, 'call', _334 => _334("canceled")])) {
13017
+ if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _347 => _347.message, 'optionalAccess', _348 => _348.includes, 'call', _349 => _349("canceled")])) {
12877
13018
  console.log(_chalk2.default.gray("\nConfiguration cancelled."));
12878
13019
  return;
12879
13020
  }
@@ -12890,9 +13031,9 @@ ${selectedProvider} is not configured yet. Let's set it up!
12890
13031
  const response = await fetch(`${ollamaUrl}/api/tags`);
12891
13032
  if (response.ok) {
12892
13033
  const data = await response.json();
12893
- availableModels = _optionalChain([data, 'access', _335 => _335.models, 'optionalAccess', _336 => _336.map, 'call', _337 => _337((m) => m.name)]) || [];
13034
+ availableModels = _optionalChain([data, 'access', _350 => _350.models, 'optionalAccess', _351 => _351.map, 'call', _352 => _352((m) => m.name)]) || [];
12894
13035
  }
12895
- } catch (e67) {
13036
+ } catch (e69) {
12896
13037
  console.log(_chalk2.default.yellow("\u26A0 Could not connect to Ollama. Make sure it's running.\n"));
12897
13038
  }
12898
13039
  let modelAnswer;
@@ -12923,11 +13064,11 @@ ${selectedProvider} is not configured yet. Let's set it up!
12923
13064
  };
12924
13065
  this.runtime.config.provider = "ollama";
12925
13066
  this.runtime.options.model = modelAnswer.model;
12926
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, this.runtime.config);
13067
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, this.runtime.config);
12927
13068
  this.resetLlmClient("ollama", modelAnswer.model);
12928
13069
  console.log(_chalk2.default.green("\n\u2713 Ollama configured successfully!"));
12929
13070
  } catch (error) {
12930
- if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _338 => _338.message, 'optionalAccess', _339 => _339.includes, 'call', _340 => _340("canceled")])) {
13071
+ if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _353 => _353.message, 'optionalAccess', _354 => _354.includes, 'call', _355 => _355("canceled")])) {
12931
13072
  console.log(_chalk2.default.gray("\nConfiguration cancelled."));
12932
13073
  return;
12933
13074
  }
@@ -12959,11 +13100,11 @@ ${selectedProvider} is not configured yet. Let's set it up!
12959
13100
  };
12960
13101
  this.runtime.config.provider = "llamacpp";
12961
13102
  this.runtime.options.model = answers.model;
12962
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, this.runtime.config);
13103
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, this.runtime.config);
12963
13104
  this.resetLlmClient("llamacpp", answers.model);
12964
13105
  console.log(_chalk2.default.green("\n\u2713 llama.cpp configured successfully!"));
12965
13106
  } catch (error) {
12966
- if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _341 => _341.message, 'optionalAccess', _342 => _342.includes, 'call', _343 => _343("canceled")])) {
13107
+ if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _356 => _356.message, 'optionalAccess', _357 => _357.includes, 'call', _358 => _358("canceled")])) {
12967
13108
  console.log(_chalk2.default.gray("\nConfiguration cancelled."));
12968
13109
  return;
12969
13110
  }
@@ -13001,11 +13142,64 @@ ${selectedProvider} is not configured yet. Let's set it up!
13001
13142
  };
13002
13143
  this.runtime.config.provider = "openai";
13003
13144
  this.runtime.options.model = answers.model;
13004
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, this.runtime.config);
13145
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, this.runtime.config);
13005
13146
  this.resetLlmClient("openai", answers.model);
13006
13147
  console.log(_chalk2.default.green("\n\u2713 OpenAI configured successfully!"));
13007
13148
  } catch (error) {
13008
- if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _344 => _344.message, 'optionalAccess', _345 => _345.includes, 'call', _346 => _346("canceled")])) {
13149
+ if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _359 => _359.message, 'optionalAccess', _360 => _360.includes, 'call', _361 => _361("canceled")])) {
13150
+ console.log(_chalk2.default.gray("\nConfiguration cancelled."));
13151
+ return;
13152
+ }
13153
+ throw error;
13154
+ }
13155
+ }
13156
+ async configureMLX() {
13157
+ try {
13158
+ console.log(_chalk2.default.cyan("MLX Configuration (Apple Silicon)"));
13159
+ console.log(_chalk2.default.gray("MLX provides local LLM inference optimized for Apple Silicon."));
13160
+ console.log(_chalk2.default.gray("Make sure mlx-lm server is running: mlx_lm.server --model <model-name>\n"));
13161
+ const mlxUrl = "http://localhost:8080";
13162
+ let availableModels = [];
13163
+ try {
13164
+ const response = await fetch(`${mlxUrl}/v1/models`);
13165
+ if (response.ok) {
13166
+ const data = await response.json();
13167
+ availableModels = _optionalChain([data, 'access', _362 => _362.data, 'optionalAccess', _363 => _363.map, 'call', _364 => _364((m) => m.id)]) || [];
13168
+ }
13169
+ } catch (e70) {
13170
+ console.log(_chalk2.default.yellow("\u26A0 Could not connect to MLX server. Make sure it's running.\n"));
13171
+ }
13172
+ let modelAnswer;
13173
+ if (availableModels.length > 0) {
13174
+ modelAnswer = await _enquirer2.default.prompt([
13175
+ {
13176
+ type: "select",
13177
+ name: "model",
13178
+ message: "Select a model",
13179
+ choices: availableModels
13180
+ }
13181
+ ]);
13182
+ } else {
13183
+ modelAnswer = await _enquirer2.default.prompt([
13184
+ {
13185
+ type: "input",
13186
+ name: "model",
13187
+ message: "Enter model name (e.g., mlx-community/Llama-3.2-3B-Instruct-4bit)",
13188
+ initial: "mlx-community/Llama-3.2-3B-Instruct-4bit"
13189
+ }
13190
+ ]);
13191
+ }
13192
+ this.runtime.config.mlx = {
13193
+ baseUrl: mlxUrl,
13194
+ model: modelAnswer.model
13195
+ };
13196
+ this.runtime.config.provider = "mlx";
13197
+ this.runtime.options.model = modelAnswer.model;
13198
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, this.runtime.config);
13199
+ this.resetLlmClient("mlx", modelAnswer.model);
13200
+ console.log(_chalk2.default.green("\n\u2713 MLX configured successfully!"));
13201
+ } catch (error) {
13202
+ if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _365 => _365.message, 'optionalAccess', _366 => _366.includes, 'call', _367 => _367("canceled")])) {
13009
13203
  console.log(_chalk2.default.gray("\nConfiguration cancelled."));
13010
13204
  return;
13011
13205
  }
@@ -13014,14 +13208,14 @@ ${selectedProvider} is not configured yet. Let's set it up!
13014
13208
  }
13015
13209
  async changeProviderModel(provider) {
13016
13210
  try {
13017
- const currentSettings = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, provider);
13018
- const currentModel = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([currentSettings, 'optionalAccess', _347 => _347.model]))), () => ( ""));
13019
- if (provider === "ollama" && _optionalChain([currentSettings, 'optionalAccess', _348 => _348.baseUrl])) {
13211
+ const currentSettings = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, provider);
13212
+ const currentModel = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([currentSettings, 'optionalAccess', _368 => _368.model]))), () => ( ""));
13213
+ if (provider === "ollama" && _optionalChain([currentSettings, 'optionalAccess', _369 => _369.baseUrl])) {
13020
13214
  try {
13021
13215
  const response = await fetch(`${currentSettings.baseUrl}/api/tags`);
13022
13216
  if (response.ok) {
13023
13217
  const data = await response.json();
13024
- const models = _optionalChain([data, 'access', _349 => _349.models, 'optionalAccess', _350 => _350.map, 'call', _351 => _351((m) => m.name)]) || [];
13218
+ const models = _optionalChain([data, 'access', _370 => _370.models, 'optionalAccess', _371 => _371.map, 'call', _372 => _372((m) => m.name)]) || [];
13025
13219
  if (models.length > 0) {
13026
13220
  const answer2 = await _enquirer2.default.prompt([
13027
13221
  {
@@ -13036,7 +13230,7 @@ ${selectedProvider} is not configured yet. Let's set it up!
13036
13230
  return;
13037
13231
  }
13038
13232
  }
13039
- } catch (e68) {
13233
+ } catch (e71) {
13040
13234
  }
13041
13235
  }
13042
13236
  if (provider === "openai") {
@@ -13061,9 +13255,9 @@ ${selectedProvider} is not configured yet. Let's set it up!
13061
13255
  initial: currentModel
13062
13256
  }
13063
13257
  ]);
13064
- await this.applyModelChange(provider, _optionalChain([answer, 'access', _352 => _352.model, 'optionalAccess', _353 => _353.trim, 'call', _354 => _354()]), currentModel);
13258
+ await this.applyModelChange(provider, _optionalChain([answer, 'access', _373 => _373.model, 'optionalAccess', _374 => _374.trim, 'call', _375 => _375()]), currentModel);
13065
13259
  } catch (error) {
13066
- if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _355 => _355.message, 'optionalAccess', _356 => _356.includes, 'call', _357 => _357("canceled")])) {
13260
+ if (error.name === "ExitPromptError" || _optionalChain([error, 'access', _376 => _376.message, 'optionalAccess', _377 => _377.includes, 'call', _378 => _378("canceled")])) {
13067
13261
  console.log(_chalk2.default.gray("\nModel change cancelled."));
13068
13262
  return;
13069
13263
  }
@@ -13080,7 +13274,7 @@ ${selectedProvider} is not configured yet. Let's set it up!
13080
13274
  this.runtime.options.model = newModel;
13081
13275
  this.setProviderModel(provider, newModel);
13082
13276
  this.resetLlmClient(provider, newModel);
13083
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, this.runtime.config);
13277
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, this.runtime.config);
13084
13278
  this.contextWindow = getContextWindow(newModel);
13085
13279
  this.contextPercentLeft = 100;
13086
13280
  this.emitStatus();
@@ -13232,8 +13426,8 @@ No provider is configured yet. Let's set one up!
13232
13426
  return this.runInstruction(instruction);
13233
13427
  }
13234
13428
  const err = error instanceof Error ? error : new Error(String(error));
13235
- const maxRetries = _nullishCoalesce(_optionalChain([this, 'access', _358 => _358.runtime, 'access', _359 => _359.config, 'access', _360 => _360.agent, 'optionalAccess', _361 => _361.sessionRetryLimit]), () => ( 3));
13236
- const baseDelay = _nullishCoalesce(_optionalChain([this, 'access', _362 => _362.runtime, 'access', _363 => _363.config, 'access', _364 => _364.agent, 'optionalAccess', _365 => _365.sessionRetryDelay]), () => ( 1e3));
13429
+ const maxRetries = _nullishCoalesce(_optionalChain([this, 'access', _379 => _379.runtime, 'access', _380 => _380.config, 'access', _381 => _381.agent, 'optionalAccess', _382 => _382.sessionRetryLimit]), () => ( 3));
13430
+ const baseDelay = _nullishCoalesce(_optionalChain([this, 'access', _383 => _383.runtime, 'access', _384 => _384.config, 'access', _385 => _385.agent, 'optionalAccess', _386 => _386.sessionRetryDelay]), () => ( 1e3));
13237
13431
  if (this.isRetryableSessionError(err) && this.sessionRetryCount < maxRetries) {
13238
13432
  this.sessionRetryCount++;
13239
13433
  await this.submitSessionFailureBugReport(err, this.sessionRetryCount, maxRetries);
@@ -13274,7 +13468,7 @@ No provider is configured yet. Let's set one up!
13274
13468
  if (this.taskStartedAt && !canceledByUser && !this.useInkRenderer) {
13275
13469
  const elapsed = this.formatElapsedTime(this.taskStartedAt);
13276
13470
  const tokens = this.formatTokens(this.totalTokensUsed);
13277
- const queueCount = this.pendingInkInstructions.length + (_nullishCoalesce(_optionalChain([this, 'access', _366 => _366.inkRenderer, 'optionalAccess', _367 => _367.getQueueCount, 'call', _368 => _368()]), () => ( 0))) + this.persistentInput.getQueueLength();
13471
+ const queueCount = this.pendingInkInstructions.length + (_nullishCoalesce(_optionalChain([this, 'access', _387 => _387.inkRenderer, 'optionalAccess', _388 => _388.getQueueCount, 'call', _389 => _389()]), () => ( 0))) + this.persistentInput.getQueueLength();
13278
13472
  const queueStatus = queueCount > 0 ? ` \xB7 ${queueCount} queued` : "";
13279
13473
  console.log(_chalk2.default.gray(`
13280
13474
  Completed in ${elapsed} \xB7 ${tokens} used${queueStatus}`));
@@ -13347,7 +13541,7 @@ Completed in ${elapsed} \xB7 ${tokens} used${queueStatus}`));
13347
13541
  const session = this.sessionManager.getCurrentSession();
13348
13542
  const sessionDuration = Date.now() - this.sessionStartedAt;
13349
13543
  await this.hookManager.executeHooks("session-end", {
13350
- sessionId: _optionalChain([session, 'optionalAccess', _369 => _369.metadata, 'access', _370 => _370.sessionId]),
13544
+ sessionId: _optionalChain([session, 'optionalAccess', _390 => _390.metadata, 'access', _391 => _391.sessionId]),
13351
13545
  sessionEndReason: "quit",
13352
13546
  duration: sessionDuration
13353
13547
  });
@@ -13358,7 +13552,7 @@ Completed in ${elapsed} \xB7 ${tokens} used${queueStatus}`));
13358
13552
  }
13359
13553
  const messages = session.getMessages();
13360
13554
  const lastUserMsg = messages.filter((m) => m.role === "user").slice(-1)[0];
13361
- const summary = _optionalChain([lastUserMsg, 'optionalAccess', _371 => _371.content, 'access', _372 => _372.slice, 'call', _373 => _373(0, 60)]) || "Session complete";
13555
+ const summary = _optionalChain([lastUserMsg, 'optionalAccess', _392 => _392.content, 'access', _393 => _393.slice, 'call', _394 => _394(0, 60)]) || "Session complete";
13362
13556
  const syncResult = await this.telemetryManager.syncSession({
13363
13557
  messages: messages.map((m) => ({
13364
13558
  role: m.role,
@@ -13381,15 +13575,15 @@ Completed in ${elapsed} \xB7 ${tokens} used${queueStatus}`));
13381
13575
  `));
13382
13576
  }
13383
13577
  async runReactLoop(abortController) {
13384
- const debugMode = _optionalChain([this, 'access', _374 => _374.runtime, 'access', _375 => _375.config, 'access', _376 => _376.agent, 'optionalAccess', _377 => _377.debug]) === true || process.env.AUTOHAND_DEBUG === "1";
13578
+ const debugMode = _optionalChain([this, 'access', _395 => _395.runtime, 'access', _396 => _396.config, 'access', _397 => _397.agent, 'optionalAccess', _398 => _398.debug]) === true || process.env.AUTOHAND_DEBUG === "1";
13385
13579
  if (debugMode) process.stderr.write(`[AGENT DEBUG] runReactLoop started
13386
13580
  `);
13387
- const maxIterations = _nullishCoalesce(_optionalChain([this, 'access', _378 => _378.runtime, 'access', _379 => _379.config, 'access', _380 => _380.agent, 'optionalAccess', _381 => _381.maxIterations]), () => ( 100));
13581
+ const maxIterations = _nullishCoalesce(_optionalChain([this, 'access', _399 => _399.runtime, 'access', _400 => _400.config, 'access', _401 => _401.agent, 'optionalAccess', _402 => _402.maxIterations]), () => ( 100));
13388
13582
  const allTools = this.toolManager.toFunctionDefinitions();
13389
13583
  if (debugMode) process.stderr.write(`[AGENT DEBUG] Loaded ${allTools.length} tools, maxIterations=${maxIterations}
13390
13584
  `);
13391
13585
  this.startStatusUpdates();
13392
- const showThinking = _optionalChain([this, 'access', _382 => _382.runtime, 'access', _383 => _383.config, 'access', _384 => _384.ui, 'optionalAccess', _385 => _385.showThinking]) !== false;
13586
+ const showThinking = _optionalChain([this, 'access', _403 => _403.runtime, 'access', _404 => _404.config, 'access', _405 => _405.ui, 'optionalAccess', _406 => _406.showThinking]) !== false;
13393
13587
  for (let iteration = 0; iteration < maxIterations; iteration += 1) {
13394
13588
  if (abortController.signal.aborted) {
13395
13589
  if (debugMode) process.stderr.write("[AGENT DEBUG] Abort detected at loop start, breaking\n");
@@ -13397,14 +13591,14 @@ Completed in ${elapsed} \xB7 ${tokens} used${queueStatus}`));
13397
13591
  }
13398
13592
  const messages = this.conversation.history();
13399
13593
  const tools = filterToolsByRelevance(allTools, messages);
13400
- const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([_chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider), 'optionalAccess', _386 => _386.model]))), () => ( "unconfigured"));
13594
+ const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([_chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider), 'optionalAccess', _407 => _407.model]))), () => ( "unconfigured"));
13401
13595
  const contextUsage = calculateContextUsage(
13402
13596
  messages,
13403
13597
  tools,
13404
13598
  model
13405
13599
  );
13406
13600
  if (contextUsage.isCritical) {
13407
- _optionalChain([this, 'access', _387 => _387.runtime, 'access', _388 => _388.spinner, 'optionalAccess', _389 => _389.stop, 'call', _390 => _390()]);
13601
+ _optionalChain([this, 'access', _408 => _408.runtime, 'access', _409 => _409.spinner, 'optionalAccess', _410 => _410.stop, 'call', _411 => _411()]);
13408
13602
  console.log(_chalk2.default.yellow("\n\u26A0 Context at critical level, auto-cropping old messages..."));
13409
13603
  const targetTokens = Math.floor(contextUsage.contextWindow * 0.7);
13410
13604
  const tokensToRemove = contextUsage.totalTokens - targetTokens;
@@ -13427,9 +13621,9 @@ ${summary}`
13427
13621
  \u26A0 Context at ${Math.round(contextUsage.usagePercent * 100)}% - approaching limit`));
13428
13622
  }
13429
13623
  if (iteration >= 10 && iteration % 10 === 0) {
13430
- _optionalChain([this, 'access', _391 => _391.runtime, 'access', _392 => _392.spinner, 'optionalAccess', _393 => _393.start, 'call', _394 => _394(`Working... (step ${iteration + 1})`)]);
13624
+ _optionalChain([this, 'access', _412 => _412.runtime, 'access', _413 => _413.spinner, 'optionalAccess', _414 => _414.start, 'call', _415 => _415(`Working... (step ${iteration + 1})`)]);
13431
13625
  } else {
13432
- _optionalChain([this, 'access', _395 => _395.runtime, 'access', _396 => _396.spinner, 'optionalAccess', _397 => _397.start, 'call', _398 => _398("Working ...")]);
13626
+ _optionalChain([this, 'access', _416 => _416.runtime, 'access', _417 => _417.spinner, 'optionalAccess', _418 => _418.start, 'call', _419 => _419("Working ...")]);
13433
13627
  }
13434
13628
  const messagesWithImages = this.getMessagesWithImages();
13435
13629
  if (debugMode) process.stderr.write(`[AGENT DEBUG] Calling LLM with ${messagesWithImages.length} messages, ${tools.length} tools
@@ -13446,7 +13640,7 @@ ${summary}`
13446
13640
  maxTokens: 16e3
13447
13641
  // Allow large outputs for file generation
13448
13642
  });
13449
- if (debugMode) process.stderr.write(`[AGENT DEBUG] LLM returned: content length=${_nullishCoalesce(_optionalChain([completion, 'access', _399 => _399.content, 'optionalAccess', _400 => _400.length]), () => ( 0))}, toolCalls=${_nullishCoalesce(_optionalChain([completion, 'access', _401 => _401.toolCalls, 'optionalAccess', _402 => _402.length]), () => ( 0))}
13643
+ if (debugMode) process.stderr.write(`[AGENT DEBUG] LLM returned: content length=${_nullishCoalesce(_optionalChain([completion, 'access', _420 => _420.content, 'optionalAccess', _421 => _421.length]), () => ( 0))}, toolCalls=${_nullishCoalesce(_optionalChain([completion, 'access', _422 => _422.toolCalls, 'optionalAccess', _423 => _423.length]), () => ( 0))}
13450
13644
  `);
13451
13645
  } catch (llmError) {
13452
13646
  const errMsg = llmError instanceof Error ? llmError.message : String(llmError);
@@ -13462,10 +13656,10 @@ ${summary}`
13462
13656
  this.forceRenderSpinner();
13463
13657
  }
13464
13658
  const payload = this.parseAssistantResponse(completion);
13465
- if (debugMode) process.stderr.write(`[AGENT DEBUG] Parsed payload: finalResponse=${!!payload.finalResponse}, thought=${!!payload.thought}, toolCalls=${_nullishCoalesce(_optionalChain([payload, 'access', _403 => _403.toolCalls, 'optionalAccess', _404 => _404.length]), () => ( 0))}
13659
+ if (debugMode) process.stderr.write(`[AGENT DEBUG] Parsed payload: finalResponse=${!!payload.finalResponse}, thought=${!!payload.thought}, toolCalls=${_nullishCoalesce(_optionalChain([payload, 'access', _424 => _424.toolCalls, 'optionalAccess', _425 => _425.length]), () => ( 0))}
13466
13660
  `);
13467
13661
  const assistantMessage = { role: "assistant", content: completion.content };
13468
- if (_optionalChain([completion, 'access', _405 => _405.toolCalls, 'optionalAccess', _406 => _406.length])) {
13662
+ if (_optionalChain([completion, 'access', _426 => _426.toolCalls, 'optionalAccess', _427 => _427.length])) {
13469
13663
  assistantMessage.tool_calls = completion.toolCalls;
13470
13664
  }
13471
13665
  this.conversation.addMessage(assistantMessage);
@@ -13474,14 +13668,14 @@ ${summary}`
13474
13668
  if (debugMode) {
13475
13669
  console.log(_chalk2.default.yellow(`
13476
13670
  [DEBUG] Iteration ${iteration}:`));
13477
- console.log(_chalk2.default.yellow(` - toolCalls: ${_nullishCoalesce(_optionalChain([payload, 'access', _407 => _407.toolCalls, 'optionalAccess', _408 => _408.length]), () => ( 0))}`));
13478
- console.log(_chalk2.default.yellow(` - thought: ${_optionalChain([payload, 'access', _409 => _409.thought, 'optionalAccess', _410 => _410.slice, 'call', _411 => _411(0, 100)]) || "(none)"}`));
13479
- console.log(_chalk2.default.yellow(` - finalResponse: ${_optionalChain([payload, 'access', _412 => _412.finalResponse, 'optionalAccess', _413 => _413.slice, 'call', _414 => _414(0, 100)]) || "(none)"}`));
13480
- console.log(_chalk2.default.yellow(` - raw content: ${_optionalChain([completion, 'access', _415 => _415.content, 'optionalAccess', _416 => _416.slice, 'call', _417 => _417(0, 200)]) || "(empty)"}`));
13671
+ console.log(_chalk2.default.yellow(` - toolCalls: ${_nullishCoalesce(_optionalChain([payload, 'access', _428 => _428.toolCalls, 'optionalAccess', _429 => _429.length]), () => ( 0))}`));
13672
+ console.log(_chalk2.default.yellow(` - thought: ${_optionalChain([payload, 'access', _430 => _430.thought, 'optionalAccess', _431 => _431.slice, 'call', _432 => _432(0, 100)]) || "(none)"}`));
13673
+ console.log(_chalk2.default.yellow(` - finalResponse: ${_optionalChain([payload, 'access', _433 => _433.finalResponse, 'optionalAccess', _434 => _434.slice, 'call', _435 => _435(0, 100)]) || "(none)"}`));
13674
+ console.log(_chalk2.default.yellow(` - raw content: ${_optionalChain([completion, 'access', _436 => _436.content, 'optionalAccess', _437 => _437.slice, 'call', _438 => _438(0, 200)]) || "(empty)"}`));
13481
13675
  }
13482
- const toolCount = _nullishCoalesce(_optionalChain([payload, 'access', _418 => _418.toolCalls, 'optionalAccess', _419 => _419.length]), () => ( 0));
13676
+ const toolCount = _nullishCoalesce(_optionalChain([payload, 'access', _439 => _439.toolCalls, 'optionalAccess', _440 => _440.length]), () => ( 0));
13483
13677
  const hasResponse = Boolean(payload.finalResponse || payload.response || !toolCount && payload.thought);
13484
- const thoughtPreview = _optionalChain([payload, 'access', _420 => _420.thought, 'optionalAccess', _421 => _421.slice, 'call', _422 => _422(0, 80)]) || "";
13678
+ const thoughtPreview = _optionalChain([payload, 'access', _441 => _441.thought, 'optionalAccess', _442 => _442.slice, 'call', _443 => _443(0, 80)]) || "";
13485
13679
  if (this.inkRenderer) {
13486
13680
  if (toolCount > 0) {
13487
13681
  const toolNames = payload.toolCalls.map((t) => t.tool).join(", ");
@@ -13528,23 +13722,23 @@ ${summary}`
13528
13722
  role: "tool",
13529
13723
  name: result.tool,
13530
13724
  content,
13531
- tool_call_id: _optionalChain([otherCalls, 'access', _423 => _423[i], 'optionalAccess', _424 => _424.id])
13725
+ tool_call_id: _optionalChain([otherCalls, 'access', _444 => _444[i], 'optionalAccess', _445 => _445.id])
13532
13726
  });
13533
- await this.saveToolMessage(result.tool, content, _optionalChain([otherCalls, 'access', _425 => _425[i], 'optionalAccess', _426 => _426.id]));
13727
+ await this.saveToolMessage(result.tool, content, _optionalChain([otherCalls, 'access', _446 => _446[i], 'optionalAccess', _447 => _447.id]));
13534
13728
  }
13535
13729
  this.updateContextUsage(this.conversation.history(), tools);
13536
- const charLimit = _nullishCoalesce(_optionalChain([this, 'access', _427 => _427.runtime, 'access', _428 => _428.config, 'access', _429 => _429.ui, 'optionalAccess', _430 => _430.readFileCharLimit]), () => ( 300));
13730
+ const charLimit = _nullishCoalesce(_optionalChain([this, 'access', _448 => _448.runtime, 'access', _449 => _449.config, 'access', _450 => _450.ui, 'optionalAccess', _451 => _451.readFileCharLimit]), () => ( 300));
13537
13731
  outputLines.push(this.formatToolResultsBatch(results, charLimit, otherCalls, thought));
13538
13732
  }
13539
13733
  if (this.inkRenderer) {
13540
13734
  const thought2 = showThinking && payload.thought && !payload.thought.trim().startsWith("{") ? payload.thought : void 0;
13541
13735
  if (results.length > 0) {
13542
- const charLimit = _nullishCoalesce(_optionalChain([this, 'access', _431 => _431.runtime, 'access', _432 => _432.config, 'access', _433 => _433.ui, 'optionalAccess', _434 => _434.readFileCharLimit]), () => ( 300));
13736
+ const charLimit = _nullishCoalesce(_optionalChain([this, 'access', _452 => _452.runtime, 'access', _453 => _453.config, 'access', _454 => _454.ui, 'optionalAccess', _455 => _455.readFileCharLimit]), () => ( 300));
13543
13737
  this.addUIToolOutputs(results.map((r, i) => {
13544
13738
  const call = otherCalls[i];
13545
- const filePath = _optionalChain([call, 'optionalAccess', _435 => _435.args, 'optionalAccess', _436 => _436.path]);
13546
- const command = _optionalChain([call, 'optionalAccess', _437 => _437.args, 'optionalAccess', _438 => _438.command]);
13547
- const commandArgs = _optionalChain([call, 'optionalAccess', _439 => _439.args, 'optionalAccess', _440 => _440.args]);
13739
+ const filePath = _optionalChain([call, 'optionalAccess', _456 => _456.args, 'optionalAccess', _457 => _457.path]);
13740
+ const command = _optionalChain([call, 'optionalAccess', _458 => _458.args, 'optionalAccess', _459 => _459.command]);
13741
+ const commandArgs = _optionalChain([call, 'optionalAccess', _460 => _460.args, 'optionalAccess', _461 => _461.args]);
13548
13742
  return {
13549
13743
  tool: r.tool,
13550
13744
  success: r.success,
@@ -13555,13 +13749,13 @@ ${summary}`
13555
13749
  }));
13556
13750
  }
13557
13751
  } else {
13558
- _optionalChain([this, 'access', _441 => _441.runtime, 'access', _442 => _442.spinner, 'optionalAccess', _443 => _443.stop, 'call', _444 => _444()]);
13752
+ _optionalChain([this, 'access', _462 => _462.runtime, 'access', _463 => _463.spinner, 'optionalAccess', _464 => _464.stop, 'call', _465 => _465()]);
13559
13753
  if (outputLines.length > 0) {
13560
13754
  console.log("\n" + outputLines.join("\n"));
13561
13755
  }
13562
13756
  }
13563
13757
  if (results.length > 0) {
13564
- const sessionId = _optionalChain([this, 'access', _445 => _445.sessionManager, 'access', _446 => _446.getCurrentSession, 'call', _447 => _447(), 'optionalAccess', _448 => _448.metadata, 'access', _449 => _449.sessionId]) || "unknown";
13758
+ const sessionId = _optionalChain([this, 'access', _466 => _466.sessionManager, 'access', _467 => _467.getCurrentSession, 'call', _468 => _468(), 'optionalAccess', _469 => _469.metadata, 'access', _470 => _470.sessionId]) || "unknown";
13565
13759
  for (const result of results) {
13566
13760
  if (result.success) {
13567
13761
  await this.projectManager.recordSuccess(this.runtime.workspaceRoot, {
@@ -13595,7 +13789,7 @@ ${summary}`
13595
13789
  const searchTools = ["search", "search_with_context", "semantic_search"];
13596
13790
  const searchCallsThisIteration = otherCalls.filter((call) => searchTools.includes(call.tool));
13597
13791
  for (const call of searchCallsThisIteration) {
13598
- const query = String(_optionalChain([call, 'access', _450 => _450.args, 'optionalAccess', _451 => _451.query]) || _optionalChain([call, 'access', _452 => _452.args, 'optionalAccess', _453 => _453.pattern]) || "unknown");
13792
+ const query = String(_optionalChain([call, 'access', _471 => _471.args, 'optionalAccess', _472 => _472.query]) || _optionalChain([call, 'access', _473 => _473.args, 'optionalAccess', _474 => _474.pattern]) || "unknown");
13599
13793
  this.searchQueries.push(query);
13600
13794
  }
13601
13795
  if (searchCallsThisIteration.length >= 3) {
@@ -13616,7 +13810,7 @@ ${summary}`
13616
13810
  continue;
13617
13811
  }
13618
13812
  const pendingResponse = payload.finalResponse || payload.response || "";
13619
- if (this.expressesIntentToAct(pendingResponse) && !_optionalChain([payload, 'access', _454 => _454.toolCalls, 'optionalAccess', _455 => _455.length])) {
13813
+ if (this.expressesIntentToAct(pendingResponse) && !_optionalChain([payload, 'access', _475 => _475.toolCalls, 'optionalAccess', _476 => _476.length])) {
13620
13814
  const intentRetryKey = "__intentRetryCount";
13621
13815
  const intentRetries = (_nullishCoalesce(this[intentRetryKey], () => ( 0))) + 1;
13622
13816
  this[intentRetryKey] = intentRetries;
@@ -13636,7 +13830,7 @@ ${summary}`
13636
13830
  rawResponse = payload.finalResponse;
13637
13831
  } else if (payload.response) {
13638
13832
  rawResponse = payload.response;
13639
- } else if (!_optionalChain([payload, 'access', _456 => _456.toolCalls, 'optionalAccess', _457 => _457.length]) && payload.thought) {
13833
+ } else if (!_optionalChain([payload, 'access', _477 => _477.toolCalls, 'optionalAccess', _478 => _478.length]) && payload.thought) {
13640
13834
  rawResponse = payload.thought;
13641
13835
  } else {
13642
13836
  const cleanedContent = this.cleanupModelResponse(completion.content);
@@ -13656,7 +13850,7 @@ ${summary}`
13656
13850
  this.inkRenderer.setWorking(false);
13657
13851
  this.inkRenderer.setFinalResponse(fallback);
13658
13852
  } else {
13659
- _optionalChain([this, 'access', _458 => _458.runtime, 'access', _459 => _459.spinner, 'optionalAccess', _460 => _460.stop, 'call', _461 => _461()]);
13853
+ _optionalChain([this, 'access', _479 => _479.runtime, 'access', _480 => _480.spinner, 'optionalAccess', _481 => _481.stop, 'call', _482 => _482()]);
13660
13854
  console.log(fallback);
13661
13855
  }
13662
13856
  this[consecutiveEmptyKey] = 0;
@@ -13682,7 +13876,7 @@ ${summary}`
13682
13876
  this.inkRenderer.setWorking(false);
13683
13877
  this.inkRenderer.setFinalResponse(response);
13684
13878
  } else {
13685
- _optionalChain([this, 'access', _462 => _462.runtime, 'access', _463 => _463.spinner, 'optionalAccess', _464 => _464.stop, 'call', _465 => _465()]);
13879
+ _optionalChain([this, 'access', _483 => _483.runtime, 'access', _484 => _484.spinner, 'optionalAccess', _485 => _485.stop, 'call', _486 => _486()]);
13686
13880
  if (showThinking && payload.thought && !payload.thought.trim().startsWith("{")) {
13687
13881
  console.log(_chalk2.default.gray(`Thinking: ${payload.thought}`));
13688
13882
  console.log();
@@ -13692,7 +13886,7 @@ ${summary}`
13692
13886
  return;
13693
13887
  }
13694
13888
  this.stopStatusUpdates();
13695
- _optionalChain([this, 'access', _466 => _466.runtime, 'access', _467 => _467.spinner, 'optionalAccess', _468 => _468.stop, 'call', _469 => _469()]);
13889
+ _optionalChain([this, 'access', _487 => _487.runtime, 'access', _488 => _488.spinner, 'optionalAccess', _489 => _489.stop, 'call', _490 => _490()]);
13696
13890
  console.log(_chalk2.default.yellow(`
13697
13891
  \u26A0 Task exceeded ${maxIterations} tool iterations without completing.`));
13698
13892
  console.log(_chalk2.default.gray("This usually means the task is too complex for a single turn."));
@@ -13705,7 +13899,7 @@ ${summary}`
13705
13899
  * while falling back to JSON parsing for providers without native support.
13706
13900
  */
13707
13901
  parseAssistantResponse(completion) {
13708
- if (_optionalChain([completion, 'access', _470 => _470.toolCalls, 'optionalAccess', _471 => _471.length])) {
13902
+ if (_optionalChain([completion, 'access', _491 => _491.toolCalls, 'optionalAccess', _492 => _492.length])) {
13709
13903
  let thought;
13710
13904
  if (completion.content) {
13711
13905
  const trimmed = completion.content.trim();
@@ -13713,7 +13907,7 @@ ${summary}`
13713
13907
  try {
13714
13908
  const parsed = JSON.parse(trimmed);
13715
13909
  thought = typeof parsed.thought === "string" ? parsed.thought : void 0;
13716
- } catch (e69) {
13910
+ } catch (e72) {
13717
13911
  thought = this.cleanupModelResponse(trimmed) || void 0;
13718
13912
  }
13719
13913
  } else {
@@ -13780,9 +13974,9 @@ ${summary}`
13780
13974
  return { finalResponse: contentValue };
13781
13975
  }
13782
13976
  return { finalResponse: raw.trim() };
13783
- } catch (e70) {
13977
+ } catch (e73) {
13784
13978
  const thoughtMatch = raw.match(/"thought"\s*:\s*"([^"]+)"/);
13785
- if (_optionalChain([thoughtMatch, 'optionalAccess', _472 => _472[1]])) {
13979
+ if (_optionalChain([thoughtMatch, 'optionalAccess', _493 => _493[1]])) {
13786
13980
  return { thought: thoughtMatch[1], finalResponse: thoughtMatch[1] };
13787
13981
  }
13788
13982
  if (raw.trim().startsWith("{")) {
@@ -13922,11 +14116,11 @@ ${mentionContext.block}`);
13922
14116
  return `- ${def.name}(${args}) - ${def.description}`;
13923
14117
  }
13924
14118
  async buildSystemPrompt() {
13925
- const toolDefs = _nullishCoalesce(_optionalChain([this, 'access', _473 => _473.toolManager, 'optionalAccess', _474 => _474.listDefinitions, 'call', _475 => _475()]), () => ( []));
14119
+ const toolDefs = _nullishCoalesce(_optionalChain([this, 'access', _494 => _494.toolManager, 'optionalAccess', _495 => _495.listDefinitions, 'call', _496 => _496()]), () => ( []));
13926
14120
  const toolSignatures = toolDefs.map((def) => this.formatToolSignature(def)).join("\n");
13927
14121
  const memories = await this.memoryManager.getContextMemories();
13928
14122
  const instructions = await this.loadInstructionFiles();
13929
- const authUser = _optionalChain([this, 'access', _476 => _476.runtime, 'access', _477 => _477.config, 'access', _478 => _478.auth, 'optionalAccess', _479 => _479.user]);
14123
+ const authUser = _optionalChain([this, 'access', _497 => _497.runtime, 'access', _498 => _498.config, 'access', _499 => _499.auth, 'optionalAccess', _500 => _500.user]);
13930
14124
  const parts = [
13931
14125
  // ═══════════════════════════════════════════════════════════════════
13932
14126
  // 1. IDENTITY & CORE STANDARDS
@@ -14262,7 +14456,7 @@ ${toolSignatures}
14262
14456
  try {
14263
14457
  const stats = await _fsextra2.default.stat(fullPath);
14264
14458
  return stats.isFile();
14265
- } catch (e71) {
14459
+ } catch (e74) {
14266
14460
  return false;
14267
14461
  }
14268
14462
  }
@@ -14423,10 +14617,10 @@ ${ctx.contents}`).join("\n\n");
14423
14617
  for (let i = 0; i < results.length; i++) {
14424
14618
  const result = results[i];
14425
14619
  const content = result.success ? _nullishCoalesce(result.output, () => ( "(no output)")) : _nullishCoalesce(_nullishCoalesce(result.error, () => ( result.output)), () => ( "Tool failed without error message"));
14426
- const call = _optionalChain([toolCalls, 'optionalAccess', _480 => _480[i]]);
14427
- const filePath = _optionalChain([call, 'optionalAccess', _481 => _481.args, 'optionalAccess', _482 => _482.path]);
14428
- const command = _optionalChain([call, 'optionalAccess', _483 => _483.args, 'optionalAccess', _484 => _484.command]);
14429
- const commandArgs = _optionalChain([call, 'optionalAccess', _485 => _485.args, 'optionalAccess', _486 => _486.args]);
14620
+ const call = _optionalChain([toolCalls, 'optionalAccess', _501 => _501[i]]);
14621
+ const filePath = _optionalChain([call, 'optionalAccess', _502 => _502.args, 'optionalAccess', _503 => _503.path]);
14622
+ const command = _optionalChain([call, 'optionalAccess', _504 => _504.args, 'optionalAccess', _505 => _505.command]);
14623
+ const commandArgs = _optionalChain([call, 'optionalAccess', _506 => _506.args, 'optionalAccess', _507 => _507.args]);
14430
14624
  const display = result.success ? formatToolOutputForDisplay({ tool: result.tool, content, charLimit, filePath, command, commandArgs }) : { output: content, truncated: false, totalChars: content.length };
14431
14625
  const icon = result.success ? _chalk2.default.green("\u2714") : _chalk2.default.red("\u2716");
14432
14626
  lines.push(`${icon} ${_chalk2.default.bold(result.tool)}`);
@@ -14457,22 +14651,22 @@ ${ctx.contents}`).join("\n\n");
14457
14651
  )));
14458
14652
  this.inkRenderer = createInkRenderer({
14459
14653
  onInstruction: (text) => {
14460
- _optionalChain([this, 'access', _487 => _487.inkRenderer, 'optionalAccess', _488 => _488.addQueuedInstruction, 'call', _489 => _489(text)]);
14654
+ _optionalChain([this, 'access', _508 => _508.inkRenderer, 'optionalAccess', _509 => _509.addQueuedInstruction, 'call', _510 => _510(text)]);
14461
14655
  },
14462
14656
  onEscape: () => {
14463
14657
  if (abortController && !abortController.signal.aborted) {
14464
14658
  abortController.abort();
14465
- _optionalChain([onCancel, 'optionalCall', _490 => _490()]);
14659
+ _optionalChain([onCancel, 'optionalCall', _511 => _511()]);
14466
14660
  }
14467
14661
  },
14468
14662
  onCtrlC: () => {
14469
14663
  },
14470
- enableQueueInput: _optionalChain([this, 'access', _491 => _491.runtime, 'access', _492 => _492.config, 'access', _493 => _493.agent, 'optionalAccess', _494 => _494.enableRequestQueue]) !== false
14664
+ enableQueueInput: _optionalChain([this, 'access', _512 => _512.runtime, 'access', _513 => _513.config, 'access', _514 => _514.agent, 'optionalAccess', _515 => _515.enableRequestQueue]) !== false
14471
14665
  });
14472
14666
  this.inkRenderer.start();
14473
14667
  this.inkRenderer.setWorking(true, "Gathering context...");
14474
14668
  this.runtime.inkRenderer = this.inkRenderer;
14475
- } catch (e72) {
14669
+ } catch (e75) {
14476
14670
  this.useInkRenderer = false;
14477
14671
  this.initFallbackSpinner();
14478
14672
  }
@@ -14633,17 +14827,17 @@ ${parts.join("\n")}`
14633
14827
  }
14634
14828
  let ctrlCCount = 0;
14635
14829
  this.queueInput = "";
14636
- const enableQueue = _optionalChain([this, 'access', _495 => _495.runtime, 'access', _496 => _496.config, 'access', _497 => _497.agent, 'optionalAccess', _498 => _498.enableRequestQueue]) !== false;
14830
+ const enableQueue = _optionalChain([this, 'access', _516 => _516.runtime, 'access', _517 => _517.config, 'access', _518 => _518.agent, 'optionalAccess', _519 => _519.enableRequestQueue]) !== false;
14637
14831
  const handler = (_str, key) => {
14638
14832
  if (controller.signal.aborted) {
14639
14833
  return;
14640
14834
  }
14641
- if (_optionalChain([key, 'optionalAccess', _499 => _499.name]) === "escape") {
14835
+ if (_optionalChain([key, 'optionalAccess', _520 => _520.name]) === "escape") {
14642
14836
  controller.abort();
14643
14837
  onCancel();
14644
14838
  return;
14645
14839
  }
14646
- if (ctrlCInterrupt && _optionalChain([key, 'optionalAccess', _500 => _500.name]) === "c" && key.ctrl) {
14840
+ if (ctrlCInterrupt && _optionalChain([key, 'optionalAccess', _521 => _521.name]) === "c" && key.ctrl) {
14647
14841
  ctrlCCount += 1;
14648
14842
  if (ctrlCCount >= 2) {
14649
14843
  controller.abort();
@@ -14654,7 +14848,7 @@ ${parts.join("\n")}`
14654
14848
  return;
14655
14849
  }
14656
14850
  if (enableQueue) {
14657
- if (_optionalChain([key, 'optionalAccess', _501 => _501.name]) === "return" || _optionalChain([key, 'optionalAccess', _502 => _502.name]) === "enter") {
14851
+ if (_optionalChain([key, 'optionalAccess', _522 => _522.name]) === "return" || _optionalChain([key, 'optionalAccess', _523 => _523.name]) === "enter") {
14658
14852
  if (this.queueInput.trim()) {
14659
14853
  const text = this.queueInput.trim();
14660
14854
  this.queueInput = "";
@@ -14670,12 +14864,12 @@ ${parts.join("\n")}`
14670
14864
  }
14671
14865
  return;
14672
14866
  }
14673
- if (_optionalChain([key, 'optionalAccess', _503 => _503.name]) === "backspace") {
14867
+ if (_optionalChain([key, 'optionalAccess', _524 => _524.name]) === "backspace") {
14674
14868
  this.queueInput = this.queueInput.slice(0, -1);
14675
14869
  this.updateInputLine();
14676
14870
  return;
14677
14871
  }
14678
- if (_optionalChain([key, 'optionalAccess', _504 => _504.ctrl]) || _optionalChain([key, 'optionalAccess', _505 => _505.meta])) {
14872
+ if (_optionalChain([key, 'optionalAccess', _525 => _525.ctrl]) || _optionalChain([key, 'optionalAccess', _526 => _526.meta])) {
14679
14873
  return;
14680
14874
  }
14681
14875
  if (_str) {
@@ -14806,8 +15000,8 @@ ${parts.join("\n")}`
14806
15000
  async submitSessionFailureBugReport(error, retryAttempt, maxRetries) {
14807
15001
  try {
14808
15002
  const history = this.conversation.history();
14809
- const recentToolCalls = history.filter((m) => m.role === "assistant" && m.tool_calls).slice(-3).flatMap((m) => _optionalChain([m, 'access', _506 => _506.tool_calls, 'optionalAccess', _507 => _507.map, 'call', _508 => _508((tc) => _optionalChain([tc, 'access', _509 => _509.function, 'optionalAccess', _510 => _510.name]))]) || []).filter(Boolean);
14810
- const model = _nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([_chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider), 'optionalAccess', _511 => _511.model])));
15003
+ const recentToolCalls = history.filter((m) => m.role === "assistant" && m.tool_calls).slice(-3).flatMap((m) => _optionalChain([m, 'access', _527 => _527.tool_calls, 'optionalAccess', _528 => _528.map, 'call', _529 => _529((tc) => _optionalChain([tc, 'access', _530 => _530.function, 'optionalAccess', _531 => _531.name]))]) || []).filter(Boolean);
15004
+ const model = _nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([_chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider), 'optionalAccess', _532 => _532.model])));
14811
15005
  await this.telemetryManager.trackSessionFailureBug({
14812
15006
  error,
14813
15007
  retryAttempt,
@@ -15030,7 +15224,7 @@ ${parts.join("\n")}`
15030
15224
  const elapsed = this.formatElapsedTime(this.taskStartedAt);
15031
15225
  const sessionTotal = this.sessionTokensUsed + this.totalTokensUsed;
15032
15226
  const tokens = this.formatTokens(sessionTotal);
15033
- const queueCount = _nullishCoalesce(_optionalChain([this, 'access', _512 => _512.inkRenderer, 'optionalAccess', _513 => _513.getQueueCount, 'call', _514 => _514()]), () => ( this.persistentInput.getQueueLength()));
15227
+ const queueCount = _nullishCoalesce(_optionalChain([this, 'access', _533 => _533.inkRenderer, 'optionalAccess', _534 => _534.getQueueCount, 'call', _535 => _535()]), () => ( this.persistentInput.getQueueLength()));
15034
15228
  const queueHint = queueCount > 0 ? ` [${queueCount} queued]` : "";
15035
15229
  const statusLine = `Working... (esc to interrupt \xB7 ${elapsed} \xB7 ${tokens}${queueHint})`;
15036
15230
  if (this.inkRenderer) {
@@ -15070,7 +15264,7 @@ ${_chalk2.default.gray("\u203A")} ${inputPreview}${_chalk2.default.gray("\u258B"
15070
15264
  return;
15071
15265
  }
15072
15266
  if (tools) {
15073
- const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([_chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider), 'optionalAccess', _515 => _515.model]))), () => ( "unconfigured"));
15267
+ const model = _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([_chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider), 'optionalAccess', _536 => _536.model]))), () => ( "unconfigured"));
15074
15268
  const usage = calculateContextUsage(
15075
15269
  messages,
15076
15270
  tools,
@@ -15086,7 +15280,7 @@ ${_chalk2.default.gray("\u203A")} ${inputPreview}${_chalk2.default.gray("\u258B"
15086
15280
  }
15087
15281
  formatStatusLine() {
15088
15282
  const percent = Number.isFinite(this.contextPercentLeft) ? Math.max(0, Math.min(100, this.contextPercentLeft)) : 100;
15089
- const queueCount = _nullishCoalesce(_optionalChain([this, 'access', _516 => _516.inkRenderer, 'optionalAccess', _517 => _517.getQueueCount, 'call', _518 => _518()]), () => ( this.persistentInput.getQueueLength()));
15283
+ const queueCount = _nullishCoalesce(_optionalChain([this, 'access', _537 => _537.inkRenderer, 'optionalAccess', _538 => _538.getQueueCount, 'call', _539 => _539()]), () => ( this.persistentInput.getQueueLength()));
15090
15284
  const queueStatus = queueCount > 0 ? ` \xB7 ${queueCount} queued` : "";
15091
15285
  return `${percent}% context left \xB7 / for commands \xB7 @ to mention files${queueStatus}`;
15092
15286
  }
@@ -15102,6 +15296,7 @@ ${_chalk2.default.gray("\u203A")} ${inputPreview}${_chalk2.default.gray("\u258B"
15102
15296
  if (this.runtime.config.ollama) providers.push("ollama");
15103
15297
  if (this.runtime.config.llamacpp) providers.push("llamacpp");
15104
15298
  if (this.runtime.config.openai) providers.push("openai");
15299
+ if (this.runtime.config.mlx) providers.push("mlx");
15105
15300
  return providers.length ? providers : ["openrouter"];
15106
15301
  }
15107
15302
  setProviderModel(provider, model) {
@@ -15109,7 +15304,8 @@ ${_chalk2.default.gray("\u203A")} ${inputPreview}${_chalk2.default.gray("\u258B"
15109
15304
  openrouter: _nullishCoalesce(this.runtime.config.openrouter, () => ( (this.runtime.config.openrouter = { apiKey: "", model }))),
15110
15305
  ollama: _nullishCoalesce(this.runtime.config.ollama, () => ( (this.runtime.config.ollama = { model }))),
15111
15306
  llamacpp: _nullishCoalesce(this.runtime.config.llamacpp, () => ( (this.runtime.config.llamacpp = { model }))),
15112
- openai: _nullishCoalesce(this.runtime.config.openai, () => ( (this.runtime.config.openai = { model })))
15307
+ openai: _nullishCoalesce(this.runtime.config.openai, () => ( (this.runtime.config.openai = { model }))),
15308
+ mlx: _nullishCoalesce(this.runtime.config.mlx, () => ( (this.runtime.config.mlx = { model })))
15113
15309
  };
15114
15310
  cfgMap[provider].model = model;
15115
15311
  this.activeProvider = provider;
@@ -15140,7 +15336,7 @@ ${_chalk2.default.gray("\u203A")} ${inputPreview}${_chalk2.default.gray("\u258B"
15140
15336
  this.activeProvider = provider;
15141
15337
  }
15142
15338
  async confirmDangerousAction(message, context) {
15143
- if (this.runtime.options.yes || _optionalChain([this, 'access', _519 => _519.runtime, 'access', _520 => _520.config, 'access', _521 => _521.ui, 'optionalAccess', _522 => _522.autoConfirm])) {
15339
+ if (this.runtime.options.yes || _optionalChain([this, 'access', _540 => _540.runtime, 'access', _541 => _541.config, 'access', _542 => _542.ui, 'optionalAccess', _543 => _543.autoConfirm])) {
15144
15340
  return true;
15145
15341
  }
15146
15342
  if (this.confirmationCallback) {
@@ -15150,9 +15346,9 @@ ${_chalk2.default.gray("\u203A")} ${inputPreview}${_chalk2.default.gray("\u258B"
15150
15346
  return confirm(message);
15151
15347
  }
15152
15348
  this.stopStatusUpdates();
15153
- const spinnerWasSpinning = _optionalChain([this, 'access', _523 => _523.runtime, 'access', _524 => _524.spinner, 'optionalAccess', _525 => _525.isSpinning]);
15349
+ const spinnerWasSpinning = _optionalChain([this, 'access', _544 => _544.runtime, 'access', _545 => _545.spinner, 'optionalAccess', _546 => _546.isSpinning]);
15154
15350
  if (spinnerWasSpinning) {
15155
- _optionalChain([this, 'access', _526 => _526.runtime, 'access', _527 => _527.spinner, 'optionalAccess', _528 => _528.stop, 'call', _529 => _529()]);
15351
+ _optionalChain([this, 'access', _547 => _547.runtime, 'access', _548 => _548.spinner, 'optionalAccess', _549 => _549.stop, 'call', _550 => _550()]);
15156
15352
  }
15157
15353
  this.persistentInput.pause();
15158
15354
  if (this.inkRenderer) {
@@ -15211,9 +15407,9 @@ ${_chalk2.default.gray("\u203A")} ${inputPreview}${_chalk2.default.gray("\u258B"
15211
15407
  }
15212
15408
  }
15213
15409
  getStatusSnapshot() {
15214
- const providerSettings = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
15410
+ const providerSettings = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, this.runtime.config, this.activeProvider);
15215
15411
  return {
15216
- model: _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _530 => _530.model]))), () => ( "unconfigured")),
15412
+ model: _nullishCoalesce(_nullishCoalesce(this.runtime.options.model, () => ( _optionalChain([providerSettings, 'optionalAccess', _551 => _551.model]))), () => ( "unconfigured")),
15217
15413
  workspace: this.runtime.workspaceRoot,
15218
15414
  contextPercent: this.contextPercentLeft,
15219
15415
  tokensUsed: this.totalTokensUsed
@@ -15399,7 +15595,7 @@ var ProjectAnalyzer = class {
15399
15595
  if (allDeps.eslint || allDeps.prettier || allDeps.biome) {
15400
15596
  analysis.patterns.push("linting");
15401
15597
  }
15402
- } catch (e73) {
15598
+ } catch (e76) {
15403
15599
  }
15404
15600
  }
15405
15601
  /**
@@ -15424,7 +15620,7 @@ var ProjectAnalyzer = class {
15424
15620
  analysis.hasTests = true;
15425
15621
  analysis.patterns.push("testing");
15426
15622
  }
15427
- } catch (e74) {
15623
+ } catch (e77) {
15428
15624
  }
15429
15625
  }
15430
15626
  if (await _fsextra2.default.pathExists(pyprojectPath)) {
@@ -15493,7 +15689,7 @@ var ProjectAnalyzer = class {
15493
15689
  }
15494
15690
  }
15495
15691
  }
15496
- } catch (e75) {
15692
+ } catch (e78) {
15497
15693
  }
15498
15694
  }
15499
15695
  await walk(this.projectRoot, 0);
@@ -15609,21 +15805,21 @@ async function generateAutoSkills(analysis, llm) {
15609
15805
  let skills = [];
15610
15806
  try {
15611
15807
  skills = JSON.parse(content);
15612
- } catch (e76) {
15808
+ } catch (e79) {
15613
15809
  const jsonMatch = content.match(/\[[\s\S]*\]/);
15614
15810
  if (!jsonMatch) {
15615
15811
  return [];
15616
15812
  }
15617
15813
  try {
15618
15814
  skills = JSON.parse(jsonMatch[0]);
15619
- } catch (e77) {
15815
+ } catch (e80) {
15620
15816
  return [];
15621
15817
  }
15622
15818
  }
15623
15819
  return skills.filter(
15624
15820
  (s) => s && typeof s.name === "string" && typeof s.description === "string" && typeof s.body === "string" && /^[a-z0-9-]+$/.test(s.name)
15625
15821
  );
15626
- } catch (e78) {
15822
+ } catch (e81) {
15627
15823
  return [];
15628
15824
  }
15629
15825
  }
@@ -15646,7 +15842,7 @@ allowed-tools: ${skill.allowedTools.join(" ")}`;
15646
15842
  const content = frontmatter + skill.body + "\n";
15647
15843
  await _fsextra2.default.writeFile(skillPath, content, "utf-8");
15648
15844
  return true;
15649
- } catch (e79) {
15845
+ } catch (e82) {
15650
15846
  return false;
15651
15847
  }
15652
15848
  }
@@ -15661,7 +15857,7 @@ async function runAutoSkillGeneration(workspaceRoot, llm) {
15661
15857
  let analysis;
15662
15858
  try {
15663
15859
  analysis = await analyzer.analyze();
15664
- } catch (e80) {
15860
+ } catch (e83) {
15665
15861
  result.error = "Failed to analyze project";
15666
15862
  return result;
15667
15863
  }
@@ -15825,7 +16021,7 @@ function parseRequest(line) {
15825
16021
  let parsed;
15826
16022
  try {
15827
16023
  parsed = JSON.parse(trimmed);
15828
- } catch (e81) {
16024
+ } catch (e84) {
15829
16025
  return {
15830
16026
  type: "error",
15831
16027
  code: JSON_RPC_ERROR_CODES.PARSE_ERROR,
@@ -16032,7 +16228,7 @@ var RPCAdapter = class {
16032
16228
  this.model = model;
16033
16229
  this.workspace = workspace;
16034
16230
  this.sessionId = generateId("session");
16035
- this.imageManager = _nullishCoalesce(_optionalChain([agent, 'access', _531 => _531.getImageManager, 'optionalCall', _532 => _532()]), () => ( new ImageManager()));
16231
+ this.imageManager = _nullishCoalesce(_optionalChain([agent, 'access', _552 => _552.getImageManager, 'optionalCall', _553 => _553()]), () => ( new ImageManager()));
16036
16232
  agent.setStatusListener((snapshot) => {
16037
16233
  this.contextPercent = snapshot.contextPercent;
16038
16234
  this.model = snapshot.model;
@@ -16058,7 +16254,7 @@ var RPCAdapter = class {
16058
16254
  model: this.model,
16059
16255
  workspace: this.workspace,
16060
16256
  contextPercent: this.contextPercent,
16061
- messageCount: _nullishCoalesce(_optionalChain([this, 'access', _533 => _533.conversation, 'optionalAccess', _534 => _534.history, 'call', _535 => _535(), 'access', _536 => _536.length]), () => ( 0))
16257
+ messageCount: _nullishCoalesce(_optionalChain([this, 'access', _554 => _554.conversation, 'optionalAccess', _555 => _555.history, 'call', _556 => _556(), 'access', _557 => _557.length]), () => ( 0))
16062
16258
  };
16063
16259
  }
16064
16260
  /**
@@ -16095,7 +16291,7 @@ var RPCAdapter = class {
16095
16291
  });
16096
16292
  try {
16097
16293
  const imagePlaceholders = [];
16098
- process.stderr.write(`[RPC] handlePrompt: images=${_optionalChain([params, 'access', _537 => _537.images, 'optionalAccess', _538 => _538.length]) || 0}, hasImageManager=${!!this.imageManager}, model=${this.model}
16294
+ process.stderr.write(`[RPC] handlePrompt: images=${_optionalChain([params, 'access', _558 => _558.images, 'optionalAccess', _559 => _559.length]) || 0}, hasImageManager=${!!this.imageManager}, model=${this.model}
16099
16295
  `);
16100
16296
  if (params.images && params.images.length > 0) {
16101
16297
  if (!supportsVision(this.model)) {
@@ -16114,7 +16310,7 @@ var RPCAdapter = class {
16114
16310
  `);
16115
16311
  for (const img of params.images) {
16116
16312
  try {
16117
- process.stderr.write(`[RPC] Image: mimeType=${img.mimeType}, dataLength=${_optionalChain([img, 'access', _539 => _539.data, 'optionalAccess', _540 => _540.length]) || 0}
16313
+ process.stderr.write(`[RPC] Image: mimeType=${img.mimeType}, dataLength=${_optionalChain([img, 'access', _560 => _560.data, 'optionalAccess', _561 => _561.length]) || 0}
16118
16314
  `);
16119
16315
  if (!isValidImageMimeType(img.mimeType)) {
16120
16316
  process.stderr.write(`[RPC] Invalid MIME type: ${img.mimeType}
@@ -16167,7 +16363,7 @@ ${instruction}`;
16167
16363
  process.stderr.write(`[RPC] WARNING: Images provided but no placeholders generated!
16168
16364
  `);
16169
16365
  }
16170
- if (_optionalChain([params, 'access', _541 => _541.context, 'optionalAccess', _542 => _542.selection])) {
16366
+ if (_optionalChain([params, 'access', _562 => _562.context, 'optionalAccess', _563 => _563.selection])) {
16171
16367
  const sel = params.context.selection;
16172
16368
  instruction = `${instruction}
16173
16369
 
@@ -16279,12 +16475,12 @@ ${sel.text}
16279
16475
  timestamp: createTimestamp()
16280
16476
  });
16281
16477
  const durationMs = this.turnStartTime ? Date.now() - this.turnStartTime : void 0;
16282
- const snapshot = _optionalChain([this, 'access', _543 => _543.agent, 'optionalAccess', _544 => _544.getStatusSnapshot, 'call', _545 => _545()]);
16478
+ const snapshot = _optionalChain([this, 'access', _564 => _564.agent, 'optionalAccess', _565 => _565.getStatusSnapshot, 'call', _566 => _566()]);
16283
16479
  writeNotification(RPC_NOTIFICATIONS.TURN_END, {
16284
16480
  turnId: this.currentTurnId,
16285
16481
  timestamp: createTimestamp(),
16286
16482
  contextPercent: this.contextPercent,
16287
- tokensUsed: _optionalChain([snapshot, 'optionalAccess', _546 => _546.tokensUsed]),
16483
+ tokensUsed: _optionalChain([snapshot, 'optionalAccess', _567 => _567.tokensUsed]),
16288
16484
  durationMs
16289
16485
  });
16290
16486
  this.status = "idle";
@@ -16295,12 +16491,12 @@ ${sel.text}
16295
16491
  return { success };
16296
16492
  } catch (error) {
16297
16493
  const durationMs = this.turnStartTime ? Date.now() - this.turnStartTime : void 0;
16298
- const snapshot = _optionalChain([this, 'access', _547 => _547.agent, 'optionalAccess', _548 => _548.getStatusSnapshot, 'call', _549 => _549()]);
16494
+ const snapshot = _optionalChain([this, 'access', _568 => _568.agent, 'optionalAccess', _569 => _569.getStatusSnapshot, 'call', _570 => _570()]);
16299
16495
  writeNotification(RPC_NOTIFICATIONS.TURN_END, {
16300
16496
  turnId: this.currentTurnId,
16301
16497
  timestamp: createTimestamp(),
16302
16498
  contextPercent: this.contextPercent,
16303
- tokensUsed: _optionalChain([snapshot, 'optionalAccess', _550 => _550.tokensUsed]),
16499
+ tokensUsed: _optionalChain([snapshot, 'optionalAccess', _571 => _571.tokensUsed]),
16304
16500
  durationMs
16305
16501
  });
16306
16502
  this.status = "idle";
@@ -16339,12 +16535,12 @@ ${sel.text}
16339
16535
  }
16340
16536
  if (this.currentTurnId) {
16341
16537
  const durationMs = this.turnStartTime ? Date.now() - this.turnStartTime : void 0;
16342
- const snapshot = _optionalChain([this, 'access', _551 => _551.agent, 'optionalAccess', _552 => _552.getStatusSnapshot, 'call', _553 => _553()]);
16538
+ const snapshot = _optionalChain([this, 'access', _572 => _572.agent, 'optionalAccess', _573 => _573.getStatusSnapshot, 'call', _574 => _574()]);
16343
16539
  writeNotification(RPC_NOTIFICATIONS.TURN_END, {
16344
16540
  turnId: this.currentTurnId,
16345
16541
  timestamp: createTimestamp(),
16346
16542
  contextPercent: this.contextPercent,
16347
- tokensUsed: _optionalChain([snapshot, 'optionalAccess', _554 => _554.tokensUsed]),
16543
+ tokensUsed: _optionalChain([snapshot, 'optionalAccess', _575 => _575.tokensUsed]),
16348
16544
  durationMs
16349
16545
  });
16350
16546
  }
@@ -16363,10 +16559,10 @@ ${sel.text}
16363
16559
  handleReset(requestId) {
16364
16560
  if (this.conversation) {
16365
16561
  const history = this.conversation.history();
16366
- const systemPrompt = _nullishCoalesce(_optionalChain([history, 'access', _555 => _555.find, 'call', _556 => _556((m) => m.role === "system"), 'optionalAccess', _557 => _557.content]), () => ( ""));
16562
+ const systemPrompt = _nullishCoalesce(_optionalChain([history, 'access', _576 => _576.find, 'call', _577 => _577((m) => m.role === "system"), 'optionalAccess', _578 => _578.content]), () => ( ""));
16367
16563
  this.conversation.reset(systemPrompt);
16368
16564
  }
16369
- _optionalChain([this, 'access', _558 => _558.imageManager, 'optionalAccess', _559 => _559.clear, 'call', _560 => _560()]);
16565
+ _optionalChain([this, 'access', _579 => _579.imageManager, 'optionalAccess', _580 => _580.clear, 'call', _581 => _581()]);
16370
16566
  this.sessionId = generateId("session");
16371
16567
  this.status = "idle";
16372
16568
  this.currentTurnId = null;
@@ -16726,7 +16922,7 @@ ${sel.text}
16726
16922
  * Handle changes decision from client (accept/reject)
16727
16923
  */
16728
16924
  async handleChangesDecision(requestId, params) {
16729
- const fileManager = _optionalChain([this, 'access', _561 => _561.agent, 'optionalAccess', _562 => _562.getFileManager, 'optionalCall', _563 => _563()]);
16925
+ const fileManager = _optionalChain([this, 'access', _582 => _582.agent, 'optionalAccess', _583 => _583.getFileManager, 'optionalCall', _584 => _584()]);
16730
16926
  if (!fileManager) {
16731
16927
  return {
16732
16928
  success: false,
@@ -16778,7 +16974,7 @@ ${sel.text}
16778
16974
  const cache = new CommunitySkillsCache();
16779
16975
  const fetcher = new GitHubRegistryFetcher();
16780
16976
  let registry;
16781
- if (_optionalChain([params, 'optionalAccess', _564 => _564.forceRefresh])) {
16977
+ if (_optionalChain([params, 'optionalAccess', _585 => _585.forceRefresh])) {
16782
16978
  process.stderr.write("[RPC] Force refreshing skills registry from GitHub\n");
16783
16979
  registry = await fetcher.fetchRegistry();
16784
16980
  await cache.setRegistry(registry);
@@ -16825,7 +17021,7 @@ ${sel.text}
16825
17021
  */
16826
17022
  async handleInstallSkill(requestId, params) {
16827
17023
  try {
16828
- const skillsRegistry = _optionalChain([this, 'access', _565 => _565.agent, 'optionalAccess', _566 => _566.getSkillsRegistry, 'optionalCall', _567 => _567()]);
17024
+ const skillsRegistry = _optionalChain([this, 'access', _586 => _586.agent, 'optionalAccess', _587 => _587.getSkillsRegistry, 'optionalCall', _588 => _588()]);
16829
17025
  if (!skillsRegistry) {
16830
17026
  return {
16831
17027
  success: false,
@@ -16929,7 +17125,7 @@ ${sel.text}
16929
17125
  * Handle output events from the agent
16930
17126
  */
16931
17127
  handleAgentOutput(event) {
16932
- process.stderr.write(`[RPC DEBUG] handleAgentOutput: type=${event.type}, content length=${_nullishCoalesce(_optionalChain([event, 'access', _568 => _568.content, 'optionalAccess', _569 => _569.length]), () => ( 0))}
17128
+ process.stderr.write(`[RPC DEBUG] handleAgentOutput: type=${event.type}, content length=${_nullishCoalesce(_optionalChain([event, 'access', _589 => _589.content, 'optionalAccess', _590 => _590.length]), () => ( 0))}
16933
17129
  `);
16934
17130
  switch (event.type) {
16935
17131
  case "thinking":
@@ -17037,14 +17233,14 @@ ${sel.text}
17037
17233
  toolCalls = msg.tool_calls.map((tc) => {
17038
17234
  let args = {};
17039
17235
  try {
17040
- if (_optionalChain([tc, 'access', _570 => _570.function, 'optionalAccess', _571 => _571.arguments])) {
17236
+ if (_optionalChain([tc, 'access', _591 => _591.function, 'optionalAccess', _592 => _592.arguments])) {
17041
17237
  args = JSON.parse(tc.function.arguments);
17042
17238
  }
17043
- } catch (e82) {
17239
+ } catch (e85) {
17044
17240
  }
17045
17241
  return {
17046
17242
  id: tc.id,
17047
- name: _nullishCoalesce(_optionalChain([tc, 'access', _572 => _572.function, 'optionalAccess', _573 => _573.name]), () => ( "unknown")),
17243
+ name: _nullishCoalesce(_optionalChain([tc, 'access', _593 => _593.function, 'optionalAccess', _594 => _594.name]), () => ( "unknown")),
17048
17244
  args
17049
17245
  };
17050
17246
  });
@@ -17077,7 +17273,7 @@ async function runRpcMode(options) {
17077
17273
  let adapter = null;
17078
17274
  let agent = null;
17079
17275
  try {
17080
- const config = await _chunkSXUZ3CX3cjs.loadConfig.call(void 0, options.config);
17276
+ const config = await _chunkQMVTT55Ycjs.loadConfig.call(void 0, options.config);
17081
17277
  if (!config.ui) {
17082
17278
  config.ui = {};
17083
17279
  }
@@ -17103,18 +17299,18 @@ async function runRpcMode(options) {
17103
17299
  adapter.initialize(
17104
17300
  agent,
17105
17301
  conversation,
17106
- _nullishCoalesce(_nullishCoalesce(options.model, () => ( _optionalChain([config, 'access', _574 => _574.openrouter, 'optionalAccess', _575 => _575.model]))), () => ( "unknown")),
17302
+ _nullishCoalesce(_nullishCoalesce(options.model, () => ( _optionalChain([config, 'access', _595 => _595.openrouter, 'optionalAccess', _596 => _596.model]))), () => ( "unknown")),
17107
17303
  workspaceRoot
17108
17304
  );
17109
17305
  agent.setConfirmationCallback(async (message, context) => {
17110
17306
  if (!adapter) {
17111
17307
  throw new Error("RPC adapter not initialized");
17112
17308
  }
17113
- const tool = _nullishCoalesce(_optionalChain([context, 'optionalAccess', _576 => _576.tool]), () => ( "action"));
17309
+ const tool = _nullishCoalesce(_optionalChain([context, 'optionalAccess', _597 => _597.tool]), () => ( "action"));
17114
17310
  const description = message;
17115
17311
  const permContext = {};
17116
- if (_optionalChain([context, 'optionalAccess', _577 => _577.command])) permContext.command = context.command;
17117
- if (_optionalChain([context, 'optionalAccess', _578 => _578.path])) permContext.path = context.path;
17312
+ if (_optionalChain([context, 'optionalAccess', _598 => _598.command])) permContext.command = context.command;
17313
+ if (_optionalChain([context, 'optionalAccess', _599 => _599.path])) permContext.path = context.path;
17118
17314
  return adapter.requestPermission(tool, description, permContext);
17119
17315
  });
17120
17316
  const reader = new LineReader(process.stdin);
@@ -17133,7 +17329,7 @@ async function runRpcMode(options) {
17133
17329
  } catch (error) {
17134
17330
  const message = error instanceof Error ? error.message : String(error);
17135
17331
  writeErrorResponse(null, JSON_RPC_ERROR_CODES.INTERNAL_ERROR, `Initialization error: ${message}`);
17136
- _optionalChain([adapter, 'optionalAccess', _579 => _579.shutdown, 'call', _580 => _580("error")]);
17332
+ _optionalChain([adapter, 'optionalAccess', _600 => _600.shutdown, 'call', _601 => _601("error")]);
17137
17333
  process.exit(1);
17138
17334
  }
17139
17335
  }
@@ -17166,7 +17362,7 @@ async function handleSingleRequest(request, adapter) {
17166
17362
  switch (method) {
17167
17363
  case RPC_METHODS.PROMPT: {
17168
17364
  const promptParams = params;
17169
- if (!_optionalChain([promptParams, 'optionalAccess', _581 => _581.message])) {
17365
+ if (!_optionalChain([promptParams, 'optionalAccess', _602 => _602.message])) {
17170
17366
  if (shouldRespond) {
17171
17367
  return createErrorResponse(
17172
17368
  id,
@@ -17208,12 +17404,12 @@ async function handleSingleRequest(request, adapter) {
17208
17404
  }
17209
17405
  case RPC_METHODS.GET_MESSAGES: {
17210
17406
  const messagesParams = params;
17211
- result = adapter.handleGetMessages(id, _optionalChain([messagesParams, 'optionalAccess', _582 => _582.limit]));
17407
+ result = adapter.handleGetMessages(id, _optionalChain([messagesParams, 'optionalAccess', _603 => _603.limit]));
17212
17408
  break;
17213
17409
  }
17214
17410
  case RPC_METHODS.PERMISSION_RESPONSE: {
17215
17411
  const permParams = params;
17216
- if (!_optionalChain([permParams, 'optionalAccess', _583 => _583.requestId]) || _optionalChain([permParams, 'optionalAccess', _584 => _584.allowed]) === void 0) {
17412
+ if (!_optionalChain([permParams, 'optionalAccess', _604 => _604.requestId]) || _optionalChain([permParams, 'optionalAccess', _605 => _605.allowed]) === void 0) {
17217
17413
  if (shouldRespond) {
17218
17414
  return createErrorResponse(
17219
17415
  id,
@@ -17228,7 +17424,7 @@ async function handleSingleRequest(request, adapter) {
17228
17424
  }
17229
17425
  case RPC_METHODS.PERMISSION_ACKNOWLEDGED: {
17230
17426
  const ackParams = params;
17231
- if (!_optionalChain([ackParams, 'optionalAccess', _585 => _585.requestId])) {
17427
+ if (!_optionalChain([ackParams, 'optionalAccess', _606 => _606.requestId])) {
17232
17428
  if (shouldRespond) {
17233
17429
  return createErrorResponse(
17234
17430
  id,
@@ -17243,7 +17439,7 @@ async function handleSingleRequest(request, adapter) {
17243
17439
  }
17244
17440
  case RPC_METHODS.CHANGES_DECISION: {
17245
17441
  const decisionParams = params;
17246
- if (!_optionalChain([decisionParams, 'optionalAccess', _586 => _586.batchId]) || !_optionalChain([decisionParams, 'optionalAccess', _587 => _587.action])) {
17442
+ if (!_optionalChain([decisionParams, 'optionalAccess', _607 => _607.batchId]) || !_optionalChain([decisionParams, 'optionalAccess', _608 => _608.action])) {
17247
17443
  if (shouldRespond) {
17248
17444
  return createErrorResponse(
17249
17445
  id,
@@ -17263,7 +17459,7 @@ async function handleSingleRequest(request, adapter) {
17263
17459
  }
17264
17460
  case RPC_METHODS.INSTALL_SKILL: {
17265
17461
  const installParams = params;
17266
- if (!_optionalChain([installParams, 'optionalAccess', _588 => _588.skillName]) || !_optionalChain([installParams, 'optionalAccess', _589 => _589.scope])) {
17462
+ if (!_optionalChain([installParams, 'optionalAccess', _609 => _609.skillName]) || !_optionalChain([installParams, 'optionalAccess', _610 => _610.scope])) {
17267
17463
  if (shouldRespond) {
17268
17464
  return createErrorResponse(
17269
17465
  id,
@@ -17308,20 +17504,20 @@ async function handleSingleRequest(request, adapter) {
17308
17504
  process.title = "autohand";
17309
17505
  function getGitCommit() {
17310
17506
  if (true) {
17311
- return "f92e70a";
17507
+ return "5392e8c";
17312
17508
  }
17313
17509
  try {
17314
17510
  return _child_process.execSync.call(void 0, "git rev-parse --short HEAD", { encoding: "utf8", stdio: ["pipe", "pipe", "ignore"] }).trim();
17315
- } catch (e83) {
17511
+ } catch (e86) {
17316
17512
  return "unknown";
17317
17513
  }
17318
17514
  }
17319
17515
  function getVersionString() {
17320
17516
  const commit = getGitCommit();
17321
- return `${_chunk7EIL6P6Qcjs.package_default.version} (${commit})`;
17517
+ return `${_chunkXJZYEURAcjs.package_default.version} (${commit})`;
17322
17518
  }
17323
17519
  async function validateAuthOnStartup(config) {
17324
- if (!_optionalChain([config, 'access', _590 => _590.auth, 'optionalAccess', _591 => _591.token])) {
17520
+ if (!_optionalChain([config, 'access', _611 => _611.auth, 'optionalAccess', _612 => _612.token])) {
17325
17521
  return void 0;
17326
17522
  }
17327
17523
  if (config.auth.expiresAt) {
@@ -17329,8 +17525,8 @@ async function validateAuthOnStartup(config) {
17329
17525
  if (expiresAt < /* @__PURE__ */ new Date()) {
17330
17526
  config.auth = void 0;
17331
17527
  try {
17332
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, config);
17333
- } catch (e84) {
17528
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, config);
17529
+ } catch (e87) {
17334
17530
  }
17335
17531
  return void 0;
17336
17532
  }
@@ -17341,17 +17537,17 @@ async function validateAuthOnStartup(config) {
17341
17537
  if (!result.authenticated) {
17342
17538
  config.auth = void 0;
17343
17539
  try {
17344
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, config);
17345
- } catch (e85) {
17540
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, config);
17541
+ } catch (e88) {
17346
17542
  }
17347
17543
  return void 0;
17348
17544
  }
17349
17545
  if (result.user && config.auth) {
17350
17546
  config.auth.user = result.user;
17351
17547
  }
17352
- return _optionalChain([config, 'access', _592 => _592.auth, 'optionalAccess', _593 => _593.user]);
17353
- } catch (e86) {
17354
- return _optionalChain([config, 'access', _594 => _594.auth, 'optionalAccess', _595 => _595.user]);
17548
+ return _optionalChain([config, 'access', _613 => _613.auth, 'optionalAccess', _614 => _614.user]);
17549
+ } catch (e89) {
17550
+ return _optionalChain([config, 'access', _615 => _615.auth, 'optionalAccess', _616 => _616.user]);
17355
17551
  }
17356
17552
  }
17357
17553
  process.on("uncaughtException", (err) => {
@@ -17407,9 +17603,9 @@ program.command("resume <sessionId>").description("Resume a previous session").o
17407
17603
  async function runCLI(options) {
17408
17604
  const statusPanel = null;
17409
17605
  try {
17410
- let config = await _chunkSXUZ3CX3cjs.loadConfig.call(void 0, options.config);
17606
+ let config = await _chunkQMVTT55Ycjs.loadConfig.call(void 0, options.config);
17411
17607
  const providerName = _nullishCoalesce(config.provider, () => ( "openrouter"));
17412
- const providerConfig = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, config, providerName);
17608
+ const providerConfig = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, config, providerName);
17413
17609
  if (!providerConfig) {
17414
17610
  if (config.isNewConfig) {
17415
17611
  console.log(_chalk2.default.cyan("\n\u2728 Welcome to Autohand!\n"));
@@ -17433,7 +17629,7 @@ async function runCLI(options) {
17433
17629
  });
17434
17630
  apiKey = result.apiKey;
17435
17631
  } catch (error) {
17436
- if (_optionalChain([error, 'optionalAccess', _596 => _596.code]) === "ERR_USE_AFTER_CLOSE" || _optionalChain([error, 'optionalAccess', _597 => _597.message, 'optionalAccess', _598 => _598.includes, 'call', _599 => _599("cancelled")])) {
17632
+ if (_optionalChain([error, 'optionalAccess', _617 => _617.code]) === "ERR_USE_AFTER_CLOSE" || _optionalChain([error, 'optionalAccess', _618 => _618.message, 'optionalAccess', _619 => _619.includes, 'call', _620 => _620("cancelled")])) {
17437
17633
  console.log(_chalk2.default.gray("\nSetup cancelled."));
17438
17634
  process.exit(0);
17439
17635
  }
@@ -17443,20 +17639,20 @@ async function runCLI(options) {
17443
17639
  config.openrouter = {
17444
17640
  ...config.openrouter,
17445
17641
  apiKey: apiKey.trim(),
17446
- baseUrl: _optionalChain([config, 'access', _600 => _600.openrouter, 'optionalAccess', _601 => _601.baseUrl]) || "https://openrouter.ai/api/v1",
17447
- model: _optionalChain([config, 'access', _602 => _602.openrouter, 'optionalAccess', _603 => _603.model]) || "anthropic/claude-sonnet-4-20250514"
17642
+ baseUrl: _optionalChain([config, 'access', _621 => _621.openrouter, 'optionalAccess', _622 => _622.baseUrl]) || "https://openrouter.ai/api/v1",
17643
+ model: _optionalChain([config, 'access', _623 => _623.openrouter, 'optionalAccess', _624 => _624.model]) || "anthropic/claude-sonnet-4-20250514"
17448
17644
  };
17449
17645
  } else if (providerName === "openai") {
17450
17646
  config.openai = {
17451
17647
  ...config.openai,
17452
17648
  apiKey: apiKey.trim(),
17453
- model: _optionalChain([config, 'access', _604 => _604.openai, 'optionalAccess', _605 => _605.model]) || "gpt-4o"
17649
+ model: _optionalChain([config, 'access', _625 => _625.openai, 'optionalAccess', _626 => _626.model]) || "gpt-4o"
17454
17650
  };
17455
17651
  }
17456
- await _chunkSXUZ3CX3cjs.saveConfig.call(void 0, config);
17652
+ await _chunkQMVTT55Ycjs.saveConfig.call(void 0, config);
17457
17653
  console.log(_chalk2.default.green("\u2713 API key saved to config\n"));
17458
17654
  }
17459
- const workspaceRoot = _chunkSXUZ3CX3cjs.resolveWorkspaceRoot.call(void 0, config, options.path);
17655
+ const workspaceRoot = _chunkQMVTT55Ycjs.resolveWorkspaceRoot.call(void 0, config, options.path);
17460
17656
  const safetyCheck = checkWorkspaceSafety(workspaceRoot);
17461
17657
  if (!safetyCheck.safe) {
17462
17658
  printDangerousWorkspaceWarning(workspaceRoot, safetyCheck);
@@ -17468,8 +17664,8 @@ async function runCLI(options) {
17468
17664
  options
17469
17665
  };
17470
17666
  const authUser = await validateAuthOnStartup(config);
17471
- const versionCheck = _optionalChain([config, 'access', _606 => _606.ui, 'optionalAccess', _607 => _607.checkForUpdates]) !== false ? await checkForUpdates(_chunk7EIL6P6Qcjs.package_default.version, {
17472
- checkIntervalHours: _nullishCoalesce(_optionalChain([config, 'access', _608 => _608.ui, 'optionalAccess', _609 => _609.updateCheckInterval]), () => ( 24))
17667
+ const versionCheck = _optionalChain([config, 'access', _627 => _627.ui, 'optionalAccess', _628 => _628.checkForUpdates]) !== false ? await checkForUpdates(_chunkXJZYEURAcjs.package_default.version, {
17668
+ checkIntervalHours: _nullishCoalesce(_optionalChain([config, 'access', _629 => _629.ui, 'optionalAccess', _630 => _630.updateCheckInterval]), () => ( 24))
17473
17669
  }) : null;
17474
17670
  printBanner();
17475
17671
  printWelcome(runtime, authUser, versionCheck);
@@ -17531,9 +17727,9 @@ function printWelcome(runtime, authUser, versionCheck) {
17531
17727
  }
17532
17728
  const model = (() => {
17533
17729
  try {
17534
- const settings = _chunkSXUZ3CX3cjs.getProviderConfig.call(void 0, runtime.config);
17535
- return _nullishCoalesce(_nullishCoalesce(runtime.options.model, () => ( _optionalChain([settings, 'optionalAccess', _610 => _610.model]))), () => ( "unknown"));
17536
- } catch (e87) {
17730
+ const settings = _chunkQMVTT55Ycjs.getProviderConfig.call(void 0, runtime.config);
17731
+ return _nullishCoalesce(_nullishCoalesce(runtime.options.model, () => ( _optionalChain([settings, 'optionalAccess', _631 => _631.model]))), () => ( "unknown"));
17732
+ } catch (e90) {
17537
17733
  return _nullishCoalesce(runtime.options.model, () => ( "unknown"));
17538
17734
  }
17539
17735
  })();
@@ -17547,7 +17743,7 @@ function printWelcome(runtime, authUser, versionCheck) {
17547
17743
  }
17548
17744
  }
17549
17745
  console.log(versionLine);
17550
- if (_optionalChain([versionCheck, 'optionalAccess', _611 => _611.updateAvailable])) {
17746
+ if (_optionalChain([versionCheck, 'optionalAccess', _632 => _632.updateAvailable])) {
17551
17747
  console.log(_chalk2.default.gray(" \u21B3 Run: ") + _chalk2.default.cyan("curl -fsSL https://autohand.ai/install.sh | sh"));
17552
17748
  }
17553
17749
  if (authUser) {
@@ -17564,8 +17760,8 @@ function printWelcome(runtime, authUser, versionCheck) {
17564
17760
  console.log();
17565
17761
  }
17566
17762
  async function runSkillInstall(opts) {
17567
- const config = await _chunkSXUZ3CX3cjs.loadConfig.call(void 0, opts.config);
17568
- const workspaceRoot = _chunkSXUZ3CX3cjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17763
+ const config = await _chunkQMVTT55Ycjs.loadConfig.call(void 0, opts.config);
17764
+ const workspaceRoot = _chunkQMVTT55Ycjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17569
17765
  const safetyCheck = checkWorkspaceSafety(workspaceRoot);
17570
17766
  if (!safetyCheck.safe) {
17571
17767
  printDangerousWorkspaceWarning(workspaceRoot, safetyCheck);
@@ -17584,8 +17780,8 @@ async function runSkillInstall(opts) {
17584
17780
  }, skillName);
17585
17781
  }
17586
17782
  async function displayPermissions(opts) {
17587
- const config = await _chunkSXUZ3CX3cjs.loadConfig.call(void 0, opts.config);
17588
- const workspaceRoot = _chunkSXUZ3CX3cjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17783
+ const config = await _chunkQMVTT55Ycjs.loadConfig.call(void 0, opts.config);
17784
+ const workspaceRoot = _chunkQMVTT55Ycjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17589
17785
  const safetyCheck = checkWorkspaceSafety(workspaceRoot);
17590
17786
  if (!safetyCheck.safe) {
17591
17787
  printDangerousWorkspaceWarning(workspaceRoot, safetyCheck);
@@ -17595,18 +17791,18 @@ async function displayPermissions(opts) {
17595
17791
  const { loadLocalProjectSettings } = await Promise.resolve().then(() => _interopRequireWildcard(require("./localProjectPermissions-75X3ZGKH.cjs")));
17596
17792
  const localSettings = await loadLocalProjectSettings(workspaceRoot);
17597
17793
  const mergedSettings = {
17598
- mode: _nullishCoalesce(_nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _612 => _612.permissions, 'optionalAccess', _613 => _613.mode]), () => ( _optionalChain([config, 'access', _614 => _614.permissions, 'optionalAccess', _615 => _615.mode]))), () => ( "interactive")),
17794
+ mode: _nullishCoalesce(_nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _633 => _633.permissions, 'optionalAccess', _634 => _634.mode]), () => ( _optionalChain([config, 'access', _635 => _635.permissions, 'optionalAccess', _636 => _636.mode]))), () => ( "interactive")),
17599
17795
  whitelist: [
17600
- ..._nullishCoalesce(_optionalChain([config, 'access', _616 => _616.permissions, 'optionalAccess', _617 => _617.whitelist]), () => ( [])),
17601
- ..._nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _618 => _618.permissions, 'optionalAccess', _619 => _619.whitelist]), () => ( []))
17796
+ ..._nullishCoalesce(_optionalChain([config, 'access', _637 => _637.permissions, 'optionalAccess', _638 => _638.whitelist]), () => ( [])),
17797
+ ..._nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _639 => _639.permissions, 'optionalAccess', _640 => _640.whitelist]), () => ( []))
17602
17798
  ],
17603
17799
  blacklist: [
17604
- ..._nullishCoalesce(_optionalChain([config, 'access', _620 => _620.permissions, 'optionalAccess', _621 => _621.blacklist]), () => ( [])),
17605
- ..._nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _622 => _622.permissions, 'optionalAccess', _623 => _623.blacklist]), () => ( []))
17800
+ ..._nullishCoalesce(_optionalChain([config, 'access', _641 => _641.permissions, 'optionalAccess', _642 => _642.blacklist]), () => ( [])),
17801
+ ..._nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _643 => _643.permissions, 'optionalAccess', _644 => _644.blacklist]), () => ( []))
17606
17802
  ],
17607
17803
  rules: [
17608
- ..._nullishCoalesce(_optionalChain([config, 'access', _624 => _624.permissions, 'optionalAccess', _625 => _625.rules]), () => ( [])),
17609
- ..._nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _626 => _626.permissions, 'optionalAccess', _627 => _627.rules]), () => ( []))
17804
+ ..._nullishCoalesce(_optionalChain([config, 'access', _645 => _645.permissions, 'optionalAccess', _646 => _646.rules]), () => ( [])),
17805
+ ..._nullishCoalesce(_optionalChain([localSettings, 'optionalAccess', _647 => _647.permissions, 'optionalAccess', _648 => _648.rules]), () => ( []))
17610
17806
  ]
17611
17807
  };
17612
17808
  const manager = new PermissionManager2({ settings: mergedSettings });
@@ -17656,8 +17852,8 @@ async function runPatchMode(opts) {
17656
17852
  }
17657
17853
  const fs21 = await Promise.resolve().then(() => _interopRequireWildcard(require("fs-extra")));
17658
17854
  const { generateUnifiedPatch, formatChangeSummary } = await Promise.resolve().then(() => _interopRequireWildcard(require("./patch-J32X2QQP.cjs")));
17659
- const config = await _chunkSXUZ3CX3cjs.loadConfig.call(void 0, opts.config);
17660
- const workspaceRoot = _chunkSXUZ3CX3cjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17855
+ const config = await _chunkQMVTT55Ycjs.loadConfig.call(void 0, opts.config);
17856
+ const workspaceRoot = _chunkQMVTT55Ycjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17661
17857
  const safetyCheck = checkWorkspaceSafety(workspaceRoot);
17662
17858
  if (!safetyCheck.safe) {
17663
17859
  printDangerousWorkspaceWarning(workspaceRoot, safetyCheck);
@@ -17719,8 +17915,8 @@ async function runAutoMode(opts) {
17719
17915
  console.error(_chalk2.default.red("Error: --auto-mode requires a task prompt"));
17720
17916
  process.exit(1);
17721
17917
  }
17722
- const config = await _chunkSXUZ3CX3cjs.loadConfig.call(void 0, opts.config);
17723
- const workspaceRoot = _chunkSXUZ3CX3cjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17918
+ const config = await _chunkQMVTT55Ycjs.loadConfig.call(void 0, opts.config);
17919
+ const workspaceRoot = _chunkQMVTT55Ycjs.resolveWorkspaceRoot.call(void 0, config, opts.path);
17724
17920
  const safetyCheck = checkWorkspaceSafety(workspaceRoot);
17725
17921
  if (!safetyCheck.safe) {
17726
17922
  printDangerousWorkspaceWarning(workspaceRoot, safetyCheck);
@@ -17744,7 +17940,7 @@ async function runAutoMode(opts) {
17744
17940
  const llmProvider = ProviderFactory.create(config);
17745
17941
  const files = new FileActionManager(workspaceRoot);
17746
17942
  const providerName = _nullishCoalesce(config.provider, () => ( "openrouter"));
17747
- const modelName = _nullishCoalesce(_nullishCoalesce(opts.model, () => ( _optionalChain([config, 'access', _628 => _628[providerName], 'optionalAccess', _629 => _629.model]))), () => ( "unknown"));
17943
+ const modelName = _nullishCoalesce(_nullishCoalesce(opts.model, () => ( _optionalChain([config, 'access', _649 => _649[providerName], 'optionalAccess', _650 => _650.model]))), () => ( "unknown"));
17748
17944
  const sessionManager = new SessionManager2();
17749
17945
  await sessionManager.initialize();
17750
17946
  const session = await sessionManager.createSession(workspaceRoot, modelName);
@@ -17826,11 +18022,11 @@ async function runAutoMode(opts) {
17826
18022
  if (finalState) {
17827
18023
  session.metadata.automodeIterations = finalState.currentIteration;
17828
18024
  const statusText = finalState.status === "completed" ? "completed" : `ended (${finalState.status})`;
17829
- await sessionManager.closeSession(`Auto-mode ${statusText} after ${finalState.currentIteration} iterations: ${_optionalChain([opts, 'access', _630 => _630.autoMode, 'optionalAccess', _631 => _631.slice, 'call', _632 => _632(0, 50)])}...`);
18025
+ await sessionManager.closeSession(`Auto-mode ${statusText} after ${finalState.currentIteration} iterations: ${_optionalChain([opts, 'access', _651 => _651.autoMode, 'optionalAccess', _652 => _652.slice, 'call', _653 => _653(0, 50)])}...`);
17830
18026
  console.log(_chalk2.default.gray(`
17831
18027
  \u{1F4C1} Session saved: ${session.metadata.sessionId}`));
17832
18028
  }
17833
- process.exit(_optionalChain([finalState, 'optionalAccess', _633 => _633.status]) === "completed" ? 0 : 1);
18029
+ process.exit(_optionalChain([finalState, 'optionalAccess', _654 => _654.status]) === "completed" ? 0 : 1);
17834
18030
  } catch (error) {
17835
18031
  if (process.stdin.isTTY) {
17836
18032
  process.stdin.setRawMode(false);