|
@@ -119,13 +119,38 @@ describe("transcript", () => {
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
const result = formatPart(part, options)
|
|
const result = formatPart(part, options)
|
|
|
- expect(result).toContain("Tool: bash")
|
|
|
|
|
|
|
+ expect(result).toContain("**Tool: bash**")
|
|
|
expect(result).toContain("**Input:**")
|
|
expect(result).toContain("**Input:**")
|
|
|
expect(result).toContain('"command": "ls"')
|
|
expect(result).toContain('"command": "ls"')
|
|
|
expect(result).toContain("**Output:**")
|
|
expect(result).toContain("**Output:**")
|
|
|
expect(result).toContain("file1.txt")
|
|
expect(result).toContain("file1.txt")
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ test("formats tool output containing triple backticks without breaking markdown", () => {
|
|
|
|
|
+ const part: Part = {
|
|
|
|
|
+ id: "part_1",
|
|
|
|
|
+ sessionID: "ses_123",
|
|
|
|
|
+ messageID: "msg_123",
|
|
|
|
|
+ type: "tool",
|
|
|
|
|
+ callID: "call_1",
|
|
|
|
|
+ tool: "bash",
|
|
|
|
|
+ state: {
|
|
|
|
|
+ status: "completed",
|
|
|
|
|
+ input: { command: "echo '```hello```'" },
|
|
|
|
|
+ output: "```hello```",
|
|
|
|
|
+ title: "Echo backticks",
|
|
|
|
|
+ metadata: {},
|
|
|
|
|
+ time: { start: 1000, end: 1100 },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+ const result = formatPart(part, options)
|
|
|
|
|
+ // The tool header should not be inside a code block
|
|
|
|
|
+ expect(result).toStartWith("**Tool: bash**\n")
|
|
|
|
|
+ // Input and output should each be in their own code blocks
|
|
|
|
|
+ expect(result).toContain("**Input:**\n```json")
|
|
|
|
|
+ expect(result).toContain("**Output:**\n```\n```hello```\n```")
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
test("formats tool part without details when disabled", () => {
|
|
test("formats tool part without details when disabled", () => {
|
|
|
const part: Part = {
|
|
const part: Part = {
|
|
|
id: "part_1",
|
|
id: "part_1",
|
|
@@ -144,7 +169,7 @@ describe("transcript", () => {
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
const result = formatPart(part, { ...options, toolDetails: false })
|
|
const result = formatPart(part, { ...options, toolDetails: false })
|
|
|
- expect(result).toContain("Tool: bash")
|
|
|
|
|
|
|
+ expect(result).toContain("**Tool: bash**")
|
|
|
expect(result).not.toContain("**Input:**")
|
|
expect(result).not.toContain("**Input:**")
|
|
|
expect(result).not.toContain("**Output:**")
|
|
expect(result).not.toContain("**Output:**")
|
|
|
})
|
|
})
|