@nhtio/adk 0.1.0-master-e6c58205 → 0.1.0-master-89b47bec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -0
- package/__vite-browser-external-CU7uua8b.mjs +9 -0
- package/__vite-browser-external-CU7uua8b.mjs.map +1 -0
- package/__vite-browser-external-DAHxjh-D.js +13 -0
- package/__vite-browser-external-DAHxjh-D.js.map +1 -0
- package/batteries/embeddings/openai/adapter.cjs +1 -1
- package/batteries/embeddings/openai/adapter.mjs +1 -1
- package/batteries/embeddings/webllm/adapter.cjs +1 -1
- package/batteries/embeddings/webllm/adapter.mjs +1 -1
- package/batteries/llm/ollama/adapter.cjs +5 -5
- package/batteries/llm/ollama/adapter.mjs +5 -5
- package/batteries/llm/ollama/helpers.cjs +2 -2
- package/batteries/llm/ollama/helpers.mjs +2 -2
- package/batteries/llm/ollama/validation.cjs +1 -1
- package/batteries/llm/ollama/validation.mjs +1 -1
- package/batteries/llm/openai_chat_completions/adapter.cjs +5 -5
- package/batteries/llm/openai_chat_completions/adapter.mjs +5 -5
- package/batteries/llm/openai_chat_completions/helpers.cjs +2 -2
- package/batteries/llm/openai_chat_completions/helpers.mjs +2 -2
- package/batteries/llm/openai_chat_completions/validation.cjs +1 -1
- package/batteries/llm/openai_chat_completions/validation.mjs +1 -1
- package/batteries/llm/webllm_chat_completions/adapter.cjs +5 -5
- package/batteries/llm/webllm_chat_completions/adapter.mjs +5 -5
- package/batteries/llm/webllm_chat_completions/validation.cjs +1 -1
- package/batteries/llm/webllm_chat_completions/validation.mjs +1 -1
- package/batteries/media/contracts.cjs +38 -8
- package/batteries/media/contracts.cjs.map +1 -1
- package/batteries/media/contracts.d.ts +86 -6
- package/batteries/media/contracts.mjs +37 -9
- package/batteries/media/contracts.mjs.map +1 -1
- package/batteries/media/engines/audio_decode.cjs +46 -6
- package/batteries/media/engines/audio_decode.cjs.map +1 -1
- package/batteries/media/engines/audio_decode.d.ts +9 -5
- package/batteries/media/engines/audio_decode.mjs +47 -7
- package/batteries/media/engines/audio_decode.mjs.map +1 -1
- package/batteries/media/engines/data.cjs +159 -0
- package/batteries/media/engines/data.cjs.map +1 -0
- package/batteries/media/engines/data.d.ts +36 -0
- package/batteries/media/engines/data.mjs +157 -0
- package/batteries/media/engines/data.mjs.map +1 -0
- package/batteries/media/engines/exceljs.cjs +290 -0
- package/batteries/media/engines/exceljs.cjs.map +1 -0
- package/batteries/media/engines/exceljs.d.ts +41 -0
- package/batteries/media/engines/exceljs.mjs +288 -0
- package/batteries/media/engines/exceljs.mjs.map +1 -0
- package/batteries/media/engines/execa_executor.cjs +1 -1
- package/batteries/media/engines/execa_executor.mjs +1 -1
- package/batteries/media/engines/fs_workspace.cjs +1 -1
- package/batteries/media/engines/fs_workspace.mjs +1 -1
- package/batteries/media/engines/jimp.cjs +24 -2
- package/batteries/media/engines/jimp.cjs.map +1 -1
- package/batteries/media/engines/jimp.d.ts +3 -1
- package/batteries/media/engines/jimp.mjs +24 -2
- package/batteries/media/engines/jimp.mjs.map +1 -1
- package/batteries/media/engines/sharp.cjs +37 -4
- package/batteries/media/engines/sharp.cjs.map +1 -1
- package/batteries/media/engines/sharp.d.ts +5 -3
- package/batteries/media/engines/sharp.mjs +37 -4
- package/batteries/media/engines/sharp.mjs.map +1 -1
- package/batteries/media/engines/sheetjs.cjs +438 -0
- package/batteries/media/engines/sheetjs.cjs.map +1 -0
- package/batteries/media/engines/sheetjs.d.ts +51 -0
- package/batteries/media/engines/sheetjs.mjs +436 -0
- package/batteries/media/engines/sheetjs.mjs.map +1 -0
- package/batteries/media/engines/soffice.cjs +37 -3
- package/batteries/media/engines/soffice.cjs.map +1 -1
- package/batteries/media/engines/soffice.mjs +38 -4
- package/batteries/media/engines/soffice.mjs.map +1 -1
- package/batteries/media/engines/tesseract_js.cjs +1 -1
- package/batteries/media/engines/tesseract_js.mjs +1 -1
- package/batteries/media/engines/transformers_asr.cjs +1 -1
- package/batteries/media/engines/transformers_asr.mjs +1 -1
- package/batteries/media/forge.cjs +89 -20
- package/batteries/media/forge.cjs.map +1 -1
- package/batteries/media/forge.mjs +89 -20
- package/batteries/media/forge.mjs.map +1 -1
- package/batteries/media/formats.d.ts +9 -0
- package/batteries/media/index.d.ts +8 -6
- package/batteries/media/lint.cjs +270 -58
- package/batteries/media/lint.cjs.map +1 -1
- package/batteries/media/lint.d.ts +45 -0
- package/batteries/media/lint.mjs +267 -58
- package/batteries/media/lint.mjs.map +1 -1
- package/batteries/media/registry.d.ts +11 -2
- package/batteries/media/steps/data.d.ts +26 -0
- package/batteries/media/steps/doc.d.ts +17 -7
- package/batteries/media/steps/patch.d.ts +90 -0
- package/batteries/media/steps/sheet.d.ts +10 -6
- package/batteries/media/steps/text.d.ts +4 -1
- package/batteries/media/validate.d.ts +5 -0
- package/batteries/media/verbs.d.ts +12 -1
- package/batteries/media.cjs +869 -448
- package/batteries/media.cjs.map +1 -1
- package/batteries/media.mjs +829 -409
- package/batteries/media.mjs.map +1 -1
- package/batteries/storage/flydrive.cjs +3 -6
- package/batteries/storage/flydrive.cjs.map +1 -1
- package/batteries/storage/flydrive.mjs +3 -6
- package/batteries/storage/flydrive.mjs.map +1 -1
- package/batteries/storage/in_memory.cjs +1 -1
- package/batteries/storage/in_memory.mjs +1 -1
- package/batteries/storage/opfs.cjs +1 -1
- package/batteries/storage/opfs.mjs +1 -1
- package/batteries/tools/_shared.cjs +2 -2
- package/batteries/tools/_shared.mjs +2 -2
- package/batteries/tools/color.cjs +2 -2
- package/batteries/tools/color.mjs +2 -2
- package/batteries/tools/comparison.cjs +3 -3
- package/batteries/tools/comparison.mjs +3 -3
- package/batteries/tools/data_structure.cjs +3 -3
- package/batteries/tools/data_structure.mjs +3 -3
- package/batteries/tools/datetime_extended.cjs +3 -3
- package/batteries/tools/datetime_extended.mjs +3 -3
- package/batteries/tools/datetime_math.cjs +3 -3
- package/batteries/tools/datetime_math.mjs +3 -3
- package/batteries/tools/encoding.cjs +3 -3
- package/batteries/tools/encoding.mjs +3 -3
- package/batteries/tools/formatting.cjs +3 -3
- package/batteries/tools/formatting.mjs +3 -3
- package/batteries/tools/geo_basics.cjs +2 -2
- package/batteries/tools/geo_basics.mjs +2 -2
- package/batteries/tools/math.cjs +3 -3
- package/batteries/tools/math.mjs +3 -3
- package/batteries/tools/memory.cjs +6 -6
- package/batteries/tools/memory.mjs +6 -6
- package/batteries/tools/parsing.cjs +4 -4
- package/batteries/tools/parsing.mjs +4 -4
- package/batteries/tools/retrievables.cjs +5 -5
- package/batteries/tools/retrievables.mjs +5 -5
- package/batteries/tools/scrapper.cjs +1 -1
- package/batteries/tools/scrapper.mjs +1 -1
- package/batteries/tools/searxng.cjs +1 -1
- package/batteries/tools/searxng.mjs +1 -1
- package/batteries/tools/standing_instructions.cjs +4 -4
- package/batteries/tools/standing_instructions.mjs +4 -4
- package/batteries/tools/statistics.cjs +4 -4
- package/batteries/tools/statistics.mjs +4 -4
- package/batteries/tools/string_processing.cjs +3 -3
- package/batteries/tools/string_processing.mjs +3 -3
- package/batteries/tools/structured_data.cjs +3 -3
- package/batteries/tools/structured_data.mjs +3 -3
- package/batteries/tools/text_analysis.cjs +3 -3
- package/batteries/tools/text_analysis.mjs +3 -3
- package/batteries/tools/text_comparison.cjs +2 -2
- package/batteries/tools/text_comparison.mjs +2 -2
- package/batteries/tools/time.cjs +3 -3
- package/batteries/tools/time.mjs +3 -3
- package/batteries/tools/unit_conversion.cjs +2 -2
- package/batteries/tools/unit_conversion.mjs +2 -2
- package/batteries/tools/web_retrieval.cjs +1 -1
- package/batteries/tools/web_retrieval.mjs +1 -1
- package/batteries/tools.cjs +2 -2
- package/batteries/tools.mjs +2 -2
- package/batteries/vector/arangodb.cjs +1 -1
- package/batteries/vector/arangodb.mjs +1 -1
- package/batteries/vector/clickhouse.cjs +1 -1
- package/batteries/vector/clickhouse.mjs +1 -1
- package/batteries/vector/cloudflare.cjs +1 -1
- package/batteries/vector/cloudflare.mjs +1 -1
- package/batteries/vector/couchbase.cjs +1 -1
- package/batteries/vector/couchbase.mjs +1 -1
- package/batteries/vector/duckdb.cjs +1 -1
- package/batteries/vector/duckdb.mjs +1 -1
- package/batteries/vector/elasticsearch.cjs +1 -1
- package/batteries/vector/elasticsearch.mjs +1 -1
- package/batteries/vector/filters.cjs +1 -1
- package/batteries/vector/filters.mjs +1 -1
- package/batteries/vector/hnswlib.cjs +1 -1
- package/batteries/vector/hnswlib.mjs +1 -1
- package/batteries/vector/lancedb.cjs +1 -1
- package/batteries/vector/lancedb.mjs +1 -1
- package/batteries/vector/mariadb.cjs +1 -1
- package/batteries/vector/mariadb.mjs +1 -1
- package/batteries/vector/meilisearch.cjs +1 -1
- package/batteries/vector/meilisearch.mjs +1 -1
- package/batteries/vector/migrate.cjs +1 -1
- package/batteries/vector/migrate.mjs +1 -1
- package/batteries/vector/mongodb.cjs +1 -1
- package/batteries/vector/mongodb.mjs +1 -1
- package/batteries/vector/neo4j.cjs +1 -1
- package/batteries/vector/neo4j.mjs +1 -1
- package/batteries/vector/opensearch.cjs +1 -1
- package/batteries/vector/opensearch.mjs +1 -1
- package/batteries/vector/oracle23ai.cjs +1 -1
- package/batteries/vector/oracle23ai.mjs +1 -1
- package/batteries/vector/pinecone.cjs +1 -1
- package/batteries/vector/pinecone.mjs +1 -1
- package/batteries/vector/redis.cjs +1 -1
- package/batteries/vector/redis.mjs +1 -1
- package/batteries/vector/retrievable.cjs +1 -1
- package/batteries/vector/retrievable.mjs +1 -1
- package/batteries/vector/s3vectors.cjs +1 -1
- package/batteries/vector/s3vectors.mjs +1 -1
- package/batteries/vector/solr.cjs +1 -1
- package/batteries/vector/solr.mjs +1 -1
- package/batteries/vector/surrealdb.cjs +1 -1
- package/batteries/vector/surrealdb.mjs +1 -1
- package/batteries/vector/typesense.cjs +1 -1
- package/batteries/vector/typesense.mjs +1 -1
- package/batteries/vector/vespa.cjs +1 -1
- package/batteries/vector/vespa.mjs +1 -1
- package/batteries/vector/weaviate.cjs +1 -1
- package/batteries/vector/weaviate.mjs +1 -1
- package/batteries.cjs +2 -2
- package/batteries.mjs +2 -2
- package/bundled_xlsx.d.ts +1075 -0
- package/{common-BxoznqbX.mjs → common-BQoFv108.mjs} +7 -7
- package/{common-BxoznqbX.mjs.map → common-BQoFv108.mjs.map} +1 -1
- package/{common-BBK2e5ro.js → common-DmDn4Gfl.js} +7 -7
- package/{common-BBK2e5ro.js.map → common-DmDn4Gfl.js.map} +1 -1
- package/common.cjs +7 -7
- package/common.mjs +7 -7
- package/{dispatch_runner-Hn5idJYx.js → dispatch_runner-BwplbCPr.js} +3 -3
- package/{dispatch_runner-Hn5idJYx.js.map → dispatch_runner-BwplbCPr.js.map} +1 -1
- package/{dispatch_runner-DUrpj0xR.mjs → dispatch_runner-C1ar_D7W.mjs} +3 -3
- package/{dispatch_runner-DUrpj0xR.mjs.map → dispatch_runner-C1ar_D7W.mjs.map} +1 -1
- package/dispatch_runner.cjs +1 -1
- package/dispatch_runner.mjs +1 -1
- package/eslint.cjs +1 -1
- package/eslint.mjs +1 -1
- package/forge.cjs +4 -4
- package/forge.mjs +4 -4
- package/formats-CCylUHZw.mjs +161 -0
- package/formats-CCylUHZw.mjs.map +1 -0
- package/formats-DZVuqZUN.js +196 -0
- package/formats-DZVuqZUN.js.map +1 -0
- package/guards.cjs +8 -8
- package/guards.mjs +8 -8
- package/index.cjs +11 -11
- package/index.mjs +11 -11
- package/mcp/adk-docs-corpus.json +1 -1
- package/package.json +198 -182
- package/{scrapper-DLj_KkxK.mjs → scrapper-Dn2wXu0Y.mjs} +5 -5
- package/{scrapper-DLj_KkxK.mjs.map → scrapper-Dn2wXu0Y.mjs.map} +1 -1
- package/{scrapper-Cmf1CSA-.js → scrapper-mBZ0Odq7.js} +5 -5
- package/{scrapper-Cmf1CSA-.js.map → scrapper-mBZ0Odq7.js.map} +1 -1
- package/{searxng-BKs5s8Su.js → searxng-Dj-iP_Vz.js} +5 -5
- package/{searxng-BKs5s8Su.js.map → searxng-Dj-iP_Vz.js.map} +1 -1
- package/{searxng-BJ-aZcMz.mjs → searxng-DjFxtFf6.mjs} +5 -5
- package/{searxng-BJ-aZcMz.mjs.map → searxng-DjFxtFf6.mjs.map} +1 -1
- package/server.json +21 -0
- package/skills/adk-assembly/SKILL.md +2 -2
- package/{spooled_artifact-BR0IhU9y.js → spooled_artifact-BCmPrxZS.js} +3 -3
- package/{spooled_artifact-BR0IhU9y.js.map → spooled_artifact-BCmPrxZS.js.map} +1 -1
- package/{spooled_artifact-nTE6ujM8.mjs → spooled_artifact-DL36jnqA.mjs} +3 -3
- package/{spooled_artifact-nTE6ujM8.mjs.map → spooled_artifact-DL36jnqA.mjs.map} +1 -1
- package/spooled_artifact.cjs +2 -2
- package/spooled_artifact.mjs +2 -2
- package/{spooled_markdown_artifact-Dj3fNowz.js → spooled_markdown_artifact-CD4PrrpV.js} +3 -3
- package/{spooled_markdown_artifact-Dj3fNowz.js.map → spooled_markdown_artifact-CD4PrrpV.js.map} +1 -1
- package/{spooled_markdown_artifact-DIYzbQv8.mjs → spooled_markdown_artifact-Da-Xnebh.mjs} +3 -3
- package/{spooled_markdown_artifact-DIYzbQv8.mjs.map → spooled_markdown_artifact-Da-Xnebh.mjs.map} +1 -1
- package/{thought-Cde2Y_GK.mjs → thought-CtOoZUSE.mjs} +3 -3
- package/{thought-Cde2Y_GK.mjs.map → thought-CtOoZUSE.mjs.map} +1 -1
- package/{thought-BFtsnUTU.js → thought-eka4iUHa.js} +3 -3
- package/{thought-BFtsnUTU.js.map → thought-eka4iUHa.js.map} +1 -1
- package/{tool-CcxYxA5X.mjs → tool-CITF20yJ.mjs} +3 -3
- package/{tool-CcxYxA5X.mjs.map → tool-CITF20yJ.mjs.map} +1 -1
- package/{tool-B2nnkwNU.js → tool-Dhjca7rC.js} +3 -3
- package/{tool-B2nnkwNU.js.map → tool-Dhjca7rC.js.map} +1 -1
- package/{tool_call-BxL3eU1k.js → tool_call-Cyi0hUUc.js} +4 -4
- package/{tool_call-BxL3eU1k.js.map → tool_call-Cyi0hUUc.js.map} +1 -1
- package/{tool_call-B3MOog2R.mjs → tool_call-D_k36aI4.mjs} +4 -4
- package/{tool_call-B3MOog2R.mjs.map → tool_call-D_k36aI4.mjs.map} +1 -1
- package/{tool_registry-BaLUIzWz.mjs → tool_registry-CZ55mIti.mjs} +152 -143
- package/tool_registry-CZ55mIti.mjs.map +1 -0
- package/{tool_registry-BdKlPuHS.js → tool_registry-DwZ6pzN4.js} +151 -142
- package/tool_registry-DwZ6pzN4.js.map +1 -0
- package/{turn_runner-M2I8G2ok.js → turn_runner-CCZcsoDU.js} +5 -5
- package/{turn_runner-M2I8G2ok.js.map → turn_runner-CCZcsoDU.js.map} +1 -1
- package/{turn_runner-BV4BaZK9.mjs → turn_runner-DRPpVvsd.mjs} +5 -5
- package/{turn_runner-BV4BaZK9.mjs.map → turn_runner-DRPpVvsd.mjs.map} +1 -1
- package/turn_runner.cjs +1 -1
- package/turn_runner.mjs +1 -1
- package/{validate-JOHfh-BB.mjs → validate-C_hTnDBE.mjs} +95 -8
- package/validate-C_hTnDBE.mjs.map +1 -0
- package/{validate-DgDZkUKs.js → validate-gaSa9bsk.js} +95 -8
- package/validate-gaSa9bsk.js.map +1 -0
- package/xlsx-B0sTpEC2.js +30615 -0
- package/xlsx-B0sTpEC2.js.map +1 -0
- package/xlsx-DiMpn_Xv.mjs +30596 -0
- package/xlsx-DiMpn_Xv.mjs.map +1 -0
- package/xlsx.zahl-D2_Q-Xs4.mjs +6 -0
- package/xlsx.zahl-D2_Q-Xs4.mjs.map +1 -0
- package/xlsx.zahl-ZIcUQVv8.js +7 -0
- package/xlsx.zahl-ZIcUQVv8.js.map +1 -0
- package/tool_registry-BaLUIzWz.mjs.map +0 -1
- package/tool_registry-BdKlPuHS.js.map +0 -1
- package/validate-DgDZkUKs.js.map +0 -1
- package/validate-JOHfh-BB.mjs.map +0 -1
package/validate-DgDZkUKs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-DgDZkUKs.js","names":[],"sources":["../src/batteries/media/plan.ts","../src/batteries/media/verbs.ts","../src/batteries/media/validate.ts"],"sourcesContent":["/**\n * The neutral `MediaPlan` intermediate representation and its canonical serializers.\n *\n * @remarks\n * Internal sibling of the `@nhtio/adk/batteries/media` entry. All three front-ends — the\n * chainable builder, the pipe-string parser, and the JSON ops array — compile to this one IR,\n * and the step runtime consumes only this IR. Invariants (frozen design, section 0.7):\n *\n * - **Serializable.** No live `RegExp`, `Media`, or function values — regexes are\n * `{ source, flags }`, media refs are typed handles. A plan can be logged, content-hashed,\n * and embedded in a tool result.\n * - **Round-trip is fixed-point.** `parsePipe(toPipe(plan))` produces an equal plan and\n * `toPipe` is idempotent. `toPipe(parsePipe(s)) === s` is NOT promised (e.g. `2,3,4,5`\n * renders as `2-5`).\n * - **Engine-agnostic.** Steps name verbs, never engines.\n */\n\nimport { isObject } from '@nhtio/adk/guards'\nimport { E_MEDIA_NOT_PIPE_EXPRESSIBLE } from './exceptions'\n\n/**\n * A serializable regex reference. Never a live `RegExp` in the IR.\n */\nexport interface RegExpRef {\n /** The regex source, exactly as `RegExp.prototype.source` would report it. */\n source: string\n /** Sorted flag characters (canonicalized — `gi`, never `ig`). */\n flags: string\n}\n\n/**\n * A reference to another media participating in a multi-input verb (`merge`, `diff`,\n * `apply_patch`, `slides.update_image`).\n *\n * @remarks\n * The `id` variant is the canonical model-facing form — the pipe syntax is an inline\n * `@id` token (`merge with=@018f…`) and the ops form carries the same id. The `builder`\n * variant is implementor-only (a nested chain: `mp(a).diff(mp(b).convert('txt'))`) and is\n * not expressible in a flat pipe string.\n */\nexport type MediaRef = { kind: 'id'; id: string } | { kind: 'builder'; plan: MediaPlan }\n\n/** Scalar arg values the flat pipe grammar can express directly. */\nexport type MediaArgScalar = string | number | boolean | RegExpRef | MediaRef\n\n/**\n * A structured (JSON-shaped) arg value. In the pipe surface these are written as quoted JSON\n * (`updates='[{\"address\":\"B2\",\"value\":3}]'`); in ops they are plain JSON. `null` is legal only\n * inside structured values (cell values), never as a top-level scalar.\n */\nexport type MediaArgJson =\n | string\n | number\n | boolean\n | null\n | MediaArgJson[]\n | { [key: string]: MediaArgJson }\n\n/**\n * The value space of a single verb arg in the IR.\n *\n * @remarks\n * Flat lists (`types=image,font` → `['image','font']`) are `MediaArgScalar[]`. Whether a\n * value parsed from quoted JSON or a flat token is decided by the verb's arg schema — the IR\n * stores the final shape only.\n */\nexport type MediaArgValue = MediaArgScalar | MediaArgScalar[] | MediaArgJson\n\n/** Source span carried by steps parsed from a pipe string, for error mapping. */\nexport interface SourceSpan {\n /** Zero-based character offset into the source string. */\n offset: number\n /** One-based line number. */\n line: number\n /** One-based column number. */\n col: number\n /** Length of the spanned text in characters. */\n length: number\n}\n\n/** One transform step: a canonical verb id plus its validated content args. */\nexport interface MediaStep {\n /**\n * Canonical verb id — dot-namespaced snake_case (`convert`, `select`, `extract.text`,\n * `sheet.update_cells`, `image.resize`).\n */\n verb: string\n /** Validated content args for this verb. */\n args: Record<string, MediaArgValue>\n /** Present when the step came from a pipe string; absent for builder/ops origins. */\n span?: SourceSpan\n}\n\n/** The neutral plan: an ordered, linear list of steps. No branching. */\nexport interface MediaPlan {\n /** The ordered transform steps. */\n steps: MediaStep[]\n}\n\n/** The JSON ops front-end's step shape — identical to {@link MediaStep} minus the span. */\nexport interface MediaOp {\n /** The canonical (or foldable) verb id. */\n verb: string\n /** The verb's named args. */\n args: Record<string, MediaArgValue>\n}\n\n// ── guards ───────────────────────────────────────────────────────────────────\n\n/** `true` when `value` is a {@link RegExpRef}. */\nexport const isRegExpRef = (value: unknown): value is RegExpRef => {\n if (!isObject(value)) return false\n const v = value as Record<string, unknown>\n return typeof v.source === 'string' && typeof v.flags === 'string' && Object.keys(v).length === 2\n}\n\n/** `true` when `value` is a {@link MediaRef}. */\nexport const isMediaRef = (value: unknown): value is MediaRef => {\n if (!isObject(value)) return false\n const v = value as MediaRef\n if (v.kind === 'id') return typeof (v as { id?: unknown }).id === 'string'\n if (v.kind === 'builder') return isObject((v as { plan?: unknown }).plan)\n return false\n}\n\n// ── canonical rendering helpers ──────────────────────────────────────────────\n\n/** Characters legal in an unquoted bareword value. */\nconst BAREWORD = /^[A-Za-z0-9_]+$/\n/** Strings that would lex as a non-ident token and therefore must be quoted. */\nconst LEXES_AS_OTHER = /^(?:\\d+(?:-\\d+)?|\\d+\\.\\d+|true|false|@.*)$/\n\n/**\n * The frozen quoting predicate: quote any string that is empty, would lex as a number, range,\n * boolean, or `@id` token, starts with `/`, or contains a character outside `[A-Za-z0-9_]`.\n */\nconst renderString = (s: string): string => {\n if (s.length === 0 || !BAREWORD.test(s) || LEXES_AS_OTHER.test(s) || s.startsWith('/')) {\n return `\"${s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n')}\"`\n }\n return s\n}\n\n/** Canonicalize regex flags: validate against JS flags and sort. */\nexport const canonicalFlags = (flags: string): string => Array.from(flags).sort().join('')\n\n/** Render a {@link RegExpRef} back to a pipe regex literal, re-escaping bare slashes. */\nconst renderRegExp = (ref: RegExpRef): string => {\n const source = ref.source.length === 0 ? '(?:)' : ref.source\n // Escape bare `/` that are not already escaped and not inside a character class.\n let out = ''\n let inClass = false\n for (let i = 0; i < source.length; i++) {\n const ch = source[i]\n if (ch === '\\\\') {\n out += ch + (source[i + 1] ?? '')\n i++\n continue\n }\n if (ch === '[') inClass = true\n else if (ch === ']') inClass = false\n if (ch === '/' && !inClass) {\n out += '\\\\/'\n continue\n }\n out += ch\n }\n return `/${out}/${canonicalFlags(ref.flags)}`\n}\n\n/**\n * Compress maximal ascending consecutive runs in a number list to `a-b` range tokens.\n * Order-preserving and lossless on the array; never sorts or dedupes.\n */\nconst renderNumberList = (nums: number[]): string => {\n const parts: string[] = []\n let i = 0\n while (i < nums.length) {\n let j = i\n while (\n j + 1 < nums.length &&\n Number.isInteger(nums[j]) &&\n nums[j + 1] === (nums[j] as number) + 1\n ) {\n j++\n }\n if (j - i >= 1 && Number.isInteger(nums[i])) {\n parts.push(`${nums[i]}-${nums[j]}`)\n } else {\n parts.push(String(nums[i]))\n j = i\n }\n i = j + 1\n }\n return parts.join(',')\n}\n\nconst renderScalar = (value: MediaArgScalar): string => {\n if (typeof value === 'number') return String(value)\n if (typeof value === 'boolean') return String(value)\n if (typeof value === 'string') return renderString(value)\n if (isRegExpRef(value)) return renderRegExp(value)\n // MediaRef\n if (value.kind === 'id') return `@${value.id}`\n throw new E_MEDIA_NOT_PIPE_EXPRESSIBLE(['nested builder refs have no pipe form; use toOps()'])\n}\n\nconst isScalar = (value: MediaArgValue): value is MediaArgScalar =>\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n isRegExpRef(value) ||\n isMediaRef(value)\n\nconst renderValue = (value: MediaArgValue): string => {\n if (value === null) {\n // null is only legal inside structured JSON values\n throw new E_MEDIA_NOT_PIPE_EXPRESSIBLE(['null is not a flat pipe value; use toOps()'])\n }\n if (Array.isArray(value)) {\n const arr = value as MediaArgScalar[]\n if (arr.length > 0 && arr.every((v) => typeof v === 'number')) {\n return renderNumberList(arr as number[])\n }\n if (arr.every(isScalar)) {\n return arr.map(renderScalar).join(',')\n }\n // structured (nested) array -> quoted JSON\n return `'${JSON.stringify(value)}'`\n }\n if (isScalar(value)) return renderScalar(value)\n // structured object -> quoted JSON\n return `'${JSON.stringify(value)}'`\n}\n\n/**\n * Render a {@link MediaPlan} to its canonical pipe string.\n *\n * @remarks\n * Total for every plan except those containing builder-variant media refs, which throw\n * {@link E_MEDIA_NOT_PIPE_EXPRESSIBLE}. Structured args render as quoted JSON. The output is\n * canonical: dot-namespaced verbs render as space-separated words, number runs compress to\n * ranges, strings quote per the frozen predicate.\n *\n * @param plan - The plan to render.\n * @returns The canonical pipe expression.\n */\nexport const toPipe = (plan: MediaPlan): string =>\n plan.steps\n .map((step) => {\n const verb = step.verb.replace(/\\./g, ' ')\n const args = Object.entries(step.args)\n .map(([k, v]) => `${k}=${renderValue(v)}`)\n .join(' ')\n return args.length > 0 ? `${verb} ${args}` : verb\n })\n .join(' | ')\n\n/**\n * Render a {@link MediaPlan} to its JSON ops array. Total — every plan has an ops form.\n *\n * @param plan - The plan to render.\n * @returns The ops array (spans stripped).\n */\nexport const toOps = (plan: MediaPlan): MediaOp[] =>\n plan.steps.map((step) => ({ verb: step.verb, args: step.args }))\n\n/**\n * Build a {@link MediaPlan} from a JSON ops array. The inverse of {@link toOps}.\n *\n * @remarks\n * Performs structural normalization only (verb-id folding via the caller's verb table happens\n * in validation, not here). Steps carry no spans.\n *\n * @param ops - The ops array.\n * @returns The equivalent plan.\n */\nexport const fromOps = (ops: MediaOp[]): MediaPlan => ({\n steps: ops.map((op) => ({ verb: op.verb, args: op.args })),\n})\n","/**\n * The canonical verb table: every verb the media DSL knows, with arg schemas, engine\n * requirements, format-family applicability, and output kinds.\n *\n * @remarks\n * Internal sibling of the `@nhtio/adk/batteries/media` entry. This table is the single source\n * of truth consumed by:\n *\n * - the pipe parser's semantic validator (unknown-verb/arg detection, did-you-mean),\n * - the plan compiler (arg coercion + constraint checks),\n * - the engine-narrowing pass (which verbs a deployment advertises),\n * - the forge (generating the `media_query` tool description and few-shot examples),\n * - the builder (typed front-end methods map 1:1 onto entries here).\n *\n * Frozen design decisions (design doc section 0): canonical verb ids are dot-namespaced\n * snake_case; verb matching is separator-insensitive (space/`_`/`.` fold); args are named-only;\n * indices are 1-based everywhere; arg names follow one-meaning-one-name (`to`, `with`, `match`,\n * `replace`, `order`, `pages`, `at`).\n */\n\nimport { PCM_MIME } from './contracts'\n\n/** The value type of a single declared arg. */\nexport type VerbArgType =\n | 'string'\n | 'number'\n | 'boolean'\n | 'enum'\n | 'number-list'\n | 'string-list'\n | 'regex-or-string-list'\n | 'name-or-index'\n | 'media-ref'\n | 'media-ref-list'\n | 'json'\n\n/** Declaration of one named arg on a verb. */\nexport interface VerbArgSpec {\n /** The arg's value type. */\n type: VerbArgType\n /** Whether the statement must supply this arg. */\n required?: boolean\n /** Legal values when `type === 'enum'` (or per-element for list types). */\n values?: readonly string[]\n /** Inclusive minimum for numbers / per-element for number lists. */\n min?: number\n /** Inclusive maximum for numbers / per-element for number lists. */\n max?: number\n /** Model-facing description used in generated tool grammar text. */\n description: string\n}\n\n/**\n * A verb's capability requirement against the deployment's engine registry. Verbs with no\n * requirement are always advertised; input-conditional engine needs (e.g. `extract.text`\n * needing OCR only for images) stay runtime checks inside the step implementation.\n */\nexport type VerbRequirement =\n | { capability: 'convert'; from?: string; to?: string }\n | { capability: 'mutate' }\n\n/** Broad input families used for verb-applicability checks. */\nexport type FormatFamily =\n | 'document' // pdf/docx/odt/rtf/txt/md/html...\n | 'spreadsheet' // xlsx/ods/xls/csv\n | 'presentation' // pptx/odp/ppt\n | 'image'\n | 'audio'\n | 'any'\n\n/** What awaiting a chain ending in this verb resolves to. */\nexport type VerbOutput = 'media' | 'media-list' | 'text' | 'json'\n\n/** One verb table entry. */\nexport interface VerbSpec {\n /** Canonical id: dot-namespaced snake_case (`extract.text`, `sheet.update_cells`). */\n id: string\n /** Model-facing one-line description. */\n description: string\n /** Named args (named-only grammar; no positionals). */\n args: Record<string, VerbArgSpec>\n /**\n * Capability the verb always requires, if any — gates whether the verb is advertised and\n * accepted under a given engine configuration. Input-conditional needs are handled (and\n * error-messaged) by the step implementation at runtime.\n */\n requires?: VerbRequirement\n /** Input families the verb applies to. */\n appliesTo: readonly FormatFamily[]\n /** Output kind. May be refined by an `out`-style arg (documented per verb). */\n output: VerbOutput\n}\n\n/** Conversion targets supported by `convert` (matches the server's enum exactly). */\nexport const CONVERT_TARGETS = [\n 'pdf',\n 'html',\n 'txt',\n 'md',\n 'csv',\n 'json',\n 'docx',\n 'doc',\n 'rtf',\n 'odt',\n 'xlsx',\n 'xls',\n 'ods',\n 'pptx',\n 'ppt',\n 'odp',\n] as const\n\n/** Image output formats supported by `image.format`. */\nexport const IMAGE_FORMATS = ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif'] as const\n\n/** The canonical verb table. Order is presentation order in generated grammar text. */\nexport const VERBS: readonly VerbSpec[] = [\n // ── root: document transforms ──────────────────────────────────────────────\n {\n id: 'convert',\n description: 'Convert the media to another format.',\n args: {\n to: {\n type: 'enum',\n required: true,\n values: CONVERT_TARGETS,\n description: 'Target format.',\n },\n },\n requires: { capability: 'convert' },\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'select',\n description: 'Keep only the listed pages/slides/sections (1-based), producing one file.',\n args: {\n pages: {\n type: 'number-list',\n required: true,\n min: 1,\n description: 'Pages (or slides/sections) to keep, 1-based. Ranges allowed: 2-5,8.',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'split',\n description: 'Split the media into multiple files by page or section.',\n args: {\n by: {\n type: 'enum',\n values: ['page', 'section'],\n description: 'Split unit. Default: page.',\n },\n ranges: {\n type: 'json',\n description:\n \"Explicit grouping as a JSON array of [start,end] pairs (1-based), e.g. '[[1,3],[5,7]]'.\",\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media-list',\n },\n {\n id: 'merge',\n description: 'Merge other media into this one, in order.',\n args: {\n with: {\n type: 'media-ref-list',\n required: true,\n description: 'Other media to append, as @id refs: with=@<media id>,@<media id>.',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'reorder',\n description: 'Reorder pages/slides/sections by the given 1-based index order.',\n args: {\n order: {\n type: 'number-list',\n required: true,\n min: 1,\n description: 'New order of existing 1-based indices.',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'redact',\n description: 'Redact matching text. Prefer literal strings; /regex/ is supported.',\n args: {\n match: {\n type: 'regex-or-string-list',\n required: true,\n description: 'Literal string(s) or a /regex/ to redact.',\n },\n replace: {\n type: 'string',\n description: 'Replacement text. Default: blackout/removal.',\n },\n },\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'sanitize',\n description: 'Remove potentially unsafe embedded content from the media.',\n args: {},\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'normalize',\n description: 'Normalize the media structure/encoding for downstream consistency.',\n args: {},\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'update_text',\n description: 'Replace the first occurrence of an anchor text.',\n args: {\n anchor: {\n type: 'string',\n required: true,\n description: 'Existing text to find.',\n },\n replace: {\n type: 'string',\n required: true,\n description: 'Replacement text (empty string deletes).',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'diff',\n description: 'Compare this media against another; returns a structured diff.',\n args: {\n with: {\n type: 'media-ref',\n required: true,\n description: 'The media to compare against, as an @id ref.',\n },\n },\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'json',\n },\n {\n id: 'apply_patch',\n description: 'Apply a unified-diff patch to the media text.',\n args: {\n patch: {\n type: 'string',\n required: true,\n description: 'The unified diff content.',\n },\n with: {\n type: 'media-ref-list',\n description: 'Optional additional context media, as @id refs.',\n },\n },\n appliesTo: ['document'],\n output: 'media',\n },\n // ── root: extraction ────────────────────────────────────────────────────────\n {\n id: 'extract.text',\n description:\n 'Extract text from any supported media (document, spreadsheet, image). To limit pages: select pages=… | extract text.',\n args: {\n ocr: {\n type: 'enum',\n values: ['off', 'auto', 'force'],\n description: 'OCR behavior. Default auto (OCR only when there is no text layer).',\n },\n ocr_out: {\n type: 'enum',\n values: ['txt', 'hocr', 'json'],\n description: 'OCR output structure when OCR runs. Default txt.',\n },\n lang: {\n type: 'string-list',\n description: 'OCR language hint(s), e.g. lang=eng,deu. Quote tags with dashes.',\n },\n },\n appliesTo: ['document', 'spreadsheet', 'presentation', 'image'],\n output: 'text',\n },\n {\n id: 'extract.metadata',\n description: 'Extract document metadata (author, dates, page count) as JSON.',\n args: {},\n appliesTo: ['document', 'spreadsheet', 'presentation', 'image', 'audio'],\n output: 'json',\n },\n {\n id: 'extract.assets',\n description: 'Extract embedded assets (images, fonts, attachments) as separate media.',\n args: {\n types: {\n type: 'string-list',\n values: ['image', 'font', 'attachment', 'all'],\n description: 'Asset kinds to extract. Default all.',\n },\n format: {\n type: 'enum',\n values: IMAGE_FORMATS,\n description:\n 'Re-encode extracted images to this format. Default: native encoding as stored.',\n },\n },\n appliesTo: ['document', 'presentation', 'spreadsheet'],\n output: 'media-list',\n },\n {\n id: 'chunk',\n description: 'Split extracted text into chunks for retrieval/indexing.',\n args: {\n by: {\n type: 'enum',\n values: ['sentence', 'paragraph', 'fixed'],\n description: 'Chunking strategy. Default paragraph.',\n },\n size: {\n type: 'number',\n min: 1,\n description: 'Chunk size for fixed strategy / max size otherwise.',\n },\n overlap: {\n type: 'number',\n min: 0,\n description: 'Overlap between consecutive chunks.',\n },\n },\n appliesTo: ['document', 'any'],\n output: 'json',\n },\n // ── sheet namespace ─────────────────────────────────────────────────────────\n {\n id: 'sheet.add_rows',\n description: 'Insert rows into a worksheet.',\n args: {\n sheet: {\n type: 'name-or-index',\n description: 'Target worksheet: bare number = 1-based index, quoted string = name.',\n },\n rows: {\n type: 'json',\n required: true,\n description: 'Rows as a JSON array of arrays of cell values, e.g. \\'[[\"a\",1],[\"b\",2]]\\'.',\n },\n before: { type: 'number', min: 1, description: 'Insert before this 1-based row.' },\n after: { type: 'number', min: 1, description: 'Insert after this 1-based row.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.add_columns',\n description: 'Insert columns into a worksheet.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n headers: {\n type: 'string-list',\n description: 'Header names for the new columns (values empty).',\n },\n columns: {\n type: 'json',\n description: 'Full column descriptors as JSON: \\'[{\"header\":\"X\",\"values\":[1,2]}]\\'.',\n },\n before: { type: 'number', min: 1, description: 'Insert before this 1-based column.' },\n after: { type: 'number', min: 1, description: 'Insert after this 1-based column.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.update_cells',\n description: 'Update specific cells.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n updates: {\n type: 'json',\n required: true,\n description:\n 'JSON array of updates: \\'[{\"address\":\"B2\",\"value\":42}]\\' or \\'[{\"row\":2,\"col\":3,\"value\":\"x\"}]\\'.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.delete_rows',\n description: 'Delete rows by 1-based index.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n rows: {\n type: 'number-list',\n required: true,\n min: 1,\n description: '1-based row indices to delete.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.delete_columns',\n description: 'Delete columns by 1-based index.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n columns: {\n type: 'number-list',\n required: true,\n min: 1,\n description: '1-based column indices to delete.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.rename_sheet',\n description: 'Rename a worksheet. The target must be a sheet NAME (quote it).',\n args: {\n sheet: {\n type: 'string',\n required: true,\n description: 'Current sheet name (names only for rename; quote it).',\n },\n to: { type: 'string', required: true, description: 'New sheet name.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.add_sheet',\n description: 'Add a new worksheet.',\n args: {\n name: { type: 'string', required: true, description: 'Name for the new worksheet.' },\n at: { type: 'number', min: 1, description: 'Insert at this 1-based position.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.remove_sheet',\n description: 'Remove a worksheet. The target must be a sheet NAME (quote it).',\n args: {\n sheet: {\n type: 'string',\n required: true,\n description: 'Sheet name to remove (names only; quote it).',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.reorder_sheets',\n description: 'Reorder worksheets.',\n args: {\n order: {\n type: 'json',\n required: true,\n description:\n 'JSON array of sheet names and/or 1-based indices in the new order: \\'[\"Summary\",2,3]\\'.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.transform_table',\n description: 'Rename/select/drop table columns by header name.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n header_row: { type: 'number', min: 1, description: '1-based header row. Default 1.' },\n select: { type: 'string-list', description: 'Column headers to keep.' },\n drop: { type: 'string-list', description: 'Column headers to drop.' },\n rename: {\n type: 'json',\n description: 'JSON array of renames: \\'[{\"from\":\"Old\",\"to\":\"New\"}]\\'.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n // ── slides namespace ────────────────────────────────────────────────────────\n {\n id: 'slides.add',\n description: 'Add a new slide.',\n args: {\n at: { type: 'number', min: 1, description: 'Insert at this 1-based position.' },\n title: { type: 'string', description: 'Title text for the new slide.' },\n layout: { type: 'string', description: 'Layout name (template-dependent).' },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_text',\n description: 'Update text on a slide.',\n args: {\n slide: {\n type: 'name-or-index',\n description: 'Target slide: bare number = 1-based index, quoted string = title.',\n },\n placeholder: { type: 'string', description: 'Placeholder/shape to target.' },\n text: { type: 'string', required: true, description: 'Replacement text.' },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_table',\n description: 'Update table cells on a slide.',\n args: {\n slide: { type: 'name-or-index', description: 'Target slide (index or quoted title).' },\n updates: {\n type: 'json',\n required: true,\n description: 'JSON array: \\'[{\"row\":1,\"col\":2,\"value\":\"x\"}]\\' (1-based).',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_image',\n description: 'Replace an image on a slide with another media.',\n args: {\n slide: { type: 'name-or-index', description: 'Target slide (index or quoted title).' },\n placeholder: { type: 'string', description: 'Placeholder/shape to target.' },\n with: {\n type: 'media-ref',\n required: true,\n description: 'The replacement image, as an @id ref.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_chart',\n description: 'Update chart data on a slide.',\n args: {\n slide: { type: 'name-or-index', description: 'Target slide (index or quoted title).' },\n data: {\n type: 'json',\n description: 'JSON array-of-arrays of chart data: \\'[[\"Q1\",10],[\"Q2\",20]]\\'.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.delete',\n description: 'Delete slides by 1-based index.',\n args: {\n slides: {\n type: 'number-list',\n required: true,\n min: 1,\n description: '1-based slide indices to delete.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.reorder',\n description: 'Reorder slides.',\n args: {\n order: {\n type: 'number-list',\n required: true,\n min: 1,\n description: 'New order of existing 1-based slide indices.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.duplicate',\n description: 'Duplicate a slide.',\n args: {\n slide: { type: 'number', required: true, min: 1, description: '1-based slide to copy.' },\n at: { type: 'number', min: 1, description: 'Insert the copy at this position.' },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n // ── image namespace (split verbs; runtime fuses adjacent image.* steps) ─────\n {\n id: 'image.resize',\n description: 'Resize the image.',\n args: {\n width: { type: 'number', min: 1, max: 16384, description: 'Target width in px.' },\n height: { type: 'number', min: 1, max: 16384, description: 'Target height in px.' },\n fit: {\n type: 'enum',\n values: ['cover', 'contain', 'fill', 'inside', 'outside'],\n description: 'Resize fit mode. Default cover.',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.format',\n description: 'Re-encode the image to another format.',\n args: {\n to: {\n type: 'enum',\n required: true,\n values: IMAGE_FORMATS,\n description: 'Target image format.',\n },\n quality: { type: 'number', min: 1, max: 100, description: 'Quality for lossy formats.' },\n strip_metadata: {\n type: 'boolean',\n description: 'Remove EXIF/ICC metadata from the output.',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.rotate',\n description: 'Rotate the image.',\n args: {\n deg: {\n type: 'enum',\n required: true,\n values: ['90', '180', '270'],\n description: 'Rotation in degrees (clockwise).',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.flip',\n description: 'Flip the image.',\n args: {\n axis: {\n type: 'enum',\n required: true,\n values: ['horizontal', 'vertical', 'both'],\n description: 'Flip axis.',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.strip_metadata',\n description: 'Remove EXIF/ICC metadata from the image without other changes.',\n args: {},\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n // ── audio namespace ─────────────────────────────────────────────────────────\n {\n id: 'audio.transcribe',\n description: 'Transcribe speech to text.',\n args: {\n lang: {\n type: 'string',\n description: 'Language hint, e.g. lang=en. Quote tags with dashes: lang=\"en-US\".',\n },\n out: {\n type: 'enum',\n values: ['txt', 'srt', 'vtt', 'json'],\n description: 'Output format. Default txt. srt/vtt produce subtitles.',\n },\n translate: {\n type: 'boolean',\n description: 'Translate the transcription to English.',\n },\n },\n requires: { capability: 'convert', from: PCM_MIME },\n appliesTo: ['audio'],\n output: 'text',\n },\n] as const\n\n/** Map of canonical verb id → spec, for direct lookup. */\nexport const VERB_INDEX: ReadonlyMap<string, VerbSpec> = new Map(VERBS.map((v) => [v.id, v]))\n\n/**\n * Fold a verb token sequence to canonical form: lowercase, separators (space/`_`/`.`)\n * normalized so `extract_text` ≡ `extract text` ≡ `extract.text` all match `extract.text`.\n *\n * @param words - The verb word tokens as written (1 or 2 words, possibly containing `_`/`.`).\n * @returns The canonical verb id when a fold-match exists, otherwise `undefined`.\n */\nexport const foldVerb = (words: string[]): string | undefined => {\n const flat = words\n .join(' ')\n .toLowerCase()\n .replace(/[._\\s]+/g, ' ')\n .trim()\n return FOLDED_INDEX.get(flat)\n}\n\n/** Internal: folded \"word word\" form → canonical id. */\nconst FOLDED_INDEX: ReadonlyMap<string, string> = (() => {\n const map = new Map<string, string>()\n for (const v of VERBS) {\n const folded = v.id.replace(/[._]+/g, ' ')\n if (map.has(folded)) {\n throw new Error(`verb table invariant violated: \"${folded}\" folds to multiple verbs`)\n }\n map.set(folded, v.id)\n }\n return map\n})()\n\n/**\n * All folded verb word-sequences, for the parser's longest-match verb recognition and for\n * generated grammar text.\n */\nexport const FOLDED_VERBS: readonly string[] = Array.from(FOLDED_INDEX.keys())\n\n/**\n * Suggest the nearest verbs to an unknown input, for did-you-mean errors. Matches whole folded\n * forms AND suffix words (`resize` suggests `image resize`), per the frozen error model.\n *\n * @param input - The unknown verb text as written.\n * @param candidates - The folded verb forms to search (pass the narrowed set to avoid\n * suggesting unconfigured verbs).\n * @returns Up to three suggestions, best first.\n */\nexport const suggestVerbs = (input: string, candidates: readonly string[]): string[] => {\n const folded = input\n .toLowerCase()\n .replace(/[._\\s]+/g, ' ')\n .trim()\n const scored: Array<{ name: string; score: number }> = []\n for (const cand of candidates) {\n const direct = levenshtein(folded, cand)\n const words = cand.split(' ')\n const suffix = words.length > 1 ? levenshtein(folded, words[words.length - 1]) : Infinity\n const score = Math.min(direct, suffix)\n if (score <= Math.max(2, Math.floor(folded.length / 3))) {\n scored.push({ name: cand, score })\n }\n }\n scored.sort((a, b) => a.score - b.score)\n return scored.slice(0, 3).map((s) => s.name)\n}\n\n/** Classic two-row Levenshtein distance. */\nconst levenshtein = (a: string, b: string): number => {\n if (a === b) return 0\n if (a.length === 0) return b.length\n if (b.length === 0) return a.length\n let prev = Array.from({ length: b.length + 1 }, (_, i) => i)\n let curr = new Array<number>(b.length + 1)\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1\n curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost)\n }\n ;[prev, curr] = [curr, prev]\n }\n return prev[b.length]\n}\n","/**\n * The semantic validator: checks raw parsed segments (or ops) against the verb table and the\n * deployment's configured engines, producing the validated {@link MediaPlan} or a\n * model-actionable error.\n *\n * @remarks\n * Internal sibling of the `@nhtio/adk/batteries/media` entry. This is the layer no parser\n * toolkit could supply — every error names what was wrong, suggests the nearest valid form,\n * and shows a corrective exemplar (frozen design 0.14). Engine narrowing happens HERE, never\n * at parse time (frozen 0.3): the same string parses identically in every deployment; only\n * validation differs.\n */\n\nimport { isMediaRef, isRegExpRef } from './plan'\nimport { isError, isObject } from '@nhtio/adk/guards'\nimport { VERB_INDEX, suggestVerbs, foldVerb } from './verbs'\nimport {\n E_MEDIA_UNKNOWN_VERB,\n E_MEDIA_UNKNOWN_ARG,\n E_MEDIA_BAD_ARG,\n E_MEDIA_MISSING_ARG,\n E_MEDIA_ENGINE_REQUIRED,\n} from './exceptions'\nimport type { RawSegment, RawArgValue } from './pipe'\nimport type { VerbSpec, VerbArgSpec, VerbRequirement } from './verbs'\nimport type { MediaPlan, MediaStep, MediaArgValue, MediaArgScalar, MediaOp } from './plan'\n\n/**\n * The minimal synchronous capability probe the validator narrows against. The pipeline's\n * engine registry implements it; tests stub it.\n */\nexport interface CapabilityProbe {\n /** `true` when some engine declares a matching convert edge (omit either side for \"any\"). */\n hasConvert(from?: string, to?: string): boolean\n /** `true` when some engine declares a mutate capability. */\n hasMutate(): boolean\n}\n\n/** Options for {@link validateSegments} / {@link validateOps}. */\nexport interface ValidateOptions {\n /** The deployment's capabilities. Narrows advertised verbs + error suggestions. */\n capabilities: CapabilityProbe\n}\n\n/** `true` when the deployment satisfies a verb's capability requirement. */\nconst satisfies = (capabilities: CapabilityProbe, requires: VerbRequirement): boolean =>\n requires.capability === 'mutate'\n ? capabilities.hasMutate()\n : capabilities.hasConvert(requires.from, requires.to)\n\n/** A human phrase for an unmet requirement, for the do-not-retry error. */\nconst requirementText = (requires: VerbRequirement): string => {\n if (requires.capability === 'mutate') return 'an engine that can mutate this media'\n const from = requires.from ? ` from ${requires.from}` : ''\n const to = requires.to ? ` to ${requires.to}` : ''\n return `an engine that can convert${from}${to}`\n}\n\n/** The folded verb forms available under a given capability configuration. */\nexport const availableVerbs = (capabilities: CapabilityProbe): string[] => {\n const out: string[] = []\n for (const [id, spec] of VERB_INDEX) {\n if (spec.requires && !satisfies(capabilities, spec.requires)) continue\n out.push(id.replace(/[._]+/g, ' '))\n }\n return out\n}\n\nconst levSuggest = (verbText: string, capabilities: CapabilityProbe): string => {\n const suggestions = suggestVerbs(verbText, availableVerbs(capabilities))\n return suggestions.length > 0 ? ` did you mean \"${suggestions[0]}\"?` : ''\n}\n\nconst verbList = (capabilities: CapabilityProbe): string => availableVerbs(capabilities).join(', ')\n\nconst resolveVerb = (\n verbText: string,\n capabilities: CapabilityProbe,\n position: number\n): VerbSpec => {\n const canonical = foldVerb(verbText.split(' ')) ?? verbText\n const spec = VERB_INDEX.get(canonical)\n if (!spec) {\n throw new E_MEDIA_UNKNOWN_VERB([\n `unknown verb \"${verbText}\" at segment ${position}.${levSuggest(verbText, capabilities)} Available verbs: ${verbList(capabilities)}`,\n ])\n }\n if (spec.requires && !satisfies(capabilities, spec.requires)) {\n throw new E_MEDIA_ENGINE_REQUIRED([\n `verb \"${verbText}\" requires ${requirementText(spec.requires)}, and none is configured in this deployment. Do not retry this verb here. Available verbs: ${verbList(capabilities)}`,\n ])\n }\n return spec\n}\n\nconst suggestArg = (name: string, spec: VerbSpec): string => {\n const candidates = Object.keys(spec.args)\n const ranked = suggestVerbs(name, candidates)\n return ranked.length > 0 ? ` did you mean \"${ranked[0]}\"?` : ''\n}\n\nconst argList = (spec: VerbSpec): string => {\n const names = Object.keys(spec.args)\n return names.length > 0 ? names.join(', ') : '(none)'\n}\n\nconst exemplar = (spec: VerbSpec): string => {\n const verb = spec.id.replace(/\\./g, ' ')\n const parts: string[] = [verb]\n for (const [name, arg] of Object.entries(spec.args)) {\n if (!arg.required) continue\n parts.push(`${name}=${exampleValue(arg)}`)\n }\n return parts.join(' ')\n}\n\nconst exampleValue = (arg: VerbArgSpec): string => {\n switch (arg.type) {\n case 'enum':\n return arg.values?.[0] ?? 'value'\n case 'number':\n return String(arg.min ?? 1)\n case 'number-list':\n return '1-3,5'\n case 'string-list':\n return 'a,b'\n case 'boolean':\n return 'true'\n case 'regex-or-string-list':\n return '\"literal text\"'\n case 'media-ref':\n return '@<media id>'\n case 'media-ref-list':\n return '@<media id>'\n case 'json':\n return `'[…]'`\n default:\n return '\"value\"'\n }\n}\n\n/** Coerce + check one arg value against its spec. Returns the IR-final value. */\nconst checkArg = (\n verb: VerbSpec,\n name: string,\n raw: { value: MediaArgValue; quoted: boolean }\n): MediaArgValue => {\n const spec = verb.args[name]\n const verbText = verb.id.replace(/\\./g, ' ')\n const where = `arg \"${name}\" on \"${verbText}\"`\n const bad = (msg: string): never => {\n throw new E_MEDIA_BAD_ARG([`${where}: ${msg}. Write it like: ${exemplar(verb)}`])\n }\n const v = raw.value\n switch (spec.type) {\n case 'name-or-index': {\n if (typeof v === 'number') {\n if (!Number.isInteger(v) || v < 1) bad('indices are 1-based integers')\n return v\n }\n if (typeof v !== 'string') bad('expected a 1-based index or a quoted name')\n return v\n }\n case 'string': {\n if (typeof v === 'number' && !raw.quoted) return String(v)\n if (typeof v !== 'string')\n bad(`expected text${typeof v === 'object' ? ', got a structured value' : ''}`)\n return v\n }\n case 'number': {\n if (typeof v !== 'number') bad('expected a number')\n const n = v as number\n if (spec.min !== undefined && n < spec.min) bad(`must be ≥ ${spec.min} (indices are 1-based)`)\n if (spec.max !== undefined && n > spec.max) bad(`must be ≤ ${spec.max}`)\n return n\n }\n case 'boolean': {\n if (typeof v !== 'boolean') bad('expected true or false')\n return v\n }\n case 'enum': {\n const s = typeof v === 'number' ? String(v) : v\n if (typeof s !== 'string' || !spec.values?.includes(s)) {\n bad(`\"${String(v)}\" is not valid; valid values: ${spec.values?.join(', ')}`)\n }\n return s as string\n }\n case 'number-list': {\n const arr = Array.isArray(v) ? v : [v]\n if (!arr.every((x): x is number => typeof x === 'number'))\n bad('expected numbers (e.g. 1-3,5)')\n const nums = arr as number[]\n if (spec.min !== undefined && nums.some((n) => n < (spec.min as number))) {\n bad(`values must be ≥ ${spec.min} (indices are 1-based)`)\n }\n return nums\n }\n case 'string-list': {\n const arr = Array.isArray(v) ? v : [v]\n if (!arr.every((x): x is string => typeof x === 'string'))\n bad('expected names (quote values with special characters)')\n const strs = arr as string[]\n if (spec.values && !strs.every((s) => spec.values?.includes(s))) {\n bad(`valid values: ${spec.values.join(', ')}`)\n }\n return strs\n }\n case 'regex-or-string-list': {\n if (isRegExpRef(v)) return v\n const arr = Array.isArray(v) ? v : [v]\n if (arr.every((x) => typeof x === 'string' || isRegExpRef(x))) return arr as MediaArgScalar[]\n bad('expected literal text, a list of literals, or a /regex/')\n break\n }\n case 'media-ref': {\n if (isMediaRef(v)) return v\n bad('expected a media reference: with=@<media id> (get ids from list_media)')\n break\n }\n case 'media-ref-list': {\n const arr = Array.isArray(v) ? v : [v]\n if (arr.every(isMediaRef)) return arr as MediaArgScalar[]\n bad('expected media references: with=@<id>,@<id> (get ids from list_media)')\n break\n }\n case 'json': {\n // From pipe: a quoted string containing JSON. From ops: already-structured JSON.\n if (typeof v === 'string') {\n if (!raw.quoted) bad(`expected a quoted JSON value, e.g. ${name}='[…]'`)\n try {\n return JSON.parse(v) as MediaArgValue\n } catch (err) {\n const detail = isError(err) ? err.message : String(err)\n bad(`the quoted value is not valid JSON (${detail})`)\n }\n }\n if (isObject(v) || Array.isArray(v)) return v\n bad(`expected a JSON value, e.g. ${name}='[…]'`)\n break\n }\n }\n /* unreachable */\n throw new E_MEDIA_BAD_ARG([`${where}: invalid value`])\n}\n\nconst checkStep = (\n spec: VerbSpec,\n args: ReadonlyMap<string, { value: MediaArgValue; quoted: boolean }>\n): MediaStep => {\n const verbText = spec.id.replace(/\\./g, ' ')\n const finalArgs: Record<string, MediaArgValue> = {}\n for (const [name, raw] of args) {\n if (!(name in spec.args)) {\n throw new E_MEDIA_UNKNOWN_ARG([\n `verb \"${verbText}\" has no arg \"${name}\".${suggestArg(name, spec)} Args: ${argList(spec)}. Write it like: ${exemplar(spec)}`,\n ])\n }\n finalArgs[name] = checkArg(spec, name, raw)\n }\n for (const [name, argSpec] of Object.entries(spec.args)) {\n if (argSpec.required && !(name in finalArgs)) {\n throw new E_MEDIA_MISSING_ARG([\n `verb \"${verbText}\" requires arg \"${name}\" (${argSpec.description}). Write it like: ${exemplar(spec)}`,\n ])\n }\n }\n return { verb: spec.id, args: finalArgs }\n}\n\n/**\n * Validate raw pipe segments into a {@link MediaPlan}.\n *\n * @param segments - Output of `parsePipeRaw`.\n * @param options - The deployment's capability probe.\n * @returns The validated plan, spans preserved.\n */\nexport const validateSegments = (\n segments: readonly RawSegment[],\n options: ValidateOptions\n): MediaPlan => {\n const steps: MediaStep[] = []\n segments.forEach((seg, i) => {\n const spec = resolveVerb(seg.verb.replace(/\\./g, ' '), options.capabilities, i + 1)\n const step = checkStep(spec, seg.args)\n step.span = seg.span\n steps.push(step)\n })\n return { steps }\n}\n\n/**\n * Validate a JSON ops array into a {@link MediaPlan}. The same checks as the pipe path —\n * verbs fold the same way, args validate against the same specs — so the two front-ends\n * produce identical plans for equivalent statements.\n *\n * @param ops - The ops array.\n * @param options - The deployment's capability probe.\n * @returns The validated plan (no spans).\n */\nexport const validateOps = (ops: readonly MediaOp[], options: ValidateOptions): MediaPlan => {\n const steps: MediaStep[] = []\n ops.forEach((op, i) => {\n const spec = resolveVerb(op.verb.replace(/[._]+/g, ' '), options.capabilities, i + 1)\n const args = new Map<string, RawArgValue>(\n Object.entries(op.args).map(([k, v]) => [\n k,\n {\n value: v,\n quoted: typeof v === 'string',\n span: { offset: 0, line: 1, col: 1, length: 0 },\n },\n ])\n )\n steps.push(checkStep(spec, args))\n })\n return { steps }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8GA,IAAa,eAAe,UAAuC;CACjE,IAAI,CAAC,sBAAA,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;EAE3B,MAAM,OAAO,UADA,YAAY,IAAI,KAAK,QAAQ,OAAO,GAAG,GAAG,QAAQ,cAAc,IAAI,CAC1D,GAAM,IAAI,IAAI;EACrC,KAAK,OAAO,IAAI;EAChB,MAAM,KAAK,IAAI;CACjB,CAAC;CACD,OAAO,EAAE,MAAM;AACjB;;;;;;;;;;AAWA,IAAa,eAAe,KAAyB,YAAwC;CAC3F,MAAM,QAAqB,CAAC;CAC5B,IAAI,SAAS,IAAI,MAAM;EACrB,MAAM,OAAO,YAAY,GAAG,KAAK,QAAQ,UAAU,GAAG,GAAG,QAAQ,cAAc,IAAI,CAAC;EACpF,MAAM,OAAO,IAAI,IACf,OAAO,QAAQ,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CACtC,GACA;GACE,OAAO;GACP,QAAQ,OAAO,MAAM;GACrB,MAAM;IAAE,QAAQ;IAAG,MAAM;IAAG,KAAK;IAAG,QAAQ;GAAE;EAChD,CACF,CAAC,CACH;EACA,MAAM,KAAK,UAAU,MAAM,IAAI,CAAC;CAClC,CAAC;CACD,OAAO,EAAE,MAAM;AACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-JOHfh-BB.mjs","names":[],"sources":["../src/batteries/media/plan.ts","../src/batteries/media/verbs.ts","../src/batteries/media/validate.ts"],"sourcesContent":["/**\n * The neutral `MediaPlan` intermediate representation and its canonical serializers.\n *\n * @remarks\n * Internal sibling of the `@nhtio/adk/batteries/media` entry. All three front-ends — the\n * chainable builder, the pipe-string parser, and the JSON ops array — compile to this one IR,\n * and the step runtime consumes only this IR. Invariants (frozen design, section 0.7):\n *\n * - **Serializable.** No live `RegExp`, `Media`, or function values — regexes are\n * `{ source, flags }`, media refs are typed handles. A plan can be logged, content-hashed,\n * and embedded in a tool result.\n * - **Round-trip is fixed-point.** `parsePipe(toPipe(plan))` produces an equal plan and\n * `toPipe` is idempotent. `toPipe(parsePipe(s)) === s` is NOT promised (e.g. `2,3,4,5`\n * renders as `2-5`).\n * - **Engine-agnostic.** Steps name verbs, never engines.\n */\n\nimport { isObject } from '@nhtio/adk/guards'\nimport { E_MEDIA_NOT_PIPE_EXPRESSIBLE } from './exceptions'\n\n/**\n * A serializable regex reference. Never a live `RegExp` in the IR.\n */\nexport interface RegExpRef {\n /** The regex source, exactly as `RegExp.prototype.source` would report it. */\n source: string\n /** Sorted flag characters (canonicalized — `gi`, never `ig`). */\n flags: string\n}\n\n/**\n * A reference to another media participating in a multi-input verb (`merge`, `diff`,\n * `apply_patch`, `slides.update_image`).\n *\n * @remarks\n * The `id` variant is the canonical model-facing form — the pipe syntax is an inline\n * `@id` token (`merge with=@018f…`) and the ops form carries the same id. The `builder`\n * variant is implementor-only (a nested chain: `mp(a).diff(mp(b).convert('txt'))`) and is\n * not expressible in a flat pipe string.\n */\nexport type MediaRef = { kind: 'id'; id: string } | { kind: 'builder'; plan: MediaPlan }\n\n/** Scalar arg values the flat pipe grammar can express directly. */\nexport type MediaArgScalar = string | number | boolean | RegExpRef | MediaRef\n\n/**\n * A structured (JSON-shaped) arg value. In the pipe surface these are written as quoted JSON\n * (`updates='[{\"address\":\"B2\",\"value\":3}]'`); in ops they are plain JSON. `null` is legal only\n * inside structured values (cell values), never as a top-level scalar.\n */\nexport type MediaArgJson =\n | string\n | number\n | boolean\n | null\n | MediaArgJson[]\n | { [key: string]: MediaArgJson }\n\n/**\n * The value space of a single verb arg in the IR.\n *\n * @remarks\n * Flat lists (`types=image,font` → `['image','font']`) are `MediaArgScalar[]`. Whether a\n * value parsed from quoted JSON or a flat token is decided by the verb's arg schema — the IR\n * stores the final shape only.\n */\nexport type MediaArgValue = MediaArgScalar | MediaArgScalar[] | MediaArgJson\n\n/** Source span carried by steps parsed from a pipe string, for error mapping. */\nexport interface SourceSpan {\n /** Zero-based character offset into the source string. */\n offset: number\n /** One-based line number. */\n line: number\n /** One-based column number. */\n col: number\n /** Length of the spanned text in characters. */\n length: number\n}\n\n/** One transform step: a canonical verb id plus its validated content args. */\nexport interface MediaStep {\n /**\n * Canonical verb id — dot-namespaced snake_case (`convert`, `select`, `extract.text`,\n * `sheet.update_cells`, `image.resize`).\n */\n verb: string\n /** Validated content args for this verb. */\n args: Record<string, MediaArgValue>\n /** Present when the step came from a pipe string; absent for builder/ops origins. */\n span?: SourceSpan\n}\n\n/** The neutral plan: an ordered, linear list of steps. No branching. */\nexport interface MediaPlan {\n /** The ordered transform steps. */\n steps: MediaStep[]\n}\n\n/** The JSON ops front-end's step shape — identical to {@link MediaStep} minus the span. */\nexport interface MediaOp {\n /** The canonical (or foldable) verb id. */\n verb: string\n /** The verb's named args. */\n args: Record<string, MediaArgValue>\n}\n\n// ── guards ───────────────────────────────────────────────────────────────────\n\n/** `true` when `value` is a {@link RegExpRef}. */\nexport const isRegExpRef = (value: unknown): value is RegExpRef => {\n if (!isObject(value)) return false\n const v = value as Record<string, unknown>\n return typeof v.source === 'string' && typeof v.flags === 'string' && Object.keys(v).length === 2\n}\n\n/** `true` when `value` is a {@link MediaRef}. */\nexport const isMediaRef = (value: unknown): value is MediaRef => {\n if (!isObject(value)) return false\n const v = value as MediaRef\n if (v.kind === 'id') return typeof (v as { id?: unknown }).id === 'string'\n if (v.kind === 'builder') return isObject((v as { plan?: unknown }).plan)\n return false\n}\n\n// ── canonical rendering helpers ──────────────────────────────────────────────\n\n/** Characters legal in an unquoted bareword value. */\nconst BAREWORD = /^[A-Za-z0-9_]+$/\n/** Strings that would lex as a non-ident token and therefore must be quoted. */\nconst LEXES_AS_OTHER = /^(?:\\d+(?:-\\d+)?|\\d+\\.\\d+|true|false|@.*)$/\n\n/**\n * The frozen quoting predicate: quote any string that is empty, would lex as a number, range,\n * boolean, or `@id` token, starts with `/`, or contains a character outside `[A-Za-z0-9_]`.\n */\nconst renderString = (s: string): string => {\n if (s.length === 0 || !BAREWORD.test(s) || LEXES_AS_OTHER.test(s) || s.startsWith('/')) {\n return `\"${s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n')}\"`\n }\n return s\n}\n\n/** Canonicalize regex flags: validate against JS flags and sort. */\nexport const canonicalFlags = (flags: string): string => Array.from(flags).sort().join('')\n\n/** Render a {@link RegExpRef} back to a pipe regex literal, re-escaping bare slashes. */\nconst renderRegExp = (ref: RegExpRef): string => {\n const source = ref.source.length === 0 ? '(?:)' : ref.source\n // Escape bare `/` that are not already escaped and not inside a character class.\n let out = ''\n let inClass = false\n for (let i = 0; i < source.length; i++) {\n const ch = source[i]\n if (ch === '\\\\') {\n out += ch + (source[i + 1] ?? '')\n i++\n continue\n }\n if (ch === '[') inClass = true\n else if (ch === ']') inClass = false\n if (ch === '/' && !inClass) {\n out += '\\\\/'\n continue\n }\n out += ch\n }\n return `/${out}/${canonicalFlags(ref.flags)}`\n}\n\n/**\n * Compress maximal ascending consecutive runs in a number list to `a-b` range tokens.\n * Order-preserving and lossless on the array; never sorts or dedupes.\n */\nconst renderNumberList = (nums: number[]): string => {\n const parts: string[] = []\n let i = 0\n while (i < nums.length) {\n let j = i\n while (\n j + 1 < nums.length &&\n Number.isInteger(nums[j]) &&\n nums[j + 1] === (nums[j] as number) + 1\n ) {\n j++\n }\n if (j - i >= 1 && Number.isInteger(nums[i])) {\n parts.push(`${nums[i]}-${nums[j]}`)\n } else {\n parts.push(String(nums[i]))\n j = i\n }\n i = j + 1\n }\n return parts.join(',')\n}\n\nconst renderScalar = (value: MediaArgScalar): string => {\n if (typeof value === 'number') return String(value)\n if (typeof value === 'boolean') return String(value)\n if (typeof value === 'string') return renderString(value)\n if (isRegExpRef(value)) return renderRegExp(value)\n // MediaRef\n if (value.kind === 'id') return `@${value.id}`\n throw new E_MEDIA_NOT_PIPE_EXPRESSIBLE(['nested builder refs have no pipe form; use toOps()'])\n}\n\nconst isScalar = (value: MediaArgValue): value is MediaArgScalar =>\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n isRegExpRef(value) ||\n isMediaRef(value)\n\nconst renderValue = (value: MediaArgValue): string => {\n if (value === null) {\n // null is only legal inside structured JSON values\n throw new E_MEDIA_NOT_PIPE_EXPRESSIBLE(['null is not a flat pipe value; use toOps()'])\n }\n if (Array.isArray(value)) {\n const arr = value as MediaArgScalar[]\n if (arr.length > 0 && arr.every((v) => typeof v === 'number')) {\n return renderNumberList(arr as number[])\n }\n if (arr.every(isScalar)) {\n return arr.map(renderScalar).join(',')\n }\n // structured (nested) array -> quoted JSON\n return `'${JSON.stringify(value)}'`\n }\n if (isScalar(value)) return renderScalar(value)\n // structured object -> quoted JSON\n return `'${JSON.stringify(value)}'`\n}\n\n/**\n * Render a {@link MediaPlan} to its canonical pipe string.\n *\n * @remarks\n * Total for every plan except those containing builder-variant media refs, which throw\n * {@link E_MEDIA_NOT_PIPE_EXPRESSIBLE}. Structured args render as quoted JSON. The output is\n * canonical: dot-namespaced verbs render as space-separated words, number runs compress to\n * ranges, strings quote per the frozen predicate.\n *\n * @param plan - The plan to render.\n * @returns The canonical pipe expression.\n */\nexport const toPipe = (plan: MediaPlan): string =>\n plan.steps\n .map((step) => {\n const verb = step.verb.replace(/\\./g, ' ')\n const args = Object.entries(step.args)\n .map(([k, v]) => `${k}=${renderValue(v)}`)\n .join(' ')\n return args.length > 0 ? `${verb} ${args}` : verb\n })\n .join(' | ')\n\n/**\n * Render a {@link MediaPlan} to its JSON ops array. Total — every plan has an ops form.\n *\n * @param plan - The plan to render.\n * @returns The ops array (spans stripped).\n */\nexport const toOps = (plan: MediaPlan): MediaOp[] =>\n plan.steps.map((step) => ({ verb: step.verb, args: step.args }))\n\n/**\n * Build a {@link MediaPlan} from a JSON ops array. The inverse of {@link toOps}.\n *\n * @remarks\n * Performs structural normalization only (verb-id folding via the caller's verb table happens\n * in validation, not here). Steps carry no spans.\n *\n * @param ops - The ops array.\n * @returns The equivalent plan.\n */\nexport const fromOps = (ops: MediaOp[]): MediaPlan => ({\n steps: ops.map((op) => ({ verb: op.verb, args: op.args })),\n})\n","/**\n * The canonical verb table: every verb the media DSL knows, with arg schemas, engine\n * requirements, format-family applicability, and output kinds.\n *\n * @remarks\n * Internal sibling of the `@nhtio/adk/batteries/media` entry. This table is the single source\n * of truth consumed by:\n *\n * - the pipe parser's semantic validator (unknown-verb/arg detection, did-you-mean),\n * - the plan compiler (arg coercion + constraint checks),\n * - the engine-narrowing pass (which verbs a deployment advertises),\n * - the forge (generating the `media_query` tool description and few-shot examples),\n * - the builder (typed front-end methods map 1:1 onto entries here).\n *\n * Frozen design decisions (design doc section 0): canonical verb ids are dot-namespaced\n * snake_case; verb matching is separator-insensitive (space/`_`/`.` fold); args are named-only;\n * indices are 1-based everywhere; arg names follow one-meaning-one-name (`to`, `with`, `match`,\n * `replace`, `order`, `pages`, `at`).\n */\n\nimport { PCM_MIME } from './contracts'\n\n/** The value type of a single declared arg. */\nexport type VerbArgType =\n | 'string'\n | 'number'\n | 'boolean'\n | 'enum'\n | 'number-list'\n | 'string-list'\n | 'regex-or-string-list'\n | 'name-or-index'\n | 'media-ref'\n | 'media-ref-list'\n | 'json'\n\n/** Declaration of one named arg on a verb. */\nexport interface VerbArgSpec {\n /** The arg's value type. */\n type: VerbArgType\n /** Whether the statement must supply this arg. */\n required?: boolean\n /** Legal values when `type === 'enum'` (or per-element for list types). */\n values?: readonly string[]\n /** Inclusive minimum for numbers / per-element for number lists. */\n min?: number\n /** Inclusive maximum for numbers / per-element for number lists. */\n max?: number\n /** Model-facing description used in generated tool grammar text. */\n description: string\n}\n\n/**\n * A verb's capability requirement against the deployment's engine registry. Verbs with no\n * requirement are always advertised; input-conditional engine needs (e.g. `extract.text`\n * needing OCR only for images) stay runtime checks inside the step implementation.\n */\nexport type VerbRequirement =\n | { capability: 'convert'; from?: string; to?: string }\n | { capability: 'mutate' }\n\n/** Broad input families used for verb-applicability checks. */\nexport type FormatFamily =\n | 'document' // pdf/docx/odt/rtf/txt/md/html...\n | 'spreadsheet' // xlsx/ods/xls/csv\n | 'presentation' // pptx/odp/ppt\n | 'image'\n | 'audio'\n | 'any'\n\n/** What awaiting a chain ending in this verb resolves to. */\nexport type VerbOutput = 'media' | 'media-list' | 'text' | 'json'\n\n/** One verb table entry. */\nexport interface VerbSpec {\n /** Canonical id: dot-namespaced snake_case (`extract.text`, `sheet.update_cells`). */\n id: string\n /** Model-facing one-line description. */\n description: string\n /** Named args (named-only grammar; no positionals). */\n args: Record<string, VerbArgSpec>\n /**\n * Capability the verb always requires, if any — gates whether the verb is advertised and\n * accepted under a given engine configuration. Input-conditional needs are handled (and\n * error-messaged) by the step implementation at runtime.\n */\n requires?: VerbRequirement\n /** Input families the verb applies to. */\n appliesTo: readonly FormatFamily[]\n /** Output kind. May be refined by an `out`-style arg (documented per verb). */\n output: VerbOutput\n}\n\n/** Conversion targets supported by `convert` (matches the server's enum exactly). */\nexport const CONVERT_TARGETS = [\n 'pdf',\n 'html',\n 'txt',\n 'md',\n 'csv',\n 'json',\n 'docx',\n 'doc',\n 'rtf',\n 'odt',\n 'xlsx',\n 'xls',\n 'ods',\n 'pptx',\n 'ppt',\n 'odp',\n] as const\n\n/** Image output formats supported by `image.format`. */\nexport const IMAGE_FORMATS = ['png', 'jpg', 'jpeg', 'webp', 'tiff', 'avif'] as const\n\n/** The canonical verb table. Order is presentation order in generated grammar text. */\nexport const VERBS: readonly VerbSpec[] = [\n // ── root: document transforms ──────────────────────────────────────────────\n {\n id: 'convert',\n description: 'Convert the media to another format.',\n args: {\n to: {\n type: 'enum',\n required: true,\n values: CONVERT_TARGETS,\n description: 'Target format.',\n },\n },\n requires: { capability: 'convert' },\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'select',\n description: 'Keep only the listed pages/slides/sections (1-based), producing one file.',\n args: {\n pages: {\n type: 'number-list',\n required: true,\n min: 1,\n description: 'Pages (or slides/sections) to keep, 1-based. Ranges allowed: 2-5,8.',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'split',\n description: 'Split the media into multiple files by page or section.',\n args: {\n by: {\n type: 'enum',\n values: ['page', 'section'],\n description: 'Split unit. Default: page.',\n },\n ranges: {\n type: 'json',\n description:\n \"Explicit grouping as a JSON array of [start,end] pairs (1-based), e.g. '[[1,3],[5,7]]'.\",\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media-list',\n },\n {\n id: 'merge',\n description: 'Merge other media into this one, in order.',\n args: {\n with: {\n type: 'media-ref-list',\n required: true,\n description: 'Other media to append, as @id refs: with=@<media id>,@<media id>.',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'reorder',\n description: 'Reorder pages/slides/sections by the given 1-based index order.',\n args: {\n order: {\n type: 'number-list',\n required: true,\n min: 1,\n description: 'New order of existing 1-based indices.',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'redact',\n description: 'Redact matching text. Prefer literal strings; /regex/ is supported.',\n args: {\n match: {\n type: 'regex-or-string-list',\n required: true,\n description: 'Literal string(s) or a /regex/ to redact.',\n },\n replace: {\n type: 'string',\n description: 'Replacement text. Default: blackout/removal.',\n },\n },\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'sanitize',\n description: 'Remove potentially unsafe embedded content from the media.',\n args: {},\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'normalize',\n description: 'Normalize the media structure/encoding for downstream consistency.',\n args: {},\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'media',\n },\n {\n id: 'update_text',\n description: 'Replace the first occurrence of an anchor text.',\n args: {\n anchor: {\n type: 'string',\n required: true,\n description: 'Existing text to find.',\n },\n replace: {\n type: 'string',\n required: true,\n description: 'Replacement text (empty string deletes).',\n },\n },\n appliesTo: ['document', 'presentation'],\n output: 'media',\n },\n {\n id: 'diff',\n description: 'Compare this media against another; returns a structured diff.',\n args: {\n with: {\n type: 'media-ref',\n required: true,\n description: 'The media to compare against, as an @id ref.',\n },\n },\n appliesTo: ['document', 'spreadsheet', 'presentation'],\n output: 'json',\n },\n {\n id: 'apply_patch',\n description: 'Apply a unified-diff patch to the media text.',\n args: {\n patch: {\n type: 'string',\n required: true,\n description: 'The unified diff content.',\n },\n with: {\n type: 'media-ref-list',\n description: 'Optional additional context media, as @id refs.',\n },\n },\n appliesTo: ['document'],\n output: 'media',\n },\n // ── root: extraction ────────────────────────────────────────────────────────\n {\n id: 'extract.text',\n description:\n 'Extract text from any supported media (document, spreadsheet, image). To limit pages: select pages=… | extract text.',\n args: {\n ocr: {\n type: 'enum',\n values: ['off', 'auto', 'force'],\n description: 'OCR behavior. Default auto (OCR only when there is no text layer).',\n },\n ocr_out: {\n type: 'enum',\n values: ['txt', 'hocr', 'json'],\n description: 'OCR output structure when OCR runs. Default txt.',\n },\n lang: {\n type: 'string-list',\n description: 'OCR language hint(s), e.g. lang=eng,deu. Quote tags with dashes.',\n },\n },\n appliesTo: ['document', 'spreadsheet', 'presentation', 'image'],\n output: 'text',\n },\n {\n id: 'extract.metadata',\n description: 'Extract document metadata (author, dates, page count) as JSON.',\n args: {},\n appliesTo: ['document', 'spreadsheet', 'presentation', 'image', 'audio'],\n output: 'json',\n },\n {\n id: 'extract.assets',\n description: 'Extract embedded assets (images, fonts, attachments) as separate media.',\n args: {\n types: {\n type: 'string-list',\n values: ['image', 'font', 'attachment', 'all'],\n description: 'Asset kinds to extract. Default all.',\n },\n format: {\n type: 'enum',\n values: IMAGE_FORMATS,\n description:\n 'Re-encode extracted images to this format. Default: native encoding as stored.',\n },\n },\n appliesTo: ['document', 'presentation', 'spreadsheet'],\n output: 'media-list',\n },\n {\n id: 'chunk',\n description: 'Split extracted text into chunks for retrieval/indexing.',\n args: {\n by: {\n type: 'enum',\n values: ['sentence', 'paragraph', 'fixed'],\n description: 'Chunking strategy. Default paragraph.',\n },\n size: {\n type: 'number',\n min: 1,\n description: 'Chunk size for fixed strategy / max size otherwise.',\n },\n overlap: {\n type: 'number',\n min: 0,\n description: 'Overlap between consecutive chunks.',\n },\n },\n appliesTo: ['document', 'any'],\n output: 'json',\n },\n // ── sheet namespace ─────────────────────────────────────────────────────────\n {\n id: 'sheet.add_rows',\n description: 'Insert rows into a worksheet.',\n args: {\n sheet: {\n type: 'name-or-index',\n description: 'Target worksheet: bare number = 1-based index, quoted string = name.',\n },\n rows: {\n type: 'json',\n required: true,\n description: 'Rows as a JSON array of arrays of cell values, e.g. \\'[[\"a\",1],[\"b\",2]]\\'.',\n },\n before: { type: 'number', min: 1, description: 'Insert before this 1-based row.' },\n after: { type: 'number', min: 1, description: 'Insert after this 1-based row.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.add_columns',\n description: 'Insert columns into a worksheet.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n headers: {\n type: 'string-list',\n description: 'Header names for the new columns (values empty).',\n },\n columns: {\n type: 'json',\n description: 'Full column descriptors as JSON: \\'[{\"header\":\"X\",\"values\":[1,2]}]\\'.',\n },\n before: { type: 'number', min: 1, description: 'Insert before this 1-based column.' },\n after: { type: 'number', min: 1, description: 'Insert after this 1-based column.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.update_cells',\n description: 'Update specific cells.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n updates: {\n type: 'json',\n required: true,\n description:\n 'JSON array of updates: \\'[{\"address\":\"B2\",\"value\":42}]\\' or \\'[{\"row\":2,\"col\":3,\"value\":\"x\"}]\\'.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.delete_rows',\n description: 'Delete rows by 1-based index.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n rows: {\n type: 'number-list',\n required: true,\n min: 1,\n description: '1-based row indices to delete.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.delete_columns',\n description: 'Delete columns by 1-based index.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n columns: {\n type: 'number-list',\n required: true,\n min: 1,\n description: '1-based column indices to delete.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.rename_sheet',\n description: 'Rename a worksheet. The target must be a sheet NAME (quote it).',\n args: {\n sheet: {\n type: 'string',\n required: true,\n description: 'Current sheet name (names only for rename; quote it).',\n },\n to: { type: 'string', required: true, description: 'New sheet name.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.add_sheet',\n description: 'Add a new worksheet.',\n args: {\n name: { type: 'string', required: true, description: 'Name for the new worksheet.' },\n at: { type: 'number', min: 1, description: 'Insert at this 1-based position.' },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.remove_sheet',\n description: 'Remove a worksheet. The target must be a sheet NAME (quote it).',\n args: {\n sheet: {\n type: 'string',\n required: true,\n description: 'Sheet name to remove (names only; quote it).',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.reorder_sheets',\n description: 'Reorder worksheets.',\n args: {\n order: {\n type: 'json',\n required: true,\n description:\n 'JSON array of sheet names and/or 1-based indices in the new order: \\'[\"Summary\",2,3]\\'.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n {\n id: 'sheet.transform_table',\n description: 'Rename/select/drop table columns by header name.',\n args: {\n sheet: { type: 'name-or-index', description: 'Target worksheet (index or quoted name).' },\n header_row: { type: 'number', min: 1, description: '1-based header row. Default 1.' },\n select: { type: 'string-list', description: 'Column headers to keep.' },\n drop: { type: 'string-list', description: 'Column headers to drop.' },\n rename: {\n type: 'json',\n description: 'JSON array of renames: \\'[{\"from\":\"Old\",\"to\":\"New\"}]\\'.',\n },\n },\n appliesTo: ['spreadsheet'],\n output: 'media',\n },\n // ── slides namespace ────────────────────────────────────────────────────────\n {\n id: 'slides.add',\n description: 'Add a new slide.',\n args: {\n at: { type: 'number', min: 1, description: 'Insert at this 1-based position.' },\n title: { type: 'string', description: 'Title text for the new slide.' },\n layout: { type: 'string', description: 'Layout name (template-dependent).' },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_text',\n description: 'Update text on a slide.',\n args: {\n slide: {\n type: 'name-or-index',\n description: 'Target slide: bare number = 1-based index, quoted string = title.',\n },\n placeholder: { type: 'string', description: 'Placeholder/shape to target.' },\n text: { type: 'string', required: true, description: 'Replacement text.' },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_table',\n description: 'Update table cells on a slide.',\n args: {\n slide: { type: 'name-or-index', description: 'Target slide (index or quoted title).' },\n updates: {\n type: 'json',\n required: true,\n description: 'JSON array: \\'[{\"row\":1,\"col\":2,\"value\":\"x\"}]\\' (1-based).',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_image',\n description: 'Replace an image on a slide with another media.',\n args: {\n slide: { type: 'name-or-index', description: 'Target slide (index or quoted title).' },\n placeholder: { type: 'string', description: 'Placeholder/shape to target.' },\n with: {\n type: 'media-ref',\n required: true,\n description: 'The replacement image, as an @id ref.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.update_chart',\n description: 'Update chart data on a slide.',\n args: {\n slide: { type: 'name-or-index', description: 'Target slide (index or quoted title).' },\n data: {\n type: 'json',\n description: 'JSON array-of-arrays of chart data: \\'[[\"Q1\",10],[\"Q2\",20]]\\'.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.delete',\n description: 'Delete slides by 1-based index.',\n args: {\n slides: {\n type: 'number-list',\n required: true,\n min: 1,\n description: '1-based slide indices to delete.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.reorder',\n description: 'Reorder slides.',\n args: {\n order: {\n type: 'number-list',\n required: true,\n min: 1,\n description: 'New order of existing 1-based slide indices.',\n },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n {\n id: 'slides.duplicate',\n description: 'Duplicate a slide.',\n args: {\n slide: { type: 'number', required: true, min: 1, description: '1-based slide to copy.' },\n at: { type: 'number', min: 1, description: 'Insert the copy at this position.' },\n },\n appliesTo: ['presentation'],\n output: 'media',\n },\n // ── image namespace (split verbs; runtime fuses adjacent image.* steps) ─────\n {\n id: 'image.resize',\n description: 'Resize the image.',\n args: {\n width: { type: 'number', min: 1, max: 16384, description: 'Target width in px.' },\n height: { type: 'number', min: 1, max: 16384, description: 'Target height in px.' },\n fit: {\n type: 'enum',\n values: ['cover', 'contain', 'fill', 'inside', 'outside'],\n description: 'Resize fit mode. Default cover.',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.format',\n description: 'Re-encode the image to another format.',\n args: {\n to: {\n type: 'enum',\n required: true,\n values: IMAGE_FORMATS,\n description: 'Target image format.',\n },\n quality: { type: 'number', min: 1, max: 100, description: 'Quality for lossy formats.' },\n strip_metadata: {\n type: 'boolean',\n description: 'Remove EXIF/ICC metadata from the output.',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.rotate',\n description: 'Rotate the image.',\n args: {\n deg: {\n type: 'enum',\n required: true,\n values: ['90', '180', '270'],\n description: 'Rotation in degrees (clockwise).',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.flip',\n description: 'Flip the image.',\n args: {\n axis: {\n type: 'enum',\n required: true,\n values: ['horizontal', 'vertical', 'both'],\n description: 'Flip axis.',\n },\n },\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n {\n id: 'image.strip_metadata',\n description: 'Remove EXIF/ICC metadata from the image without other changes.',\n args: {},\n requires: { capability: 'mutate' },\n appliesTo: ['image'],\n output: 'media',\n },\n // ── audio namespace ─────────────────────────────────────────────────────────\n {\n id: 'audio.transcribe',\n description: 'Transcribe speech to text.',\n args: {\n lang: {\n type: 'string',\n description: 'Language hint, e.g. lang=en. Quote tags with dashes: lang=\"en-US\".',\n },\n out: {\n type: 'enum',\n values: ['txt', 'srt', 'vtt', 'json'],\n description: 'Output format. Default txt. srt/vtt produce subtitles.',\n },\n translate: {\n type: 'boolean',\n description: 'Translate the transcription to English.',\n },\n },\n requires: { capability: 'convert', from: PCM_MIME },\n appliesTo: ['audio'],\n output: 'text',\n },\n] as const\n\n/** Map of canonical verb id → spec, for direct lookup. */\nexport const VERB_INDEX: ReadonlyMap<string, VerbSpec> = new Map(VERBS.map((v) => [v.id, v]))\n\n/**\n * Fold a verb token sequence to canonical form: lowercase, separators (space/`_`/`.`)\n * normalized so `extract_text` ≡ `extract text` ≡ `extract.text` all match `extract.text`.\n *\n * @param words - The verb word tokens as written (1 or 2 words, possibly containing `_`/`.`).\n * @returns The canonical verb id when a fold-match exists, otherwise `undefined`.\n */\nexport const foldVerb = (words: string[]): string | undefined => {\n const flat = words\n .join(' ')\n .toLowerCase()\n .replace(/[._\\s]+/g, ' ')\n .trim()\n return FOLDED_INDEX.get(flat)\n}\n\n/** Internal: folded \"word word\" form → canonical id. */\nconst FOLDED_INDEX: ReadonlyMap<string, string> = (() => {\n const map = new Map<string, string>()\n for (const v of VERBS) {\n const folded = v.id.replace(/[._]+/g, ' ')\n if (map.has(folded)) {\n throw new Error(`verb table invariant violated: \"${folded}\" folds to multiple verbs`)\n }\n map.set(folded, v.id)\n }\n return map\n})()\n\n/**\n * All folded verb word-sequences, for the parser's longest-match verb recognition and for\n * generated grammar text.\n */\nexport const FOLDED_VERBS: readonly string[] = Array.from(FOLDED_INDEX.keys())\n\n/**\n * Suggest the nearest verbs to an unknown input, for did-you-mean errors. Matches whole folded\n * forms AND suffix words (`resize` suggests `image resize`), per the frozen error model.\n *\n * @param input - The unknown verb text as written.\n * @param candidates - The folded verb forms to search (pass the narrowed set to avoid\n * suggesting unconfigured verbs).\n * @returns Up to three suggestions, best first.\n */\nexport const suggestVerbs = (input: string, candidates: readonly string[]): string[] => {\n const folded = input\n .toLowerCase()\n .replace(/[._\\s]+/g, ' ')\n .trim()\n const scored: Array<{ name: string; score: number }> = []\n for (const cand of candidates) {\n const direct = levenshtein(folded, cand)\n const words = cand.split(' ')\n const suffix = words.length > 1 ? levenshtein(folded, words[words.length - 1]) : Infinity\n const score = Math.min(direct, suffix)\n if (score <= Math.max(2, Math.floor(folded.length / 3))) {\n scored.push({ name: cand, score })\n }\n }\n scored.sort((a, b) => a.score - b.score)\n return scored.slice(0, 3).map((s) => s.name)\n}\n\n/** Classic two-row Levenshtein distance. */\nconst levenshtein = (a: string, b: string): number => {\n if (a === b) return 0\n if (a.length === 0) return b.length\n if (b.length === 0) return a.length\n let prev = Array.from({ length: b.length + 1 }, (_, i) => i)\n let curr = new Array<number>(b.length + 1)\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1\n curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost)\n }\n ;[prev, curr] = [curr, prev]\n }\n return prev[b.length]\n}\n","/**\n * The semantic validator: checks raw parsed segments (or ops) against the verb table and the\n * deployment's configured engines, producing the validated {@link MediaPlan} or a\n * model-actionable error.\n *\n * @remarks\n * Internal sibling of the `@nhtio/adk/batteries/media` entry. This is the layer no parser\n * toolkit could supply — every error names what was wrong, suggests the nearest valid form,\n * and shows a corrective exemplar (frozen design 0.14). Engine narrowing happens HERE, never\n * at parse time (frozen 0.3): the same string parses identically in every deployment; only\n * validation differs.\n */\n\nimport { isMediaRef, isRegExpRef } from './plan'\nimport { isError, isObject } from '@nhtio/adk/guards'\nimport { VERB_INDEX, suggestVerbs, foldVerb } from './verbs'\nimport {\n E_MEDIA_UNKNOWN_VERB,\n E_MEDIA_UNKNOWN_ARG,\n E_MEDIA_BAD_ARG,\n E_MEDIA_MISSING_ARG,\n E_MEDIA_ENGINE_REQUIRED,\n} from './exceptions'\nimport type { RawSegment, RawArgValue } from './pipe'\nimport type { VerbSpec, VerbArgSpec, VerbRequirement } from './verbs'\nimport type { MediaPlan, MediaStep, MediaArgValue, MediaArgScalar, MediaOp } from './plan'\n\n/**\n * The minimal synchronous capability probe the validator narrows against. The pipeline's\n * engine registry implements it; tests stub it.\n */\nexport interface CapabilityProbe {\n /** `true` when some engine declares a matching convert edge (omit either side for \"any\"). */\n hasConvert(from?: string, to?: string): boolean\n /** `true` when some engine declares a mutate capability. */\n hasMutate(): boolean\n}\n\n/** Options for {@link validateSegments} / {@link validateOps}. */\nexport interface ValidateOptions {\n /** The deployment's capabilities. Narrows advertised verbs + error suggestions. */\n capabilities: CapabilityProbe\n}\n\n/** `true` when the deployment satisfies a verb's capability requirement. */\nconst satisfies = (capabilities: CapabilityProbe, requires: VerbRequirement): boolean =>\n requires.capability === 'mutate'\n ? capabilities.hasMutate()\n : capabilities.hasConvert(requires.from, requires.to)\n\n/** A human phrase for an unmet requirement, for the do-not-retry error. */\nconst requirementText = (requires: VerbRequirement): string => {\n if (requires.capability === 'mutate') return 'an engine that can mutate this media'\n const from = requires.from ? ` from ${requires.from}` : ''\n const to = requires.to ? ` to ${requires.to}` : ''\n return `an engine that can convert${from}${to}`\n}\n\n/** The folded verb forms available under a given capability configuration. */\nexport const availableVerbs = (capabilities: CapabilityProbe): string[] => {\n const out: string[] = []\n for (const [id, spec] of VERB_INDEX) {\n if (spec.requires && !satisfies(capabilities, spec.requires)) continue\n out.push(id.replace(/[._]+/g, ' '))\n }\n return out\n}\n\nconst levSuggest = (verbText: string, capabilities: CapabilityProbe): string => {\n const suggestions = suggestVerbs(verbText, availableVerbs(capabilities))\n return suggestions.length > 0 ? ` did you mean \"${suggestions[0]}\"?` : ''\n}\n\nconst verbList = (capabilities: CapabilityProbe): string => availableVerbs(capabilities).join(', ')\n\nconst resolveVerb = (\n verbText: string,\n capabilities: CapabilityProbe,\n position: number\n): VerbSpec => {\n const canonical = foldVerb(verbText.split(' ')) ?? verbText\n const spec = VERB_INDEX.get(canonical)\n if (!spec) {\n throw new E_MEDIA_UNKNOWN_VERB([\n `unknown verb \"${verbText}\" at segment ${position}.${levSuggest(verbText, capabilities)} Available verbs: ${verbList(capabilities)}`,\n ])\n }\n if (spec.requires && !satisfies(capabilities, spec.requires)) {\n throw new E_MEDIA_ENGINE_REQUIRED([\n `verb \"${verbText}\" requires ${requirementText(spec.requires)}, and none is configured in this deployment. Do not retry this verb here. Available verbs: ${verbList(capabilities)}`,\n ])\n }\n return spec\n}\n\nconst suggestArg = (name: string, spec: VerbSpec): string => {\n const candidates = Object.keys(spec.args)\n const ranked = suggestVerbs(name, candidates)\n return ranked.length > 0 ? ` did you mean \"${ranked[0]}\"?` : ''\n}\n\nconst argList = (spec: VerbSpec): string => {\n const names = Object.keys(spec.args)\n return names.length > 0 ? names.join(', ') : '(none)'\n}\n\nconst exemplar = (spec: VerbSpec): string => {\n const verb = spec.id.replace(/\\./g, ' ')\n const parts: string[] = [verb]\n for (const [name, arg] of Object.entries(spec.args)) {\n if (!arg.required) continue\n parts.push(`${name}=${exampleValue(arg)}`)\n }\n return parts.join(' ')\n}\n\nconst exampleValue = (arg: VerbArgSpec): string => {\n switch (arg.type) {\n case 'enum':\n return arg.values?.[0] ?? 'value'\n case 'number':\n return String(arg.min ?? 1)\n case 'number-list':\n return '1-3,5'\n case 'string-list':\n return 'a,b'\n case 'boolean':\n return 'true'\n case 'regex-or-string-list':\n return '\"literal text\"'\n case 'media-ref':\n return '@<media id>'\n case 'media-ref-list':\n return '@<media id>'\n case 'json':\n return `'[…]'`\n default:\n return '\"value\"'\n }\n}\n\n/** Coerce + check one arg value against its spec. Returns the IR-final value. */\nconst checkArg = (\n verb: VerbSpec,\n name: string,\n raw: { value: MediaArgValue; quoted: boolean }\n): MediaArgValue => {\n const spec = verb.args[name]\n const verbText = verb.id.replace(/\\./g, ' ')\n const where = `arg \"${name}\" on \"${verbText}\"`\n const bad = (msg: string): never => {\n throw new E_MEDIA_BAD_ARG([`${where}: ${msg}. Write it like: ${exemplar(verb)}`])\n }\n const v = raw.value\n switch (spec.type) {\n case 'name-or-index': {\n if (typeof v === 'number') {\n if (!Number.isInteger(v) || v < 1) bad('indices are 1-based integers')\n return v\n }\n if (typeof v !== 'string') bad('expected a 1-based index or a quoted name')\n return v\n }\n case 'string': {\n if (typeof v === 'number' && !raw.quoted) return String(v)\n if (typeof v !== 'string')\n bad(`expected text${typeof v === 'object' ? ', got a structured value' : ''}`)\n return v\n }\n case 'number': {\n if (typeof v !== 'number') bad('expected a number')\n const n = v as number\n if (spec.min !== undefined && n < spec.min) bad(`must be ≥ ${spec.min} (indices are 1-based)`)\n if (spec.max !== undefined && n > spec.max) bad(`must be ≤ ${spec.max}`)\n return n\n }\n case 'boolean': {\n if (typeof v !== 'boolean') bad('expected true or false')\n return v\n }\n case 'enum': {\n const s = typeof v === 'number' ? String(v) : v\n if (typeof s !== 'string' || !spec.values?.includes(s)) {\n bad(`\"${String(v)}\" is not valid; valid values: ${spec.values?.join(', ')}`)\n }\n return s as string\n }\n case 'number-list': {\n const arr = Array.isArray(v) ? v : [v]\n if (!arr.every((x): x is number => typeof x === 'number'))\n bad('expected numbers (e.g. 1-3,5)')\n const nums = arr as number[]\n if (spec.min !== undefined && nums.some((n) => n < (spec.min as number))) {\n bad(`values must be ≥ ${spec.min} (indices are 1-based)`)\n }\n return nums\n }\n case 'string-list': {\n const arr = Array.isArray(v) ? v : [v]\n if (!arr.every((x): x is string => typeof x === 'string'))\n bad('expected names (quote values with special characters)')\n const strs = arr as string[]\n if (spec.values && !strs.every((s) => spec.values?.includes(s))) {\n bad(`valid values: ${spec.values.join(', ')}`)\n }\n return strs\n }\n case 'regex-or-string-list': {\n if (isRegExpRef(v)) return v\n const arr = Array.isArray(v) ? v : [v]\n if (arr.every((x) => typeof x === 'string' || isRegExpRef(x))) return arr as MediaArgScalar[]\n bad('expected literal text, a list of literals, or a /regex/')\n break\n }\n case 'media-ref': {\n if (isMediaRef(v)) return v\n bad('expected a media reference: with=@<media id> (get ids from list_media)')\n break\n }\n case 'media-ref-list': {\n const arr = Array.isArray(v) ? v : [v]\n if (arr.every(isMediaRef)) return arr as MediaArgScalar[]\n bad('expected media references: with=@<id>,@<id> (get ids from list_media)')\n break\n }\n case 'json': {\n // From pipe: a quoted string containing JSON. From ops: already-structured JSON.\n if (typeof v === 'string') {\n if (!raw.quoted) bad(`expected a quoted JSON value, e.g. ${name}='[…]'`)\n try {\n return JSON.parse(v) as MediaArgValue\n } catch (err) {\n const detail = isError(err) ? err.message : String(err)\n bad(`the quoted value is not valid JSON (${detail})`)\n }\n }\n if (isObject(v) || Array.isArray(v)) return v\n bad(`expected a JSON value, e.g. ${name}='[…]'`)\n break\n }\n }\n /* unreachable */\n throw new E_MEDIA_BAD_ARG([`${where}: invalid value`])\n}\n\nconst checkStep = (\n spec: VerbSpec,\n args: ReadonlyMap<string, { value: MediaArgValue; quoted: boolean }>\n): MediaStep => {\n const verbText = spec.id.replace(/\\./g, ' ')\n const finalArgs: Record<string, MediaArgValue> = {}\n for (const [name, raw] of args) {\n if (!(name in spec.args)) {\n throw new E_MEDIA_UNKNOWN_ARG([\n `verb \"${verbText}\" has no arg \"${name}\".${suggestArg(name, spec)} Args: ${argList(spec)}. Write it like: ${exemplar(spec)}`,\n ])\n }\n finalArgs[name] = checkArg(spec, name, raw)\n }\n for (const [name, argSpec] of Object.entries(spec.args)) {\n if (argSpec.required && !(name in finalArgs)) {\n throw new E_MEDIA_MISSING_ARG([\n `verb \"${verbText}\" requires arg \"${name}\" (${argSpec.description}). Write it like: ${exemplar(spec)}`,\n ])\n }\n }\n return { verb: spec.id, args: finalArgs }\n}\n\n/**\n * Validate raw pipe segments into a {@link MediaPlan}.\n *\n * @param segments - Output of `parsePipeRaw`.\n * @param options - The deployment's capability probe.\n * @returns The validated plan, spans preserved.\n */\nexport const validateSegments = (\n segments: readonly RawSegment[],\n options: ValidateOptions\n): MediaPlan => {\n const steps: MediaStep[] = []\n segments.forEach((seg, i) => {\n const spec = resolveVerb(seg.verb.replace(/\\./g, ' '), options.capabilities, i + 1)\n const step = checkStep(spec, seg.args)\n step.span = seg.span\n steps.push(step)\n })\n return { steps }\n}\n\n/**\n * Validate a JSON ops array into a {@link MediaPlan}. The same checks as the pipe path —\n * verbs fold the same way, args validate against the same specs — so the two front-ends\n * produce identical plans for equivalent statements.\n *\n * @param ops - The ops array.\n * @param options - The deployment's capability probe.\n * @returns The validated plan (no spans).\n */\nexport const validateOps = (ops: readonly MediaOp[], options: ValidateOptions): MediaPlan => {\n const steps: MediaStep[] = []\n ops.forEach((op, i) => {\n const spec = resolveVerb(op.verb.replace(/[._]+/g, ' '), options.capabilities, i + 1)\n const args = new Map<string, RawArgValue>(\n Object.entries(op.args).map(([k, v]) => [\n k,\n {\n value: v,\n quoted: typeof v === 'string',\n span: { offset: 0, line: 1, col: 1, length: 0 },\n },\n ])\n )\n steps.push(checkStep(spec, args))\n })\n return { steps }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8GA,IAAa,eAAe,UAAuC;CACjE,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO;CAC7B,MAAM,IAAI;CACV,OAAO,OAAO,EAAE,WAAW,YAAY,OAAO,EAAE,UAAU,YAAY,OAAO,KAAK,CAAC,EAAE,WAAW;AAClG;;AAGA,IAAa,cAAc,UAAsC;CAC/D,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO;CAC7B,MAAM,IAAI;CACV,IAAI,EAAE,SAAS,MAAM,OAAO,OAAQ,EAAuB,OAAO;CAClE,IAAI,EAAE,SAAS,WAAW,OAAO,SAAU,EAAyB,IAAI;CACxE,OAAO;AACT;;AAKA,IAAM,WAAW;;AAEjB,IAAM,iBAAiB;;;;;AAMvB,IAAM,gBAAgB,MAAsB;CAC1C,IAAI,EAAE,WAAW,KAAK,CAAC,SAAS,KAAK,CAAC,KAAK,eAAe,KAAK,CAAC,KAAK,E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