@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.
- package/docs/ARCHITECTURE.md +29 -0
- package/package.json +1 -1
- package/src/agentLoop.js +72 -37
- package/src/agentLoop.ts +70 -38
- package/src/browser/browserRuntime.js +13 -8
- package/src/browser/browserRuntime.ts +16 -8
- package/src/browser/causyneBrowser.js +7 -2
- package/src/browser/causyneBrowser.ts +8 -2
- package/src/browser/searchProviders.js +18 -7
- package/src/browser/searchProviders.ts +17 -5
- package/src/browser/snapshotWindow.js +1 -1
- package/src/browser/snapshotWindow.ts +1 -1
- package/src/browser/urlPolicy.js +21 -10
- package/src/browser/urlPolicy.ts +19 -10
- package/src/browser/workspacePreview.js +13 -1
- package/src/browser/workspacePreview.ts +11 -1
- package/src/computerUse/visionGrounding.js +31 -27
- package/src/computerUse/visionGrounding.ts +27 -27
- package/src/continuum/ui/continuumPicker.js +14 -6
- package/src/continuum/ui/continuumPicker.ts +13 -6
- package/src/continuum/ui/continuumPickerView.js +24 -15
- package/src/continuum/ui/continuumPickerView.ts +24 -16
- package/src/observer/advisory.js +32 -22
- package/src/observer/advisory.ts +30 -18
- package/src/observer/coldObserver.js +21 -33
- package/src/observer/coldObserver.ts +20 -33
- package/src/observer/evidence.js +20 -13
- package/src/observer/evidence.ts +21 -13
- package/src/observer.js +47 -12
- package/src/observer.ts +50 -18
- package/src/pluginsFactory/discovery.js +28 -16
- package/src/pluginsFactory/discovery.ts +29 -16
- package/src/pluginsFactory/pluginsFactory.js +213 -38
- package/src/pluginsFactory/pluginsFactory.ts +218 -39
- package/src/pluginsFactory/strategy.js +26 -16
- package/src/pluginsFactory/strategy.ts +34 -19
- package/src/pluginsFactory/templates.js +183 -62
- package/src/pluginsFactory/templates.ts +174 -54
- package/src/timeMachine.js +43 -22
- package/src/timeMachine.ts +44 -22
- package/src/tool-scripts/desktop_act.applescript +1 -0
- package/src/tools/computerUse.js +23 -10
- package/src/tools/computerUse.ts +19 -8
- package/src/tools/desktopAct.js +12 -1
- package/src/tools/pluginsFactory.js +108 -5
- package/src/tools/pluginsFactory.ts +115 -5
- package/src/tui/CausyneRotor.js +24 -10
- package/src/tui/CausyneRotor.ts +25 -10
- package/src/tui/activityLayout.js +9 -5
- package/src/tui/activityLayout.ts +9 -5
- package/src/tui/ask.js +34 -14
- package/src/tui/banner.js +55 -18
- package/src/tui/banner.ts +52 -17
- package/src/tui/block.js +47 -20
- package/src/tui/block.ts +54 -27
- package/src/tui/chatRenderer.js +135 -83
- package/src/tui/chatboxClipboard.js +12 -5
- package/src/tui/chatboxClipboard.ts +10 -4
- package/src/tui/clipboardImage.js +52 -42
- package/src/tui/clipboardImage.ts +50 -39
- package/src/tui/clipboardSync.js +12 -1
- package/src/tui/clipboardSync.ts +9 -1
- package/src/tui/codeProgress.js +57 -26
- package/src/tui/codeProgress.ts +57 -25
- package/src/tui/codeStreamRenderer.js +59 -14
- package/src/tui/codeStreamRenderer.ts +58 -14
- package/src/tui/commandPresentation.js +9 -2
- package/src/tui/commandPresentation.ts +9 -2
- package/src/tui/completion.js +45 -23
- package/src/tui/composerControls.js +21 -10
- package/src/tui/composerControls.ts +18 -10
- package/src/tui/composerGeometry.js +6 -4
- package/src/tui/composerGeometry.ts +6 -4
- package/src/tui/consoleGuard.js +29 -7
- package/src/tui/consoleGuard.ts +28 -7
- package/src/tui/dialogs.js +134 -71
- package/src/tui/diff.js +8 -4
- package/src/tui/history.js +6 -5
- package/src/tui/home.js +25 -13
- package/src/tui/homeView.js +37 -18
- package/src/tui/homeView.ts +38 -18
- package/src/tui/inlineSlash.js +6 -5
- package/src/tui/inlineSlash.ts +6 -5
- package/src/tui/keys.js +33 -17
- package/src/tui/layout.js +27 -9
- package/src/tui/layout.ts +26 -9
- package/src/tui/lineEditor.js +49 -23
- package/src/tui/markdownMath.js +64 -14
- package/src/tui/markdownMath.ts +69 -13
- package/src/tui/messageActionPlacement.js +28 -13
- package/src/tui/messageActionPlacement.ts +28 -13
- package/src/tui/messageInteraction.js +111 -46
- package/src/tui/messageInteraction.ts +115 -47
- package/src/tui/modelPicker.js +44 -15
- package/src/tui/modelPicker.ts +48 -15
- package/src/tui/observerPicker.js +56 -13
- package/src/tui/observerPicker.ts +73 -30
- package/src/tui/overlay.js +79 -35
- package/src/tui/overlay.ts +81 -34
- package/src/tui/prompt.js +162 -94
- package/src/tui/runningLight.js +1 -1
- package/src/tui/runningLight.ts +1 -1
- package/src/tui/scrollInteraction.js +64 -36
- package/src/tui/scrollInteraction.ts +70 -37
- package/src/tui/selectList.js +60 -32
- package/src/tui/sessionLayout.js +11 -3
- package/src/tui/sessionLayout.ts +10 -3
- package/src/tui/sessionPicker.js +74 -46
- package/src/tui/sessionPicker.ts +73 -48
- package/src/tui/sessionPickerView.js +32 -19
- package/src/tui/sessionPickerView.ts +31 -18
- package/src/tui/sessionSidebar.js +87 -57
- package/src/tui/sessionSidebar.ts +90 -54
- package/src/tui/setup.js +28 -3
- package/src/tui/setup.ts +27 -3
- package/src/tui/skillAuthoring.js +11 -5
- package/src/tui/skillAuthoring.ts +11 -5
- package/src/tui/smartLinkClick.js +75 -23
- package/src/tui/smartLinkClick.ts +86 -26
- package/src/tui/stage.js +47 -16
- package/src/tui/stage.ts +53 -18
- package/src/tui/stageSurface.js +120 -49
- package/src/tui/statusLine.js +85 -53
- package/src/tui/statusLine.ts +82 -46
- package/src/tui/terminalInputFramer.js +5 -2
- package/src/tui/text.js +117 -46
- package/src/tui/text.ts +113 -43
- package/src/tui/textLayout.js +6 -4
- package/src/tui/textLayout.ts +11 -5
- package/src/tui/theme.js +17 -8
- package/src/tui/thinkingBox.js +95 -95
- package/src/tui/thinkingBox.ts +105 -80
- package/src/tui/toolActivityPolicy.js +8 -1
- package/src/tui/toolActivityPolicy.ts +7 -1
- package/src/tui/toolDisplay.js +15 -6
- package/src/tui/toolDisplay.ts +16 -6
- package/src/tui/toolOutputNormalizer.js +16 -3
- package/src/tui/toolOutputNormalizer.ts +13 -3
- package/src/tui/transcript.js +15 -9
- package/src/tui/turnRail.js +156 -67
- package/src/tui/turnRail.ts +155 -58
- package/src/tui/usageCard.js +80 -45
- package/src/tui/usageCard.ts +81 -46
- package/src/tui/viewport.js +48 -23
- package/src/tui/viewport.ts +48 -27
- package/src/tui/viewportAnchor.js +2 -2
- package/src/tui/viewportAnchor.ts +2 -2
- package/src/tui/workspaceFileIndex.js +8 -6
- package/src/tui/workspaceFileIndex.ts +8 -6
- package/src/tui/workspaceSwitch.js +13 -10
- package/src/tui/workspaceSwitch.ts +11 -7
package/src/tui/toolDisplay.js
CHANGED
|
@@ -124,8 +124,14 @@ function fallbackDisplay(toolName, args) {
|
|
|
124
124
|
*
|
|
125
125
|
* Never throws: a display helper must not be able to break the transcript.
|
|
126
126
|
*/
|
|
127
|
+
function cleanSingleLine(text) {
|
|
128
|
+
return safeDisplay(text).replace(/\s+/g, ' ').trim();
|
|
129
|
+
}
|
|
130
|
+
function normalizeRecordArgs(args) {
|
|
131
|
+
return args && typeof args === 'object' && !Array.isArray(args) ? args : {};
|
|
132
|
+
}
|
|
127
133
|
export function describeTool(toolName, args) {
|
|
128
|
-
const safeArgs = args
|
|
134
|
+
const safeArgs = normalizeRecordArgs(args);
|
|
129
135
|
const safeName = typeof toolName === 'string' ? toolName : '';
|
|
130
136
|
let display;
|
|
131
137
|
try {
|
|
@@ -136,9 +142,9 @@ export function describeTool(toolName, args) {
|
|
|
136
142
|
display = fallbackDisplay(safeName, safeArgs);
|
|
137
143
|
}
|
|
138
144
|
return {
|
|
139
|
-
verb:
|
|
145
|
+
verb: cleanSingleLine(display.verb || ''),
|
|
140
146
|
// Untrusted: an argument can carry escapes or a credential the model echoed.
|
|
141
|
-
detail:
|
|
147
|
+
detail: cleanSingleLine(display.detail || '')
|
|
142
148
|
};
|
|
143
149
|
}
|
|
144
150
|
/** True when a curated entry exists — used by tests and by /help style output. */
|
|
@@ -150,13 +156,16 @@ export function hasCuratedDisplay(toolName) {
|
|
|
150
156
|
* row. Reuses the same ordering and the same redaction.
|
|
151
157
|
*/
|
|
152
158
|
export function describeToolForApproval(args) {
|
|
153
|
-
const safeArgs = args
|
|
159
|
+
const safeArgs = normalizeRecordArgs(args);
|
|
154
160
|
const lines = [];
|
|
155
161
|
for (const key of FALLBACK_KEYS) {
|
|
156
162
|
const value = safeArgs[key];
|
|
157
163
|
if (typeof value !== 'string' || value.length === 0)
|
|
158
164
|
continue;
|
|
159
|
-
|
|
165
|
+
const cleaned = cleanSingleLine(shortenHome(value));
|
|
166
|
+
if (!cleaned)
|
|
167
|
+
continue;
|
|
168
|
+
lines.push(`${key}: ${cleaned}`);
|
|
160
169
|
if (lines.length >= 4)
|
|
161
170
|
break;
|
|
162
171
|
}
|
|
@@ -164,7 +173,7 @@ export function describeToolForApproval(args) {
|
|
|
164
173
|
try {
|
|
165
174
|
const compact = JSON.stringify(safeArgs);
|
|
166
175
|
if (compact && compact !== '{}')
|
|
167
|
-
lines.push(
|
|
176
|
+
lines.push(cleanSingleLine(compact));
|
|
168
177
|
}
|
|
169
178
|
catch { /* nothing showable */ }
|
|
170
179
|
}
|
package/src/tui/toolDisplay.ts
CHANGED
|
@@ -142,8 +142,16 @@ function fallbackDisplay(toolName: string, args: Record<string, unknown>): ToolD
|
|
|
142
142
|
*
|
|
143
143
|
* Never throws: a display helper must not be able to break the transcript.
|
|
144
144
|
*/
|
|
145
|
+
function cleanSingleLine(text: string): string {
|
|
146
|
+
return safeDisplay(text).replace(/\s+/g, ' ').trim();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function normalizeRecordArgs(args?: Record<string, unknown> | null): Record<string, unknown> {
|
|
150
|
+
return args && typeof args === 'object' && !Array.isArray(args) ? args : {};
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
export function describeTool(toolName?: string, args?: Record<string, unknown> | null): ToolDisplayResult {
|
|
146
|
-
const safeArgs = args
|
|
154
|
+
const safeArgs = normalizeRecordArgs(args);
|
|
147
155
|
const safeName = typeof toolName === 'string' ? toolName : '';
|
|
148
156
|
let display: ToolDisplayResult;
|
|
149
157
|
|
|
@@ -155,9 +163,9 @@ export function describeTool(toolName?: string, args?: Record<string, unknown> |
|
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
return {
|
|
158
|
-
verb:
|
|
166
|
+
verb: cleanSingleLine(display.verb || ''),
|
|
159
167
|
// Untrusted: an argument can carry escapes or a credential the model echoed.
|
|
160
|
-
detail:
|
|
168
|
+
detail: cleanSingleLine(display.detail || '')
|
|
161
169
|
};
|
|
162
170
|
}
|
|
163
171
|
|
|
@@ -171,20 +179,22 @@ export function hasCuratedDisplay(toolName: string): boolean {
|
|
|
171
179
|
* row. Reuses the same ordering and the same redaction.
|
|
172
180
|
*/
|
|
173
181
|
export function describeToolForApproval(args?: Record<string, unknown> | null): string[] {
|
|
174
|
-
const safeArgs = args
|
|
182
|
+
const safeArgs = normalizeRecordArgs(args);
|
|
175
183
|
const lines: string[] = [];
|
|
176
184
|
|
|
177
185
|
for (const key of FALLBACK_KEYS) {
|
|
178
186
|
const value = safeArgs[key];
|
|
179
187
|
if (typeof value !== 'string' || value.length === 0) continue;
|
|
180
|
-
|
|
188
|
+
const cleaned = cleanSingleLine(shortenHome(value));
|
|
189
|
+
if (!cleaned) continue;
|
|
190
|
+
lines.push(`${key}: ${cleaned}`);
|
|
181
191
|
if (lines.length >= 4) break;
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
if (lines.length === 0) {
|
|
185
195
|
try {
|
|
186
196
|
const compact = JSON.stringify(safeArgs);
|
|
187
|
-
if (compact && compact !== '{}') lines.push(
|
|
197
|
+
if (compact && compact !== '{}') lines.push(cleanSingleLine(compact));
|
|
188
198
|
} catch { /* nothing showable */ }
|
|
189
199
|
}
|
|
190
200
|
return lines;
|
|
@@ -100,8 +100,17 @@ function readSpillPreview(spillPath, maxBytes = 4096) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
function extractSpillPathFromDecay(content) {
|
|
103
|
-
const
|
|
104
|
-
|
|
103
|
+
const markerIndex = content.indexOf('— read or search');
|
|
104
|
+
if (markerIndex < 0)
|
|
105
|
+
return undefined;
|
|
106
|
+
const prefix = content.slice(0, markerIndex).trimEnd();
|
|
107
|
+
const atIndex = prefix.lastIndexOf(' at ');
|
|
108
|
+
if (atIndex < 0)
|
|
109
|
+
return undefined;
|
|
110
|
+
const candidate = prefix.slice(atIndex + 4).trim();
|
|
111
|
+
if (!candidate || candidate.includes('\n') || candidate.includes('\r'))
|
|
112
|
+
return undefined;
|
|
113
|
+
return candidate.startsWith('/') || /^[A-Za-z]:[\\/]/.test(candidate) ? candidate : undefined;
|
|
105
114
|
}
|
|
106
115
|
function recoverBrokenJsonOutput(raw, spillPath) {
|
|
107
116
|
const prefixMatch = /^\s*\{\s*"success"\s*:\s*(true|false)\b/.exec(raw);
|
|
@@ -140,6 +149,10 @@ function recoverBrokenJsonOutput(raw, spillPath) {
|
|
|
140
149
|
* `[decayed]` or shortened tool observations.
|
|
141
150
|
*/
|
|
142
151
|
export function normalizeHistoricalToolResult(toolName, toolMsg, options = {}) {
|
|
152
|
+
if (!toolMsg || typeof toolMsg !== 'object') {
|
|
153
|
+
return { skipStep: false, result: { success: true, output: '' } };
|
|
154
|
+
}
|
|
155
|
+
const safeOptions = options && typeof options === 'object' ? options : {};
|
|
143
156
|
const explicitSpill = typeof toolMsg.spillPath === 'string' && toolMsg.spillPath.trim()
|
|
144
157
|
? toolMsg.spillPath.trim()
|
|
145
158
|
: undefined;
|
|
@@ -151,7 +164,7 @@ export function normalizeHistoricalToolResult(toolName, toolMsg, options = {}) {
|
|
|
151
164
|
const success = !isFailure;
|
|
152
165
|
if (toolName === 'update_plan') {
|
|
153
166
|
return {
|
|
154
|
-
skipStep: Boolean(
|
|
167
|
+
skipStep: Boolean(safeOptions.unpaired),
|
|
155
168
|
result: { success: true, output: '' }
|
|
156
169
|
};
|
|
157
170
|
}
|
|
@@ -134,8 +134,14 @@ function readSpillPreview(spillPath: string, maxBytes = 4096): string {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
function extractSpillPathFromDecay(content: string): string | undefined {
|
|
137
|
-
const
|
|
138
|
-
return
|
|
137
|
+
const markerIndex = content.indexOf('— read or search');
|
|
138
|
+
if (markerIndex < 0) return undefined;
|
|
139
|
+
const prefix = content.slice(0, markerIndex).trimEnd();
|
|
140
|
+
const atIndex = prefix.lastIndexOf(' at ');
|
|
141
|
+
if (atIndex < 0) return undefined;
|
|
142
|
+
const candidate = prefix.slice(atIndex + 4).trim();
|
|
143
|
+
if (!candidate || candidate.includes('\n') || candidate.includes('\r')) return undefined;
|
|
144
|
+
return candidate.startsWith('/') || /^[A-Za-z]:[\\/]/.test(candidate) ? candidate : undefined;
|
|
139
145
|
}
|
|
140
146
|
|
|
141
147
|
function recoverBrokenJsonOutput(raw: string, spillPath?: string | undefined): Record<string, unknown> | null {
|
|
@@ -179,6 +185,10 @@ export function normalizeHistoricalToolResult(
|
|
|
179
185
|
toolMsg: HistoricalToolMessage,
|
|
180
186
|
options: { unpaired?: boolean | undefined } = {}
|
|
181
187
|
): NormalizedHistoricalToolResult {
|
|
188
|
+
if (!toolMsg || typeof toolMsg !== 'object') {
|
|
189
|
+
return { skipStep: false, result: { success: true, output: '' } };
|
|
190
|
+
}
|
|
191
|
+
const safeOptions = options && typeof options === 'object' ? options : {};
|
|
182
192
|
const explicitSpill = typeof toolMsg.spillPath === 'string' && toolMsg.spillPath.trim()
|
|
183
193
|
? toolMsg.spillPath.trim()
|
|
184
194
|
: undefined;
|
|
@@ -191,7 +201,7 @@ export function normalizeHistoricalToolResult(
|
|
|
191
201
|
const success = !isFailure;
|
|
192
202
|
if (toolName === 'update_plan') {
|
|
193
203
|
return {
|
|
194
|
-
skipStep: Boolean(
|
|
204
|
+
skipStep: Boolean(safeOptions.unpaired),
|
|
195
205
|
result: { success: true, output: '' }
|
|
196
206
|
};
|
|
197
207
|
}
|
package/src/tui/transcript.js
CHANGED
|
@@ -39,10 +39,10 @@ function normalizeRows(produced) {
|
|
|
39
39
|
if (!Array.isArray(produced)) return [];
|
|
40
40
|
const rows = [];
|
|
41
41
|
for (const row of produced) {
|
|
42
|
-
const text = row == null ? '' : String(row);
|
|
43
|
-
// A frame may never contain a newline: the Stage paints
|
|
44
|
-
// cursor motion only, and
|
|
45
|
-
//
|
|
42
|
+
const text = (row == null ? '' : String(row)).replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
43
|
+
// A frame may never contain a newline or carriage return: the Stage paints
|
|
44
|
+
// with relative cursor motion only, and an embedded '\n' or '\r' corrupts
|
|
45
|
+
// the terminal band. Split cleanly rather than drop, so nothing is lost.
|
|
46
46
|
if (text.includes('\n')) rows.push(...text.split('\n'));
|
|
47
47
|
else rows.push(text);
|
|
48
48
|
}
|
|
@@ -50,9 +50,11 @@ function normalizeRows(produced) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export class Transcript {
|
|
53
|
-
constructor(
|
|
53
|
+
constructor(options = {}) {
|
|
54
|
+
const { maxFrames = MAX_FRAMES, onEvict = null, onChange = null } =
|
|
55
|
+
options && typeof options === 'object' ? options : {};
|
|
54
56
|
this.frames = [];
|
|
55
|
-
this.maxFrames = Math.max(1, maxFrames);
|
|
57
|
+
this.maxFrames = Number.isFinite(maxFrames) ? Math.max(1, Math.floor(maxFrames)) : MAX_FRAMES;
|
|
56
58
|
this.onEvict = typeof onEvict === 'function' ? onEvict : null;
|
|
57
59
|
// Fired after any structural change. In scrollback mode the renderer's
|
|
58
60
|
// onAfterWrite hook is what tells the prompt to repaint; in stage mode no
|
|
@@ -88,7 +90,9 @@ export class Transcript {
|
|
|
88
90
|
* `produce` is called lazily and may be called again at a different width.
|
|
89
91
|
* It must not mutate anything the caller will read later.
|
|
90
92
|
*/
|
|
91
|
-
append(
|
|
93
|
+
append(options = {}) {
|
|
94
|
+
const { kind = 'notice', produce, meta = null } =
|
|
95
|
+
options && typeof options === 'object' ? options : {};
|
|
92
96
|
if (typeof produce !== 'function') return null;
|
|
93
97
|
const frame = {
|
|
94
98
|
id: this.nextId++,
|
|
@@ -114,7 +118,9 @@ export class Transcript {
|
|
|
114
118
|
* tokens arrive, and appending a frame per token would make the rail useless
|
|
115
119
|
* and the flatten quadratic.
|
|
116
120
|
*/
|
|
117
|
-
replaceTail(
|
|
121
|
+
replaceTail(options = {}) {
|
|
122
|
+
const { kind, produce, meta } =
|
|
123
|
+
options && typeof options === 'object' ? options : {};
|
|
118
124
|
const frame = this.frames[this.frames.length - 1];
|
|
119
125
|
if (!frame || typeof produce !== 'function') return this.append({ kind, produce, meta });
|
|
120
126
|
if (kind && KINDS.includes(kind)) frame.kind = kind;
|
|
@@ -189,7 +195,7 @@ export class Transcript {
|
|
|
189
195
|
* unchanged transcript costs one comparison.
|
|
190
196
|
*/
|
|
191
197
|
flatten(width) {
|
|
192
|
-
const w = Math.max(1, Math.floor(width)
|
|
198
|
+
const w = Number.isFinite(width) && width > 0 ? Math.max(1, Math.floor(width)) : this.lastWidth;
|
|
193
199
|
if (this.cache && this.cache.width === w && this.cache.revision === this.revision) {
|
|
194
200
|
return this.cache;
|
|
195
201
|
}
|