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
@@ -96,5 +96,9 @@ Prefix-stable while the guidance text is unchanged.
## Known Limitations and Deferred Work
- **Dormant until configured:** the image-task injection is gated on a usable
provider, so without a configured endpoint the capability is inert and the
model is not guided to recognition. Direct `recognize_image` calls then throw
a clear `ImageRecognitionError`.
- Path/URL detection is heuristic and can be disabled; misdetections are possible.
- Requires a configured, available provider — see `dsh-image-recognition-http`.
@@ -150,6 +150,9 @@ export function apply(ctx: Context, config: Config = {}): void {
const decision = await next()
if (decision.kind === 'reject') return decision
if (!hasImageSignal(decision.messages, detectBlocks, detectPaths)) return decision
// Dormant until configured: without a usable provider the recognition
// surface is inert, so the model is not guided to a call that can only fail.
if (!ctx.imageRecognition.available()) return decision
signal.throwIfAborted()
const lookup = { cwd: agent.session.header.cwd, signal, scope: agent }
const skill = await ctx.skills.get(SKILL_NAME, lookup)