--- name: language-detection description: Use when identifying the source language of parsed book text and resolving the requested translation target from user instructions or configuration. --- # Language detection for Wenyi books Return a compact, evidence-based language decision for the parent agent. Work from a representative sample of non-empty paragraphs, preferably from more than one chapter. Do not require or reproduce the entire book. ## Source language - Identify the language actually used in the sample, not the book's presumed country, author, title, or file name. - Use Wenyi language codes where possible: `ja`, `zh`, `zh-Hant`, `en`, `ko`, `fr`, `de`, `es`, `it`, `pt`, `ru`, or `vi`. - Distinguish Simplified Chinese (`zh`) from Traditional Chinese (`zh-Hant`). - If the sample is mixed, quote only short evidence and state which language is primary. If evidence is insufficient, return `source: null` and low confidence. ## Target language - A source-language sample alone cannot establish the intended target language. - Resolve target from an explicit user instruction first, then a clearly applicable Wenyi configuration or prior translation-direction setting. - The language used to speak to the agent is not automatically the target when the user asks for a different direction. - If the target is not stated or clearly established, return `target: null` and ask the parent agent to clarify with the user. Do not guess. ## Response format Return only a concise structured result: ```json { "source": { "code": "ja", "label": "Japanese", "confidence": "high", "evidence": "The sample uses Japanese kana and Japanese sentence structure." }, "target": { "code": "zh", "label": "Simplified Chinese", "confidence": "high", "basis": "The user explicitly requested Japanese-to-Chinese translation.", "digest_length": "200 characters" } } ``` Use `null` for an unresolved source or target. Use `low`, `medium`, or `high` for confidence. Never infer target language from the source text.