fix(read): expose artifact source line totals

This commit is contained in:
can1357
2026-08-05 01:11:59 +02:00
parent a0f203bfd4
commit abc628b63c
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -3244,6 +3244,7 @@ export class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
if (!rawSelector && artifact.size > MAX_ARTIFACT_RAW_INLINE_BYTES) {
outputText += `\n\n[${this.#formatArtifactWorkflowNotice(artifact, artifactUrl)}]`;
}
if (reachedEof) details.totalLines = totalFileLines;
if (displayContent) details.displayContent = displayContent;
if (truncationInfo) details.truncation = truncationInfo.result;
const resultBuilder = toolResult<ReadToolDetails>(details)
@@ -104,6 +104,12 @@ describe("read tool large artifact handling", () => {
expect(output).not.toContain("line-032");
});
it("records the source line count for an open-ended artifact range that reaches EOF", async () => {
const result = await tool.execute("call-raw-tail", { path: "artifact://0:raw:301-" });
expect(result.details?.totalLines).toBe(400);
});
it("shortens artifact paths under the user's home dir instead of leaking the absolute path", async () => {
const homeSpy = spyOn(os, "homedir").mockReturnValue(testDir);
try {