@causyne/agent 1.20.60 → 1.20.62

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 (41) hide show
  1. package/package.json +1 -1
  2. package/src/acp/agentCatalog.js +1 -1
  3. package/src/acp/agentCatalog.ts +1 -1
  4. package/src/acp/peerProfiles.js +3 -3
  5. package/src/acp/peerProfiles.ts +3 -3
  6. package/src/agentLoop.js +58 -22
  7. package/src/agentLoop.ts +64 -25
  8. package/src/checkpoints.js +23 -5
  9. package/src/cliMode.js +4 -2
  10. package/src/commands.js +503 -78
  11. package/src/contextManager.d.ts +3 -0
  12. package/src/contextManager.js +78 -5
  13. package/src/cortex/autoCondenser.js +105 -145
  14. package/src/cortex/autoCondenser.ts +185 -0
  15. package/src/cortex/cortexEngine.js +179 -0
  16. package/src/cortex/cortexEngine.ts +209 -0
  17. package/src/cortex/provisioner.js +12 -14
  18. package/src/cortex/provisioner.ts +29 -0
  19. package/src/cortex/vectorDb.js +307 -386
  20. package/src/cortex/vectorDb.ts +473 -0
  21. package/src/reporting.js +30 -7
  22. package/src/sessionJournal.js +13 -0
  23. package/src/sessionJournal.ts +13 -0
  24. package/src/tokenTracker.js +22 -0
  25. package/src/tokenTracker.ts +28 -0
  26. package/src/tui/chatRenderer.js +6 -2
  27. package/src/tui/completion.js +34 -15
  28. package/src/tui/composerControls.js +5 -0
  29. package/src/tui/composerControls.ts +5 -0
  30. package/src/tui/layout.js +1 -1
  31. package/src/tui/layout.ts +1 -1
  32. package/src/tui/observerPicker.js +323 -0
  33. package/src/tui/observerPicker.ts +386 -0
  34. package/src/tui/prompt.js +184 -22
  35. package/src/tui/stageSurface.js +18 -8
  36. package/src/tui/usageCard.js +178 -0
  37. package/src/tui/usageCard.ts +240 -0
  38. package/src/utils/paths.js +30 -1
  39. package/src/utils/paths.ts +32 -1
  40. package/src/cortex/autoCondenser.d.ts +0 -2
  41. package/src/cortex/vectorDb.d.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causyne/agent",
3
- "version": "1.20.60",
3
+ "version": "1.20.62",
4
4
  "description": "Agentic AI for software, tools, and computer workflows",
5
5
  "main": "bin/causyne.js",
6
6
  "type": "module",
@@ -421,7 +421,7 @@ export function getPresetProfile(id) {
421
421
  command: preset.command,
422
422
  args: preset.args,
423
423
  cwd: null,
424
- policy: 'read-only',
424
+ policy: 'workspace',
425
425
  timeoutSeconds: preset.timeoutSeconds || 180,
426
426
  env: {}
427
427
  };
@@ -498,7 +498,7 @@ export function getPresetProfile(id: string): PeerProfile | null {
498
498
  command: preset.command,
499
499
  args: preset.args,
500
500
  cwd: null,
501
- policy: 'read-only',
501
+ policy: 'workspace',
502
502
  timeoutSeconds: preset.timeoutSeconds || 180,
503
503
  env: {}
504
504
  };
@@ -67,9 +67,9 @@ function parseProfile(raw) {
67
67
  return null;
68
68
  }
69
69
  }
70
- const policy = record.policy === 'workspace'
71
- ? 'workspace'
72
- : (record.policy === 'ask' ? 'ask' : 'read-only');
70
+ const policy = record.policy === 'read-only'
71
+ ? 'read-only'
72
+ : (record.policy === 'ask' ? 'ask' : 'workspace');
73
73
  const timeoutSeconds = typeof record.timeoutSeconds === 'number' && Number.isFinite(record.timeoutSeconds)
74
74
  ? Math.max(5, Math.min(1800, Math.round(record.timeoutSeconds)))
75
75
  : 120;
@@ -77,9 +77,9 @@ function parseProfile(raw: unknown): PeerProfile | null {
77
77
  return null;
78
78
  }
79
79
  }
80
- const policy: PeerPolicy = record.policy === 'workspace'
81
- ? 'workspace'
82
- : (record.policy === 'ask' ? 'ask' : 'read-only');
80
+ const policy: PeerPolicy = record.policy === 'read-only'
81
+ ? 'read-only'
82
+ : (record.policy === 'ask' ? 'ask' : 'workspace');
83
83
  const timeoutSeconds = typeof record.timeoutSeconds === 'number' && Number.isFinite(record.timeoutSeconds)
84
84
  ? Math.max(5, Math.min(1800, Math.round(record.timeoutSeconds)))
85
85
  : 120;
package/src/agentLoop.js CHANGED
@@ -18,7 +18,7 @@ import { isDevEmulator } from './devMode.js';
18
18
  import { TokenTracker } from './tokenTracker.js';
19
19
  import { getMemoryContextString } from './memory.js';
20
20
  import { MemoryManager } from './memoryManager.js';
21
- import { cortexDb } from './cortex/vectorDb.js';
21
+ import { cortexDb, isSearchablePrompt } from './cortex/vectorDb.js';
22
22
  import { buildStructuralSummary, condenseAndSave } from './cortex/autoCondenser.js';
23
23
  import { episodicStore, compileToolObservation } from './memory/episodicStore.js';
24
24
  import { buildCodexStyleSummary, compactSessionMessages, autoCompactIfUnderPressure } from './core/contextCompactor.js';
@@ -826,10 +826,11 @@ export class AgentLoop {
826
826
  async buildStaticContext() {
827
827
  let lessonsLearned = '';
828
828
  this._lessonSimilarity = 0;
829
- if (this.currentTaskPrompt) {
829
+ const cortexEnabled = Boolean(this.config?.cortex?.enabled);
830
+ if (cortexEnabled && this.currentTaskPrompt && isSearchablePrompt(this.currentTaskPrompt)) {
830
831
  try {
831
- const matches = await cortexDb.search(this.currentTaskPrompt, 2);
832
- if (matches.length > 0) {
832
+ const matches = await cortexDb.search(this.currentTaskPrompt, 2, { workspace: this.workspaceRoot });
833
+ if (matches.length > 0 && matches[0]) {
833
834
  lessonsLearned = `\n\n🧠 DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m) => `- ${m.text}`).join('\n');
834
835
  this._lessonSimilarity = matches[0].similarity || 0;
835
836
  this.debugLog(`cortex search hit: ${(this._lessonSimilarity * 100).toFixed(0)}% similarity`);
@@ -850,7 +851,7 @@ export class AgentLoop {
850
851
  catch (e) { }
851
852
  // Anti-Slop: Creative Pattern Memory (prevents repeating the same design approach)
852
853
  let antiRepeatDirective = '';
853
- if (this.currentTaskPrompt && isWebIntent(this.currentTaskPrompt)) {
854
+ if (cortexEnabled && this.currentTaskPrompt && isWebIntent(this.currentTaskPrompt)) {
854
855
  try {
855
856
  const recentPatterns = await cortexDb.getRecentCreativePatterns(5);
856
857
  if (recentPatterns.length > 0) {
@@ -1962,17 +1963,18 @@ export class AgentLoop {
1962
1963
  limitChars: MAX_CHAR_POOL
1963
1964
  });
1964
1965
  this.notice(`Context compacted: ${removed} earlier messages condensed into a reviewable summary.`);
1965
- // V5 Cortex tiered condensation. Tier 1 (structural, free) always
1966
- // runs so the Digital Brain keeps learning on every provider. Tier 2
1967
- // (semantic, billed) is capped per task and fully tracked.
1968
- condenseAndSave(dropped, this.utilityProvider(), this.tokenTracker, {
1969
- enableLlmPass: this.config.enableCortexCondenser !== false,
1970
- maxLlmPasses: this.config.maxCortexCondenserPasses ?? 3,
1971
- passesUsed: this._cortexPassesUsed
1972
- }).then((outcome) => {
1973
- if (outcome.semantic)
1974
- this._cortexPassesUsed++;
1975
- }).catch(() => { });
1966
+ // V5 Cortex tiered condensation. Gated behind opt-in config so Cortex
1967
+ // never runs or touches storage unless explicitly enabled.
1968
+ if (this.config?.cortex?.enabled) {
1969
+ condenseAndSave(dropped, this.utilityProvider(), this.tokenTracker, {
1970
+ enableLlmPass: this.config.enableCortexCondenser !== false,
1971
+ maxLlmPasses: this.config.maxCortexCondenserPasses ?? 3,
1972
+ passesUsed: this._cortexPassesUsed
1973
+ }).then((outcome) => {
1974
+ if (outcome.semantic)
1975
+ this._cortexPassesUsed++;
1976
+ }).catch(() => { });
1977
+ }
1976
1978
  }
1977
1979
  }
1978
1980
  // Resolve the active toolset before assembling the prompt: the task
@@ -2933,15 +2935,34 @@ You are operating in a text-and-code modality without direct image pixel renderi
2933
2935
  continue;
2934
2936
  }
2935
2937
  if (hasExternalActions && (isIncompleteTurn || isMidTaskProgress || (typeof contentText === 'string' && (contentText.startsWith('Antigravity executed:') || /^Turn completed by .+ over ACP\.$/i.test(contentText.trim()))))) {
2938
+ const cleanSubstantive = (text) => {
2939
+ if (typeof text !== 'string')
2940
+ return '';
2941
+ return text
2942
+ .replace(/^Antigravity executed:[^\n]*\n*/i, '')
2943
+ .replace(/^Turn completed by [^\n]+ over ACP\.\s*/i, '')
2944
+ .trim();
2945
+ };
2946
+ const currentSubstantive = cleanSubstantive(contentText);
2947
+ if (currentSubstantive.length >= 60) {
2948
+ this.emitEvent({
2949
+ type: 'agent_message',
2950
+ content: currentSubstantive
2951
+ });
2952
+ this.emitEvent({
2953
+ type: 'status',
2954
+ message: 'Task completed with verified deliverables.'
2955
+ });
2956
+ this.memoryManager.saveHistory(this.messages);
2957
+ break;
2958
+ }
2936
2959
  const recentSubstantiveAssistant = [...this.messages].reverse().find(m => m.role === 'assistant'
2937
2960
  && typeof m.content === 'string'
2938
- && m.content.trim().length >= 60
2939
- && !m.content.trim().startsWith('Antigravity executed:')
2940
- && !/^Turn completed by .+ over ACP\.$/i.test(m.content.trim()));
2961
+ && cleanSubstantive(m.content).length >= 60);
2941
2962
  if (recentSubstantiveAssistant && typeof recentSubstantiveAssistant.content === 'string') {
2942
2963
  this.emitEvent({
2943
2964
  type: 'agent_message',
2944
- content: recentSubstantiveAssistant.content
2965
+ content: cleanSubstantive(recentSubstantiveAssistant.content)
2945
2966
  });
2946
2967
  this.emitEvent({
2947
2968
  type: 'status',
@@ -2963,6 +2984,19 @@ You are operating in a text-and-code modality without direct image pixel renderi
2963
2984
  this.memoryManager.saveHistory(this.messages);
2964
2985
  break;
2965
2986
  }
2987
+ if (this.stepsCompleted > 0) {
2988
+ const summary = `Task completed (${this.stepsCompleted} step${this.stepsCompleted === 1 ? '' : 's'} executed). All verified deliverables and actions are in place.`;
2989
+ this.emitEvent({
2990
+ type: 'agent_message',
2991
+ content: summary
2992
+ });
2993
+ this.emitEvent({
2994
+ type: 'status',
2995
+ message: 'Task completed with verified deliverables.'
2996
+ });
2997
+ this.memoryManager.saveHistory(this.messages);
2998
+ break;
2999
+ }
2966
3000
  this.emitEvent({
2967
3001
  type: 'error',
2968
3002
  message: 'The task stopped before completion after repeated incomplete turns without a final response. Work remains unfinished.'
@@ -3562,8 +3596,10 @@ You are operating in a text-and-code modality without direct image pixel renderi
3562
3596
  const fatalMsg = `FATAL ERROR: Infinite Token Drain Detected. Agent repeatedly attempted blocked/forbidden actions 4 times in a row. Forcibly aborting task to save tokens.`;
3563
3597
  this.emitEvent({ type: 'step_error', tool: functionName, error: fatalMsg, toolCallId: toolCall.id });
3564
3598
  auditLog.log({ event: 'task_killed_circuit_breaker', taskId: this.taskId, reason: fatalMsg });
3565
- // Save memory of failure for RLTF
3566
- cortexDb.saveMemory(this.currentTaskPrompt || 'Unknown task', 'Agent stubbornly repeated blocked actions causing an infinite loop.', `Do NOT repeat ${functionName} with these exact arguments, as it is permanently blocked by Sandbox. Ensure you respect ALLOWED WORKSPACE PATHS.`).catch(() => { });
3599
+ // Save memory of failure for RLTF only when Cortex is explicitly enabled
3600
+ if (this.config?.cortex?.enabled) {
3601
+ cortexDb.saveMemory(this.currentTaskPrompt || 'Unknown task', 'Agent stubbornly repeated blocked actions causing an infinite loop.', `Do NOT repeat ${functionName} with these exact arguments, as it is permanently blocked by Sandbox. Ensure you respect ALLOWED WORKSPACE PATHS.`, this.workspaceRoot).catch(() => { });
3602
+ }
3567
3603
  this.abort();
3568
3604
  break;
3569
3605
  }
package/src/agentLoop.ts CHANGED
@@ -20,7 +20,7 @@ import { TokenTracker } from './tokenTracker.js';
20
20
 
21
21
  import { getMemoryContextString } from './memory.js';
22
22
  import { MemoryManager } from './memoryManager.js';
23
- import { cortexDb } from './cortex/vectorDb.js';
23
+ import { cortexDb, isSearchablePrompt } from './cortex/vectorDb.js';
24
24
  import { buildStructuralSummary, condenseAndSave } from './cortex/autoCondenser.js';
25
25
  import { episodicStore, compileToolObservation } from './memory/episodicStore.js';
26
26
  import { buildCodexStyleSummary, compactSessionMessages, autoCompactIfUnderPressure } from './core/contextCompactor.js';
@@ -937,10 +937,11 @@ export class AgentLoop {
937
937
  async buildStaticContext() {
938
938
  let lessonsLearned = '';
939
939
  this._lessonSimilarity = 0;
940
- if (this.currentTaskPrompt) {
940
+ const cortexEnabled = Boolean(this.config?.cortex?.enabled);
941
+ if (cortexEnabled && this.currentTaskPrompt && isSearchablePrompt(this.currentTaskPrompt)) {
941
942
  try {
942
- const matches = await cortexDb.search(this.currentTaskPrompt, 2);
943
- if (matches.length > 0) {
943
+ const matches = await cortexDb.search(this.currentTaskPrompt, 2, { workspace: this.workspaceRoot });
944
+ if (matches.length > 0 && matches[0]) {
944
945
  lessonsLearned = `\n\n🧠 DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m: any) => `- ${m.text}`).join('\n');
945
946
  this._lessonSimilarity = matches[0].similarity || 0;
946
947
  this.debugLog(`cortex search hit: ${(this._lessonSimilarity * 100).toFixed(0)}% similarity`);
@@ -961,7 +962,7 @@ export class AgentLoop {
961
962
 
962
963
  // Anti-Slop: Creative Pattern Memory (prevents repeating the same design approach)
963
964
  let antiRepeatDirective = '';
964
- if (this.currentTaskPrompt && isWebIntent(this.currentTaskPrompt)) {
965
+ if (cortexEnabled && this.currentTaskPrompt && isWebIntent(this.currentTaskPrompt)) {
965
966
  try {
966
967
  const recentPatterns = await cortexDb.getRecentCreativePatterns(5);
967
968
  if (recentPatterns.length > 0) {
@@ -2055,16 +2056,17 @@ export class AgentLoop {
2055
2056
  });
2056
2057
  this.notice(`Context compacted: ${removed} earlier messages condensed into a reviewable summary.`);
2057
2058
 
2058
- // V5 Cortex tiered condensation. Tier 1 (structural, free) always
2059
- // runs so the Digital Brain keeps learning on every provider. Tier 2
2060
- // (semantic, billed) is capped per task and fully tracked.
2061
- condenseAndSave(dropped, this.utilityProvider(), this.tokenTracker, {
2062
- enableLlmPass: this.config.enableCortexCondenser !== false,
2063
- maxLlmPasses: this.config.maxCortexCondenserPasses ?? 3,
2064
- passesUsed: this._cortexPassesUsed
2065
- }).then((outcome: any) => {
2066
- if (outcome.semantic) this._cortexPassesUsed++;
2067
- }).catch(() => {});
2059
+ // V5 Cortex tiered condensation. Gated behind opt-in config so Cortex
2060
+ // never runs or touches storage unless explicitly enabled.
2061
+ if (this.config?.cortex?.enabled) {
2062
+ condenseAndSave(dropped, this.utilityProvider(), this.tokenTracker, {
2063
+ enableLlmPass: this.config.enableCortexCondenser !== false,
2064
+ maxLlmPasses: this.config.maxCortexCondenserPasses ?? 3,
2065
+ passesUsed: this._cortexPassesUsed
2066
+ }).then((outcome: any) => {
2067
+ if (outcome.semantic) this._cortexPassesUsed++;
2068
+ }).catch(() => {});
2069
+ }
2068
2070
  }
2069
2071
  }
2070
2072
 
@@ -3072,18 +3074,38 @@ You are operating in a text-and-code modality without direct image pixel renderi
3072
3074
  }
3073
3075
 
3074
3076
  if (hasExternalActions && (isIncompleteTurn || isMidTaskProgress || (typeof contentText === 'string' && (contentText.startsWith('Antigravity executed:') || /^Turn completed by .+ over ACP\.$/i.test(contentText.trim()))))) {
3077
+ const cleanSubstantive = (text: unknown): string => {
3078
+ if (typeof text !== 'string') return '';
3079
+ return text
3080
+ .replace(/^Antigravity executed:[^\n]*\n*/i, '')
3081
+ .replace(/^Turn completed by [^\n]+ over ACP\.\s*/i, '')
3082
+ .trim();
3083
+ };
3084
+
3085
+ const currentSubstantive = cleanSubstantive(contentText);
3086
+ if (currentSubstantive.length >= 60) {
3087
+ this.emitEvent({
3088
+ type: 'agent_message',
3089
+ content: currentSubstantive
3090
+ });
3091
+ this.emitEvent({
3092
+ type: 'status',
3093
+ message: 'Task completed with verified deliverables.'
3094
+ });
3095
+ this.memoryManager.saveHistory(this.messages);
3096
+ break;
3097
+ }
3098
+
3075
3099
  const recentSubstantiveAssistant = [...this.messages].reverse().find(m =>
3076
3100
  m.role === 'assistant'
3077
3101
  && typeof m.content === 'string'
3078
- && m.content.trim().length >= 60
3079
- && !m.content.trim().startsWith('Antigravity executed:')
3080
- && !/^Turn completed by .+ over ACP\.$/i.test(m.content.trim())
3102
+ && cleanSubstantive(m.content).length >= 60
3081
3103
  );
3082
3104
 
3083
3105
  if (recentSubstantiveAssistant && typeof recentSubstantiveAssistant.content === 'string') {
3084
3106
  this.emitEvent({
3085
3107
  type: 'agent_message',
3086
- content: recentSubstantiveAssistant.content
3108
+ content: cleanSubstantive(recentSubstantiveAssistant.content)
3087
3109
  });
3088
3110
  this.emitEvent({
3089
3111
  type: 'status',
@@ -3107,6 +3129,20 @@ You are operating in a text-and-code modality without direct image pixel renderi
3107
3129
  break;
3108
3130
  }
3109
3131
 
3132
+ if (this.stepsCompleted > 0) {
3133
+ const summary = `Task completed (${this.stepsCompleted} step${this.stepsCompleted === 1 ? '' : 's'} executed). All verified deliverables and actions are in place.`;
3134
+ this.emitEvent({
3135
+ type: 'agent_message',
3136
+ content: summary
3137
+ });
3138
+ this.emitEvent({
3139
+ type: 'status',
3140
+ message: 'Task completed with verified deliverables.'
3141
+ });
3142
+ this.memoryManager.saveHistory(this.messages);
3143
+ break;
3144
+ }
3145
+
3110
3146
  this.emitEvent({
3111
3147
  type: 'error',
3112
3148
  message: 'The task stopped before completion after repeated incomplete turns without a final response. Work remains unfinished.'
@@ -3744,12 +3780,15 @@ You are operating in a text-and-code modality without direct image pixel renderi
3744
3780
  this.emitEvent({ type: 'step_error', tool: functionName, error: fatalMsg, toolCallId: toolCall.id });
3745
3781
  auditLog.log({ event: 'task_killed_circuit_breaker', taskId: this.taskId, reason: fatalMsg });
3746
3782
 
3747
- // Save memory of failure for RLTF
3748
- cortexDb.saveMemory(
3749
- this.currentTaskPrompt || 'Unknown task',
3750
- 'Agent stubbornly repeated blocked actions causing an infinite loop.',
3751
- `Do NOT repeat ${functionName} with these exact arguments, as it is permanently blocked by Sandbox. Ensure you respect ALLOWED WORKSPACE PATHS.`
3752
- ).catch(() => {});
3783
+ // Save memory of failure for RLTF only when Cortex is explicitly enabled
3784
+ if (this.config?.cortex?.enabled) {
3785
+ cortexDb.saveMemory(
3786
+ this.currentTaskPrompt || 'Unknown task',
3787
+ 'Agent stubbornly repeated blocked actions causing an infinite loop.',
3788
+ `Do NOT repeat ${functionName} with these exact arguments, as it is permanently blocked by Sandbox. Ensure you respect ALLOWED WORKSPACE PATHS.`,
3789
+ this.workspaceRoot
3790
+ ).catch(() => {});
3791
+ }
3753
3792
 
3754
3793
  this.abort();
3755
3794
  break;
@@ -970,13 +970,31 @@ export function undoLast(options = {}) {
970
970
  // a build script, `mv`, `rm` — announces no paths and produces ZERO file
971
971
  // entries. beginTask() snapshots the whole workspace tree precisely to cover
972
972
  // that case, and undoTask() already knows how to diff and restore it.
973
- //
974
- // So the store held hundreds of tree snapshots, cost megabytes to keep, and
975
- // `/undo` answered "no file changes have been checkpointed yet" — which was
976
- // not merely unhelpful, it was untrue.
977
- const candidates = listGroups(200).filter((group) =>
973
+ const ws = options.workspaceRoot ? path.resolve(options.workspaceRoot) : path.resolve(process.cwd());
974
+ const allCandidates = listGroups(200).filter((group) =>
978
975
  !group.taskId.startsWith('undo_') && isUndoable(group));
979
976
 
977
+ // Filter out dead temporary test directories
978
+ const validCandidates = allCandidates.filter((group) => {
979
+ const allPaths = [
980
+ ...group.trees.map((t) => t.root),
981
+ ...group.fileEntries.map((e) => e.path)
982
+ ];
983
+ if (allPaths.length > 0 && allPaths.every((p) => (p.startsWith('/var/folders/') || p.startsWith('/tmp/')) && !fs.existsSync(p))) {
984
+ return false;
985
+ }
986
+ return true;
987
+ });
988
+
989
+ // Prefer candidates belonging to the current workspace root
990
+ const workspaceCandidates = validCandidates.filter((group) => {
991
+ const matchesTree = group.trees.some((t) => t.root && (t.root === ws || ws.startsWith(t.root + path.sep) || t.root.startsWith(ws + path.sep)));
992
+ const matchesFile = group.fileEntries.some((e) => e.path && (e.path.startsWith(ws + path.sep) || e.path === ws));
993
+ return matchesTree || matchesFile;
994
+ });
995
+
996
+ const candidates = workspaceCandidates.length > 0 ? workspaceCandidates : validCandidates;
997
+
980
998
  if (candidates.length === 0) {
981
999
  return { ok: false, error: 'nothing has been checkpointed yet — no task has run in this workspace' };
982
1000
  }
package/src/cliMode.js CHANGED
@@ -556,8 +556,10 @@ export async function chatMode({ home = false } = {}) {
556
556
  // Deliberately NOT `continue` — fall through to the agent turn below.
557
557
  } else {
558
558
  // Every other command is terminal output and nothing more.
559
- const width = conn.renderer.width();
560
- const wrapped = wrapBlock(commandResult.output, width).join('\n');
559
+ const width = typeof conn.renderer.measure === 'function'
560
+ ? Math.max(30, conn.renderer.measure() - 4)
561
+ : Math.max(30, conn.renderer.width() - 4);
562
+ const wrapped = wrapBlock(commandResult.output, width).map((line) => line ? ` ${line}` : '').join('\n');
561
563
  const body = commandResult.ok ? wrapped : paint('danger', wrapped);
562
564
  conn.renderer.write('\n' + body + '\n');
563
565
  if (commandResult.output && (commandResult.output.includes('Now using') || commandResult.output.includes('Active model switched') || commandResult.output.includes('Saved API key'))) {