@causyne/agent 1.20.54 → 1.20.60
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/package.json +1 -1
- package/src/agentLoop.js +37 -1
- package/src/agentLoop.ts +42 -1
- package/src/decisionPolicy.js +74 -4
- package/src/decisionPolicy.ts +72 -4
- package/src/observer/coldObserver.js +10 -4
- package/src/observer/coldObserver.ts +10 -4
- package/src/observer/evidence.js +8 -3
- package/src/observer/evidence.ts +8 -3
- package/src/tools/memoryWrite.js +11 -3
- package/src/tools/memoryWrite.ts +12 -3
- package/src/tools/toolSelfRepair.js +11 -0
- package/src/tools/toolSelfRepair.ts +10 -0
- package/src/tui/chatRenderer.js +23 -2
- package/src/tui/messageInteraction.js +1 -1
- package/src/tui/messageInteraction.ts +1 -1
- package/src/tui/prompt.js +1 -1
- package/src/tui/sessionSidebar.js +2 -4
- package/src/tui/sessionSidebar.ts +2 -4
- package/src/tui/stage.js +2 -2
- package/src/tui/stageSurface.js +4 -19
- package/src/tui/statusLine.js +156 -214
- package/src/tui/statusLine.ts +222 -0
- package/src/tui/thinkingBox.js +2 -2
- package/src/tui/thinkingBox.ts +2 -2
- package/src/tui/toolDisplay.js +117 -120
- package/src/tui/toolDisplay.ts +191 -0
package/package.json
CHANGED
package/src/agentLoop.js
CHANGED
|
@@ -2402,10 +2402,16 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2402
2402
|
}
|
|
2403
2403
|
const isCompleted = action.status === 'completed';
|
|
2404
2404
|
const isFailed = action.status === 'failed';
|
|
2405
|
+
const rawExtCommand = action.parameters?.CommandLine
|
|
2406
|
+
|| action.parameters?.commandLine
|
|
2407
|
+
|| action.parameters?.command
|
|
2408
|
+
|| action.parameters?.cmd
|
|
2409
|
+
|| action.parameters?.script
|
|
2410
|
+
|| (['bash', 'terminal', 'sh', 'zsh', 'sysrun', 'run_command', 'run', 'execute', 'exec'].includes(action.name.toLowerCase()) ? (action.detail || '') : '');
|
|
2405
2411
|
const actionArgs = {
|
|
2406
2412
|
...(action.parameters && typeof action.parameters === 'object' ? action.parameters : {}),
|
|
2407
2413
|
path: action.parameters?.path || action.parameters?.Path || action.parameters?.filePath || action.detail || '',
|
|
2408
|
-
command:
|
|
2414
|
+
command: typeof rawExtCommand === 'string' ? rawExtCommand.trim() : ''
|
|
2409
2415
|
};
|
|
2410
2416
|
const terminalId = action.id ? String(action.id) : '';
|
|
2411
2417
|
const freshTerminal = !terminalId || !observedNativeTerminalIds.has(terminalId);
|
|
@@ -2927,6 +2933,36 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2927
2933
|
continue;
|
|
2928
2934
|
}
|
|
2929
2935
|
if (hasExternalActions && (isIncompleteTurn || isMidTaskProgress || (typeof contentText === 'string' && (contentText.startsWith('Antigravity executed:') || /^Turn completed by .+ over ACP\.$/i.test(contentText.trim()))))) {
|
|
2936
|
+
const recentSubstantiveAssistant = [...this.messages].reverse().find(m => m.role === 'assistant'
|
|
2937
|
+
&& 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()));
|
|
2941
|
+
if (recentSubstantiveAssistant && typeof recentSubstantiveAssistant.content === 'string') {
|
|
2942
|
+
this.emitEvent({
|
|
2943
|
+
type: 'agent_message',
|
|
2944
|
+
content: recentSubstantiveAssistant.content
|
|
2945
|
+
});
|
|
2946
|
+
this.emitEvent({
|
|
2947
|
+
type: 'status',
|
|
2948
|
+
message: 'Task completed with verified deliverables.'
|
|
2949
|
+
});
|
|
2950
|
+
this.memoryManager.saveHistory(this.messages);
|
|
2951
|
+
break;
|
|
2952
|
+
}
|
|
2953
|
+
if (isLaunchOnlyPrompt(taskPrompt) && this.stepsCompleted > 0) {
|
|
2954
|
+
const launchSummary = 'Project opened in your default browser. Verification checks completed.';
|
|
2955
|
+
this.emitEvent({
|
|
2956
|
+
type: 'agent_message',
|
|
2957
|
+
content: launchSummary
|
|
2958
|
+
});
|
|
2959
|
+
this.emitEvent({
|
|
2960
|
+
type: 'status',
|
|
2961
|
+
message: 'Task completed: project launched and verified.'
|
|
2962
|
+
});
|
|
2963
|
+
this.memoryManager.saveHistory(this.messages);
|
|
2964
|
+
break;
|
|
2965
|
+
}
|
|
2930
2966
|
this.emitEvent({
|
|
2931
2967
|
type: 'error',
|
|
2932
2968
|
message: 'The task stopped before completion after repeated incomplete turns without a final response. Work remains unfinished.'
|
package/src/agentLoop.ts
CHANGED
|
@@ -2507,10 +2507,16 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2507
2507
|
}
|
|
2508
2508
|
const isCompleted = action.status === 'completed';
|
|
2509
2509
|
const isFailed = action.status === 'failed';
|
|
2510
|
+
const rawExtCommand = action.parameters?.CommandLine
|
|
2511
|
+
|| action.parameters?.commandLine
|
|
2512
|
+
|| action.parameters?.command
|
|
2513
|
+
|| action.parameters?.cmd
|
|
2514
|
+
|| action.parameters?.script
|
|
2515
|
+
|| (['bash', 'terminal', 'sh', 'zsh', 'sysrun', 'run_command', 'run', 'execute', 'exec'].includes(action.name.toLowerCase()) ? (action.detail || '') : '');
|
|
2510
2516
|
const actionArgs: Record<string, unknown> = {
|
|
2511
2517
|
...(action.parameters && typeof action.parameters === 'object' ? action.parameters : {}),
|
|
2512
2518
|
path: action.parameters?.path || action.parameters?.Path || action.parameters?.filePath || action.detail || '',
|
|
2513
|
-
command:
|
|
2519
|
+
command: typeof rawExtCommand === 'string' ? rawExtCommand.trim() : ''
|
|
2514
2520
|
};
|
|
2515
2521
|
const terminalId = action.id ? String(action.id) : '';
|
|
2516
2522
|
const freshTerminal = !terminalId || !observedNativeTerminalIds.has(terminalId);
|
|
@@ -3066,6 +3072,41 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3066
3072
|
}
|
|
3067
3073
|
|
|
3068
3074
|
if (hasExternalActions && (isIncompleteTurn || isMidTaskProgress || (typeof contentText === 'string' && (contentText.startsWith('Antigravity executed:') || /^Turn completed by .+ over ACP\.$/i.test(contentText.trim()))))) {
|
|
3075
|
+
const recentSubstantiveAssistant = [...this.messages].reverse().find(m =>
|
|
3076
|
+
m.role === 'assistant'
|
|
3077
|
+
&& 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())
|
|
3081
|
+
);
|
|
3082
|
+
|
|
3083
|
+
if (recentSubstantiveAssistant && typeof recentSubstantiveAssistant.content === 'string') {
|
|
3084
|
+
this.emitEvent({
|
|
3085
|
+
type: 'agent_message',
|
|
3086
|
+
content: recentSubstantiveAssistant.content
|
|
3087
|
+
});
|
|
3088
|
+
this.emitEvent({
|
|
3089
|
+
type: 'status',
|
|
3090
|
+
message: 'Task completed with verified deliverables.'
|
|
3091
|
+
});
|
|
3092
|
+
this.memoryManager.saveHistory(this.messages);
|
|
3093
|
+
break;
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
if (isLaunchOnlyPrompt(taskPrompt) && this.stepsCompleted > 0) {
|
|
3097
|
+
const launchSummary = 'Project opened in your default browser. Verification checks completed.';
|
|
3098
|
+
this.emitEvent({
|
|
3099
|
+
type: 'agent_message',
|
|
3100
|
+
content: launchSummary
|
|
3101
|
+
});
|
|
3102
|
+
this.emitEvent({
|
|
3103
|
+
type: 'status',
|
|
3104
|
+
message: 'Task completed: project launched and verified.'
|
|
3105
|
+
});
|
|
3106
|
+
this.memoryManager.saveHistory(this.messages);
|
|
3107
|
+
break;
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3069
3110
|
this.emitEvent({
|
|
3070
3111
|
type: 'error',
|
|
3071
3112
|
message: 'The task stopped before completion after repeated incomplete turns without a final response. Work remains unfinished.'
|
package/src/decisionPolicy.js
CHANGED
|
@@ -18,8 +18,78 @@ const MUTATING_TOOLS = new Set([
|
|
|
18
18
|
'fs_write', 'fs_edit', 'MultiEdit', 'fs_delete', 'fs_move', 'sysRun', 'sysRunBg',
|
|
19
19
|
'gitOp', 'manage_local_dependencies', 'plugin_manage', 'tool_forge', 'plugins_factory', 'create_skill',
|
|
20
20
|
'write_file', 'write_to_file', 'edit_file', 'replace_file_content', 'multi_replace_file_content',
|
|
21
|
-
'write', 'edit', 'multiedit', 'bash', 'terminal', 'execute'
|
|
21
|
+
'write', 'edit', 'multiedit', 'bash', 'terminal', 'execute', 'run_command', 'run'
|
|
22
22
|
]);
|
|
23
|
+
function splitCommandSegments(command) {
|
|
24
|
+
const segments = [];
|
|
25
|
+
let current = '';
|
|
26
|
+
let inSingle = false;
|
|
27
|
+
let inDouble = false;
|
|
28
|
+
let escape = false;
|
|
29
|
+
for (let i = 0; i < command.length; i++) {
|
|
30
|
+
const ch = command[i];
|
|
31
|
+
if (escape) {
|
|
32
|
+
current += ch;
|
|
33
|
+
escape = false;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (ch === '\\') {
|
|
37
|
+
escape = true;
|
|
38
|
+
current += ch;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (ch === "'" && !inDouble) {
|
|
42
|
+
inSingle = !inSingle;
|
|
43
|
+
current += ch;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (ch === '"' && !inSingle) {
|
|
47
|
+
inDouble = !inDouble;
|
|
48
|
+
current += ch;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (!inSingle && !inDouble) {
|
|
52
|
+
if (ch === ';') {
|
|
53
|
+
if (current.trim())
|
|
54
|
+
segments.push(current.trim());
|
|
55
|
+
current = '';
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (ch === '&' && command[i + 1] === '&') {
|
|
59
|
+
if (current.trim())
|
|
60
|
+
segments.push(current.trim());
|
|
61
|
+
current = '';
|
|
62
|
+
i++;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (ch === '|' && command[i + 1] === '|') {
|
|
66
|
+
if (current.trim())
|
|
67
|
+
segments.push(current.trim());
|
|
68
|
+
current = '';
|
|
69
|
+
i++;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
current += ch;
|
|
74
|
+
}
|
|
75
|
+
if (current.trim())
|
|
76
|
+
segments.push(current.trim());
|
|
77
|
+
return segments;
|
|
78
|
+
}
|
|
79
|
+
const READ_ONLY_CMD_REGEX = /^\s*(?:(?:pwd|ls|find|rg|grep|cat|sed|awk|head|tail|wc|diff|file|stat|which|whereis|type|du|df|pdfinfo|pdftotext|identify|mediainfo|ffprobe|otool|readelf|nm|ps|lsof|top|uptime|whoami|id|uname|env|printenv|echo|printf|pytest)\b|git\s+(?:status|diff|log|show|branch|tag|remote|rev-parse|describe)\b|npm\s+(?:view|audit|test|ls|list|explain|run\s+(?:test|check|lint|typecheck|verify))\b|pnpm\s+(?:test|view|audit|ls|list|run\s+(?:test|check|lint|typecheck|verify))\b|yarn\s+(?:test|audit|list|run\s+(?:test|check|lint|typecheck|verify))\b|bun\s+(?:test|pm)\b|npx\s+(?:jest|vitest|mocha|ava|playwright\s+test|cypress\s+run|tsc\s+--noEmit)\b|tsc\s+--noEmit\b|node\s+(?:--check|--test|-e\b|--eval\b|-p\b|--print\b|.*?(?:test|spec|verify|check))|(?:python3?|py)\s+(?:-m\s+(?:unittest|pytest|doctest|py_compile)|-c\b|.*?(?:test|spec|verify))|cargo\s+(?:test|check)\b|go\s+test\b|curl\s+(?:-I|-sI|-s\b|--head)\b)/i;
|
|
80
|
+
export function isReadOnlyShellCommand(command) {
|
|
81
|
+
const trimmed = command.trim();
|
|
82
|
+
if (!trimmed)
|
|
83
|
+
return true;
|
|
84
|
+
const segments = splitCommandSegments(trimmed);
|
|
85
|
+
return segments.length > 0 && segments.every(seg => {
|
|
86
|
+
const s = seg.trim();
|
|
87
|
+
if (!s)
|
|
88
|
+
return true;
|
|
89
|
+
const stripped = s.replace(/^(?:[a-zA-Z_][a-zA-Z0-9_]*=[^\s]+\s+)+/, '');
|
|
90
|
+
return READ_ONLY_CMD_REGEX.test(stripped);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
23
93
|
function containsAny(text, terms) {
|
|
24
94
|
return terms.some(term => text.includes(term));
|
|
25
95
|
}
|
|
@@ -68,9 +138,9 @@ export function isMutatingToolCall(toolName, args = {}) {
|
|
|
68
138
|
if (toolName === 'native_engine')
|
|
69
139
|
return !['status', 'catalog', 'describe', 'inspect', 'probe'].includes(String(args.action ?? ''));
|
|
70
140
|
if (MUTATING_TOOLS.has(toolName)) {
|
|
71
|
-
if (['sysRun', 'sysRunBg', 'bash', 'terminal', 'execute', 'sh', 'zsh'].includes(toolName)) {
|
|
72
|
-
const command = String(args.command ?? args.cmd ?? '');
|
|
73
|
-
return
|
|
141
|
+
if (['sysRun', 'sysRunBg', 'bash', 'terminal', 'execute', 'sh', 'zsh', 'run_command', 'run'].includes(toolName)) {
|
|
142
|
+
const command = String(args.CommandLine ?? args.commandLine ?? args.command ?? args.cmd ?? args.script ?? args.code ?? '');
|
|
143
|
+
return !isReadOnlyShellCommand(command);
|
|
74
144
|
}
|
|
75
145
|
if (toolName === 'gitOp') {
|
|
76
146
|
const action = String(args.action ?? args.command ?? args.operation ?? '');
|
package/src/decisionPolicy.ts
CHANGED
|
@@ -52,9 +52,77 @@ const MUTATING_TOOLS = new Set([
|
|
|
52
52
|
'fs_write', 'fs_edit', 'MultiEdit', 'fs_delete', 'fs_move', 'sysRun', 'sysRunBg',
|
|
53
53
|
'gitOp', 'manage_local_dependencies', 'plugin_manage', 'tool_forge', 'plugins_factory', 'create_skill',
|
|
54
54
|
'write_file', 'write_to_file', 'edit_file', 'replace_file_content', 'multi_replace_file_content',
|
|
55
|
-
'write', 'edit', 'multiedit', 'bash', 'terminal', 'execute'
|
|
55
|
+
'write', 'edit', 'multiedit', 'bash', 'terminal', 'execute', 'run_command', 'run'
|
|
56
56
|
]);
|
|
57
57
|
|
|
58
|
+
function splitCommandSegments(command: string): string[] {
|
|
59
|
+
const segments: string[] = [];
|
|
60
|
+
let current = '';
|
|
61
|
+
let inSingle = false;
|
|
62
|
+
let inDouble = false;
|
|
63
|
+
let escape = false;
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < command.length; i++) {
|
|
66
|
+
const ch = command[i]!;
|
|
67
|
+
if (escape) {
|
|
68
|
+
current += ch;
|
|
69
|
+
escape = false;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (ch === '\\') {
|
|
73
|
+
escape = true;
|
|
74
|
+
current += ch;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (ch === "'" && !inDouble) {
|
|
78
|
+
inSingle = !inSingle;
|
|
79
|
+
current += ch;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (ch === '"' && !inSingle) {
|
|
83
|
+
inDouble = !inDouble;
|
|
84
|
+
current += ch;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (!inSingle && !inDouble) {
|
|
88
|
+
if (ch === ';') {
|
|
89
|
+
if (current.trim()) segments.push(current.trim());
|
|
90
|
+
current = '';
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (ch === '&' && command[i + 1] === '&') {
|
|
94
|
+
if (current.trim()) segments.push(current.trim());
|
|
95
|
+
current = '';
|
|
96
|
+
i++;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (ch === '|' && command[i + 1] === '|') {
|
|
100
|
+
if (current.trim()) segments.push(current.trim());
|
|
101
|
+
current = '';
|
|
102
|
+
i++;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
current += ch;
|
|
107
|
+
}
|
|
108
|
+
if (current.trim()) segments.push(current.trim());
|
|
109
|
+
return segments;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const READ_ONLY_CMD_REGEX = /^\s*(?:(?:pwd|ls|find|rg|grep|cat|sed|awk|head|tail|wc|diff|file|stat|which|whereis|type|du|df|pdfinfo|pdftotext|identify|mediainfo|ffprobe|otool|readelf|nm|ps|lsof|top|uptime|whoami|id|uname|env|printenv|echo|printf|pytest)\b|git\s+(?:status|diff|log|show|branch|tag|remote|rev-parse|describe)\b|npm\s+(?:view|audit|test|ls|list|explain|run\s+(?:test|check|lint|typecheck|verify))\b|pnpm\s+(?:test|view|audit|ls|list|run\s+(?:test|check|lint|typecheck|verify))\b|yarn\s+(?:test|audit|list|run\s+(?:test|check|lint|typecheck|verify))\b|bun\s+(?:test|pm)\b|npx\s+(?:jest|vitest|mocha|ava|playwright\s+test|cypress\s+run|tsc\s+--noEmit)\b|tsc\s+--noEmit\b|node\s+(?:--check|--test|-e\b|--eval\b|-p\b|--print\b|.*?(?:test|spec|verify|check))|(?:python3?|py)\s+(?:-m\s+(?:unittest|pytest|doctest|py_compile)|-c\b|.*?(?:test|spec|verify))|cargo\s+(?:test|check)\b|go\s+test\b|curl\s+(?:-I|-sI|-s\b|--head)\b)/i;
|
|
113
|
+
|
|
114
|
+
export function isReadOnlyShellCommand(command: string): boolean {
|
|
115
|
+
const trimmed = command.trim();
|
|
116
|
+
if (!trimmed) return true;
|
|
117
|
+
const segments = splitCommandSegments(trimmed);
|
|
118
|
+
return segments.length > 0 && segments.every(seg => {
|
|
119
|
+
const s = seg.trim();
|
|
120
|
+
if (!s) return true;
|
|
121
|
+
const stripped = s.replace(/^(?:[a-zA-Z_][a-zA-Z0-9_]*=[^\s]+\s+)+/, '');
|
|
122
|
+
return READ_ONLY_CMD_REGEX.test(stripped);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
58
126
|
function containsAny(text: string, terms: readonly string[]): boolean {
|
|
59
127
|
return terms.some(term => text.includes(term));
|
|
60
128
|
}
|
|
@@ -107,9 +175,9 @@ export function isMutatingToolCall(toolName: string, args: Record<string, unknow
|
|
|
107
175
|
}
|
|
108
176
|
if (toolName === 'native_engine') return !['status', 'catalog', 'describe', 'inspect', 'probe'].includes(String(args.action ?? ''));
|
|
109
177
|
if (MUTATING_TOOLS.has(toolName)) {
|
|
110
|
-
if (['sysRun', 'sysRunBg', 'bash', 'terminal', 'execute', 'sh', 'zsh'].includes(toolName)) {
|
|
111
|
-
const command = String(args.command ?? args.cmd ?? '');
|
|
112
|
-
return
|
|
178
|
+
if (['sysRun', 'sysRunBg', 'bash', 'terminal', 'execute', 'sh', 'zsh', 'run_command', 'run'].includes(toolName)) {
|
|
179
|
+
const command = String(args.CommandLine ?? args.commandLine ?? args.command ?? args.cmd ?? args.script ?? args.code ?? '');
|
|
180
|
+
return !isReadOnlyShellCommand(command);
|
|
113
181
|
}
|
|
114
182
|
if (toolName === 'gitOp') {
|
|
115
183
|
const action = String(args.action ?? args.command ?? args.operation ?? '');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { auditLog } from '../auditLog.js';
|
|
4
|
+
import { isLaunchOnlyPrompt } from '../launchIntent.js';
|
|
4
5
|
import { causyneHome } from '../utils/paths.js';
|
|
5
6
|
import { boundedArgs, outcomeFromResult, scanMutation } from './evidence.js';
|
|
6
7
|
import { isLoopbackEndpoint, probeAdvisory, queryAdvisory } from './advisory.js';
|
|
@@ -130,7 +131,11 @@ function normalizeOutcome(entry) {
|
|
|
130
131
|
const error = nestedError(result);
|
|
131
132
|
const command = entry.command
|
|
132
133
|
|| (typeof args.command === 'string' ? args.command : '')
|
|
133
|
-
|| (typeof args.
|
|
134
|
+
|| (typeof args.CommandLine === 'string' ? args.CommandLine : '')
|
|
135
|
+
|| (typeof args.commandLine === 'string' ? args.commandLine : '')
|
|
136
|
+
|| (typeof args.cmd === 'string' ? args.cmd : '')
|
|
137
|
+
|| (typeof args.script === 'string' ? args.script : '')
|
|
138
|
+
|| (['run_command', 'run', 'execute', 'exec', 'bash', 'terminal', 'sh', 'zsh', 'sysrun'].includes(String(entry.tool || '').toLowerCase()) && typeof args.detail === 'string' ? args.detail : '');
|
|
134
139
|
return {
|
|
135
140
|
tool: entry.tool,
|
|
136
141
|
args: boundedArgs(args),
|
|
@@ -395,6 +400,7 @@ export class ColdObserver {
|
|
|
395
400
|
&& (TEST_COMMAND.test(outcome.command) || TEST_COMMAND.test(outcome.tool)));
|
|
396
401
|
const hasBuildRun = checks.some((outcome) => outcome.success
|
|
397
402
|
&& (BUILD_OR_CHECK_COMMAND.test(outcome.command) || outcome.tool === 'code_verify_syntax'));
|
|
403
|
+
const isLaunch = isLaunchOnlyPrompt(turnState.userPrompt || '');
|
|
398
404
|
const modifiedCode = lastCodeChange >= 0;
|
|
399
405
|
const declarativeOnly = modifiedCode && outcomes.filter(isCodeMutation).every(outcome => /\.(?:html|css)$/i.test(outcome.path));
|
|
400
406
|
const hasRenderedCheck = checks.some(outcome => outcome.success && outcome.rendered === true);
|
|
@@ -411,19 +417,19 @@ export class ColdObserver {
|
|
|
411
417
|
discrepancy = `completion claim conflicts with tool evidence: ${failureSummary(outcomes)}`;
|
|
412
418
|
coldDirective = `[OBSERVER] Your completion claim conflicts with the latest tool evidence: ${failureSummary(outcomes)}. Resolve the failure and rerun the failing check before claiming success.`;
|
|
413
419
|
}
|
|
414
|
-
else if (!caveat && TESTS_CLAIM.test(claim) && !hasTestRun) {
|
|
420
|
+
else if (!caveat && !isLaunch && modifiedCode && TESTS_CLAIM.test(claim) && !hasTestRun) {
|
|
415
421
|
overconfident = true;
|
|
416
422
|
confidence = 0.86;
|
|
417
423
|
discrepancy = 'claimed passing tests without a successful test command in this task';
|
|
418
424
|
coldDirective = '[OBSERVER] You claimed that tests passed, but no successful test command appears in this task. Run the test command and report its actual result, or state plainly that you did not run it.';
|
|
419
425
|
}
|
|
420
|
-
else if (!caveat && BUILD_CLAIM.test(claim) && !hasBuildRun) {
|
|
426
|
+
else if (!caveat && !isLaunch && modifiedCode && BUILD_CLAIM.test(claim) && !hasBuildRun) {
|
|
421
427
|
overconfident = true;
|
|
422
428
|
confidence = 0.82;
|
|
423
429
|
discrepancy = 'claimed a passing build or check without a successful verification command';
|
|
424
430
|
coldDirective = '[OBSERVER] You claimed that a build or check passed, but no successful verification command appears in this task. Run the relevant command and report its actual result, or state that it is unverified.';
|
|
425
431
|
}
|
|
426
|
-
else if (!caveat && modifiedCode && !hasBuildRun && !hasTestRun && !(declarativeOnly && (hasRenderedCheck || hasDeclarativeInspection))) {
|
|
432
|
+
else if (!caveat && !isLaunch && modifiedCode && !hasBuildRun && !hasTestRun && !(declarativeOnly && (hasRenderedCheck || hasDeclarativeInspection))) {
|
|
427
433
|
overconfident = true;
|
|
428
434
|
confidence = 0.72;
|
|
429
435
|
discrepancy = 'code was modified without a successful test or syntax check';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { auditLog } from '../auditLog.js';
|
|
4
|
+
import { isLaunchOnlyPrompt } from '../launchIntent.js';
|
|
4
5
|
import { causyneHome } from '../utils/paths.js';
|
|
5
6
|
import {
|
|
6
7
|
boundedArgs,
|
|
@@ -184,7 +185,11 @@ function normalizeOutcome(entry: TurnToolEvidence): ToolOutcome {
|
|
|
184
185
|
const error = nestedError(result);
|
|
185
186
|
const command = entry.command
|
|
186
187
|
|| (typeof args.command === 'string' ? args.command : '')
|
|
187
|
-
|| (typeof args.
|
|
188
|
+
|| (typeof args.CommandLine === 'string' ? args.CommandLine : '')
|
|
189
|
+
|| (typeof args.commandLine === 'string' ? args.commandLine : '')
|
|
190
|
+
|| (typeof args.cmd === 'string' ? args.cmd : '')
|
|
191
|
+
|| (typeof args.script === 'string' ? args.script : '')
|
|
192
|
+
|| (['run_command', 'run', 'execute', 'exec', 'bash', 'terminal', 'sh', 'zsh', 'sysrun'].includes(String(entry.tool || '').toLowerCase()) && typeof args.detail === 'string' ? args.detail : '');
|
|
188
193
|
return {
|
|
189
194
|
tool: entry.tool,
|
|
190
195
|
args: boundedArgs(args),
|
|
@@ -472,6 +477,7 @@ export class ColdObserver {
|
|
|
472
477
|
&& (TEST_COMMAND.test(outcome.command) || TEST_COMMAND.test(outcome.tool)));
|
|
473
478
|
const hasBuildRun = checks.some((outcome) => outcome.success
|
|
474
479
|
&& (BUILD_OR_CHECK_COMMAND.test(outcome.command) || outcome.tool === 'code_verify_syntax'));
|
|
480
|
+
const isLaunch = isLaunchOnlyPrompt(turnState.userPrompt || '');
|
|
475
481
|
const modifiedCode = lastCodeChange >= 0;
|
|
476
482
|
const declarativeOnly = modifiedCode && outcomes.filter(isCodeMutation).every(outcome => /\.(?:html|css)$/i.test(outcome.path));
|
|
477
483
|
const hasRenderedCheck = checks.some(outcome => outcome.success && outcome.rendered === true);
|
|
@@ -489,17 +495,17 @@ export class ColdObserver {
|
|
|
489
495
|
confidence = 0.92;
|
|
490
496
|
discrepancy = `completion claim conflicts with tool evidence: ${failureSummary(outcomes)}`;
|
|
491
497
|
coldDirective = `[OBSERVER] Your completion claim conflicts with the latest tool evidence: ${failureSummary(outcomes)}. Resolve the failure and rerun the failing check before claiming success.`;
|
|
492
|
-
} else if (!caveat && TESTS_CLAIM.test(claim) && !hasTestRun) {
|
|
498
|
+
} else if (!caveat && !isLaunch && modifiedCode && TESTS_CLAIM.test(claim) && !hasTestRun) {
|
|
493
499
|
overconfident = true;
|
|
494
500
|
confidence = 0.86;
|
|
495
501
|
discrepancy = 'claimed passing tests without a successful test command in this task';
|
|
496
502
|
coldDirective = '[OBSERVER] You claimed that tests passed, but no successful test command appears in this task. Run the test command and report its actual result, or state plainly that you did not run it.';
|
|
497
|
-
} else if (!caveat && BUILD_CLAIM.test(claim) && !hasBuildRun) {
|
|
503
|
+
} else if (!caveat && !isLaunch && modifiedCode && BUILD_CLAIM.test(claim) && !hasBuildRun) {
|
|
498
504
|
overconfident = true;
|
|
499
505
|
confidence = 0.82;
|
|
500
506
|
discrepancy = 'claimed a passing build or check without a successful verification command';
|
|
501
507
|
coldDirective = '[OBSERVER] You claimed that a build or check passed, but no successful verification command appears in this task. Run the relevant command and report its actual result, or state that it is unverified.';
|
|
502
|
-
} else if (!caveat && modifiedCode && !hasBuildRun && !hasTestRun && !(declarativeOnly && (hasRenderedCheck || hasDeclarativeInspection))) {
|
|
508
|
+
} else if (!caveat && !isLaunch && modifiedCode && !hasBuildRun && !hasTestRun && !(declarativeOnly && (hasRenderedCheck || hasDeclarativeInspection))) {
|
|
503
509
|
overconfident = true;
|
|
504
510
|
confidence = 0.72;
|
|
505
511
|
discrepancy = 'code was modified without a successful test or syntax check';
|
package/src/observer/evidence.js
CHANGED
|
@@ -425,9 +425,14 @@ export function outcomeFromResult(tool, args, result, at) {
|
|
|
425
425
|
const success = record.success !== false && typeof record.error !== 'string';
|
|
426
426
|
const rawError = typeof record.error === 'string' ? record.error : '';
|
|
427
427
|
const exitCode = typeof record.exitCode === 'number' && Number.isFinite(record.exitCode) ? record.exitCode : null;
|
|
428
|
-
const
|
|
429
|
-
? args.
|
|
430
|
-
|
|
428
|
+
const rawCommand = typeof args.command === 'string' ? args.command
|
|
429
|
+
: typeof args.CommandLine === 'string' ? args.CommandLine
|
|
430
|
+
: typeof args.commandLine === 'string' ? args.commandLine
|
|
431
|
+
: typeof args.cmd === 'string' ? args.cmd
|
|
432
|
+
: typeof args.script === 'string' ? args.script
|
|
433
|
+
: (['run_command', 'run', 'execute', 'exec', 'bash', 'terminal', 'sh', 'zsh', 'sysrun'].includes((tool || '').toLowerCase()) && typeof args.detail === 'string') ? args.detail
|
|
434
|
+
: '';
|
|
435
|
+
const command = rawCommand.trim();
|
|
431
436
|
const browserData = Array.isArray(record.data) ? record.data : [];
|
|
432
437
|
const imageCaptured = success && record._is_image_marker === true;
|
|
433
438
|
const observedImage = imageCaptured && record.visionDelivered !== false;
|
package/src/observer/evidence.ts
CHANGED
|
@@ -489,9 +489,14 @@ export function outcomeFromResult(tool: string, args: Record<string, unknown>, r
|
|
|
489
489
|
const success = record.success !== false && typeof record.error !== 'string';
|
|
490
490
|
const rawError = typeof record.error === 'string' ? record.error : '';
|
|
491
491
|
const exitCode = typeof record.exitCode === 'number' && Number.isFinite(record.exitCode) ? record.exitCode : null;
|
|
492
|
-
const
|
|
493
|
-
? args.
|
|
494
|
-
: typeof args.
|
|
492
|
+
const rawCommand = typeof args.command === 'string' ? args.command
|
|
493
|
+
: typeof args.CommandLine === 'string' ? args.CommandLine
|
|
494
|
+
: typeof args.commandLine === 'string' ? args.commandLine
|
|
495
|
+
: typeof args.cmd === 'string' ? args.cmd
|
|
496
|
+
: typeof args.script === 'string' ? args.script
|
|
497
|
+
: (['run_command', 'run', 'execute', 'exec', 'bash', 'terminal', 'sh', 'zsh', 'sysrun'].includes((tool || '').toLowerCase()) && typeof args.detail === 'string') ? args.detail
|
|
498
|
+
: '';
|
|
499
|
+
const command = rawCommand.trim();
|
|
495
500
|
const browserData = Array.isArray(record.data) ? record.data : [];
|
|
496
501
|
const imageCaptured = success && record._is_image_marker === true;
|
|
497
502
|
const observedImage = imageCaptured && record.visionDelivered !== false;
|
package/src/tools/memoryWrite.js
CHANGED
|
@@ -24,12 +24,20 @@ export const memoryWrite = {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
required: [
|
|
27
|
+
required: []
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
execute: async (args, dependencies) => {
|
|
31
|
-
if (!args || !args.fact) {
|
|
32
|
-
return { success: false, error: "Missing 'fact' parameter." };
|
|
31
|
+
if (!args || (!args.fact && !args.creativePattern)) {
|
|
32
|
+
return { success: false, error: "Missing 'fact' or 'creativePattern' parameter." };
|
|
33
|
+
}
|
|
34
|
+
if (!args.fact && args.creativePattern) {
|
|
35
|
+
const cp = args.creativePattern;
|
|
36
|
+
const project = cp.project || 'project';
|
|
37
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
38
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
39
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
40
|
+
args.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
33
41
|
}
|
|
34
42
|
try {
|
|
35
43
|
const memory = getMemory();
|
package/src/tools/memoryWrite.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const memoryWrite = {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
required: [
|
|
46
|
+
required: []
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
|
|
@@ -51,8 +51,17 @@ export const memoryWrite = {
|
|
|
51
51
|
args: MemoryWriteArgs | null | undefined,
|
|
52
52
|
dependencies?: MemoryWriteDependencies
|
|
53
53
|
): Promise<{ success: boolean; output?: string; error?: string }> => {
|
|
54
|
-
if (!args || !args.fact) {
|
|
55
|
-
return { success: false, error: "Missing 'fact' parameter." };
|
|
54
|
+
if (!args || (!args.fact && !args.creativePattern)) {
|
|
55
|
+
return { success: false, error: "Missing 'fact' or 'creativePattern' parameter." };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!args.fact && args.creativePattern) {
|
|
59
|
+
const cp = args.creativePattern;
|
|
60
|
+
const project = cp.project || 'project';
|
|
61
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
62
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
63
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
64
|
+
args.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
try {
|
|
@@ -515,6 +515,17 @@ export function resolveParameterAliases(toolName, args, schema) {
|
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
+
else if (canonicalName === 'memory_write') {
|
|
519
|
+
if (!modified.fact && modified.creativePattern && typeof modified.creativePattern === 'object') {
|
|
520
|
+
const cp = modified.creativePattern;
|
|
521
|
+
const project = cp.project || 'project';
|
|
522
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
523
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
524
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
525
|
+
modified.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
526
|
+
repairs.push("Synthesized required fact from creativePattern for 'memory_write'");
|
|
527
|
+
}
|
|
528
|
+
}
|
|
518
529
|
else if (canonicalName === 'native_engine') {
|
|
519
530
|
if (Array.isArray(modified.steps)) {
|
|
520
531
|
modified.steps = modified.steps.map((item) => {
|
|
@@ -570,6 +570,16 @@ export function resolveParameterAliases(
|
|
|
570
570
|
return normalizedItem;
|
|
571
571
|
});
|
|
572
572
|
}
|
|
573
|
+
} else if (canonicalName === 'memory_write') {
|
|
574
|
+
if (!modified.fact && modified.creativePattern && typeof modified.creativePattern === 'object') {
|
|
575
|
+
const cp = modified.creativePattern as Record<string, unknown>;
|
|
576
|
+
const project = cp.project || 'project';
|
|
577
|
+
const approach = cp.designApproach ? ` ${cp.designApproach}` : '';
|
|
578
|
+
const palette = cp.colorPalette ? ` with ${cp.colorPalette}` : '';
|
|
579
|
+
const fonts = cp.fonts ? ` (${cp.fonts})` : '';
|
|
580
|
+
modified.fact = `Creative pattern for ${project}:${approach}${palette}${fonts}`.trim();
|
|
581
|
+
repairs.push("Synthesized required fact from creativePattern for 'memory_write'");
|
|
582
|
+
}
|
|
573
583
|
} else if (canonicalName === 'native_engine') {
|
|
574
584
|
if (Array.isArray(modified.steps)) {
|
|
575
585
|
modified.steps = (modified.steps as Record<string, unknown>[]).map((item) => {
|
package/src/tui/chatRenderer.js
CHANGED
|
@@ -28,6 +28,7 @@ import { activityRows } from './activityLayout.js';
|
|
|
28
28
|
import { cleanToolOutputPreview, normalizeHistoricalToolResult, normalizeHistoricalExternalAction } from './toolOutputNormalizer.js';
|
|
29
29
|
import { formatMarkdownMath } from './markdownMath.js';
|
|
30
30
|
import { renderThinkingFrame } from './thinkingBox.js';
|
|
31
|
+
import { measureMessages, resolveCharPool } from '../contextManager.js';
|
|
31
32
|
|
|
32
33
|
// Bound the preview AFTER wrapping, not by source newlines: one 400 KB line of
|
|
33
34
|
// minified output would otherwise become thousands of rows and lock the
|
|
@@ -349,7 +350,7 @@ export class ChatRenderer {
|
|
|
349
350
|
|
|
350
351
|
/** Prose follows the current conversation column with a small text inset. */
|
|
351
352
|
measure() {
|
|
352
|
-
return chatProseWidth(this.width());
|
|
353
|
+
return this.transcript ? sessionComposerWidth(this.width()) : chatProseWidth(this.width());
|
|
353
354
|
}
|
|
354
355
|
|
|
355
356
|
// -------------------------------------------------------------------------
|
|
@@ -503,7 +504,7 @@ export class ChatRenderer {
|
|
|
503
504
|
|
|
504
505
|
this.frame('user', () => {
|
|
505
506
|
const width = this.transcript
|
|
506
|
-
? sessionComposerWidth(this.width())
|
|
507
|
+
? (this.transcript.surface?.composeWidth?.() ?? sessionComposerWidth(this.width()))
|
|
507
508
|
: composerWidth(this.measure());
|
|
508
509
|
const blockWidth = Math.max(8, width);
|
|
509
510
|
const innerWidth = Math.max(8, blockWidth - visibleWidth(GLYPHS.barHeavy || GLYPHS.bar) - 1);
|
|
@@ -566,6 +567,11 @@ export class ChatRenderer {
|
|
|
566
567
|
if (info.messagesCount === undefined || info.messagesCount === null) {
|
|
567
568
|
info.messagesCount = messages.filter(m => m && m.role !== 'system').length;
|
|
568
569
|
}
|
|
570
|
+
const measuredChars = measureMessages(messages);
|
|
571
|
+
if (measuredChars > 0) {
|
|
572
|
+
this.status.contextChars = measuredChars;
|
|
573
|
+
info.contextChars = measuredChars;
|
|
574
|
+
}
|
|
569
575
|
|
|
570
576
|
if (info.title || info.id) {
|
|
571
577
|
this.renderSessionDivider(info);
|
|
@@ -704,6 +710,21 @@ export class ChatRenderer {
|
|
|
704
710
|
}
|
|
705
711
|
}
|
|
706
712
|
|
|
713
|
+
const finalMeasured = measureMessages(messages);
|
|
714
|
+
if (finalMeasured > 0) {
|
|
715
|
+
this.status.contextChars = finalMeasured;
|
|
716
|
+
}
|
|
717
|
+
if (!this.status.contextLimit) {
|
|
718
|
+
this.status.contextLimit = resolveCharPool(this.status.tier);
|
|
719
|
+
}
|
|
720
|
+
if (sessionInfo) {
|
|
721
|
+
this.status.setSession({
|
|
722
|
+
...sessionInfo,
|
|
723
|
+
contextChars: this.status.contextChars || finalMeasured,
|
|
724
|
+
contextLimit: sessionInfo.contextLimit || this.status.contextLimit
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
|
|
707
728
|
if (this.transcript?.surface?.viewport) {
|
|
708
729
|
this.transcript.surface.viewport.manual = false;
|
|
709
730
|
this.transcript.surface.viewport.unseen = 0;
|
|
@@ -225,7 +225,7 @@ export function markHoveredMessage(rows, surface, contentWidth) {
|
|
|
225
225
|
continue;
|
|
226
226
|
const existingRow = rows[row] ?? '';
|
|
227
227
|
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
228
|
-
const alreadyHasMarker =
|
|
228
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
229
229
|
const content = transcriptRow === firstContentRow && !alreadyHasMarker
|
|
230
230
|
? `${paint('accent', '▸')} ${truncate(existingRow, Math.max(0, contentWidth - 2), '')}`
|
|
231
231
|
: existingRow;
|
|
@@ -309,7 +309,7 @@ export function markHoveredMessage(
|
|
|
309
309
|
if (row < padding || row >= rows.length) continue;
|
|
310
310
|
const existingRow = rows[row] ?? '';
|
|
311
311
|
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
312
|
-
const alreadyHasMarker =
|
|
312
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
313
313
|
const content = transcriptRow === firstContentRow && !alreadyHasMarker
|
|
314
314
|
? `${paint('accent', '▸')} ${truncate(existingRow, Math.max(0, contentWidth - 2), '')}`
|
|
315
315
|
: existingRow;
|
package/src/tui/prompt.js
CHANGED
|
@@ -1358,7 +1358,7 @@ export class ChatPrompt {
|
|
|
1358
1358
|
let body = window.slice();
|
|
1359
1359
|
|
|
1360
1360
|
if (this.editor.isEmpty && !this.completion) {
|
|
1361
|
-
const idle = fitHints([`try "${this.example}"`, '/ commands', '@ files'], inner, 'ask anything');
|
|
1361
|
+
const idle = fitHints([`try "${this.example}"`, '/ commands', '@ files'], Math.max(8, inner), 'ask anything');
|
|
1362
1362
|
body = [dim(this.busy ? 'type to queue a message…' : idle)];
|
|
1363
1363
|
}
|
|
1364
1364
|
|