Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/deepagents-code-tui-startup-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,35 @@ describe("Deep Agents Code TUI startup check helpers", () => {
expect(assertExit("1")).toBe("passed=0 failed=1");
});

it("preserves TUI lifecycle markers in the sanitized capture artifact", () => {
const captureDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-dcode-tui-markers-"));
const sanitizedCapture = path.join(captureDir, "10-deepagents-code-tui-startup.sanitized.log");

try {
const result = runTuiStartupCheckHelperResult(
[
"sandbox_exec() { printf 'NEMOCLAW_DCODE_PROBE:deepagents\\n'; }",
"ensure_expect_available() { return 0; }",
"run_tui_expect() {",
' printf "What would you like to do next?\\nNEMOCLAW_TUI_READY\\nNEMOCLAW_TUI_EXIT_CAPTURED:130\\n" >>"$1"',
"}",
"main",
].join("\n"),
{ DEEPAGENTS_TUI_CAPTURE_DIR: captureDir },
);

const sanitizedText = fs.readFileSync(sanitizedCapture, "utf8");
expect(result.status).toBe(0);
expect(result.stdout).toContain("finite expect harness reached startup and observed exit");
expect(result.stdout).toContain("dcode TUI rendered a usable startup prompt signature");
expect(result.stdout).toContain("dcode TUI exited cleanly after Ctrl-C (exit 130)");
expect(sanitizedText).toContain("NEMOCLAW_TUI_READY");
expect(sanitizedText).toContain("NEMOCLAW_TUI_EXIT_CAPTURED:130");
} finally {
fs.rmSync(captureDir, { force: true, recursive: true });
}
});

it("detects and redacts every canonical secret family in TUI startup artifacts", () => {
const detectsSecret = (token: string) =>
runTuiStartupCheckHelper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,28 @@ set capture $env(NEMOCLAW_TUI_CAPTURE)
set ready_pattern $env(NEMOCLAW_TUI_READY_PATTERN)
log_file -a $capture

proc append_marker {capture marker} {
set fh [open $capture a]
puts $fh $marker
close $fh
}

set cmd [list openshell sandbox exec --name $sandbox --tty -- sh -lc {export TERM=xterm-256color; cd /sandbox; dcode; status=$?; printf "\nNEMOCLAW_TUI_EXIT:%s\n" "$status"}]
spawn {*}$cmd
expect {
-nocase -re $ready_pattern {
append_marker $capture "NEMOCLAW_TUI_READY"
puts "\nNEMOCLAW_TUI_READY"
send -- "\003"
}
timeout {
append_marker $capture "NEMOCLAW_TUI_TIMEOUT"
puts "\nNEMOCLAW_TUI_TIMEOUT"
send -- "\003"
exit 20
}
eof {
append_marker $capture "NEMOCLAW_TUI_EOF_BEFORE_READY"
puts "\nNEMOCLAW_TUI_EOF_BEFORE_READY"
exit 21
}
Expand All @@ -171,15 +180,18 @@ expect {
set timeout 20
expect {
-re {NEMOCLAW_TUI_EXIT:([0-9]+)} {
append_marker $capture "NEMOCLAW_TUI_EXIT_CAPTURED:$expect_out(1,string)"
puts "\nNEMOCLAW_TUI_EXIT_CAPTURED:$expect_out(1,string)"
exit 0
}
timeout {
append_marker $capture "NEMOCLAW_TUI_EXIT_TIMEOUT"
puts "\nNEMOCLAW_TUI_EXIT_TIMEOUT"
send -- "\003"
exit 22
}
eof {
append_marker $capture "NEMOCLAW_TUI_EOF_BEFORE_EXIT"
puts "\nNEMOCLAW_TUI_EOF_BEFORE_EXIT"
exit 23
}
Expand Down
10 changes: 8 additions & 2 deletions test/langchain-deepagents-code-image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,14 @@ describe("LangChain Deep Agents Code image contracts", () => {
expect(tuiStartupCheck).toContain("unable to probe sandbox");
expect(tuiStartupCheck).toContain("unexpected sandbox probe output");
expect(tuiStartupCheck).toContain("cd /sandbox; dcode");
expect(tuiStartupCheck).toContain("NEMOCLAW_TUI_READY");
expect(tuiStartupCheck).toContain("NEMOCLAW_TUI_EXIT_CAPTURED");
expect(tuiStartupCheck).toContain('append_marker $capture "NEMOCLAW_TUI_READY"');
expect(tuiStartupCheck).toContain('append_marker $capture "NEMOCLAW_TUI_TIMEOUT"');
expect(tuiStartupCheck).toContain('append_marker $capture "NEMOCLAW_TUI_EOF_BEFORE_READY"');
expect(tuiStartupCheck).toContain(
'append_marker $capture "NEMOCLAW_TUI_EXIT_CAPTURED:$expect_out(1,string)"',
);
expect(tuiStartupCheck).toContain('append_marker $capture "NEMOCLAW_TUI_EXIT_TIMEOUT"');
expect(tuiStartupCheck).toContain('append_marker $capture "NEMOCLAW_TUI_EOF_BEFORE_EXIT"');
expect(tuiStartupCheck).toContain("DEEPAGENTS_TUI_TIMEOUT must be a positive integer");
expect(tuiStartupCheck).toContain("strip_terminal_control_sequences");
expect(tuiStartupCheck).toContain("is_tui_ready_capture");
Expand Down
Loading