feat(vision): gate recognition on a configured provider

Expose ImageRecognitionRuntime.available() and gate the image-task pre-step
injection on it, so the capability is dormant until an endpoint is
configured instead of guiding the model to a call that can only fail.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Pine
2026-08-14 12:08:30 +08:00
parent 2b81e38263
commit 08ac7c3da5
4 changed files with 46 additions and 0 deletions
@@ -98,3 +98,22 @@ describe('ImageRecognitionRuntime selection', () => {
.rejects.toThrow(expect.objectContaining({ code: 'IMAGE_RECOGNITION_PROVIDER_AMBIGUOUS' }))
})
})
describe('ImageRecognitionRuntime.available', () => {
it('is false with no registered provider', async () => {
const { runtime } = await mountRuntime()
expect(runtime.available()).toBe(false)
})
it('is false when the configured provider is unavailable (not configured)', async () => {
const { runtime } = await mountRuntime({ provider: 'http' })
runtime.registerProvider(makeProvider('http', unavailable, () => Promise.resolve(recognizeResult('a'))))
expect(runtime.available()).toBe(false)
})
it('is true when a configured provider is available', async () => {
const { runtime } = await mountRuntime({ provider: 'http' })
runtime.registerProvider(makeProvider('http', available, () => Promise.resolve(recognizeResult('a'))))
expect(runtime.available()).toBe(true)
})
})