open-agents-ai 0.187.116 → 0.187.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +514 -231
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22830,7 +22830,7 @@ function pbkdf2(hash, password, salt, opts) {
22830
22830
  view.setInt32(0, ti, false);
22831
22831
  (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
22832
22832
  Ti.set(u.subarray(0, Ti.length));
22833
- for (let ui = 1; ui < c4; ui++) {
22833
+ for (let ui2 = 1; ui2 < c4; ui2++) {
22834
22834
  PRF._cloneInto(prfW).update(u).digestInto(u);
22835
22835
  for (let i2 = 0; i2 < Ti.length; i2++)
22836
22836
  Ti[i2] ^= u[i2];
@@ -271286,16 +271286,16 @@ __export(theme_exports, {
271286
271286
  tuiAccent: () => tuiAccent,
271287
271287
  tuiAccentFg: () => tuiAccentFg,
271288
271288
  tuiBg: () => tuiBg,
271289
- tuiBgSeq: () => tuiBgSeq,
271289
+ tuiBgSeq: () => tuiBgSeq2,
271290
271290
  tuiBoxFg: () => tuiBoxFg,
271291
271291
  tuiTextDim: () => tuiTextDim,
271292
- tuiTextPrimary: () => tuiTextPrimary,
271292
+ tuiTextPrimary: () => tuiTextPrimary2,
271293
271293
  tuiTextPrimaryFg: () => tuiTextPrimaryFg
271294
271294
  });
271295
271295
  function themeMode() {
271296
271296
  return _config2.mode;
271297
271297
  }
271298
- function tuiBgSeq() {
271298
+ function tuiBgSeq2() {
271299
271299
  return _config2.bg < 0 ? "\x1B[49m" : `\x1B[48;5;${_config2.bg}m`;
271300
271300
  }
271301
271301
  function tuiBg() {
@@ -271310,7 +271310,7 @@ function tuiAccent() {
271310
271310
  function tuiBoxFg() {
271311
271311
  return _config2.boxColor < 0 ? "\x1B[39m" : `\x1B[38;5;${_config2.boxColor}m`;
271312
271312
  }
271313
- function tuiTextPrimary() {
271313
+ function tuiTextPrimary2() {
271314
271314
  return _config2.textPrimary;
271315
271315
  }
271316
271316
  function tuiTextPrimaryFg() {
@@ -271457,12 +271457,50 @@ var init_layout2 = __esm({
271457
271457
  });
271458
271458
 
271459
271459
  // packages/cli/dist/tui/render.js
271460
+ var render_exports = {};
271461
+ __export(render_exports, {
271462
+ SLASH_COMMANDS: () => SLASH_COMMANDS,
271463
+ c: () => c3,
271464
+ fileLink: () => fileLink,
271465
+ formatInlineMarkdown: () => formatInlineMarkdown,
271466
+ formatMarkdownBlock: () => formatMarkdownBlock,
271467
+ formatMarkdownLine: () => formatMarkdownLine,
271468
+ getColorsEnabled: () => getColorsEnabled,
271469
+ getEmojisEnabled: () => getEmojisEnabled,
271470
+ getTermWidth: () => getTermWidth,
271471
+ pastel: () => pastel,
271472
+ renderAssistantText: () => renderAssistantText,
271473
+ renderCompactHeader: () => renderCompactHeader,
271474
+ renderConfig: () => renderConfig,
271475
+ renderError: () => renderError,
271476
+ renderHeader: () => renderHeader,
271477
+ renderInfo: () => renderInfo,
271478
+ renderModelList: () => renderModelList,
271479
+ renderModelSwitch: () => renderModelSwitch,
271480
+ renderRichHeader: () => renderRichHeader,
271481
+ renderSlashHelp: () => renderSlashHelp,
271482
+ renderTaskAborted: () => renderTaskAborted,
271483
+ renderTaskComplete: () => renderTaskComplete,
271484
+ renderTaskIncomplete: () => renderTaskIncomplete,
271485
+ renderThinking: () => renderThinking,
271486
+ renderToolCallStart: () => renderToolCallStart,
271487
+ renderToolResult: () => renderToolResult,
271488
+ renderUserInterrupt: () => renderUserInterrupt,
271489
+ renderUserMessage: () => renderUserMessage,
271490
+ renderVerbose: () => renderVerbose,
271491
+ renderVoiceText: () => renderVoiceText,
271492
+ renderWarning: () => renderWarning,
271493
+ setColorsEnabled: () => setColorsEnabled,
271494
+ setContentWriteHook: () => setContentWriteHook,
271495
+ setEmojisEnabled: () => setEmojisEnabled,
271496
+ ui: () => ui
271497
+ });
271460
271498
  function accentFg() {
271461
271499
  const a2 = tuiAccent();
271462
271500
  return a2 < 0 ? "\x1B[39m" : `\x1B[38;5;${a2}m`;
271463
271501
  }
271464
271502
  function textFg() {
271465
- const t2 = tuiTextPrimary();
271503
+ const t2 = tuiTextPrimary2();
271466
271504
  return t2 < 0 ? "\x1B[39m" : `\x1B[38;5;${t2}m`;
271467
271505
  }
271468
271506
  function ansi2(code8, text) {
@@ -271602,6 +271640,11 @@ function renderAssistantText(text) {
271602
271640
  `);
271603
271641
  }
271604
271642
  }
271643
+ function renderThinking(text) {
271644
+ process.stdout.write(`
271645
+ ${c3.magenta("\u25CF")} ${c3.italic(text)}
271646
+ `);
271647
+ }
271605
271648
  function renderVoiceText(text) {
271606
271649
  process.stdout.write(` ${c3.dim("\u{1F50A}")} ${c3.italic(c3.dim(text))}
271607
271650
  `);
@@ -271909,6 +271952,69 @@ function renderVerbose(message2) {
271909
271952
  process.stdout.write(text);
271910
271953
  _contentWriteHook?.end();
271911
271954
  }
271955
+ function renderRichHeader(opts) {
271956
+ const w = getTermWidth();
271957
+ const divider = c3.dim("\u2500".repeat(Math.min(w - 4, 72)));
271958
+ let lines = 0;
271959
+ process.stdout.write("\n");
271960
+ lines++;
271961
+ const title = c3.bold(c3.cyan("open-agents"));
271962
+ const ver = c3.dim(`v${opts.version}`);
271963
+ const model = c3.dim(`model: ${c3.white(opts.model)}`);
271964
+ process.stdout.write(` ${title} ${ver} ${c3.dim("\xB7")} ${model}
271965
+ `);
271966
+ lines++;
271967
+ const ws = opts.workspace.length > 60 ? "..." + opts.workspace.slice(-57) : opts.workspace;
271968
+ process.stdout.write(` ${c3.dim("workspace:")} ${c3.white(ws)}
271969
+ `);
271970
+ lines++;
271971
+ process.stdout.write(` ${divider}
271972
+ `);
271973
+ lines++;
271974
+ process.stdout.write(` ${c3.bold("Tools")} ${c3.dim(`(${TOOL_NAMES.length}):`)} `);
271975
+ let lineLen = 14;
271976
+ for (let i2 = 0; i2 < TOOL_NAMES.length; i2++) {
271977
+ const name10 = TOOL_NAMES[i2];
271978
+ const sep = i2 < TOOL_NAMES.length - 1 ? " " : "";
271979
+ if (lineLen + name10.length + 1 > w - 4) {
271980
+ process.stdout.write(`
271981
+ ${" ".repeat(14)}`);
271982
+ lineLen = 14;
271983
+ lines++;
271984
+ }
271985
+ process.stdout.write(`${c3.cyan(name10)}${sep}`);
271986
+ lineLen += name10.length + 1;
271987
+ }
271988
+ process.stdout.write("\n");
271989
+ lines++;
271990
+ process.stdout.write(` ${c3.bold("Commands:")} ${COMMAND_NAMES.map((cmd) => c3.yellow(cmd)).join(" ")}
271991
+ `);
271992
+ lines++;
271993
+ process.stdout.write(` ${divider}
271994
+ `);
271995
+ lines++;
271996
+ const hintIdx = Math.floor(Date.now() / 1e4) % HINTS.length;
271997
+ const hint = HINTS[hintIdx];
271998
+ process.stdout.write(` ${c3.dim("\u{1F4A1}")} ${c3.italic(c3.dim(hint))}
271999
+ `);
272000
+ lines++;
272001
+ process.stdout.write(` ${c3.dim("Type a task to begin, or /help for all commands.")}
272002
+
272003
+ `);
272004
+ lines += 2;
272005
+ return lines;
272006
+ }
272007
+ function renderHeader(model) {
272008
+ const w = getTermWidth();
272009
+ process.stdout.write("\n");
272010
+ process.stdout.write(` ${c3.bold(c3.cyan("open-agents"))} ${c3.dim(model)}
272011
+ `);
272012
+ process.stdout.write(` ${c3.dim("\u2500".repeat(Math.min(w - 4, 72)))}
272013
+ `);
272014
+ process.stdout.write(` ${c3.dim("Type a task, or use /help for commands. /quit to exit.")}
272015
+
272016
+ `);
272017
+ }
271912
272018
  function renderCompactHeader(model) {
271913
272019
  process.stdout.write(`
271914
272020
  ${c3.bold(c3.cyan("open-agents"))} ${c3.dim(`(${model})`)}
@@ -271926,6 +272032,25 @@ function renderSlashHelp() {
271926
272032
  }
271927
272033
  process.stdout.write("\n");
271928
272034
  }
272035
+ function renderModelList(models, current) {
272036
+ process.stdout.write(`
272037
+ ${c3.bold("Available models:")}
272038
+
272039
+ `);
272040
+ for (const m2 of models) {
272041
+ const isCurrent = m2.name === current;
272042
+ const marker = isCurrent ? c3.green("\u25CF") : c3.dim("\u25CB");
272043
+ const name10 = isCurrent ? c3.bold(c3.green(m2.name)) : m2.name;
272044
+ const size = c3.dim(m2.size);
272045
+ const modified = c3.dim(m2.modified);
272046
+ process.stdout.write(` ${marker} ${name10.padEnd(50)} ${size.padEnd(12)} ${modified}
272047
+ `);
272048
+ }
272049
+ process.stdout.write(`
272050
+ ${c3.dim("Use /model <name> to switch models.")}
272051
+
272052
+ `);
272053
+ }
271929
272054
  function renderModelSwitch(oldModel, newModel) {
271930
272055
  const redir = _contentWriteHook?.redirect?.();
271931
272056
  const text = `
@@ -271940,6 +272065,17 @@ function renderModelSwitch(oldModel, newModel) {
271940
272065
  process.stdout.write(text);
271941
272066
  _contentWriteHook?.end();
271942
272067
  }
272068
+ function renderConfig(config) {
272069
+ process.stdout.write(`
272070
+ ${c3.bold("Configuration:")}
272071
+
272072
+ `);
272073
+ for (const [key, value2] of Object.entries(config)) {
272074
+ process.stdout.write(` ${c3.cyan(key.padEnd(20))} ${value2}
272075
+ `);
272076
+ }
272077
+ process.stdout.write("\n");
272078
+ }
271943
272079
  function formatToolArgs(toolName, args, verbose) {
271944
272080
  const maxArg = verbose ? 1e4 : Math.max(40, getTermWidth() - 20);
271945
272081
  switch (toolName) {
@@ -272028,7 +272164,7 @@ function formatDuration2(ms) {
272028
272164
  const secs = Math.floor(totalSecs % 60);
272029
272165
  return `${mins}m ${secs}s`;
272030
272166
  }
272031
- var isTTY2, c3, _emojisEnabled, _colorsEnabled, MD, TOOL_ICONS, TOOL_LABELS, accent, accentBright, accentDim, accentWarm, accentSoft, TOOL_COLORS, _contentWriteHook, SLASH_COMMANDS;
272167
+ var isTTY2, c3, ui, pastel, _emojisEnabled, _colorsEnabled, MD, TOOL_ICONS, TOOL_LABELS, accent, accentBright, accentDim, accentWarm, accentSoft, TOOL_COLORS, _contentWriteHook, HINTS, TOOL_NAMES, COMMAND_NAMES, SLASH_COMMANDS;
272032
272168
  var init_render = __esm({
272033
272169
  "packages/cli/dist/tui/render.js"() {
272034
272170
  "use strict";
@@ -272049,6 +272185,36 @@ var init_render = __esm({
272049
272185
  bgBlue: (t2) => ansi2("44", t2),
272050
272186
  bgGreen: (t2) => ansi2("42", t2)
272051
272187
  };
272188
+ ui = {
272189
+ /** Primary text — lighter grey (252) for main content */
272190
+ primary: (t2) => fg256(252, t2),
272191
+ /** Sub-text — darker grey (245) for secondary info */
272192
+ sub: (t2) => fg256(245, t2),
272193
+ /** Dim text — very dark grey (240) for hints/placeholders */
272194
+ hint: (t2) => fg256(240, t2),
272195
+ /** Error text — magenta (bright) for errors */
272196
+ error: (t2) => fg256(198, t2),
272197
+ /** Warning text — warm orange for warnings */
272198
+ warn: (t2) => fg256(214, t2),
272199
+ /** Success text — green for confirmations */
272200
+ ok: (t2) => fg256(78, t2),
272201
+ /** Accent — yellow (178) matching header/banner */
272202
+ accent: (t2) => fg256(178, t2),
272203
+ /** Muted accent — dim yellow for secondary accent */
272204
+ accentDim: (t2) => fg256(136, t2)
272205
+ };
272206
+ pastel = {
272207
+ pink: (t2) => fg256(218, t2),
272208
+ peach: (t2) => fg256(216, t2),
272209
+ lavender: (t2) => fg256(183, t2),
272210
+ mint: (t2) => fg256(158, t2),
272211
+ sky: (t2) => fg256(117, t2),
272212
+ coral: (t2) => fg256(209, t2),
272213
+ lilac: (t2) => fg256(177, t2),
272214
+ sage: (t2) => fg256(151, t2),
272215
+ butter: (t2) => fg256(229, t2),
272216
+ ice: (t2) => fg256(153, t2)
272217
+ };
272052
272218
  _emojisEnabled = false;
272053
272219
  _colorsEnabled = true;
272054
272220
  MD = {
@@ -272181,6 +272347,78 @@ var init_render = __esm({
272181
272347
  ask_user: accentBright
272182
272348
  };
272183
272349
  _contentWriteHook = null;
272350
+ HINTS = [
272351
+ "Ask the agent to connect to the Open Agents Nexus for P2P agent networking",
272352
+ "Use /voice to enable TTS voice feedback while the agent works",
272353
+ "Drop an image file onto the terminal to give the agent visual context",
272354
+ "Type while the agent works (+ prompt) to steer its approach",
272355
+ "Press Ctrl+C to abort the current task",
272356
+ "Use /model to switch between available Ollama models",
272357
+ "Use /endpoint to connect to remote vLLM or OpenAI-compatible APIs",
272358
+ "Create AGENTS.md or OA.md in your project root for custom instructions",
272359
+ "The agent stores learned patterns in .oa/memory/ for future sessions",
272360
+ "Use /update to check for and install the latest version",
272361
+ "The agent can take screenshots and OCR text from images autonomously",
272362
+ "Sub-agents can run independent tasks in parallel via sub_agent tool",
272363
+ "Background tasks let the agent run tests while making other changes",
272364
+ "Use /nexus connect to join the decentralized agent mesh network"
272365
+ ];
272366
+ TOOL_NAMES = [
272367
+ "file_read",
272368
+ "file_write",
272369
+ "file_edit",
272370
+ "file_patch",
272371
+ "shell",
272372
+ "grep_search",
272373
+ "find_files",
272374
+ "list_directory",
272375
+ "web_search",
272376
+ "web_fetch",
272377
+ "memory_read",
272378
+ "memory_write",
272379
+ "batch_edit",
272380
+ "codebase_map",
272381
+ "diagnostic",
272382
+ "git_info",
272383
+ "background_run",
272384
+ "task_status",
272385
+ "task_output",
272386
+ "task_stop",
272387
+ "sub_agent",
272388
+ "image_read",
272389
+ "screenshot",
272390
+ "ocr",
272391
+ "transcribe_file",
272392
+ "transcribe_url",
272393
+ "aiwg_setup",
272394
+ "aiwg_health",
272395
+ "aiwg_workflow",
272396
+ "create_tool",
272397
+ "manage_tools",
272398
+ "ask_user",
272399
+ "task_complete"
272400
+ ];
272401
+ COMMAND_NAMES = [
272402
+ "/model",
272403
+ "/models",
272404
+ "/endpoint",
272405
+ "/config",
272406
+ "/update",
272407
+ "/voice",
272408
+ "/listen",
272409
+ "/call",
272410
+ "/hangup",
272411
+ "/stream",
272412
+ "/verbose",
272413
+ "/dream",
272414
+ "/bruteforce",
272415
+ "/compact",
272416
+ "/tools",
272417
+ "/skills",
272418
+ "/clear",
272419
+ "/help",
272420
+ "/quit"
272421
+ ];
272184
272422
  SLASH_COMMANDS = [
272185
272423
  ["/model", "Select from available models"],
272186
272424
  ["/model <name>", "Switch to a specific model"],
@@ -278593,9 +278831,9 @@ var init_daemon_registry = __esm({
278593
278831
  */
278594
278832
  renderBar(width) {
278595
278833
  this.refresh();
278596
- const { tuiBgSeq: tuiBgSeq2 } = (init_theme(), __toCommonJS(theme_exports));
278597
- const PANEL_BG = tuiBgSeq2();
278598
- const BTN_BG = tuiBgSeq2();
278834
+ const { tuiBgSeq: tuiBgSeq3 } = (init_theme(), __toCommonJS(theme_exports));
278835
+ const PANEL_BG = tuiBgSeq3();
278836
+ const BTN_BG = tuiBgSeq3();
278599
278837
  let bar = "";
278600
278838
  for (const [, d2] of this.daemons) {
278601
278839
  const dotColor = d2.status === "running" ? "32" : (
@@ -278742,10 +278980,10 @@ function unlockFooterRedraws() {
278742
278980
  _globalFooterLock = false;
278743
278981
  }
278744
278982
  function refreshThemeVars() {
278745
- PANEL_BG_SEQ = tuiBgSeq();
278746
- CONTENT_BG_SEQ = tuiBgSeq();
278983
+ PANEL_BG_SEQ = tuiBgSeq2();
278984
+ CONTENT_BG_SEQ = tuiBgSeq2();
278747
278985
  BOX_FG = tuiBoxFg();
278748
- TEXT_PRIMARY = tuiTextPrimary() < 0 ? 252 : tuiTextPrimary();
278986
+ TEXT_PRIMARY = tuiTextPrimary2() < 0 ? 252 : tuiTextPrimary2();
278749
278987
  TEXT_DIM = tuiTextDim();
278750
278988
  }
278751
278989
  function setTerminalTitle(task, version4) {
@@ -278924,10 +279162,10 @@ var init_status_bar = __esm({
278924
279162
  return this.toolCalls > 0;
278925
279163
  }
278926
279164
  };
278927
- PANEL_BG_SEQ = tuiBgSeq();
278928
- CONTENT_BG_SEQ = tuiBgSeq();
279165
+ PANEL_BG_SEQ = tuiBgSeq2();
279166
+ CONTENT_BG_SEQ = tuiBgSeq2();
278929
279167
  BOX_FG = tuiBoxFg();
278930
- TEXT_PRIMARY = tuiTextPrimary() < 0 ? 252 : tuiTextPrimary();
279168
+ TEXT_PRIMARY = tuiTextPrimary2() < 0 ? 252 : tuiTextPrimary2();
278931
279169
  TEXT_DIM = tuiTextDim();
278932
279170
  BOX_TL = "\u256D";
278933
279171
  BOX_TR = "\u256E";
@@ -280510,7 +280748,7 @@ var init_status_bar = __esm({
280510
280748
  _origWrite = null;
280511
280749
  /** True stdout.write captured at construction — immune to interceptor stacking */
280512
280750
  _trueStdoutWrite = process.stdout.write.bind(process.stdout);
280513
- /** Write directly to the terminal, bypassing content bg monkey-patch.
280751
+ /** Write directly to the terminal, bypassing content bg/scrollback monkey-patch.
280514
280752
  * ALL footer/input/braille rendering MUST use this, never process.stdout.write.
280515
280753
  * Respects overlay isolation — when tuiSelect/dropPanel is on alt screen,
280516
280754
  * footer writes are suppressed to prevent corrupting the overlay display. */
@@ -280544,14 +280782,30 @@ var init_status_bar = __esm({
280544
280782
  if (this.writeDepth === 1 && !this._origWrite) {
280545
280783
  this._origWrite = this._trueStdoutWrite;
280546
280784
  const origBound = this._trueStdoutWrite;
280547
- process.stdout.write = ((chunk, ...args) => {
280785
+ const self2 = this;
280786
+ const bufferedWrite = function(chunk, ...args) {
280787
+ let text;
280788
+ if (typeof chunk === "string")
280789
+ text = chunk;
280790
+ else if (Buffer.isBuffer(chunk))
280791
+ text = chunk.toString();
280792
+ else
280793
+ text = String(chunk);
280794
+ const lines = text.split("\n");
280795
+ for (const line of lines) {
280796
+ const visible = line.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "");
280797
+ if (visible.trim().length > 0)
280798
+ self2.bufferContentLine(line);
280799
+ }
280548
280800
  if (typeof chunk === "string") {
280549
- chunk = chunk.replace(/\x1B\[0m/g, `\x1B[0m${CONTENT_BG_SEQ}`);
280550
- chunk = chunk.replace(/\n/g, `\x1B[K
280801
+ chunk = chunk.replace(/\x1B\[0m/g, `\x1B[0m${CONTENT_BG_SEQ}`).replace(/\n/g, `\x1B[K
280551
280802
  ${CONTENT_BG_SEQ}`);
280552
280803
  }
280553
- return origBound(chunk, ...args);
280554
- });
280804
+ return origBound.call(process.stdout, chunk, ...args);
280805
+ };
280806
+ bufferedWrite.__oa_oaWriteLayer = "statusbar";
280807
+ bufferedWrite.__oa_buffer_lines = true;
280808
+ process.stdout.write = bufferedWrite;
280555
280809
  }
280556
280810
  this.termWrite("\x1B[?2026h");
280557
280811
  process.stdout.write(`\x1B[?25l` + // hide cursor
@@ -280574,6 +280828,14 @@ ${CONTENT_BG_SEQ}`);
280574
280828
  this.writeDepth = Math.max(0, this.writeDepth - 1);
280575
280829
  if (this.writeDepth === 0) {
280576
280830
  if (this._origWrite) {
280831
+ try {
280832
+ delete process.stdout.write.__oa_oaWriteLayer;
280833
+ } catch {
280834
+ }
280835
+ try {
280836
+ delete process.stdout.write.__oa_buffer_lines;
280837
+ } catch {
280838
+ }
280577
280839
  process.stdout.write = this._origWrite;
280578
280840
  this._origWrite = null;
280579
280841
  }
@@ -280768,8 +281030,8 @@ ${CONTENT_BG_SEQ}`);
280768
281030
  buildMetricsLine() {
280769
281031
  const m2 = this.metrics;
280770
281032
  const termWidth = getTermWidth();
280771
- const pastel = (code8, s2) => `${PANEL_BG_SEQ}\x1B[38;5;${code8}m${s2}\x1B[0m${PANEL_BG_SEQ}`;
280772
- const pipe3 = pastel(60, " \u2502 ");
281033
+ const pastel2 = (code8, s2) => `${PANEL_BG_SEQ}\x1B[38;5;${code8}m${s2}\x1B[0m${PANEL_BG_SEQ}`;
281034
+ const pipe3 = pastel2(60, " \u2502 ");
280773
281035
  const pipeW = 3;
280774
281036
  const sections = [];
280775
281037
  const compactOrder = [];
@@ -280783,8 +281045,8 @@ ${CONTENT_BG_SEQ}`);
280783
281045
  const effectiveOut = this.effectiveCompletionTokens;
280784
281046
  const tokOutRaw = effectiveOut > 0 ? effectiveOut : Math.ceil(m2.totalTokens > 0 ? m2.totalTokens - m2.promptTokens : m2.estimatedContextTokens * 0.3);
280785
281047
  const tokOutVal = Math.max(0, tokOutRaw);
280786
- const tokExpanded = pastel(117, "\u2191") + c3.bold(tokInRaw.toLocaleString()) + " " + pastel(151, "\u2193") + c3.bold(tokOutVal.toLocaleString());
280787
- const tokCompact = pastel(117, "\u2191") + c3.bold(_StatusBar.compactNum(tokInRaw)) + " " + pastel(151, "\u2193") + c3.bold(_StatusBar.compactNum(tokOutVal));
281048
+ const tokExpanded = pastel2(117, "\u2191") + c3.bold(tokInRaw.toLocaleString()) + " " + pastel2(151, "\u2193") + c3.bold(tokOutVal.toLocaleString());
281049
+ const tokCompact = pastel2(117, "\u2191") + c3.bold(_StatusBar.compactNum(tokInRaw)) + " " + pastel2(151, "\u2193") + c3.bold(_StatusBar.compactNum(tokOutVal));
280788
281050
  const tokExpW = 1 + tokInRaw.toLocaleString().length + 1 + 1 + tokOutVal.toLocaleString().length;
280789
281051
  const tokCompW = 1 + _StatusBar.compactNum(tokInRaw).length + 1 + 1 + _StatusBar.compactNum(tokOutVal).length;
280790
281052
  sections.push({ expanded: tokExpanded, compact: tokCompact, expandedW: tokExpW, compactW: tokCompW, empty: false });
@@ -280816,14 +281078,14 @@ ${CONTENT_BG_SEQ}`);
280816
281078
  if (this._modelName) {
280817
281079
  const paramMatch = this._modelName.match(/(\d+\.?\d*[bBmM])/);
280818
281080
  const paramStr = paramMatch ? paramMatch[1] : this._modelName.split(":")[0]?.split("/").pop() ?? this._modelName;
280819
- const modelExpanded = pastel(146, this._modelName) + (capsStr ? " " + pastel(183, capParts.join(" ")) : "") + ctxSuffix;
280820
- const modelCompact = (capParts.length > 0 ? pastel(183, capParts.join(" ")) : pastel(146, paramStr)) + ctxCompSuffix;
281081
+ const modelExpanded = pastel2(146, this._modelName) + (capsStr ? " " + pastel2(183, capParts.join(" ")) : "") + ctxSuffix;
281082
+ const modelCompact = (capParts.length > 0 ? pastel2(183, capParts.join(" ")) : pastel2(146, paramStr)) + ctxCompSuffix;
280821
281083
  const expW = this._modelName.length + capsVisW + ctxSuffixW;
280822
281084
  const compW = (capParts.length > 0 ? capParts.length * 2 + (capParts.length - 1) : paramStr.length) + ctxCompSuffixW;
280823
281085
  modelSectionIdx = sections.length;
280824
281086
  sections.push({ expanded: modelExpanded, compact: modelCompact, expandedW: expW, compactW: compW, empty: false });
280825
281087
  } else if (capParts.length > 0) {
280826
- const capsOnly = pastel(183, capParts.join(" ")) + ctxCompSuffix;
281088
+ const capsOnly = pastel2(183, capParts.join(" ")) + ctxCompSuffix;
280827
281089
  const capsOnlyW = capParts.length * 2 + (capParts.length - 1) + ctxCompSuffixW;
280828
281090
  sections.push({ expanded: capsOnly, compact: capsOnly, expandedW: capsOnlyW, compactW: capsOnlyW, empty: false });
280829
281091
  } else if (ctxTotal > 0) {
@@ -280835,13 +281097,13 @@ ${CONTENT_BG_SEQ}`);
280835
281097
  const snrColor = snrPct >= 70 ? c3.green : snrPct >= 40 ? c3.yellow : c3.red;
280836
281098
  const dPrimeStr = this._snr.dPrime.toFixed(1);
280837
281099
  const capStr = this._snr.capacityWarning ? c3.red(" !CAP") : "";
280838
- const snrExpanded = pastel(183, "SNR ") + snrColor(c3.bold(`${snrPct}%`)) + c3.dim(` d'${dPrimeStr}`) + capStr;
281100
+ const snrExpanded = pastel2(183, "SNR ") + snrColor(c3.bold(`${snrPct}%`)) + c3.dim(` d'${dPrimeStr}`) + capStr;
280839
281101
  const snrCompact = snrColor(`${snrPct}%`);
280840
281102
  const expW = 4 + `${snrPct}%`.length + 3 + dPrimeStr.length + (this._snr.capacityWarning ? 5 : 0);
280841
281103
  sections.push({ expanded: snrExpanded, compact: snrCompact, expandedW: expW, compactW: `${snrPct}%`.length, empty: false });
280842
281104
  }
280843
281105
  if (this._emotion) {
280844
- const emotionExpanded = this._emotion.emoji + " " + pastel(183, this._emotion.label);
281106
+ const emotionExpanded = this._emotion.emoji + " " + pastel2(183, this._emotion.label);
280845
281107
  const emotionCompact = this._emotion.emoji;
280846
281108
  sections.push({
280847
281109
  expanded: emotionExpanded,
@@ -280856,7 +281118,7 @@ ${CONTENT_BG_SEQ}`);
280856
281118
  if (ratio > 0) {
280857
281119
  const ratioStr = ratio >= 10 ? `${Math.round(ratio)}x` : `${ratio.toFixed(1)}x`;
280858
281120
  const ratioColor = ratio >= 2 ? c3.green : ratio >= 1 ? c3.yellow : c3.red;
280859
- const speedExpanded = pastel(218, "Exp ") + ratioColor(c3.bold(ratioStr));
281121
+ const speedExpanded = pastel2(218, "Exp ") + ratioColor(c3.bold(ratioStr));
280860
281122
  sections.push({
280861
281123
  expanded: speedExpanded,
280862
281124
  compact: speedExpanded,
@@ -280868,7 +281130,7 @@ ${CONTENT_BG_SEQ}`);
280868
281130
  }
280869
281131
  if (m2.hasPricing && m2.estimatedCost !== void 0) {
280870
281132
  const costStr = m2.estimatedCost < 0.01 ? `$${m2.estimatedCost.toFixed(4)}` : m2.estimatedCost < 1 ? `$${m2.estimatedCost.toFixed(3)}` : `$${m2.estimatedCost.toFixed(2)}`;
280871
- const costExpanded = pastel(222, "Cost ") + c3.bold(costStr);
281133
+ const costExpanded = pastel2(222, "Cost ") + c3.bold(costStr);
280872
281134
  const costCompact = c3.bold(costStr);
280873
281135
  sections.push({
280874
281136
  expanded: costExpanded,
@@ -280891,8 +281153,8 @@ ${CONTENT_BG_SEQ}`);
280891
281153
  const visibleReqs = Array.from(this._expose.modelUsage.entries()).filter(([m3]) => !INTERNAL_CAPS.has(m3)).reduce((sum, [, n2]) => sum + n2, 0);
280892
281154
  const reqStr = visibleReqs > 0 ? ` ${visibleReqs}req` : "";
280893
281155
  const connStr = this._expose.activeConnections > 0 ? ` ${this._expose.activeConnections}conn` : "";
280894
- const exposeExpanded = statusEmoji + pastel(183, (modelStr ? " " + modelStr : "") + reqStr + connStr);
280895
- const exposeCompact = statusEmoji + (modelStr ? pastel(183, " " + modelStr) : "");
281156
+ const exposeExpanded = statusEmoji + pastel2(183, (modelStr ? " " + modelStr : "") + reqStr + connStr);
281157
+ const exposeCompact = statusEmoji + (modelStr ? pastel2(183, " " + modelStr) : "");
280896
281158
  const expFullStr = (modelStr ? " " + modelStr : "") + reqStr + connStr;
280897
281159
  const expCompStr = modelStr ? " " + modelStr : "";
280898
281160
  sections.push({
@@ -280907,7 +281169,7 @@ ${CONTENT_BG_SEQ}`);
280907
281169
  const um = this._unifiedMetrics ?? getInstantSnapshot();
280908
281170
  const rm3 = um.hardware;
280909
281171
  const isLocal = um.source === "local";
280910
- const srcTag = isLocal ? pastel(120, "L") : pastel(117, "R");
281172
+ const srcTag = isLocal ? pastel2(120, "L") : pastel2(117, "R");
280911
281173
  const srcW = 1;
280912
281174
  let hwExpStr = "";
280913
281175
  let hwCompStr = "";
@@ -280955,7 +281217,7 @@ ${CONTENT_BG_SEQ}`);
280955
281217
  const net5 = um.network;
280956
281218
  const rxStr = formatRate(net5.rxBytesPerSec);
280957
281219
  const txStr = formatRate(net5.txBytesPerSec);
280958
- const netExpStr = ` ${pastel(116, "\u2193" + rxStr)} ${pastel(218, "\u2191" + txStr)}`;
281220
+ const netExpStr = ` ${pastel2(116, "\u2193" + rxStr)} ${pastel2(218, "\u2191" + txStr)}`;
280959
281221
  const netCompStr = netExpStr;
280960
281222
  const netW = 1 + 1 + rxStr.length + 1 + 1 + txStr.length;
280961
281223
  const sysExpanded = srcTag + " " + hwExpStr + netExpStr;
@@ -280969,15 +281231,15 @@ ${CONTENT_BG_SEQ}`);
280969
281231
  });
280970
281232
  }
280971
281233
  if (this._recording) {
280972
- const dot = this._recBlink ? pastel(210, "\u25CF") : " ";
281234
+ const dot = this._recBlink ? pastel2(210, "\u25CF") : " ";
280973
281235
  const countdown = this._countdown > 0 ? c3.dim(` ${this._countdown}s`) : "";
280974
- const recStr = dot + pastel(210, " REC") + countdown;
281236
+ const recStr = dot + pastel2(210, " REC") + countdown;
280975
281237
  const recW = 1 + 4 + (this._countdown > 0 ? 1 + `${this._countdown}s`.length : 0);
280976
281238
  sections.push({ expanded: recStr, compact: recStr, expandedW: recW, compactW: recW, empty: false });
280977
281239
  }
280978
281240
  if (this._version) {
280979
281241
  versionSectionIdx = sections.length;
280980
- const vStr = pastel(245, "v" + this._version);
281242
+ const vStr = pastel2(245, "v" + this._version);
280981
281243
  const vW = 1 + this._version.length;
280982
281244
  sections.push({ expanded: vStr, compact: vStr, expandedW: vW, compactW: vW, empty: false });
280983
281245
  }
@@ -281745,7 +282007,7 @@ function tuiSelect(opts) {
281745
282007
  }
281746
282008
  stdin.resume();
281747
282009
  enterOverlay();
281748
- overlayWrite(`\x1B[?1049h${tuiBgSeq()}\x1B[2J\x1B[H\x1B[?25l\x1B[?1003h\x1B[?1006h`);
282010
+ overlayWrite(`\x1B[?1049h${tuiBgSeq2()}\x1B[2J\x1B[H\x1B[?25l\x1B[?1003h\x1B[?1006h`);
281749
282011
  let listRowOffset = 0;
281750
282012
  let backBtnHovered = false;
281751
282013
  function clampScroll(displayList) {
@@ -281766,11 +282028,11 @@ function tuiSelect(opts) {
281766
282028
  if (!opts.maxVisible) {
281767
282029
  maxVisible = Math.max(3, currentRows - selectChrome);
281768
282030
  }
281769
- overlayWrite(`${tuiBgSeq()}\x1B[H\x1B[2J`);
282031
+ overlayWrite(`${tuiBgSeq2()}\x1B[H\x1B[2J`);
281770
282032
  const lines = [];
281771
282033
  const backLabel = hasBreadcrumbs ? "\u2190 back" : "\u2190 close";
281772
282034
  const backHighlighted = backBtnHovered;
281773
- const backStyle = backHighlighted ? `\x1B[7m\x1B[38;5;245m ${backLabel} \x1B[0m${tuiBgSeq()}` : `${selectColors.dim(` ${backLabel} `)}`;
282035
+ const backStyle = backHighlighted ? `\x1B[7m\x1B[38;5;245m ${backLabel} \x1B[0m${tuiBgSeq2()}` : `${selectColors.dim(` ${backLabel} `)}`;
281774
282036
  lines.push(backStyle);
281775
282037
  if (hasBreadcrumbs) {
281776
282038
  const trail = opts.breadcrumbs.map((b) => selectColors.dim(b)).join(selectColors.dim(" \u203A "));
@@ -281849,9 +282111,9 @@ function tuiSelect(opts) {
281849
282111
  const escLabel = filter2 ? "clear filter" : hasBreadcrumbs ? "\u2190 back" : "cancel";
281850
282112
  lines.push(` ${selectColors.dim("\u2191/\u2193 navigate Enter/Click select" + actionHint + deleteHint + customHint + " Esc " + escLabel + " Type to filter")}`);
281851
282113
  }
281852
- let output = lines.join("\n").replace(/\x1B\[0m/g, `\x1B[0m${tuiBgSeq()}`).replace(/\n/g, `\x1B[K
281853
- ${tuiBgSeq()}`);
281854
- overlayWrite(tuiBgSeq() + output + "\x1B[K");
282114
+ let output = lines.join("\n").replace(/\x1B\[0m/g, `\x1B[0m${tuiBgSeq2()}`).replace(/\n/g, `\x1B[K
282115
+ ${tuiBgSeq2()}`);
282116
+ overlayWrite(tuiBgSeq2() + output + "\x1B[K");
281855
282117
  lastRenderedLines = lines.length;
281856
282118
  }
281857
282119
  function cleanup() {
@@ -285496,6 +285758,10 @@ async function startNeovimMode(opts) {
285496
285758
  {
285497
285759
  const btns = [
285498
285760
  { label: " \u2190 back ", action: "back" },
285761
+ { label: " open ", action: "open" },
285762
+ { label: " find ", action: "find" },
285763
+ { label: " split ", action: "split" },
285764
+ { label: " term ", action: "terminal" },
285499
285765
  { label: " undo ", action: "undo" },
285500
285766
  { label: " redo ", action: "redo" },
285501
285767
  { label: " save ", action: "save" }
@@ -285509,12 +285775,15 @@ async function startNeovimMode(opts) {
285509
285775
  function renderToolbar() {
285510
285776
  if (!isTTY5)
285511
285777
  return;
285778
+ const L = layout();
285779
+ const hdrRow = L.headerContent;
285780
+ const fg2 = tuiTextPrimary() < 0 ? 252 : tuiTextPrimary();
285512
285781
  let buf = "\x1B7";
285513
- buf += `\x1B[2;1H\x1B[49m\x1B[2K`;
285782
+ buf += `\x1B[${hdrRow};1H${tuiBgSeq()}\x1B[2K`;
285514
285783
  for (const btn of toolbarBtns) {
285515
- buf += `\x1B[2;${btn.startCol}H`;
285784
+ buf += `\x1B[${hdrRow};${btn.startCol}H`;
285516
285785
  buf += `\x1B]8;;oa-cmd:${btn.action}\x07`;
285517
- buf += `\x1B[38;5;245m\x1B[49m${btn.label}`;
285786
+ buf += `\x1B[38;5;${fg2}m${tuiBgSeq()}${btn.label}`;
285518
285787
  buf += `\x1B]8;;\x07`;
285519
285788
  }
285520
285789
  buf += "\x1B[0m\x1B8";
@@ -285571,13 +285840,22 @@ async function startNeovimMode(opts) {
285571
285840
  toggleFocus(state);
285572
285841
  return;
285573
285842
  }
285574
- const toolbarClick = seq.match(/\x1B\[<0;(\d+);2M/);
285843
+ const hdrRow = layout().headerContent;
285844
+ const toolbarClick = seq.match(new RegExp(`\\x1B\\[<0;(\\d+);${hdrRow}M`));
285575
285845
  if (toolbarClick) {
285576
285846
  const clickCol = parseInt(toolbarClick[1]);
285577
285847
  for (const btn of toolbarBtns) {
285578
285848
  if (clickCol >= btn.startCol && clickCol <= btn.endCol) {
285579
285849
  if (btn.action === "back") {
285580
285850
  doCleanup(state);
285851
+ } else if (btn.action === "open") {
285852
+ nvimPty.write("\x1B:Telescope find_files\r");
285853
+ } else if (btn.action === "find") {
285854
+ nvimPty.write("\x1B:Telescope live_grep\r");
285855
+ } else if (btn.action === "split") {
285856
+ nvimPty.write("\x1B:vs\r");
285857
+ } else if (btn.action === "terminal") {
285858
+ nvimPty.write("\x1B:belowright split | terminal\r");
285581
285859
  } else if (btn.action === "undo") {
285582
285860
  nvimPty.write("\x1B:undo\r");
285583
285861
  } else if (btn.action === "redo") {
@@ -285589,23 +285867,22 @@ async function startNeovimMode(opts) {
285589
285867
  }
285590
285868
  }
285591
285869
  }
285592
- if (seq.match(/\x1B\[<0;(\d+);1M/))
285870
+ if (seq.match(new RegExp(`\\x1B\\[<0;(\\d+);${layout().headerTop}M`)))
285593
285871
  return;
285594
285872
  if (state.focused) {
285595
285873
  let normalized = seq.replace(/\x1BO([ABCD])/g, "\x1B[$1");
285596
- if (topOffset > 0) {
285597
- normalized = normalized.replace(/\x1B\[<(\d+);(\d+);(\d+)([Mm])/g, (_m, btn, col, row, suffix) => {
285598
- const hostRow = parseInt(row);
285599
- if (parseInt(btn) === 0 && suffix === "M" && hostRow > topOffset + ptyRows) {
285600
- toggleFocus(state);
285601
- return "";
285602
- }
285603
- if (hostRow <= topOffset)
285604
- return "";
285605
- const nvimRow = hostRow - topOffset;
285606
- return `\x1B[<${btn};${col};${nvimRow}${suffix}`;
285607
- });
285608
- }
285874
+ normalized = normalized.replace(/\x1B\[<(\d+);(\d+);(\d+)([Mm])/g, (_m, btn, col, row, suffix) => {
285875
+ const L = layout();
285876
+ const hostRow = parseInt(row);
285877
+ if (parseInt(btn) === 0 && suffix === "M" && hostRow > L.contentBottom) {
285878
+ toggleFocus(state);
285879
+ return "";
285880
+ }
285881
+ if (hostRow < L.contentTop)
285882
+ return "";
285883
+ const nvimRow = hostRow - (L.contentTop - 1);
285884
+ return `\x1B[<${btn};${col};${nvimRow}${suffix}`;
285885
+ });
285609
285886
  if (normalized)
285610
285887
  nvimPty.write(normalized);
285611
285888
  }
@@ -289471,8 +289748,10 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
289471
289748
  });
289472
289749
  if (brewResult.stdout)
289473
289750
  process.stdout.write(brewResult.stdout);
289474
- if (brewResult.stderr)
289475
- process.stderr.write(brewResult.stderr);
289751
+ if (brewResult.stderr) {
289752
+ const { renderVerbose: renderVerbose2 } = await Promise.resolve().then(() => (init_render(), render_exports));
289753
+ renderVerbose2(brewResult.stderr);
289754
+ }
289476
289755
  const llvmPrefix = spawnSync2("brew", ["--prefix", "llvm"], { stdio: "pipe", timeout: 5e3 });
289477
289756
  if (llvmPrefix.stdout) {
289478
289757
  const prefix = llvmPrefix.stdout.toString().trim();
@@ -289507,8 +289786,10 @@ Error: ${err2 instanceof Error ? err2.message : String(err2)}`);
289507
289786
  ], { stdio: "pipe", timeout: 12e4 });
289508
289787
  if (aptResult.stdout)
289509
289788
  process.stdout.write(aptResult.stdout);
289510
- if (aptResult.stderr)
289511
- process.stderr.write(aptResult.stderr);
289789
+ if (aptResult.stderr) {
289790
+ const { renderVerbose: renderVerbose2 } = await Promise.resolve().then(() => (init_render(), render_exports));
289791
+ renderVerbose2(aptResult.stderr);
289792
+ }
289512
289793
  } else {
289513
289794
  renderWarning(" sudo not available \u2014 skipping system build deps. librosa/lhotse may fail to compile.");
289514
289795
  }
@@ -308490,24 +308771,24 @@ function gatherMemorySnippets(root) {
308490
308771
  }
308491
308772
  return snippets;
308492
308773
  }
308493
- function createDMNEventHandler(verbose, writeContent) {
308774
+ function createDMNEventHandler(verbose, writeContent2) {
308494
308775
  return (event) => {
308495
308776
  switch (event.type) {
308496
308777
  case "tool_call":
308497
308778
  if (verbose) {
308498
- writeContent(() => {
308779
+ writeContent2(() => {
308499
308780
  const args = event.toolArgs ?? {};
308500
308781
  renderToolCallStart(event.toolName ?? "unknown", args, true);
308501
308782
  });
308502
308783
  } else {
308503
308784
  const argSummary = formatDMNToolArgs(event.toolName ?? "", event.toolArgs ?? {});
308504
- writeContent(() => process.stdout.write(` ${c3.dim(`DMN \u2192 ${event.toolName}`)}${argSummary ? c3.dim(`: ${argSummary}`) : ""}
308785
+ writeContent2(() => process.stdout.write(` ${c3.dim(`DMN \u2192 ${event.toolName}`)}${argSummary ? c3.dim(`: ${argSummary}`) : ""}
308505
308786
  `));
308506
308787
  }
308507
308788
  break;
308508
308789
  case "tool_result":
308509
308790
  if (verbose) {
308510
- writeContent(() => {
308791
+ writeContent2(() => {
308511
308792
  renderToolResult(event.toolName ?? "unknown", event.success ?? false, event.content ?? "", true);
308512
308793
  });
308513
308794
  }
@@ -308515,12 +308796,12 @@ function createDMNEventHandler(verbose, writeContent) {
308515
308796
  case "model_response":
308516
308797
  if (verbose && event.content) {
308517
308798
  const preview = event.content.length > 200 ? event.content.slice(0, 200) + "..." : event.content;
308518
- writeContent(() => renderVerbose(`DMN thinking: ${preview}`));
308799
+ writeContent2(() => renderVerbose(`DMN thinking: ${preview}`));
308519
308800
  }
308520
308801
  break;
308521
308802
  case "token_usage":
308522
308803
  if (verbose && event.tokenUsage) {
308523
- writeContent(() => renderVerbose(`DMN tokens \u2014 prompt: ${event.tokenUsage.promptTokens} | completion: ${event.tokenUsage.completionTokens} | ctx: ~${event.tokenUsage.estimatedContextTokens.toLocaleString()}`));
308804
+ writeContent2(() => renderVerbose(`DMN tokens \u2014 prompt: ${event.tokenUsage.promptTokens} | completion: ${event.tokenUsage.completionTokens} | ctx: ~${event.tokenUsage.estimatedContextTokens.toLocaleString()}`));
308524
308805
  }
308525
308806
  break;
308526
308807
  }
@@ -308781,22 +309062,19 @@ RULES:
308781
309062
  }
308782
309063
  backend = new CascadeBackend(config.model, [primaryEndpoint, ...fallbackEndpoints], {
308783
309064
  onSwitch: (_from, to, reason) => {
308784
- const msg = `
308785
- [cascade] Failover \u2192 ${to.label ?? to.url}: ${reason}
308786
- `;
309065
+ const msg = `[cascade] Failover \u2192 ${to.label ?? to.url}: ${reason}`;
308787
309066
  if (isNeovimActive()) {
308788
- writeToNeovimOutput(msg);
308789
- } else if (!bufferIfOverlay("stderr", msg))
308790
- process.stderr.write(msg);
309067
+ writeToNeovimOutput("\n" + msg + "\n");
309068
+ } else if (!bufferIfOverlay("stderr", msg + "\n"))
309069
+ writeContent(() => renderWarning(msg));
308791
309070
  },
308792
309071
  onProbeResult: (ep, success) => {
308793
309072
  if (success) {
308794
- const msg = `[cascade] Primary recovered: ${ep.label ?? ep.url}
308795
- `;
309073
+ const msg = `[cascade] Primary recovered: ${ep.label ?? ep.url}`;
308796
309074
  if (isNeovimActive()) {
308797
- writeToNeovimOutput(msg);
308798
- } else if (!bufferIfOverlay("stderr", msg))
308799
- process.stderr.write(msg);
309075
+ writeToNeovimOutput(msg + "\n");
309076
+ } else if (!bufferIfOverlay("stderr", msg + "\n"))
309077
+ writeContent(() => renderInfo(msg));
308800
309078
  }
308801
309079
  }
308802
309080
  });
@@ -309229,21 +309507,26 @@ ${entry.fullContent}`
309229
309507
  }
309230
309508
  if (statusBar?.isActive) {
309231
309509
  statusBar.beginContentWrite();
309232
- const postInterceptWrite = process.stdout.write;
309233
- const boundWrite = postInterceptWrite.bind(process.stdout);
309234
- process.stdout.write = ((chunk, ...args) => {
309235
- const text = typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk);
309236
- for (const line of text.split("\n")) {
309237
- if (line.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "").length > 0) {
309238
- statusBar.bufferContentLine(line);
309510
+ const alreadyBuffered = process.stdout.write.__oa_buffer_lines === true;
309511
+ let postInterceptWrite = null;
309512
+ if (!alreadyBuffered) {
309513
+ postInterceptWrite = process.stdout.write;
309514
+ const boundWrite = postInterceptWrite.bind(process.stdout);
309515
+ process.stdout.write = ((chunk, ...args) => {
309516
+ const text = typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk);
309517
+ for (const line of text.split("\n")) {
309518
+ if (line.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "").length > 0) {
309519
+ statusBar.bufferContentLine(line);
309520
+ }
309239
309521
  }
309240
- }
309241
- return boundWrite(chunk, ...args);
309242
- });
309522
+ return boundWrite(chunk, ...args);
309523
+ });
309524
+ }
309243
309525
  try {
309244
309526
  fn();
309245
309527
  } finally {
309246
- process.stdout.write = postInterceptWrite;
309528
+ if (postInterceptWrite)
309529
+ process.stdout.write = postInterceptWrite;
309247
309530
  statusBar.endContentWrite();
309248
309531
  }
309249
309532
  } else {
@@ -309778,7 +310061,7 @@ async function startInteractive(config, repoPath) {
309778
310061
  setTermSize(process.stdout.rows ?? 24, process.stdout.columns ?? 80);
309779
310062
  process.stdout.write("\x1B[2J\x1B[3J\x1B]50;ClearScrollback\x07\x1B[H");
309780
310063
  process.stdout.write("\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?1015l\x1B[?1049h" + // enter alternate screen buffer
309781
- tuiBgSeq() + // theme bg for content area
310064
+ tuiBgSeq2() + // theme bg for content area
309782
310065
  `\x1B[2J\x1B[3J\x1B[H\x1B[1;${termRows()}r\x1B[?25l`);
309783
310066
  const restoreScreen = () => {
309784
310067
  process.stdout.write("\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?1015l\x1B[?25h\x1B[?1049l");
@@ -310133,7 +310416,7 @@ ${opts.systemPromptAddition}` : `Working directory: ${repoRoot}`;
310133
310416
  const { getLastTaskSummary: getLastTaskSummary2 } = (init_oa_directory(), __toCommonJS(oa_directory_exports));
310134
310417
  const taskSummary = hasTaskToResume ? getLastTaskSummary2(repoRoot) : null;
310135
310418
  const resumeMsg = taskSummary ? `v${version4} \u2014 picking up: ${taskSummary}` : `Updated to v${version4}.`;
310136
- writeContent(() => {
310419
+ writeContent2(() => {
310137
310420
  renderInfo(resumeMsg);
310138
310421
  const resumePrompt = buildContextRestorePrompt(repoRoot);
310139
310422
  if (resumePrompt) {
@@ -310294,12 +310577,12 @@ ${opts.systemPromptAddition}` : `Working directory: ${repoRoot}`;
310294
310577
  voiceEngine.toggle().then((msg) => {
310295
310578
  statusBar.setVoiceStatus(voiceEngine.enabled, voiceEngine.modelId || "");
310296
310579
  if (statusBar?.isActive && !statusBar.isStreaming) {
310297
- writeContent(() => renderInfo(msg));
310580
+ writeContent2(() => renderInfo(msg));
310298
310581
  }
310299
310582
  }).catch((err) => {
310300
310583
  const msg = err instanceof Error ? err.message : String(err);
310301
310584
  if (statusBar?.isActive && !statusBar.isStreaming) {
310302
- writeContent(() => renderWarning(`Voice: ${msg.slice(0, 80)}`));
310585
+ writeContent2(() => renderWarning(`Voice: ${msg.slice(0, 80)}`));
310303
310586
  }
310304
310587
  });
310305
310588
  }
@@ -310361,7 +310644,7 @@ ${opts.systemPromptAddition}` : `Working directory: ${repoRoot}`;
310361
310644
  return;
310362
310645
  const queued = await blessEngine.getNextTask();
310363
310646
  if (queued) {
310364
- writeContent(() => renderInfo(`Bless auto-cycle: processing ${queued.source} task...`));
310647
+ writeContent2(() => renderInfo(`Bless auto-cycle: processing ${queued.source} task...`));
310365
310648
  let autoPrompt = queued.prompt;
310366
310649
  if (queued.source === "telegram") {
310367
310650
  activeTelegramChatId = queued.chatId ?? null;
@@ -310377,11 +310660,11 @@ Respond concisely and safely.`;
310377
310660
  rl.emit("line", autoPrompt);
310378
310661
  return;
310379
310662
  }
310380
- writeContent(() => renderInfo("DMN re-activating..."));
310663
+ writeContent2(() => renderInfo("DMN re-activating..."));
310381
310664
  statusBar.setProcessing(true);
310382
310665
  statusBar.setBrailleMetrics({ isDreaming: true });
310383
310666
  try {
310384
- const dmnHandler = createDMNEventHandler(currentConfig.verbose ?? false, writeContent);
310667
+ const dmnHandler = createDMNEventHandler(currentConfig.verbose ?? false, writeContent2);
310385
310668
  const proposal = await dmnEngine.runCycle(dmnHandler);
310386
310669
  statusBar.setProcessing(false);
310387
310670
  statusBar.setBrailleMetrics({ isDreaming: false });
@@ -310394,7 +310677,7 @@ Respond concisely and safely.`;
310394
310677
  ${proposal.task}
310395
310678
 
310396
310679
  Rationale: ${proposal.rationale}${provenanceNote}`;
310397
- writeContent(() => renderInfo(`DMN auto-cycle: ${proposal.category} task (${Math.round(proposal.confidence * 100)}% confidence)`));
310680
+ writeContent2(() => renderInfo(`DMN auto-cycle: ${proposal.category} task (${Math.round(proposal.confidence * 100)}% confidence)`));
310398
310681
  rl.emit("line", dmnPrompt);
310399
310682
  } else {
310400
310683
  scheduleDMNRetrigger(6e4);
@@ -310402,7 +310685,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310402
310685
  } catch (err) {
310403
310686
  statusBar.setProcessing(false);
310404
310687
  statusBar.setBrailleMetrics({ isDreaming: false });
310405
- writeContent(() => renderWarning(`DMN cycle error: ${err instanceof Error ? err.message : String(err)}`));
310688
+ writeContent2(() => renderWarning(`DMN cycle error: ${err instanceof Error ? err.message : String(err)}`));
310406
310689
  scheduleDMNRetrigger(6e4);
310407
310690
  }
310408
310691
  }, delayMs);
@@ -310423,7 +310706,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310423
310706
  const RECALL_WINDOW_MS = 1500;
310424
310707
  let sessionSudoPassword = null;
310425
310708
  let sudoPromptPending = false;
310426
- const panelBg = tuiBgSeq();
310709
+ const panelBg = tuiBgSeq2();
310427
310710
  const idlePrompt = `${panelBg}${c3.bold(c3.white("\u276F "))}${panelBg}`;
310428
310711
  const activePrompt = `${panelBg}${c3.bold(c3.white("+ "))}${panelBg}`;
310429
310712
  const pausedPrompt = `${panelBg}${c3.bold(c3.yellow("| "))}${panelBg}`;
@@ -310688,7 +310971,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310688
310971
  rl.prompt();
310689
310972
  }
310690
310973
  }
310691
- function writeContent(fn) {
310974
+ function writeContent2(fn) {
310692
310975
  if (!statusBar.isActive)
310693
310976
  return;
310694
310977
  if (isNeovimActive()) {
@@ -310734,7 +311017,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310734
311017
  fn();
310735
311018
  }
310736
311019
  }
310737
- setDreamWriteContent(writeContent);
311020
+ setDreamWriteContent(writeContent2);
310738
311021
  async function writeContentAsync(fn) {
310739
311022
  if (!statusBar.isActive)
310740
311023
  return fn();
@@ -310769,7 +311052,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310769
311052
  try {
310770
311053
  const available = await isModelAvailable(currentConfig);
310771
311054
  if (!available && currentConfig.backendType === "ollama") {
310772
- writeContent(() => {
311055
+ writeContent2(() => {
310773
311056
  renderWarning(`Model "${currentConfig.model}" not available. Use /model to pick one.`);
310774
311057
  });
310775
311058
  }
@@ -310783,12 +311066,12 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310783
311066
  config = { ...config, model: expandResult.model };
310784
311067
  currentConfig = { ...currentConfig, model: expandResult.model };
310785
311068
  statusBar.setModelName(expandResult.model);
310786
- writeContent(() => renderInfo(`Created expanded context model: ${expandResult.model} (${expandResult.contextLabel}, ${expandResult.numCtx} tokens)`));
311069
+ writeContent2(() => renderInfo(`Created expanded context model: ${expandResult.model} (${expandResult.contextLabel}, ${expandResult.numCtx} tokens)`));
310787
311070
  } else if (expandResult.model !== currentConfig.model) {
310788
311071
  config = { ...config, model: expandResult.model };
310789
311072
  currentConfig = { ...currentConfig, model: expandResult.model };
310790
311073
  statusBar.setModelName(expandResult.model);
310791
- writeContent(() => renderInfo(`Using expanded context model: ${expandResult.model} (${expandResult.contextLabel})`));
311074
+ writeContent2(() => renderInfo(`Using expanded context model: ${expandResult.model} (${expandResult.contextLabel})`));
310792
311075
  }
310793
311076
  } catch {
310794
311077
  }
@@ -310806,7 +311089,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310806
311089
  throw new Error(`HTTP ${resp.status}`);
310807
311090
  } catch {
310808
311091
  const prov = detectProvider(currentConfig.backendUrl);
310809
- writeContent(() => {
311092
+ writeContent2(() => {
310810
311093
  renderWarning(`Cannot reach ${prov.label} at ${currentConfig.backendUrl}`);
310811
311094
  if (prov.id === "ollama") {
310812
311095
  renderInfo("Use /endpoint http://127.0.0.1:11434 to auto-install & start Ollama.");
@@ -310852,7 +311135,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310852
311135
  const out = r2.output || String(r2);
310853
311136
  if (out.includes("Connected") || out.includes("Already connected")) {
310854
311137
  statusBar.setNexusStatus("connected");
310855
- writeContent(() => renderInfo("Nexus P2P network connected."));
311138
+ writeContent2(() => renderInfo("Nexus P2P network connected."));
310856
311139
  _registerNexusDaemon();
310857
311140
  } else if (out.includes("failed") || out.includes("Error")) {
310858
311141
  statusBar.setNexusStatus("disconnected");
@@ -310860,7 +311143,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310860
311143
  await new Promise((r3) => setTimeout(r3, 5e3));
310861
311144
  return _tryNexusConnect(attempt + 1);
310862
311145
  }
310863
- writeContent(() => renderWarning(`Nexus auto-connect failed: ${out.slice(0, 100)}`));
311146
+ writeContent2(() => renderWarning(`Nexus auto-connect failed: ${out.slice(0, 100)}`));
310864
311147
  } else if (out.includes("still connecting") || out.includes("spawned")) {
310865
311148
  for (let i2 = 0; i2 < 30; i2++) {
310866
311149
  await new Promise((r3) => setTimeout(r3, 1e3));
@@ -310868,7 +311151,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310868
311151
  const so = sr.output || String(sr);
310869
311152
  if (/Connected:\s*true/i.test(so)) {
310870
311153
  statusBar.setNexusStatus("connected");
310871
- writeContent(() => renderInfo("Nexus P2P network connected."));
311154
+ writeContent2(() => renderInfo("Nexus P2P network connected."));
310872
311155
  _registerNexusDaemon();
310873
311156
  return;
310874
311157
  }
@@ -310885,8 +311168,8 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310885
311168
  try {
310886
311169
  const oaDir = join83(repoRoot, ".oa");
310887
311170
  const reconnected = await ExposeGateway.checkAndReconnect(oaDir, {
310888
- onInfo: (msg) => writeContent(() => renderInfo(msg)),
310889
- onError: (msg) => writeContent(() => renderWarning(msg))
311171
+ onInfo: (msg) => writeContent2(() => renderInfo(msg)),
311172
+ onError: (msg) => writeContent2(() => renderWarning(msg))
310890
311173
  });
310891
311174
  if (reconnected) {
310892
311175
  tunnelGateway = reconnected;
@@ -310899,7 +311182,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310899
311182
  });
310900
311183
  });
310901
311184
  reconnected.on("token_flash", () => statusBar.flashExposeToken());
310902
- writeContent(() => {
311185
+ writeContent2(() => {
310903
311186
  renderInfo(`Reconnected to existing expose tunnel: ${reconnected.tunnelUrl}`);
310904
311187
  });
310905
311188
  try {
@@ -310907,7 +311190,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310907
311190
  const spCfg = loadSponsorConfig2(repoRoot);
310908
311191
  if (spCfg && spCfg.status === "active" && "setSponsorLimits" in reconnected) {
310909
311192
  reconnected.setSponsorLimits(spCfg.rateLimits);
310910
- writeContent(() => renderInfo(`Sponsor rate limits restored: ${spCfg.rateLimits.maxRequestsPerMinute} req/min`));
311193
+ writeContent2(() => renderInfo(`Sponsor rate limits restored: ${spCfg.rateLimits.maxRequestsPerMinute} req/min`));
310911
311194
  }
310912
311195
  } catch {
310913
311196
  }
@@ -310917,8 +311200,8 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310917
311200
  try {
310918
311201
  const oaDir = join83(repoRoot, ".oa");
310919
311202
  const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(oaDir, new NexusTool(repoRoot), {
310920
- onInfo: (msg) => writeContent(() => renderInfo(msg)),
310921
- onError: (msg) => writeContent(() => renderWarning(msg))
311203
+ onInfo: (msg) => writeContent2(() => renderInfo(msg)),
311204
+ onError: (msg) => writeContent2(() => renderWarning(msg))
310922
311205
  }, { backendUrl: currentConfig.backendUrl, apiKey: currentConfig.apiKey });
310923
311206
  if (reconnectedP2P) {
310924
311207
  p2pGateway = reconnectedP2P;
@@ -310931,7 +311214,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
310931
311214
  });
310932
311215
  });
310933
311216
  reconnectedP2P.on("token_flash", () => statusBar.flashExposeToken());
310934
- writeContent(() => {
311217
+ writeContent2(() => {
310935
311218
  renderInfo(`Reconnected to existing P2P expose: ${reconnectedP2P.peerId}`);
310936
311219
  });
310937
311220
  }
@@ -311042,7 +311325,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311042
311325
  currentConfig.backendType = "openai";
311043
311326
  setTimeout(() => {
311044
311327
  if (statusBar.isActive) {
311045
- writeContent(() => renderInfo(`Connected to sponsored endpoint: ${best.name}`));
311328
+ writeContent2(() => renderInfo(`Connected to sponsored endpoint: ${best.name}`));
311046
311329
  }
311047
311330
  }, 2e3);
311048
311331
  }
@@ -311062,7 +311345,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311062
311345
  if (await isDaemonRunning2(apiPort)) {
311063
311346
  setTimeout(() => {
311064
311347
  if (statusBar.isActive)
311065
- writeContent(() => renderInfo(`REST API: http://localhost:${apiPort} (shared daemon)`));
311348
+ writeContent2(() => renderInfo(`REST API: http://localhost:${apiPort} (shared daemon)`));
311066
311349
  }, 1500);
311067
311350
  return;
311068
311351
  }
@@ -311070,7 +311353,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311070
311353
  if (daemonOk) {
311071
311354
  setTimeout(() => {
311072
311355
  if (statusBar.isActive)
311073
- writeContent(() => renderInfo(`REST API: http://localhost:${apiPort} (daemon started)`));
311356
+ writeContent2(() => renderInfo(`REST API: http://localhost:${apiPort} (daemon started)`));
311074
311357
  }, 1500);
311075
311358
  return;
311076
311359
  }
@@ -311083,7 +311366,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311083
311366
  apiServer.on?.("listening", () => {
311084
311367
  setTimeout(() => {
311085
311368
  if (statusBar.isActive)
311086
- writeContent(() => renderInfo(`REST API: http://localhost:${apiPort} (inline \u2014 daemon unavailable)`));
311369
+ writeContent2(() => renderInfo(`REST API: http://localhost:${apiPort} (inline \u2014 daemon unavailable)`));
311087
311370
  }, 1500);
311088
311371
  });
311089
311372
  apiServer.on?.("error", () => {
@@ -311102,7 +311385,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311102
311385
  if (process.stdout.isTTY) {
311103
311386
  process.stdout.write("\x1B[?1000l\x1B[?1002l\x1B[?1006l");
311104
311387
  }
311105
- writeContent(() => {
311388
+ writeContent2(() => {
311106
311389
  process.stdout.write(`
311107
311390
  \x1B[5;38;5;198m\u2B24 Enter Password:\x1B[0m \x1B[38;5;245mType below, Enter to submit. Ctrl+O to show/hide.\x1B[0m
311108
311391
 
@@ -311125,7 +311408,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311125
311408
  async function handleAskUser(question, options2, allowMultiple) {
311126
311409
  if (statusBar?.isActive)
311127
311410
  statusBar.beginContentWrite();
311128
- writeContent(() => {
311411
+ writeContent2(() => {
311129
311412
  process.stdout.write(`
311130
311413
  ${c3.bold(c3.cyan("?"))} ${c3.bold(question)}
311131
311414
  `);
@@ -311413,7 +311696,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311413
311696
  }
311414
311697
  try {
311415
311698
  if (!commandCtx.isExposeActive?.()) {
311416
- writeContent(() => renderInfo("COHERE: exposing local inference to mesh..."));
311699
+ writeContent2(() => renderInfo("COHERE: exposing local inference to mesh..."));
311417
311700
  await commandCtx.exposeStart?.("passthrough");
311418
311701
  }
311419
311702
  } catch {
@@ -311474,22 +311757,22 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311474
311757
  },
311475
311758
  dreamStart(mode) {
311476
311759
  if (activeTask) {
311477
- writeContent(() => renderWarning("Cannot dream while a task is running."));
311760
+ writeContent2(() => renderWarning("Cannot dream while a task is running."));
311478
311761
  return;
311479
311762
  }
311480
311763
  dreamEngine = new DreamEngine(currentConfig, repoRoot);
311481
- writeContent(() => renderDreamStart(mode));
311764
+ writeContent2(() => renderDreamStart(mode));
311482
311765
  statusBar.setProcessing(true);
311483
311766
  statusBar.setBrailleMetrics({ isDreaming: true });
311484
311767
  dreamEngine.start(mode, (event) => {
311485
311768
  const isVerbose = currentConfig.verbose ?? false;
311486
311769
  if (event.type === "tool_call") {
311487
- writeContent(() => renderToolCallStart(event.toolName ?? "unknown", event.toolArgs ?? {}, isVerbose));
311770
+ writeContent2(() => renderToolCallStart(event.toolName ?? "unknown", event.toolArgs ?? {}, isVerbose));
311488
311771
  } else if (event.type === "tool_result") {
311489
- writeContent(() => renderToolResult(event.toolName ?? "unknown", event.success ?? false, event.content ?? "", isVerbose));
311772
+ writeContent2(() => renderToolResult(event.toolName ?? "unknown", event.success ?? false, event.content ?? "", isVerbose));
311490
311773
  } else if (event.type === "model_response" && isVerbose && event.content) {
311491
311774
  const preview = event.content.length > 300 ? event.content.slice(0, 300) + "..." : event.content;
311492
- writeContent(() => renderVerbose(`Dream thinking: ${preview}`));
311775
+ writeContent2(() => renderVerbose(`Dream thinking: ${preview}`));
311493
311776
  } else if (event.type === "token_usage" && event.tokenUsage) {
311494
311777
  statusBar.updateMetrics({
311495
311778
  ...event.tokenUsage,
@@ -311500,13 +311783,13 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311500
311783
  }).then((state) => {
311501
311784
  statusBar.setProcessing(false);
311502
311785
  statusBar.setBrailleMetrics({ isDreaming: false });
311503
- writeContent(() => renderDreamEnd(state));
311786
+ writeContent2(() => renderDreamEnd(state));
311504
311787
  dreamEngine = null;
311505
311788
  showPrompt();
311506
311789
  }).catch((err) => {
311507
311790
  statusBar.setProcessing(false);
311508
311791
  statusBar.setBrailleMetrics({ isDreaming: false });
311509
- writeContent(() => renderError(`Dream error: ${err instanceof Error ? err.message : String(err)}`));
311792
+ writeContent2(() => renderError(`Dream error: ${err instanceof Error ? err.message : String(err)}`));
311510
311793
  dreamEngine = null;
311511
311794
  showPrompt();
311512
311795
  });
@@ -311525,26 +311808,26 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311525
311808
  // Bless mode (infinite warm loop)
311526
311809
  blessStart() {
311527
311810
  if (activeTask) {
311528
- writeContent(() => renderWarning("Cannot start bless mode while a task is running."));
311811
+ writeContent2(() => renderWarning("Cannot start bless mode while a task is running."));
311529
311812
  return;
311530
311813
  }
311531
311814
  if (dreamEngine?.isActive) {
311532
- writeContent(() => renderWarning("Cannot bless while dreaming. Stop dream first."));
311815
+ writeContent2(() => renderWarning("Cannot bless while dreaming. Stop dream first."));
311533
311816
  return;
311534
311817
  }
311535
311818
  blessEngine = new BlessEngine(currentConfig, repoRoot);
311536
311819
  blessEngine.start();
311537
311820
  dmnEngine = new DMNEngine(currentConfig, repoRoot);
311538
- dmnEngine.setWriteContent(writeContent);
311539
- setDreamWriteContent(writeContent);
311540
- writeContent(() => renderBlessStart());
311821
+ dmnEngine.setWriteContent(writeContent2);
311822
+ setDreamWriteContent(writeContent2);
311823
+ writeContent2(() => renderBlessStart());
311541
311824
  showPrompt();
311542
311825
  },
311543
311826
  blessStop() {
311544
311827
  if (blessEngine?.isActive) {
311545
311828
  const stats = blessEngine.stats;
311546
311829
  blessEngine.stop();
311547
- writeContent(() => renderBlessStop(stats));
311830
+ writeContent2(() => renderBlessStop(stats));
311548
311831
  blessEngine = null;
311549
311832
  dmnEngine = null;
311550
311833
  }
@@ -311555,7 +311838,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
311555
311838
  // Telegram bridge
311556
311839
  async telegramStart(token, adminId) {
311557
311840
  telegramBridge = new TelegramBridge(token, (msg) => {
311558
- writeContent(() => renderTelegramMessage(msg.username, msg.text));
311841
+ writeContent2(() => renderTelegramMessage(msg.username, msg.text));
311559
311842
  if (!activeTask) {
311560
311843
  activeTelegramChatId = msg.chatId;
311561
311844
  const safePrompt = `${TELEGRAM_SAFETY_PROMPT}
@@ -311571,20 +311854,20 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311571
311854
  if (blessEngine) {
311572
311855
  blessEngine.enqueueTask("telegram", msg.text, msg.chatId);
311573
311856
  }
311574
- writeContent(() => renderInfo(`Telegram message queued (task in progress).`));
311857
+ writeContent2(() => renderInfo(`Telegram message queued (task in progress).`));
311575
311858
  showPrompt();
311576
311859
  }
311577
311860
  }, currentConfig, repoRoot);
311578
311861
  if (adminId) {
311579
311862
  telegramBridge.setAdmin(adminId);
311580
311863
  }
311581
- telegramBridge.setWriteContent(writeContent);
311864
+ telegramBridge.setWriteContent(writeContent2);
311582
311865
  telegramBridge.setOnSubAgentEvent((chatId, username, event) => {
311583
311866
  if (event.type === "tool_call" && event.toolName) {
311584
311867
  const argsPreview = event.toolArgs ? JSON.stringify(event.toolArgs).slice(0, 60) : "";
311585
- writeContent(() => renderTelegramSubAgentToolCall(username, event.toolName, argsPreview));
311868
+ writeContent2(() => renderTelegramSubAgentToolCall(username, event.toolName, argsPreview));
311586
311869
  } else if (event.type === "status" && event.content) {
311587
- writeContent(() => renderTelegramSubAgentEvent(username, event.content));
311870
+ writeContent2(() => renderTelegramSubAgentEvent(username, event.content));
311588
311871
  }
311589
311872
  });
311590
311873
  if (adminId) {
@@ -311639,14 +311922,14 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311639
311922
  }
311640
311923
  });
311641
311924
  await telegramBridge.start();
311642
- writeContent(() => renderTelegramStart(telegramBridge.botUsername, adminId));
311925
+ writeContent2(() => renderTelegramStart(telegramBridge.botUsername, adminId));
311643
311926
  showPrompt();
311644
311927
  },
311645
311928
  telegramStop() {
311646
311929
  if (telegramBridge?.isActive) {
311647
311930
  const stats = telegramBridge.stats;
311648
311931
  telegramBridge.stop();
311649
- writeContent(() => renderTelegramStop(stats));
311932
+ writeContent2(() => renderTelegramStop(stats));
311650
311933
  telegramBridge = null;
311651
311934
  }
311652
311935
  },
@@ -311680,7 +311963,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311680
311963
  const active = telegramBridge?.isActive ?? false;
311681
311964
  const botUser = active ? telegramBridge?.botUsername : void 0;
311682
311965
  const subAgents = active ? telegramBridge?.stats.activeSubAgents : void 0;
311683
- writeContent(() => renderTelegramStatus(active, botUser, savedSettings.telegramAdmin, subAgents));
311966
+ writeContent2(() => renderTelegramStatus(active, botUser, savedSettings.telegramAdmin, subAgents));
311684
311967
  },
311685
311968
  // Listen mode (transcribe-cli integration + live voice session)
311686
311969
  async listenToggle() {
@@ -311690,7 +311973,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311690
311973
  statusBar.setRecording(false);
311691
311974
  if (voiceSession?.isActive) {
311692
311975
  const sessionMsg = await voiceSession.stop();
311693
- writeContent(() => renderVoiceSessionStop(voiceSession?.runtime ?? 0));
311976
+ writeContent2(() => renderVoiceSessionStop(voiceSession?.runtime ?? 0));
311694
311977
  voiceSession = null;
311695
311978
  return sessionMsg;
311696
311979
  }
@@ -311702,12 +311985,12 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311702
311985
  }
311703
311986
  engine.on("transcript", (text, isFinal) => {
311704
311987
  if (engine.currentMode === "confirm") {
311705
- writeContent(() => renderInfo(`Heard: "${text}" ${c3.dim("(press Enter to submit)")}`));
311988
+ writeContent2(() => renderInfo(`Heard: "${text}" ${c3.dim("(press Enter to submit)")}`));
311706
311989
  } else if (isFinal) {
311707
- writeContent(() => renderInfo(`Auto-submitting: "${text}"`));
311990
+ writeContent2(() => renderInfo(`Auto-submitting: "${text}"`));
311708
311991
  rl.feed(text + "\n");
311709
311992
  } else {
311710
- writeContent(() => renderInfo(`Hearing: "${text}"`));
311993
+ writeContent2(() => renderInfo(`Hearing: "${text}"`));
311711
311994
  }
311712
311995
  });
311713
311996
  engine.on("recording", (active) => {
@@ -311717,10 +312000,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311717
312000
  statusBar.setCountdown(seconds);
311718
312001
  });
311719
312002
  engine.on("error", (err) => {
311720
- writeContent(() => renderWarning(`Listen error: ${err.message}`));
312003
+ writeContent2(() => renderWarning(`Listen error: ${err.message}`));
311721
312004
  });
311722
312005
  engine.on("info", (msg2) => {
311723
- writeContent(() => renderInfo(msg2));
312006
+ writeContent2(() => renderInfo(msg2));
311724
312007
  });
311725
312008
  const msg = await engine.start();
311726
312009
  if (voiceEngine.enabled && voiceEngine.ready) {
@@ -311734,15 +312017,15 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311734
312017
  }
311735
312018
  };
311736
312019
  voiceSession.on("userConnected", (id, username) => {
311737
- writeContent(() => renderVoiceSessionUser("connected", username));
312020
+ writeContent2(() => renderVoiceSessionUser("connected", username));
311738
312021
  });
311739
312022
  voiceSession.on("userDisconnected", (id) => {
311740
- writeContent(() => renderVoiceSessionUser("disconnected", id));
312023
+ writeContent2(() => renderVoiceSessionUser("disconnected", id));
311741
312024
  });
311742
312025
  const tunnelUrl = await voiceSession.start();
311743
- writeContent(() => renderVoiceSessionStart(voiceSession.tunnelUrl));
312026
+ writeContent2(() => renderVoiceSessionStart(voiceSession.tunnelUrl));
311744
312027
  } catch (err) {
311745
- writeContent(() => renderWarning(`Voice session failed: ${err instanceof Error ? err.message : String(err)}`));
312028
+ writeContent2(() => renderWarning(`Voice session failed: ${err instanceof Error ? err.message : String(err)}`));
311746
312029
  voiceSession = null;
311747
312030
  }
311748
312031
  }
@@ -311765,7 +312048,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311765
312048
  if (voiceSession?.isActive) {
311766
312049
  const runtime = voiceSession.runtime;
311767
312050
  await voiceSession.stop();
311768
- writeContent(() => renderVoiceSessionStop(runtime));
312051
+ writeContent2(() => renderVoiceSessionStop(runtime));
311769
312052
  voiceSession = null;
311770
312053
  }
311771
312054
  return text ? `Stopped. Last transcript: "${text}"` : "Stopped listening.";
@@ -311778,10 +312061,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311778
312061
  return voiceSession.tunnelUrl;
311779
312062
  }
311780
312063
  if (!voiceEngine.enabled || !voiceEngine.ready) {
311781
- writeContent(() => renderInfo("Auto-enabling voice for call session..."));
312064
+ writeContent2(() => renderInfo("Auto-enabling voice for call session..."));
311782
312065
  const voiceMsg = await voiceEngine.toggle();
311783
312066
  statusBar.setVoiceStatus(voiceEngine.enabled, voiceEngine.modelId || "");
311784
- writeContent(() => renderInfo(voiceMsg));
312067
+ writeContent2(() => renderInfo(voiceMsg));
311785
312068
  }
311786
312069
  if (!adminSessionKey) {
311787
312070
  adminSessionKey = generateSessionKey();
@@ -311793,7 +312076,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311793
312076
  const ppUrl = getPersonaPlexWSUrl2();
311794
312077
  if (ppUrl) {
311795
312078
  voiceSession.personaPlexWsUrl = ppUrl;
311796
- writeContent(() => renderInfo(`PersonaPlex active \u2014 full-duplex mode at ${ppUrl}`));
312079
+ writeContent2(() => renderInfo(`PersonaPlex active \u2014 full-duplex mode at ${ppUrl}`));
311797
312080
  }
311798
312081
  }
311799
312082
  } catch {
@@ -311809,9 +312092,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311809
312092
  callState.sharedTranscriber.write(pcmChunk);
311810
312093
  };
311811
312094
  voiceSession.on("userConnected", (id, username, sessionKey) => {
311812
- writeContent(() => renderVoiceSessionUser("connected", username));
312095
+ writeContent2(() => renderVoiceSessionUser("connected", username));
311813
312096
  const tier = sessionKey && sessionKey === adminSessionKey ? "admin" : "public";
311814
- writeContent(() => renderInfo(`Call client ${id} connected as ${tier.toUpperCase()}`));
312097
+ writeContent2(() => renderInfo(`Call client ${id} connected as ${tier.toUpperCase()}`));
311815
312098
  const emotionState = emotionEngine?.getState?.();
311816
312099
  const subAgent = new CallSubAgent(id, {
311817
312100
  config: currentConfig,
@@ -311822,7 +312105,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311822
312105
  contextWindowSize: resolvedContextWindowSize > 0 ? resolvedContextWindowSize : void 0
311823
312106
  });
311824
312107
  subAgent.on("response", (text) => {
311825
- writeContent(() => renderVoiceSessionTranscript("agent", text));
312108
+ writeContent2(() => renderVoiceSessionTranscript("agent", text));
311826
312109
  voiceSession?.sendTranscriptToClient(id, "agent", text);
311827
312110
  if (voiceEngine.enabled && voiceEngine.ready) {
311828
312111
  const session = voiceSession;
@@ -311839,12 +312122,12 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311839
312122
  }
311840
312123
  });
311841
312124
  subAgent.on("error", (err) => {
311842
- writeContent(() => renderWarning(`Call sub-agent error (${id}): ${err.message}`));
312125
+ writeContent2(() => renderWarning(`Call sub-agent error (${id}): ${err.message}`));
311843
312126
  });
311844
312127
  subAgent.init().then(() => {
311845
312128
  callSubAgents.set(id, subAgent);
311846
312129
  }).catch((err) => {
311847
- writeContent(() => renderWarning(`Call sub-agent init failed (${id}): ${err instanceof Error ? err.message : String(err)}`));
312130
+ writeContent2(() => renderWarning(`Call sub-agent init failed (${id}): ${err instanceof Error ? err.message : String(err)}`));
311848
312131
  });
311849
312132
  if (!callState.sharedTranscriber && !callState.loading) {
311850
312133
  callState.loading = true;
@@ -311856,7 +312139,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311856
312139
  if (!evt.text?.trim() || !voiceSession?.isActive)
311857
312140
  return;
311858
312141
  const text = evt.text.trim();
311859
- writeContent(() => renderVoiceSessionTranscript("user", text));
312142
+ writeContent2(() => renderVoiceSessionTranscript("user", text));
311860
312143
  voiceSession?.sendTranscript("user", text);
311861
312144
  if (evt.isFinal) {
311862
312145
  for (const [clientId, agent] of callSubAgents) {
@@ -311867,14 +312150,14 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311867
312150
  }
311868
312151
  }
311869
312152
  });
311870
- writeContent(() => renderInfo("Call ASR ready \u2014 listening for speech"));
312153
+ writeContent2(() => renderInfo("Call ASR ready \u2014 listening for speech"));
311871
312154
  }).catch((err) => {
311872
- writeContent(() => renderWarning(`Call ASR unavailable: ${err instanceof Error ? err.message : String(err)}`));
312155
+ writeContent2(() => renderWarning(`Call ASR unavailable: ${err instanceof Error ? err.message : String(err)}`));
311873
312156
  });
311874
312157
  }
311875
312158
  });
311876
312159
  voiceSession.on("userDisconnected", (id) => {
311877
- writeContent(() => renderVoiceSessionUser("disconnected", id));
312160
+ writeContent2(() => renderVoiceSessionUser("disconnected", id));
311878
312161
  const subAgent = callSubAgents.get(id);
311879
312162
  if (subAgent) {
311880
312163
  subAgent.dispose();
@@ -311883,13 +312166,13 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311883
312166
  });
311884
312167
  voiceSession.on("wsClose", (id, code8, reason) => {
311885
312168
  if (code8 > 0)
311886
- writeContent(() => renderInfo(`WS close: ${id} code=${code8} ${reason}`));
312169
+ writeContent2(() => renderInfo(`WS close: ${id} code=${code8} ${reason}`));
311887
312170
  });
311888
312171
  voiceSession.on("wsError", (id, err) => {
311889
- writeContent(() => renderWarning(`WS error: ${id} ${err.message}`));
312172
+ writeContent2(() => renderWarning(`WS error: ${id} ${err.message}`));
311890
312173
  });
311891
312174
  voiceSession.on("idle_timeout", () => {
311892
- writeContent(() => renderWarning("Call session auto-closed (1 min idle \u2014 no users connected)"));
312175
+ writeContent2(() => renderWarning("Call session auto-closed (1 min idle \u2014 no users connected)"));
311893
312176
  if (callState.sharedTranscriber) {
311894
312177
  callState.sharedTranscriber.stop();
311895
312178
  callState.sharedTranscriber = null;
@@ -311902,9 +312185,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311902
312185
  try {
311903
312186
  const tunnelUrl = await voiceSession.start();
311904
312187
  const adminUrl = adminSessionKey ? `${tunnelUrl}?key=${adminSessionKey}` : tunnelUrl;
311905
- writeContent(() => renderVoiceSessionStart(tunnelUrl));
311906
- writeContent(() => renderInfo(`Admin call URL (includes key): ${adminUrl}`));
311907
- writeContent(() => renderInfo(`Public call URL (read-only): ${tunnelUrl}`));
312188
+ writeContent2(() => renderVoiceSessionStart(tunnelUrl));
312189
+ writeContent2(() => renderInfo(`Admin call URL (includes key): ${adminUrl}`));
312190
+ writeContent2(() => renderInfo(`Public call URL (read-only): ${tunnelUrl}`));
311908
312191
  if (voiceEngine.enabled && voiceEngine.ready) {
311909
312192
  const session = voiceSession;
311910
312193
  voiceEngine.onPCMOutput = (pcm, sampleRate) => {
@@ -311918,7 +312201,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311918
312201
  }
311919
312202
  return tunnelUrl;
311920
312203
  } catch (err) {
311921
- writeContent(() => renderWarning(`Voice session failed: ${err instanceof Error ? err.message : String(err)}`));
312204
+ writeContent2(() => renderWarning(`Voice session failed: ${err instanceof Error ? err.message : String(err)}`));
311922
312205
  if (callState.sharedTranscriber) {
311923
312206
  callState.sharedTranscriber.stop();
311924
312207
  callState.sharedTranscriber = null;
@@ -311934,7 +312217,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311934
312217
  if (voiceSession?.isActive) {
311935
312218
  const runtime = voiceSession.runtime;
311936
312219
  await voiceSession.stop();
311937
- writeContent(() => renderVoiceSessionStop(runtime));
312220
+ writeContent2(() => renderVoiceSessionStop(runtime));
311938
312221
  voiceSession = null;
311939
312222
  voiceEngine.onPCMOutput = null;
311940
312223
  for (const agent of callSubAgents.values())
@@ -311970,7 +312253,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311970
312253
  }
311971
312254
  const nexusTool = new NexusTool(repoRoot);
311972
312255
  const exposeSpinnerMsg = passthrough ? `Connecting to nexus P2P network (passthrough \u2192 ${targetUrl})...` : "Connecting to nexus P2P network...";
311973
- writeContent(() => {
312256
+ writeContent2(() => {
311974
312257
  renderInfo(exposeSpinnerMsg);
311975
312258
  });
311976
312259
  const newP2P = new ExposeP2PGateway({
@@ -311982,12 +312265,12 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
311982
312265
  loadbalance: loadbalance ?? false,
311983
312266
  endpointAuth: passthrough ? currentConfig.apiKey : void 0,
311984
312267
  onInfo: (msg) => {
311985
- writeContent(() => {
312268
+ writeContent2(() => {
311986
312269
  renderInfo(msg);
311987
312270
  });
311988
312271
  },
311989
312272
  onError: (msg) => {
311990
- writeContent(() => {
312273
+ writeContent2(() => {
311991
312274
  renderWarning(msg);
311992
312275
  });
311993
312276
  }
@@ -312004,13 +312287,13 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312004
312287
  try {
312005
312288
  const peerId = await newP2P.start();
312006
312289
  p2pGateway = newP2P;
312007
- writeContent(() => {
312290
+ writeContent2(() => {
312008
312291
  process.stdout.write("\n" + newP2P.formatConnectionInfo() + "\n\n");
312009
312292
  });
312010
312293
  return peerId;
312011
312294
  } catch (err) {
312012
312295
  if (!transport) {
312013
- writeContent(() => {
312296
+ writeContent2(() => {
312014
312297
  renderWarning(`libp2p expose failed: ${err instanceof Error ? err.message : String(err)}`);
312015
312298
  renderInfo("Falling back to cloudflared tunnel...");
312016
312299
  });
@@ -312036,7 +312319,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312036
312319
  try {
312037
312320
  const url = await newTunnel.start();
312038
312321
  tunnelGateway = newTunnel;
312039
- writeContent(() => {
312322
+ writeContent2(() => {
312040
312323
  process.stdout.write("\n" + newTunnel.formatConnectionInfo() + "\n\n");
312041
312324
  });
312042
312325
  return url;
@@ -312246,7 +312529,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312246
312529
  return false;
312247
312530
  activeTask.runner.abort();
312248
312531
  const bgKilled = taskManager.stopAll();
312249
- writeContent(() => renderInfo(`Task aborted.${bgKilled > 0 ? ` ${bgKilled} background task(s) killed.` : ""}`));
312532
+ writeContent2(() => renderInfo(`Task aborted.${bgKilled > 0 ? ` ${bgKilled} background task(s) killed.` : ""}`));
312250
312533
  return true;
312251
312534
  },
312252
312535
  pauseTask() {
@@ -312280,7 +312563,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312280
312563
  "Continue where you left off."
312281
312564
  ].filter(Boolean).join("\n");
312282
312565
  const shortPrompt = pendingTask.prompt.slice(0, 40) + (pendingTask.prompt.length > 40 ? "..." : "");
312283
- writeContent(() => renderInfo(`Picking up: ${shortPrompt}`));
312566
+ writeContent2(() => renderInfo(`Picking up: ${shortPrompt}`));
312284
312567
  rl.emit("line", resumeContext);
312285
312568
  }, 100);
312286
312569
  return true;
@@ -312307,7 +312590,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312307
312590
  destroyProject() {
312308
312591
  const bgKilled = taskManager.stopAll();
312309
312592
  if (bgKilled > 0) {
312310
- writeContent(() => renderInfo(`Killed ${bgKilled} background task(s).`));
312593
+ writeContent2(() => renderInfo(`Killed ${bgKilled} background task(s).`));
312311
312594
  }
312312
312595
  try {
312313
312596
  const nexusDir = join83(repoRoot, OA_DIR, "nexus");
@@ -312327,7 +312610,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312327
312610
  } catch {
312328
312611
  }
312329
312612
  }
312330
- writeContent(() => renderInfo(`Killed nexus daemon (PID ${pid}).`));
312613
+ writeContent2(() => renderInfo(`Killed nexus daemon (PID ${pid}).`));
312331
312614
  } catch {
312332
312615
  }
312333
312616
  }
@@ -312380,7 +312663,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312380
312663
  } catch {
312381
312664
  }
312382
312665
  } else {
312383
- writeContent(() => renderWarning(`Could not fully remove ${OA_DIR}/: ${err instanceof Error ? err.message : String(err)}`));
312666
+ writeContent2(() => renderWarning(`Could not fully remove ${OA_DIR}/: ${err instanceof Error ? err.message : String(err)}`));
312384
312667
  if (process.platform === "win32") {
312385
312668
  try {
312386
312669
  execSync42(`rd /s /q "${oaPath}"`, { timeout: 1e4, stdio: "ignore" });
@@ -312392,10 +312675,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312392
312675
  }
312393
312676
  }
312394
312677
  if (deleted) {
312395
- writeContent(() => renderInfo(`Removed ${OA_DIR}/ directory.`));
312678
+ writeContent2(() => renderInfo(`Removed ${OA_DIR}/ directory.`));
312396
312679
  }
312397
312680
  } else {
312398
- writeContent(() => renderInfo(`No ${OA_DIR}/ directory found.`));
312681
+ writeContent2(() => renderInfo(`No ${OA_DIR}/ directory found.`));
312399
312682
  }
312400
312683
  if (isNeovimActive())
312401
312684
  stopNeovimMode();
@@ -312482,7 +312765,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312482
312765
  const timeAgo = lastTime ? formatTimeAgo(lastTime) : "unknown";
312483
312766
  const lastTask = lastEntry.task?.slice(0, 80) || "unknown";
312484
312767
  setTimeout(async () => {
312485
- writeContent(() => {
312768
+ writeContent2(() => {
312486
312769
  renderInfo(`Previous session found (${savedCtx.entries.length} entries, last active ${timeAgo})`);
312487
312770
  renderInfo(`Last task: ${lastTask}${lastEntry.task && lastEntry.task.length > 80 ? "..." : ""}`);
312488
312771
  });
@@ -312519,12 +312802,12 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312519
312802
  if (prompt) {
312520
312803
  restoredSessionContext = prompt;
312521
312804
  const info = loadSessionContext(repoRoot);
312522
- writeContent(() => renderInfo(countdown <= 0 ? `Context auto-restored from ${info?.entries.length ?? 0} session(s).` : `Context restored from ${info?.entries.length ?? 0} session(s).`));
312805
+ writeContent2(() => renderInfo(countdown <= 0 ? `Context auto-restored from ${info?.entries.length ?? 0} session(s).` : `Context restored from ${info?.entries.length ?? 0} session(s).`));
312523
312806
  } else {
312524
- writeContent(() => renderInfo("No context to restore. Starting fresh."));
312807
+ writeContent2(() => renderInfo("No context to restore. Starting fresh."));
312525
312808
  }
312526
312809
  } else {
312527
- writeContent(() => renderInfo("Starting fresh."));
312810
+ writeContent2(() => renderInfo("Starting fresh."));
312528
312811
  }
312529
312812
  showPrompt();
312530
312813
  }, 150);
@@ -312542,7 +312825,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312542
312825
  const totalDue = dueReminders.length + activeAttention.length;
312543
312826
  if (totalDue > 0) {
312544
312827
  setTimeout(() => {
312545
- writeContent(() => {
312828
+ writeContent2(() => {
312546
312829
  if (criticalReminders.length > 0 || criticalAttention.length > 0) {
312547
312830
  renderWarning(`${criticalReminders.length + criticalAttention.length} urgent item(s) need attention`);
312548
312831
  for (const r2 of criticalReminders)
@@ -312578,7 +312861,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312578
312861
  "Continue where you left off."
312579
312862
  ].filter(Boolean).join("\n");
312580
312863
  const shortPrompt = pendingTask.prompt.slice(0, 40) + (pendingTask.prompt.length > 40 ? "..." : "");
312581
- writeContent(() => renderInfo(`Picking up: ${shortPrompt}`));
312864
+ writeContent2(() => renderInfo(`Picking up: ${shortPrompt}`));
312582
312865
  rl.emit("line", resumeContext);
312583
312866
  }, 100);
312584
312867
  }
@@ -312588,7 +312871,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
312588
312871
  try {
312589
312872
  await commandCtx.telegramStart(savedSettings.telegramKey, savedSettings.telegramAdmin);
312590
312873
  } catch (err) {
312591
- writeContent(() => renderWarning(`Telegram auto-start failed: ${err instanceof Error ? err.message : String(err)}`));
312874
+ writeContent2(() => renderWarning(`Telegram auto-start failed: ${err instanceof Error ? err.message : String(err)}`));
312592
312875
  showPrompt();
312593
312876
  }
312594
312877
  }, 200);
@@ -312716,7 +312999,7 @@ ${result.content.slice(0, 2e3)}${result.content.length > 2e3 ? "\n[truncated]" :
312716
312999
  line: rl.line ?? "",
312717
313000
  cursor: rl.cursor ?? 0
312718
313001
  }));
312719
- writeContent(() => renderInfo("\u{1F511} Password received"));
313002
+ writeContent2(() => renderInfo("\u{1F511} Password received"));
312720
313003
  showPrompt();
312721
313004
  return;
312722
313005
  }
@@ -312772,7 +313055,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
312772
313055
  if (statusBar.isActive)
312773
313056
  statusBar.setScrollRegionTop(bannerActive ? 5 : 1);
312774
313057
  }
312775
- writeContent(() => renderUserMessage(`/${cmdResult.name}${cmdResult.args ? " " + cmdResult.args : ""}`));
313058
+ writeContent2(() => renderUserMessage(`/${cmdResult.name}${cmdResult.args ? " " + cmdResult.args : ""}`));
312776
313059
  lastSubmittedPrompt = skillPrompt;
312777
313060
  emotionEngine.setCurrentTask(`/${cmdResult.name}${cmdResult.args ? " " + cmdResult.args.slice(0, 80) : ""}`);
312778
313061
  try {
@@ -312800,7 +313083,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
312800
313083
  await task.promise;
312801
313084
  } catch (err) {
312802
313085
  const errMsg = err instanceof Error ? err.message : String(err);
312803
- writeContent(() => renderError(errMsg));
313086
+ writeContent2(() => renderError(errMsg));
312804
313087
  }
312805
313088
  statusBar.setProcessing(false);
312806
313089
  activeTask = null;
@@ -312825,23 +313108,23 @@ Execute this skill now. Follow the behavioral guidance above.`;
312825
313108
  const ext = extname11(cleanPath).toLowerCase();
312826
313109
  const mime = ext === ".png" ? "image/png" : ext === ".gif" ? "image/gif" : ext === ".webp" ? "image/webp" : "image/jpeg";
312827
313110
  activeTask.runner.injectImage(base642, mime, `User shared image: ${cleanPath}`);
312828
- writeContent(() => renderUserInterrupt(`[Image: ${cleanPath}]`));
313111
+ writeContent2(() => renderUserInterrupt(`[Image: ${cleanPath}]`));
312829
313112
  } catch {
312830
313113
  activeTask.runner.injectUserMessage(input);
312831
- writeContent(() => renderUserInterrupt(input));
313114
+ writeContent2(() => renderUserInterrupt(input));
312832
313115
  }
312833
313116
  } else if (isMedia) {
312834
- writeContent(() => renderInfo(`Transcribing: ${cleanPath}...`));
313117
+ writeContent2(() => renderInfo(`Transcribing: ${cleanPath}...`));
312835
313118
  const engine = getListenEngine();
312836
313119
  const result = await engine.transcribeFile(resolve35(repoRoot, cleanPath), repoRoot);
312837
313120
  if (result) {
312838
313121
  const transcript = `[Transcription of ${cleanPath}]
312839
313122
  ${result.text}`;
312840
313123
  activeTask.runner.injectUserMessage(transcript);
312841
- writeContent(() => renderUserInterrupt(`[Audio: ${cleanPath}] (${result.text.split(" ").length} words)`));
313124
+ writeContent2(() => renderUserInterrupt(`[Audio: ${cleanPath}] (${result.text.split(" ").length} words)`));
312842
313125
  } else {
312843
313126
  activeTask.runner.injectUserMessage(`User dropped audio/video file: ${cleanPath}. Use transcribe_file tool to transcribe it.`);
312844
- writeContent(() => renderUserInterrupt(`[Media: ${cleanPath}]`));
313127
+ writeContent2(() => renderUserInterrupt(`[Media: ${cleanPath}]`));
312845
313128
  }
312846
313129
  } else {
312847
313130
  const isReplacement = lastSteeringRetracted;
@@ -312850,13 +313133,13 @@ ${result.text}`;
312850
313133
  const lineCount = input.split("\n").length;
312851
313134
  if (isReplacement) {
312852
313135
  const displayText2 = lineCount > 1 ? `[pasted ${lineCount} lines]` : input;
312853
- writeContent(() => process.stdout.write(`
313136
+ writeContent2(() => process.stdout.write(`
312854
313137
  ${c3.green("\u21BB")} ${c3.bold("Context replaced:")} ${displayText2}
312855
313138
  `));
312856
313139
  } else if (lineCount > 1) {
312857
- writeContent(() => renderUserInterrupt(`[pasted ${lineCount} lines]`));
313140
+ writeContent2(() => renderUserInterrupt(`[pasted ${lineCount} lines]`));
312858
313141
  } else {
312859
- writeContent(() => renderUserInterrupt(input));
313142
+ writeContent2(() => renderUserInterrupt(input));
312860
313143
  }
312861
313144
  if (isNeovimActive() && !isNeovimFocused()) {
312862
313145
  refocusNeovim();
@@ -312952,7 +313235,7 @@ ${result.text}`;
312952
313235
  steering = raw;
312953
313236
  }
312954
313237
  if (voiceEngine?.enabled) {
312955
- writeContent(() => renderVoiceText(acknowledgment));
313238
+ writeContent2(() => renderVoiceText(acknowledgment));
312956
313239
  voiceEngine.speak(acknowledgment);
312957
313240
  }
312958
313241
  steerRunner.injectUserMessage(steering);
@@ -312976,15 +313259,15 @@ ${result.text}`;
312976
313259
  const cloneExts = [".wav", ".mp3", ".ogg", ".flac", ".m4a"];
312977
313260
  const ext = cleanPath.toLowerCase().split(".").pop() || "";
312978
313261
  if (cloneExts.includes("." + ext)) {
312979
- writeContent(() => renderInfo(`Setting voice clone reference: ${cleanPath}`));
313262
+ writeContent2(() => renderInfo(`Setting voice clone reference: ${cleanPath}`));
312980
313263
  const msg = await voiceEngine.setCloneVoice(resolve35(repoRoot, cleanPath));
312981
- writeContent(() => renderInfo(msg));
313264
+ writeContent2(() => renderInfo(msg));
312982
313265
  showPrompt();
312983
313266
  return;
312984
313267
  }
312985
313268
  }
312986
313269
  if (isMedia && fullInput === input) {
312987
- writeContent(() => renderInfo(`Transcribing: ${cleanPath}...`));
313270
+ writeContent2(() => renderInfo(`Transcribing: ${cleanPath}...`));
312988
313271
  const engine = getListenEngine();
312989
313272
  const result = await engine.transcribeFile(resolve35(repoRoot, cleanPath), repoRoot);
312990
313273
  if (result) {
@@ -313008,7 +313291,7 @@ Summarize or analyze this transcription as appropriate.`;
313008
313291
  }
313009
313292
  const inputLineCount = fullInput.split("\n").length;
313010
313293
  const displayText = isImage ? `[Image: ${cleanPath}]` : inputLineCount > 1 ? `[pasted ${inputLineCount} lines]` : fullInput;
313011
- writeContent(() => {
313294
+ writeContent2(() => {
313012
313295
  renderUserMessage(displayText);
313013
313296
  const preview = fullInput.length > 160 ? fullInput.slice(0, 160) + "\u2026" : fullInput;
313014
313297
  renderUserInterrupt(preview);
@@ -313074,7 +313357,7 @@ ${fullInput}`;
313074
313357
  await task.promise;
313075
313358
  } catch (err) {
313076
313359
  const errMsg = err instanceof Error ? err.message : String(err);
313077
- writeContent(() => renderError(errMsg));
313360
+ writeContent2(() => renderError(errMsg));
313078
313361
  if (failureStore) {
313079
313362
  try {
313080
313363
  const { createHash: createHash7 } = await import("node:crypto");
@@ -313124,7 +313407,7 @@ ${fullInput}`;
313124
313407
  const { exec: exec5 } = await import("node:child_process");
313125
313408
  exec5(`npm install -g open-agents-ai@latest --prefer-online`, { timeout: 18e4 }, (err) => {
313126
313409
  if (!err) {
313127
- writeContent(() => renderInfo(`Updated to v${updateInfo.latestVersion} in background. Takes effect next session.`));
313410
+ writeContent2(() => renderInfo(`Updated to v${updateInfo.latestVersion} in background. Takes effect next session.`));
313128
313411
  }
313129
313412
  });
313130
313413
  }
@@ -313170,7 +313453,7 @@ ${emotion.emoji} ${emotion.label}`);
313170
313453
  }
313171
313454
  const nextTask = await blessEngine.getNextTask();
313172
313455
  if (nextTask) {
313173
- writeContent(() => renderInfo(`Bless auto-cycle: processing ${nextTask.source} task...`));
313456
+ writeContent2(() => renderInfo(`Bless auto-cycle: processing ${nextTask.source} task...`));
313174
313457
  let autoPrompt = nextTask.prompt;
313175
313458
  if (nextTask.source === "telegram") {
313176
313459
  activeTelegramChatId = nextTask.chatId ?? null;
@@ -313187,11 +313470,11 @@ Respond concisely and safely.`;
313187
313470
  return;
313188
313471
  }
313189
313472
  if (dmnEngine) {
313190
- writeContent(() => renderInfo("No queued tasks \u2014 DMN self-reflection activating..."));
313473
+ writeContent2(() => renderInfo("No queued tasks \u2014 DMN self-reflection activating..."));
313191
313474
  statusBar.setProcessing(true);
313192
313475
  statusBar.setBrailleMetrics({ isDreaming: true });
313193
313476
  try {
313194
- const dmnHandler = createDMNEventHandler(currentConfig.verbose ?? false, writeContent);
313477
+ const dmnHandler = createDMNEventHandler(currentConfig.verbose ?? false, writeContent2);
313195
313478
  const proposal = await dmnEngine.runCycle(dmnHandler);
313196
313479
  statusBar.setProcessing(false);
313197
313480
  statusBar.setBrailleMetrics({ isDreaming: false });
@@ -313204,19 +313487,19 @@ Respond concisely and safely.`;
313204
313487
  ${proposal.task}
313205
313488
 
313206
313489
  Rationale: ${proposal.rationale}${provenanceNote}`;
313207
- writeContent(() => renderInfo(`DMN auto-cycle: ${proposal.category} task (${Math.round(proposal.confidence * 100)}% confidence)`));
313490
+ writeContent2(() => renderInfo(`DMN auto-cycle: ${proposal.category} task (${Math.round(proposal.confidence * 100)}% confidence)`));
313208
313491
  setTimeout(() => rl.emit("line", dmnPrompt), 500);
313209
313492
  return;
313210
313493
  }
313211
313494
  if (blessEngine?.isActive) {
313212
313495
  const cooldownSec = 30;
313213
- writeContent(() => renderInfo(`DMN resting \u2014 will re-activate in ${cooldownSec}s`));
313496
+ writeContent2(() => renderInfo(`DMN resting \u2014 will re-activate in ${cooldownSec}s`));
313214
313497
  scheduleDMNRetrigger(cooldownSec * 1e3);
313215
313498
  }
313216
313499
  } catch (err) {
313217
313500
  statusBar.setProcessing(false);
313218
313501
  statusBar.setBrailleMetrics({ isDreaming: false });
313219
- writeContent(() => renderWarning(`DMN cycle error: ${err instanceof Error ? err.message : String(err)}`));
313502
+ writeContent2(() => renderWarning(`DMN cycle error: ${err instanceof Error ? err.message : String(err)}`));
313220
313503
  if (blessEngine?.isActive) {
313221
313504
  scheduleDMNRetrigger(6e4);
313222
313505
  }
@@ -313247,7 +313530,7 @@ ${c3.dim("Goodbye!")}
313247
313530
  clearTimeout(pasteTimer);
313248
313531
  pasteTimer = null;
313249
313532
  }
313250
- writeContent(() => process.stdout.write(`
313533
+ writeContent2(() => process.stdout.write(`
313251
313534
  ${c3.dim("(paste cancelled)")}
313252
313535
  `));
313253
313536
  showPrompt();
@@ -313256,9 +313539,9 @@ ${c3.dim("(paste cancelled)")}
313256
313539
  if (activeTask) {
313257
313540
  activeTask.runner.abort();
313258
313541
  taskManager.stopAll();
313259
- writeContent(() => renderTaskAborted());
313542
+ writeContent2(() => renderTaskAborted());
313260
313543
  } else {
313261
- writeContent(() => process.stdout.write(`
313544
+ writeContent2(() => process.stdout.write(`
313262
313545
  ${c3.dim("(Use /quit to exit)")}
313263
313546
  `));
313264
313547
  }
@@ -313294,7 +313577,7 @@ ${c3.dim("(Use /quit to exit)")}
313294
313577
  if (!activeTask)
313295
313578
  return;
313296
313579
  if (activeTask.runner.isPaused) {
313297
- writeContent(() => process.stdout.write(` ${c3.red("\u23F9")} ${c3.dim("Stopped.")}
313580
+ writeContent2(() => process.stdout.write(` ${c3.red("\u23F9")} ${c3.dim("Stopped.")}
313298
313581
  `));
313299
313582
  activeTask.runner.abort();
313300
313583
  showPrompt();
@@ -313306,12 +313589,12 @@ ${c3.dim("(Use /quit to exit)")}
313306
313589
  if (retracted) {
313307
313590
  lastSteeringInput = retracted;
313308
313591
  lastSteeringRetracted = true;
313309
- writeContent(() => process.stdout.write(` ${c3.yellow("\u23F8")} ${c3.dim("\x1B[9m" + retracted.slice(0, 120) + "\x1B[29m")} ${c3.dim("\u2190 retracted, edit below and press Enter")}
313592
+ writeContent2(() => process.stdout.write(` ${c3.yellow("\u23F8")} ${c3.dim("\x1B[9m" + retracted.slice(0, 120) + "\x1B[29m")} ${c3.dim("\u2190 retracted, edit below and press Enter")}
313310
313593
  `));
313311
313594
  rl.line = retracted;
313312
313595
  rl.cursor = retracted.length;
313313
313596
  } else {
313314
- writeContent(() => process.stdout.write(` ${c3.yellow("\u23F8")} ${c3.dim("Paused. Press Esc again to stop, or type and press Enter to steer.")}
313597
+ writeContent2(() => process.stdout.write(` ${c3.yellow("\u23F8")} ${c3.dim("Paused. Press Esc again to stop, or type and press Enter to steer.")}
313315
313598
  `));
313316
313599
  }
313317
313600
  showPrompt();