fix: stabilize pty tests and media kind

This commit is contained in:
Peter Steinberger
2026-01-17 08:10:44 +00:00
parent cccd7c7b8e
commit c5239f6a8e
3 changed files with 4 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ afterEach(() => {
test("exec supports pty output", async () => {
const tool = createExecTool({ allowBackground: false });
const result = await tool.execute("toolcall", {
command: "node -e \"process.stdout.write('ok')\"",
command: 'node -e "process.stdout.write(String.fromCharCode(111,107))"',
pty: true,
});

View File

@@ -15,7 +15,7 @@ test("process send-keys encodes Enter for pty sessions", async () => {
const processTool = createProcessTool();
const result = await execTool.execute("toolcall", {
command:
"node -e \"process.stdin.on('data', d => { process.stdout.write(d); if (d.includes(10) || d.includes(13)) process.exit(0); });\"",
'node -e "const dataEvent=String.fromCharCode(100,97,116,97);process.stdin.on(dataEvent,d=>{process.stdout.write(d);if(d.includes(10)||d.includes(13))process.exit(0);});"',
pty: true,
background: true,
});
@@ -50,7 +50,7 @@ test("process submit sends Enter for pty sessions", async () => {
const processTool = createProcessTool();
const result = await execTool.execute("toolcall", {
command:
"node -e \"process.stdin.on('data', d => { if (d.includes(10) || d.includes(13)) { process.stdout.write('submitted'); process.exit(0); } });\"",
'node -e "const dataEvent=String.fromCharCode(100,97,116,97);const submitted=String.fromCharCode(115,117,98,109,105,116,116,101,100);process.stdin.on(dataEvent,d=>{if(d.includes(10)||d.includes(13)){process.stdout.write(submitted);process.exit(0);}});"',
pty: true,
background: true,
});

View File

@@ -104,7 +104,7 @@ export function resolveAttachmentKind(
attachment: MediaAttachment,
): "image" | "audio" | "video" | "document" | "unknown" {
const kind = kindFromMime(attachment.mime);
if (kind !== "unknown") return kind;
if (kind === "image" || kind === "audio" || kind === "video") return kind;
const ext = getFileExtension(attachment.path ?? attachment.url);
if (!ext) return "unknown";