fix(cli): report missing infer media providers

This commit is contained in:
Peter Steinberger
2026-05-02 07:47:15 +01:00
parent 798515809c
commit fa7de46261
6 changed files with 145 additions and 6 deletions

View File

@@ -782,6 +782,51 @@ describe("capability cli", () => {
);
});
it("reports missing image understanding configuration for image describe", async () => {
mocks.describeImageFile.mockResolvedValueOnce({
text: undefined,
decision: {
capability: "image",
outcome: "skipped",
attachments: [{ attachmentIndex: 0, attempts: [] }],
},
} as never);
await expect(
runRegisteredCli({
register: registerCapabilityCli as (program: Command) => void,
argv: ["capability", "image", "describe", "--file", "photo.jpg", "--json"],
}),
).rejects.toThrow("exit 1");
expect(mocks.runtime.error).toHaveBeenCalledWith(
expect.stringContaining("No image understanding provider is configured or ready"),
);
expect(mocks.runtime.error).toHaveBeenCalledWith(
expect.stringContaining("agents.defaults.imageModel.primary"),
);
});
it("reports missing image understanding configuration for image describe-many", async () => {
mocks.describeImageFile.mockResolvedValueOnce({
text: undefined,
decision: {
capability: "image",
outcome: "skipped",
attachments: [{ attachmentIndex: 0, attempts: [] }],
},
} as never);
await expect(
runRegisteredCli({
register: registerCapabilityCli as (program: Command) => void,
argv: ["capability", "image", "describe-many", "--file", "photo.jpg", "--json"],
}),
).rejects.toThrow("exit 1");
expect(mocks.runtime.error).toHaveBeenCalledWith(
expect.stringContaining("No image understanding provider is configured or ready"),
);
});
it("rewrites mismatched explicit image output extensions to the detected file type", async () => {
const jpegBase64 =
"/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEBUQEBAVFRUVFRUVFRUVFRUVFRUVFRUXFhUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGhAQGi0fHyUtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAAEAAQMBIgACEQEDEQH/xAAXAAEBAQEAAAAAAAAAAAAAAAAAAQID/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAER/9oADAMBAAIQAxAAAAH2AP/EABgQAQEAAwAAAAAAAAAAAAAAAAEAEQIS/9oACAEBAAEFAk1o7//EABYRAQEBAAAAAAAAAAAAAAAAAAABEf/aAAgBAwEBPwGn/8QAFhEBAQEAAAAAAAAAAAAAAAAAABEB/9oACAECAQE/AYf/xAAaEAACAgMAAAAAAAAAAAAAAAABEQAhMUFh/9oACAEBAAY/AjK9cY2f/8QAGhABAQACAwAAAAAAAAAAAAAAAAERITFBUf/aAAgBAQABPyGQk7W5jVYkA//Z";
@@ -1278,6 +1323,30 @@ describe("capability cli", () => {
);
});
it("reports missing audio transcription configuration for audio transcribe", async () => {
mocks.transcribeAudioFile.mockResolvedValueOnce({
text: undefined,
decision: {
capability: "audio",
outcome: "skipped",
attachments: [{ attachmentIndex: 0, attempts: [] }],
},
} as never);
await expect(
runRegisteredCli({
register: registerCapabilityCli as (program: Command) => void,
argv: ["capability", "audio", "transcribe", "--file", "memo.m4a", "--json"],
}),
).rejects.toThrow("exit 1");
expect(mocks.runtime.error).toHaveBeenCalledWith(
expect.stringContaining("No audio transcription provider is configured or ready"),
);
expect(mocks.runtime.error).toHaveBeenCalledWith(
expect.stringContaining("tools.media.audio.models"),
);
});
it("surfaces the underlying transcription failure for audio transcribe", async () => {
mocks.transcribeAudioFile.mockRejectedValueOnce(
new Error("Audio transcription response missing text"),