@causyne/agent 1.20.111 → 1.20.116

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 (151) hide show
  1. package/docs/ARCHITECTURE.md +29 -0
  2. package/package.json +1 -1
  3. package/src/agentLoop.js +72 -37
  4. package/src/agentLoop.ts +70 -38
  5. package/src/browser/browserRuntime.js +13 -8
  6. package/src/browser/browserRuntime.ts +16 -8
  7. package/src/browser/causyneBrowser.js +7 -2
  8. package/src/browser/causyneBrowser.ts +8 -2
  9. package/src/browser/searchProviders.js +18 -7
  10. package/src/browser/searchProviders.ts +17 -5
  11. package/src/browser/snapshotWindow.js +1 -1
  12. package/src/browser/snapshotWindow.ts +1 -1
  13. package/src/browser/urlPolicy.js +21 -10
  14. package/src/browser/urlPolicy.ts +19 -10
  15. package/src/browser/workspacePreview.js +13 -1
  16. package/src/browser/workspacePreview.ts +11 -1
  17. package/src/computerUse/visionGrounding.js +31 -27
  18. package/src/computerUse/visionGrounding.ts +27 -27
  19. package/src/continuum/ui/continuumPicker.js +14 -6
  20. package/src/continuum/ui/continuumPicker.ts +13 -6
  21. package/src/continuum/ui/continuumPickerView.js +24 -15
  22. package/src/continuum/ui/continuumPickerView.ts +24 -16
  23. package/src/observer/advisory.js +32 -22
  24. package/src/observer/advisory.ts +30 -18
  25. package/src/observer/coldObserver.js +21 -33
  26. package/src/observer/coldObserver.ts +20 -33
  27. package/src/observer/evidence.js +20 -13
  28. package/src/observer/evidence.ts +21 -13
  29. package/src/observer.js +47 -12
  30. package/src/observer.ts +50 -18
  31. package/src/pluginsFactory/discovery.js +28 -16
  32. package/src/pluginsFactory/discovery.ts +29 -16
  33. package/src/pluginsFactory/pluginsFactory.js +213 -38
  34. package/src/pluginsFactory/pluginsFactory.ts +218 -39
  35. package/src/pluginsFactory/strategy.js +26 -16
  36. package/src/pluginsFactory/strategy.ts +34 -19
  37. package/src/pluginsFactory/templates.js +183 -62
  38. package/src/pluginsFactory/templates.ts +174 -54
  39. package/src/timeMachine.js +43 -22
  40. package/src/timeMachine.ts +44 -22
  41. package/src/tool-scripts/desktop_act.applescript +1 -0
  42. package/src/tools/computerUse.js +23 -10
  43. package/src/tools/computerUse.ts +19 -8
  44. package/src/tools/desktopAct.js +12 -1
  45. package/src/tools/pluginsFactory.js +108 -5
  46. package/src/tools/pluginsFactory.ts +115 -5
  47. package/src/tui/CausyneRotor.js +24 -10
  48. package/src/tui/CausyneRotor.ts +25 -10
  49. package/src/tui/activityLayout.js +9 -5
  50. package/src/tui/activityLayout.ts +9 -5
  51. package/src/tui/ask.js +34 -14
  52. package/src/tui/banner.js +55 -18
  53. package/src/tui/banner.ts +52 -17
  54. package/src/tui/block.js +47 -20
  55. package/src/tui/block.ts +54 -27
  56. package/src/tui/chatRenderer.js +135 -83
  57. package/src/tui/chatboxClipboard.js +12 -5
  58. package/src/tui/chatboxClipboard.ts +10 -4
  59. package/src/tui/clipboardImage.js +52 -42
  60. package/src/tui/clipboardImage.ts +50 -39
  61. package/src/tui/clipboardSync.js +12 -1
  62. package/src/tui/clipboardSync.ts +9 -1
  63. package/src/tui/codeProgress.js +57 -26
  64. package/src/tui/codeProgress.ts +57 -25
  65. package/src/tui/codeStreamRenderer.js +59 -14
  66. package/src/tui/codeStreamRenderer.ts +58 -14
  67. package/src/tui/commandPresentation.js +9 -2
  68. package/src/tui/commandPresentation.ts +9 -2
  69. package/src/tui/completion.js +45 -23
  70. package/src/tui/composerControls.js +21 -10
  71. package/src/tui/composerControls.ts +18 -10
  72. package/src/tui/composerGeometry.js +6 -4
  73. package/src/tui/composerGeometry.ts +6 -4
  74. package/src/tui/consoleGuard.js +29 -7
  75. package/src/tui/consoleGuard.ts +28 -7
  76. package/src/tui/dialogs.js +134 -71
  77. package/src/tui/diff.js +8 -4
  78. package/src/tui/history.js +6 -5
  79. package/src/tui/home.js +25 -13
  80. package/src/tui/homeView.js +37 -18
  81. package/src/tui/homeView.ts +38 -18
  82. package/src/tui/inlineSlash.js +6 -5
  83. package/src/tui/inlineSlash.ts +6 -5
  84. package/src/tui/keys.js +33 -17
  85. package/src/tui/layout.js +27 -9
  86. package/src/tui/layout.ts +26 -9
  87. package/src/tui/lineEditor.js +49 -23
  88. package/src/tui/markdownMath.js +64 -14
  89. package/src/tui/markdownMath.ts +69 -13
  90. package/src/tui/messageActionPlacement.js +28 -13
  91. package/src/tui/messageActionPlacement.ts +28 -13
  92. package/src/tui/messageInteraction.js +111 -46
  93. package/src/tui/messageInteraction.ts +115 -47
  94. package/src/tui/modelPicker.js +44 -15
  95. package/src/tui/modelPicker.ts +48 -15
  96. package/src/tui/observerPicker.js +56 -13
  97. package/src/tui/observerPicker.ts +73 -30
  98. package/src/tui/overlay.js +79 -35
  99. package/src/tui/overlay.ts +81 -34
  100. package/src/tui/prompt.js +162 -94
  101. package/src/tui/runningLight.js +1 -1
  102. package/src/tui/runningLight.ts +1 -1
  103. package/src/tui/scrollInteraction.js +64 -36
  104. package/src/tui/scrollInteraction.ts +70 -37
  105. package/src/tui/selectList.js +60 -32
  106. package/src/tui/sessionLayout.js +11 -3
  107. package/src/tui/sessionLayout.ts +10 -3
  108. package/src/tui/sessionPicker.js +74 -46
  109. package/src/tui/sessionPicker.ts +73 -48
  110. package/src/tui/sessionPickerView.js +32 -19
  111. package/src/tui/sessionPickerView.ts +31 -18
  112. package/src/tui/sessionSidebar.js +87 -57
  113. package/src/tui/sessionSidebar.ts +90 -54
  114. package/src/tui/setup.js +28 -3
  115. package/src/tui/setup.ts +27 -3
  116. package/src/tui/skillAuthoring.js +11 -5
  117. package/src/tui/skillAuthoring.ts +11 -5
  118. package/src/tui/smartLinkClick.js +75 -23
  119. package/src/tui/smartLinkClick.ts +86 -26
  120. package/src/tui/stage.js +47 -16
  121. package/src/tui/stage.ts +53 -18
  122. package/src/tui/stageSurface.js +120 -49
  123. package/src/tui/statusLine.js +85 -53
  124. package/src/tui/statusLine.ts +82 -46
  125. package/src/tui/terminalInputFramer.js +5 -2
  126. package/src/tui/text.js +117 -46
  127. package/src/tui/text.ts +113 -43
  128. package/src/tui/textLayout.js +6 -4
  129. package/src/tui/textLayout.ts +11 -5
  130. package/src/tui/theme.js +17 -8
  131. package/src/tui/thinkingBox.js +95 -95
  132. package/src/tui/thinkingBox.ts +105 -80
  133. package/src/tui/toolActivityPolicy.js +8 -1
  134. package/src/tui/toolActivityPolicy.ts +7 -1
  135. package/src/tui/toolDisplay.js +15 -6
  136. package/src/tui/toolDisplay.ts +16 -6
  137. package/src/tui/toolOutputNormalizer.js +16 -3
  138. package/src/tui/toolOutputNormalizer.ts +13 -3
  139. package/src/tui/transcript.js +15 -9
  140. package/src/tui/turnRail.js +156 -67
  141. package/src/tui/turnRail.ts +155 -58
  142. package/src/tui/usageCard.js +80 -45
  143. package/src/tui/usageCard.ts +81 -46
  144. package/src/tui/viewport.js +48 -23
  145. package/src/tui/viewport.ts +48 -27
  146. package/src/tui/viewportAnchor.js +2 -2
  147. package/src/tui/viewportAnchor.ts +2 -2
  148. package/src/tui/workspaceFileIndex.js +8 -6
  149. package/src/tui/workspaceFileIndex.ts +8 -6
  150. package/src/tui/workspaceSwitch.js +13 -10
  151. package/src/tui/workspaceSwitch.ts +11 -7
@@ -57,9 +57,9 @@ export class ScrollAcceleration {
57
57
  lastTick: number;
58
58
 
59
59
  constructor({ history = 3, streakTimeout = 150, minTickInterval = 6 }: ScrollAccelerationOptions = {}) {
60
- this.historySize = history;
61
- this.streakTimeout = streakTimeout;
62
- this.minTickInterval = minTickInterval;
60
+ this.historySize = Number.isFinite(history) ? Math.max(0, Math.floor(history)) : 3;
61
+ this.streakTimeout = Number.isFinite(streakTimeout) && streakTimeout >= 0 ? streakTimeout : 150;
62
+ this.minTickInterval = Number.isFinite(minTickInterval) && minTickInterval >= 0 ? minTickInterval : 6;
63
63
  this.intervals = [];
64
64
  this.lastTick = 0;
65
65
  }
@@ -70,6 +70,7 @@ export class ScrollAcceleration {
70
70
  }
71
71
 
72
72
  tick(now: number = Date.now()): number {
73
+ if (!Number.isFinite(now)) return 1;
73
74
  const A = 0.8;
74
75
  const tau = 3;
75
76
  const maxMultiplier = 6;
@@ -80,11 +81,14 @@ export class ScrollAcceleration {
80
81
  this.intervals = [];
81
82
  return 1;
82
83
  }
83
- if (gap < this.minTickInterval) return 1;
84
+ if (gap < Math.max(0, this.minTickInterval)) return 1;
84
85
 
85
86
  this.lastTick = now;
86
- this.intervals.push(gap);
87
- if (this.intervals.length > this.historySize) this.intervals.shift();
87
+ if (this.historySize > 0) {
88
+ this.intervals.push(gap);
89
+ while (this.intervals.length > this.historySize) this.intervals.shift();
90
+ }
91
+ if (this.intervals.length === 0) return 1;
88
92
 
89
93
  const average = this.intervals.reduce((sum, v) => sum + v, 0) / this.intervals.length;
90
94
  const velocity = 100 / average;
@@ -146,17 +150,18 @@ export class Viewport {
146
150
  lastWheelMoved: boolean;
147
151
  lastWheelDirection: 'up' | 'down' | null;
148
152
 
149
- constructor({
150
- transcript = null,
151
- height = 20,
152
- width = 80,
153
- speed = DEFAULT_SCROLL_SPEED,
154
- acceleration = null
155
- }: ViewportOptions = {}) {
153
+ constructor(options: ViewportOptions | null = {}) {
154
+ const {
155
+ transcript = null,
156
+ height = 20,
157
+ width = 80,
158
+ speed = DEFAULT_SCROLL_SPEED,
159
+ acceleration = null
160
+ } = options || {};
156
161
  this.transcript = transcript;
157
- this.viewHeight = Math.max(1, Math.floor(height));
158
- this.viewWidth = Math.max(1, Math.floor(width));
159
- this.speed = speed > 0 ? speed : DEFAULT_SCROLL_SPEED;
162
+ this.viewHeight = Number.isFinite(height) ? Math.max(1, Math.floor(height)) : 20;
163
+ this.viewWidth = Number.isFinite(width) ? Math.max(1, Math.floor(width)) : 80;
164
+ this.speed = Number.isFinite(speed) && speed > 0 ? speed : DEFAULT_SCROLL_SPEED;
160
165
  this.acceleration = acceleration || null;
161
166
 
162
167
  this.scrollTop = 0;
@@ -174,11 +179,12 @@ export class Viewport {
174
179
  /**
175
180
  * Geometry changed — a resize, or the input box growing under the viewport.
176
181
  */
177
- resize({ height, width }: { height?: number; width?: number } = {}): void {
182
+ resize(options: { height?: number; width?: number } | null = {}): void {
183
+ const { height, width } = options || {};
178
184
  const nextHeight = height !== undefined && Number.isFinite(height) && height > 0
179
- ? Math.floor(height) : this.viewHeight;
185
+ ? Math.max(1, Math.floor(height)) : this.viewHeight;
180
186
  const nextWidth = width !== undefined && Number.isFinite(width) && width > 0
181
- ? Math.floor(width) : this.viewWidth;
187
+ ? Math.max(1, Math.floor(width)) : this.viewWidth;
182
188
  const reflow = nextWidth !== this.viewWidth;
183
189
  const anchor = reflow && this.manual && this.transcript?.markers
184
190
  ? captureReadingAnchor(this.transcript.markers(this.viewWidth), this.scrollTop,
@@ -187,9 +193,10 @@ export class Viewport {
187
193
  this.viewHeight = nextHeight;
188
194
  this.viewWidth = nextWidth;
189
195
  if (anchor && this.transcript?.markers) {
190
- this.scrollTop = restoreReadingAnchor(anchor, this.transcript.markers(nextWidth),
196
+ const restored = restoreReadingAnchor(anchor, this.transcript.markers(nextWidth),
191
197
  this.transcript.height(nextWidth), nextHeight);
192
198
  const max = this.maxScrollTop();
199
+ this.scrollTop = Number.isFinite(restored) ? Math.max(0, Math.min(max, Math.floor(restored))) : max;
193
200
  // A deliberate scroll must not suddenly become follow-mode just because
194
201
  // a paragraph gained or lost wrapped rows during resize.
195
202
  this.manual = max > 0 && this.scrollTop < max;
@@ -200,7 +207,8 @@ export class Viewport {
200
207
  }
201
208
 
202
209
  contentHeight(): number {
203
- return this.transcript ? this.transcript.height(this.viewWidth) : 0;
210
+ const measured = this.transcript ? this.transcript.height(this.viewWidth) : 0;
211
+ return Number.isFinite(measured) ? Math.max(0, Math.floor(measured)) : 0;
204
212
  }
205
213
 
206
214
  maxScrollTop(): number {
@@ -240,29 +248,33 @@ export class Viewport {
240
248
  * evicted. This is where auto-scroll actually happens.
241
249
  */
242
250
  refresh(grownBy: number = 0): void {
251
+ const safeGrownBy = Number.isFinite(grownBy) && grownBy > 0 ? grownBy : 0;
243
252
  const wasApplying = this.applyingSticky;
244
253
  this.applyingSticky = true;
245
254
  try {
246
255
  const max = this.maxScrollTop();
247
- const tolerance = grownBy > 0 ? REENGAGE_TOLERANCE : 0;
256
+ const tolerance = safeGrownBy > 0 ? REENGAGE_TOLERANCE : 0;
248
257
 
249
- if (!this.manual) {
258
+ if (!this.manual || max <= 0) {
259
+ this.manual = false;
250
260
  this.scrollTop = max;
251
261
  this.unseen = 0;
252
- } else if (max > 0 && this.scrollTop >= max - tolerance) {
262
+ } else if (this.scrollTop >= max - tolerance) {
253
263
  this.manual = false;
254
264
  this.scrollTop = max;
255
265
  this.unseen = 0;
256
266
  } else {
257
267
  this.scrollTop = Math.min(this.scrollTop, max);
258
- if (grownBy > 0) this.unseen += grownBy;
268
+ if (safeGrownBy > 0) this.unseen += safeGrownBy;
259
269
  }
260
270
  } finally {
261
271
  this.applyingSticky = wasApplying;
262
272
  }
263
273
  }
264
274
 
265
- scrollTo(position: number, { snap = false }: { snap?: boolean } = {}): number {
275
+ scrollTo(position: number, options: { snap?: boolean } | null = {}): number {
276
+ const { snap = false } = options || {};
277
+ if (!Number.isFinite(position)) return this.scrollTop;
266
278
  const max = this.maxScrollTop();
267
279
  let next = Math.max(0, Math.min(Math.round(position), max));
268
280
 
@@ -284,6 +296,10 @@ export class Viewport {
284
296
  * quietly round to 1 or 2 forever.
285
297
  */
286
298
  wheel(direction: 'up' | 'down', notches: number = 1, now: number = Date.now()): number {
299
+ if (!Number.isFinite(notches) || !Number.isFinite(now)) {
300
+ this.lastWheelMoved = false;
301
+ return this.scrollTop;
302
+ }
287
303
  const before = this.scrollTop;
288
304
  if (this.lastWheelDirection && this.lastWheelDirection !== direction) {
289
305
  this.accumulator = 0;
@@ -292,6 +308,10 @@ export class Viewport {
292
308
 
293
309
  const multiplier = this.acceleration ? this.acceleration.tick(now) : 1;
294
310
  const amount = Math.abs(notches) * this.speed * multiplier;
311
+ if (!Number.isFinite(amount)) {
312
+ this.lastWheelMoved = false;
313
+ return this.scrollTop;
314
+ }
295
315
  this.accumulator += direction === 'up' ? -amount : amount;
296
316
  const whole = Math.trunc(this.accumulator);
297
317
  if (whole !== 0) {
@@ -318,9 +338,10 @@ export class Viewport {
318
338
  }
319
339
 
320
340
  jump(direction: number, kinds: string[] | null = null): number {
341
+ if (!Number.isFinite(direction) || direction === 0) return this.scrollTop;
321
342
  if (!this.transcript || typeof this.transcript.markers !== 'function') return this.scrollTop;
322
343
  const markers = this.transcript.markers(this.viewWidth)
323
- .filter((m) => !kinds || kinds.includes(m.kind));
344
+ .filter((m) => Boolean(m && Number.isFinite(m.row) && (!kinds || kinds.includes(m.kind))));
324
345
  if (markers.length === 0) return this.scrollTop;
325
346
 
326
347
  if (direction < 0) {
@@ -59,8 +59,8 @@ export function restoreReadingAnchor(anchor, markers, totalHeight, viewportHeigh
59
59
  let selected = anchor.id == null
60
60
  ? -1
61
61
  : entries.findIndex(marker => marker.id === anchor.id);
62
- if (selected < 0 && anchor.id == null && entries[anchor.index]?.originalIndex === anchor.index) {
63
- selected = anchor.index;
62
+ if (selected < 0 && anchor.id == null) {
63
+ selected = entries.findIndex(marker => marker.originalIndex === anchor.index);
64
64
  }
65
65
  if (selected < 0) {
66
66
  // When the anchored frame was evicted, recover in the surviving transcript.
@@ -86,8 +86,8 @@ export function restoreReadingAnchor(
86
86
  let selected = anchor.id == null
87
87
  ? -1
88
88
  : entries.findIndex(marker => marker.id === anchor.id);
89
- if (selected < 0 && anchor.id == null && entries[anchor.index]?.originalIndex === anchor.index) {
90
- selected = anchor.index;
89
+ if (selected < 0 && anchor.id == null) {
90
+ selected = entries.findIndex(marker => marker.originalIndex === anchor.index);
91
91
  }
92
92
  if (selected < 0) {
93
93
  // When the anchored frame was evicted, recover in the surviving transcript.
@@ -38,11 +38,13 @@ export class WorkspaceFileIndex {
38
38
  maxDepth;
39
39
  refreshMs;
40
40
  constructor(root, options = {}) {
41
- this.root = path.resolve(root);
42
- this.maxEntries = finiteInt(options.maxEntries, DEFAULT_MAX_ENTRIES);
43
- this.maxDirs = finiteInt(options.maxDirs, DEFAULT_MAX_DIRS);
44
- this.maxDepth = finiteInt(options.maxDepth, DEFAULT_MAX_DEPTH);
45
- this.refreshMs = finiteInt(options.refreshMs, DEFAULT_REFRESH_MS, 0);
41
+ const safeRoot = typeof root === 'string' && root.length > 0 ? root : '.';
42
+ const safeOptions = options && typeof options === 'object' ? options : {};
43
+ this.root = path.resolve(safeRoot);
44
+ this.maxEntries = finiteInt(safeOptions.maxEntries, DEFAULT_MAX_ENTRIES);
45
+ this.maxDirs = finiteInt(safeOptions.maxDirs, DEFAULT_MAX_DIRS);
46
+ this.maxDepth = finiteInt(safeOptions.maxDepth, DEFAULT_MAX_DEPTH);
47
+ this.refreshMs = finiteInt(safeOptions.refreshMs, DEFAULT_REFRESH_MS, 0);
46
48
  }
47
49
  get isReady() { return this.entries !== null; }
48
50
  get isBuilding() { return this.building !== null; }
@@ -108,7 +110,7 @@ export class WorkspaceFileIndex {
108
110
  }
109
111
  /** Contiguous matches take priority; fuzzy matching remains the JS fallback. */
110
112
  candidates(query) {
111
- if (!query)
113
+ if (typeof query !== 'string' || !query)
112
114
  return this.entries ?? [];
113
115
  const needle = query.toLocaleLowerCase();
114
116
  const direct = this.indexed.filter(entry => entry.folded.includes(needle));
@@ -55,11 +55,13 @@ export class WorkspaceFileIndex {
55
55
  private readonly refreshMs: number;
56
56
 
57
57
  constructor(root: string, options: WorkspaceFileIndexOptions = {}) {
58
- this.root = path.resolve(root);
59
- this.maxEntries = finiteInt(options.maxEntries, DEFAULT_MAX_ENTRIES);
60
- this.maxDirs = finiteInt(options.maxDirs, DEFAULT_MAX_DIRS);
61
- this.maxDepth = finiteInt(options.maxDepth, DEFAULT_MAX_DEPTH);
62
- this.refreshMs = finiteInt(options.refreshMs, DEFAULT_REFRESH_MS, 0);
58
+ const safeRoot = typeof root === 'string' && root.length > 0 ? root : '.';
59
+ const safeOptions = options && typeof options === 'object' ? options : {};
60
+ this.root = path.resolve(safeRoot);
61
+ this.maxEntries = finiteInt(safeOptions.maxEntries, DEFAULT_MAX_ENTRIES);
62
+ this.maxDirs = finiteInt(safeOptions.maxDirs, DEFAULT_MAX_DIRS);
63
+ this.maxDepth = finiteInt(safeOptions.maxDepth, DEFAULT_MAX_DEPTH);
64
+ this.refreshMs = finiteInt(safeOptions.refreshMs, DEFAULT_REFRESH_MS, 0);
63
65
  }
64
66
 
65
67
  get isReady(): boolean { return this.entries !== null; }
@@ -120,7 +122,7 @@ export class WorkspaceFileIndex {
120
122
 
121
123
  /** Contiguous matches take priority; fuzzy matching remains the JS fallback. */
122
124
  candidates(query: string): string[] {
123
- if (!query) return this.entries ?? [];
125
+ if (typeof query !== 'string' || !query) return this.entries ?? [];
124
126
  const needle = query.toLocaleLowerCase();
125
127
  const direct = this.indexed.filter(entry => entry.folded.includes(needle));
126
128
  return (direct.length > 0 ? direct.map(entry => entry.value) : this.entries ?? []);
@@ -26,7 +26,8 @@ export function switchChatWorkspace({ workspaceRoot, createLoop, prompt = null,
26
26
  replacement.waitForApproval = approvalHandler;
27
27
  replacement.waitForDecision = decisionHandler;
28
28
  if (prompt) {
29
- prompt.setWorkingRoot(workspaceRoot);
29
+ if (typeof prompt.setWorkingRoot === 'function')
30
+ prompt.setWorkingRoot(workspaceRoot);
30
31
  prompt.messageActionLoop = replacement;
31
32
  // A workspace switch is also a change of task context. Do not transfer
32
33
  // queued attachments or active skills from the previous workspace.
@@ -35,18 +36,20 @@ export function switchChatWorkspace({ workspaceRoot, createLoop, prompt = null,
35
36
  if (typeof prompt.scheduleDraw === 'function')
36
37
  prompt.scheduleDraw();
37
38
  }
39
+ const workspaceLabel = replacement.sandbox?.grantAllAccess
40
+ ? 'ALL ACCESS'
41
+ : (Array.isArray(replacement.sandbox?.workspacePaths) ? replacement.sandbox.workspacePaths.join(', ') : '');
38
42
  if (headerInfo) {
39
43
  headerInfo.cwd = workspaceRoot;
40
- headerInfo.workspace = replacement.sandbox?.grantAllAccess
41
- ? 'ALL ACCESS'
42
- : replacement.sandbox?.workspacePaths?.join(', ') ?? '';
43
- if (renderer?.status?.setSession)
44
+ headerInfo.workspace = workspaceLabel;
45
+ if (typeof renderer?.status?.setSession === 'function')
44
46
  renderer.status.setSession(headerInfo);
45
- if (surface?.setSessionInfo)
46
- surface.setSessionInfo({
47
- ...headerInfo,
48
- activeSkill: null
49
- });
47
+ }
48
+ if (typeof surface?.setSessionInfo === 'function') {
49
+ surface.setSessionInfo({
50
+ ...(headerInfo || { cwd: workspaceRoot, workspace: workspaceLabel }),
51
+ activeSkill: null
52
+ });
50
53
  }
51
54
  return replacement;
52
55
  }
@@ -54,7 +54,7 @@ export function switchChatWorkspace<TLoop extends {
54
54
  replacement.waitForDecision = decisionHandler;
55
55
 
56
56
  if (prompt) {
57
- prompt.setWorkingRoot(workspaceRoot);
57
+ if (typeof prompt.setWorkingRoot === 'function') prompt.setWorkingRoot(workspaceRoot);
58
58
  prompt.messageActionLoop = replacement;
59
59
  // A workspace switch is also a change of task context. Do not transfer
60
60
  // queued attachments or active skills from the previous workspace.
@@ -63,14 +63,18 @@ export function switchChatWorkspace<TLoop extends {
63
63
  if (typeof prompt.scheduleDraw === 'function') prompt.scheduleDraw();
64
64
  }
65
65
 
66
+ const workspaceLabel = replacement.sandbox?.grantAllAccess
67
+ ? 'ALL ACCESS'
68
+ : (Array.isArray(replacement.sandbox?.workspacePaths) ? replacement.sandbox.workspacePaths.join(', ') : '');
69
+
66
70
  if (headerInfo) {
67
71
  headerInfo.cwd = workspaceRoot;
68
- headerInfo.workspace = replacement.sandbox?.grantAllAccess
69
- ? 'ALL ACCESS'
70
- : replacement.sandbox?.workspacePaths?.join(', ') ?? '';
71
- if (renderer?.status?.setSession) renderer.status.setSession(headerInfo);
72
- if (surface?.setSessionInfo) surface.setSessionInfo({
73
- ...headerInfo,
72
+ headerInfo.workspace = workspaceLabel;
73
+ if (typeof renderer?.status?.setSession === 'function') renderer.status.setSession(headerInfo);
74
+ }
75
+ if (typeof surface?.setSessionInfo === 'function') {
76
+ surface.setSessionInfo({
77
+ ...(headerInfo || { cwd: workspaceRoot, workspace: workspaceLabel }),
74
78
  activeSkill: null
75
79
  });
76
80
  }