{"version":3,"sources":["../core/kind-schema.types.ts","../directives/grammar.ts","../directives/legacy-shell.ts","../directives/decode.ts","../directives/display.ts","../directives/item-summary.ts","../directives/item-kind.ts"],"names":["humanizeIdentifier","isUuidShape"],"mappings":";;;;;;AAsDO,IAAM,QAAA,GAAW;;;AC3BjB,IAAM,eAAA,GAAkB;AAGxB,IAAM,iBAAA,GAAoB;AAG1B,IAAM,WAAA,GAAc,CAAA,EAAG,eAAe,CAAA,EAAG,iBAAiB,CAAA,CAAA;AAG1D,IAAM,OAAA,GAAU;AAAA,EACrB,WAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF;AAOO,IAAM,mBAAA,GAA6E;AAAA,EACxF,SAAA,EAAW,MAAA;AAAA,EACX,IAAA,EAAM,MAAA;AAAA,EACN,UAAA,EAAY,MAAA;AAAA,EACZ,MAAA,EAAQ,WAAA;AAAA,EACR,MAAA,EAAQ,aAAA;AAAA,EACR,MAAA,EAAQ,aAAA;AAAA,EACR,MAAA,EAAQ,aAAA;AAAA,EACR,MAAA,EAAQ;AACV;AAGO,IAAM,sBAAmD,IAAI,GAAA;AAAA,EAClE,QAAQ,MAAA,CAAO,CAAC,MAAM,mBAAA,CAAoB,CAAC,MAAM,aAAa;AAChE;AAMO,IAAM,kBAAA,uBAAsD,GAAA,CAAoB;AAAA,EACrF,WAAA;AAAA,EACA;AACF,CAAC;AAeM,SAAS,iBAAiB,KAAA,EAAyC;AACxE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,MAAA,CAAO,UAAU,cAAA,CAAe,IAAA,CAAK,qBAAqB,KAAK,CAAA;AAEnE;AAQO,SAAS,wBAAwB,IAAA,EAA+B;AACrE,EAAA,OAAO,OAAO,IAAA,KAAS,QAAA,IAAY,IAAA,CAAK,WAAW,eAAe,CAAA;AACpE;AAGA,SAAS,QAAQ,KAAA,EAAwB;AACvC,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AK,KAAA,EAAO,UAAU,GAAG,CAAA,EAAG,KAAA,EAAO,OAAA,EAAS,CAAA;AACzD,MAAA;AAAA,IACF;AACA,IAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,UAAU,SAAA,EAAW;AAC3D,MAAA,KAAA,CAAM,IAAA,CAAK,EAAE,GAAA,EAAK,KAAA,EAAO,SAAA,CAAU,GAAG,CAAA,EAAG,KAAA,EAAO,MAAA,CAAO,KAAK,CAAA,EAAG,CAAA;AAAA,IACjE;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;;;ACnFO,SAAS,2BACd,KAAA,EACe;AACf,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,IAAS,EAAC,EAAG;AAC9B,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,UAAA,IAAc,IAAA,CAAK,SAAA;AACtC,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,UAAA,IAAc,IAAA,CAAK,SAAA;AACtC,IAAA,IAAI,UAAU,OAAA,IAAW,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,OAAO,KAAA;AAAA,EACtE;AACA,EAAA,OAAO,IAAA;AACT;AAQO,SAAS,cAAA,CACd,MACA,IAAA,EACgC;AAChC,EAAA,MAAM,QAAA,GAAW,KAAK,QAAQ,CAAA;AAC9B,EAAA,MAAM,QAAA,GAAW,OAAO,QAAA,KAAa,QAAA,IAAY,WAAW,QAAA,GAAW,IAAA;AACvE,EAAA,IAAI,CAAC,UAAU,OAAO,IAAA;AACtB,EAAA,OAAO,EAAE,CAAC,QAAQ,GAAG,QAAA,EAAU,GAAG,IAAA,EAAK;AACzC","file":"directives.cjs","sourcesContent":["/**\n * KindSchema — the data-defined field model for a registered kind.\n *\n * `__kind` (KIND_KEY) is the carried discriminator: it is NOT part of a\n * kind's field map; the parser enforces it via `KindSchema.kind` and stamps\n * it onto every compliant snapshot.\n *\n * Moved from app/(dev)/demos/json-block-detector/kind-schemas.ts.\n *\n * 2026-07-15 expressivity extension (A2) — four constructs the Python-owned\n * pydantic schemas need that the v1 vocabulary could not express:\n *   - `{type:\"json\"}` / `{type:\"json[]\"}` — any JSON value / array of any\n *     JSON values (pydantic bare `Any` fields, `items: {}` arrays, `{}`\n *     schemas). A `json` value is implicitly nullable — `null` IS a JSON\n *     value — so `nullable` is meaningless (and ignored) on it.\n *   - `record` values widened to `\"json\"` (pydantic `dict[str, Any]` /\n *     `additionalProperties: true`).\n *   - `union` may now carry `kinds` (object unions — anyOf over kind refs,\n *     optionally mixed with scalars). Refs externalize to `kind_edge` rows\n *     exactly like `array.itemKinds`.\n *   - `KindSchema.root` — a NON-OBJECT root form: the kind's VALUE is the\n *     root field itself (scalar / array / json / open object), not a `__kind`\n *     object with fields. Root-form kinds are data-only: the streaming\n *     `__kind` parser cannot type them (a scalar cannot carry a\n *     discriminator) and refuses them loudly; validation goes through the\n *     emitted JSON Schema (ajv / Pydantic). `root` and a non-empty `fields`\n *     are mutually exclusive.\n *   - `inline_object.open` — `additionalProperties: true`; fixes the\n *     open-empty-object defect where an open `inline_object{fields:{}}`\n *     materialized as CLOSED (schema_proposal / item_presentation class).\n *\n * 2026-07-15 input-semantics extension (W3-A, agent-input bridge) — the\n * constructs the Wave-1 sufficiency survey of all 1,529 live agent variables\n * showed FieldSchema could not carry, added so `AgentVariable` ⇄ kind\n * conversion is faithful:\n *   - `FieldBase.description` — human guidance; round-trips JSON Schema\n *     `description` and VariableDefinition `helpText`.\n *   - `FieldBase.default` — the field's default VALUE (JSON Schema `default`,\n *     VariableDefinition `defaultValue`). Annotation-level: validators never\n *     apply it; emitters carry it verbatim.\n *   - `enum.open` — \"one of these options OR any string\" (the FE's\n *     `allowOther`). Emits as `anyOf: [{type:\"string\", enum}, {type:\"string\"}]`\n *     so the option set survives instead of widening to bare `string`.\n *   - `number` bounds `min`/`max`/`step` — JSON Schema\n *     `minimum`/`maximum`/`multipleOf` (number/slider components).\n *   - `string[].values` (+ `open`) — an items-enum: array of strings drawn\n *     from an option set (checkbox components), `open` meaning the set is\n *     advisory (`allowOther` on a multi-select).\n * Picklist bindings, scope bindings, and media component identity are\n * PROVENANCE, not structure — they never enter FieldSchema; the bridge\n * carries them out-of-band (see convert/kind-variable-bridge.ts sidecar).\n */\n\n/** System discriminator — hardcoded, not part of per-kind field schemas. */\nexport const KIND_KEY = \"__kind\";\n\nexport type ScalarFieldType = \"string\" | \"number\" | \"boolean\";\n\nexport type ArrayItemScalarType = \"string\" | \"number\" | \"boolean\";\n\n/** Value domain of a `record` field — typed scalars, or any JSON value. */\nexport type RecordValueType = ArrayItemScalarType | \"json\";\n\ntype FieldBase = {\n  required?: boolean;\n  nullable?: boolean;\n  /** Human guidance — JSON Schema `description` / variable `helpText`. */\n  description?: string;\n  /**\n   * Default VALUE (JSON Schema `default` / variable `defaultValue`).\n   * Annotation-level: validators never apply it; emitters carry it verbatim.\n   */\n  default?: unknown;\n};\n\nexport type FieldSchema =\n  | (FieldBase & { type: \"string\" | \"boolean\" })\n  | (FieldBase & {\n      type: \"number\";\n      /** Inclusive lower bound — JSON Schema `minimum`. */\n      min?: number;\n      /** Inclusive upper bound — JSON Schema `maximum`. */\n      max?: number;\n      /** Increment — JSON Schema `multipleOf`. Annotation-level in the parser. */\n      step?: number;\n    })\n  | (FieldBase & {\n      type: \"string[]\";\n      /** Items-enum: each item must be one of these values (checkbox option sets). */\n      values?: string[];\n      /** With `values`: the set is advisory — any string item is also legal (`allowOther`). */\n      open?: boolean;\n    })\n  | (FieldBase & { type: \"number[]\" | \"boolean[]\" })\n  | (FieldBase & { type: \"json\" })\n  | (FieldBase & { type: \"json[]\" })\n  | (FieldBase & { type: \"array\"; itemKinds: string[] })\n  | (FieldBase & { type: \"object\"; kind: string })\n  | (FieldBase & {\n      type: \"inline_object\";\n      fields: Record<string, FieldSchema>;\n      /** additionalProperties: true — unknown keys are legal, not residue-only. */\n      open?: boolean;\n    })\n  | (FieldBase & { type: \"record\"; values: RecordValueType })\n  | (FieldBase & {\n      type: \"enum\";\n      values: string[];\n      /** \"One of these OR any string\" — the option set is advisory (`allowOther`). */\n      open?: boolean;\n    })\n  | (FieldBase & {\n      type: \"union\";\n      scalars: Array<\"string\" | \"number\" | \"boolean\">;\n      /** Object union members — kind refs (anyOf of $refs), may mix with scalars. */\n      kinds?: string[];\n    });\n\n/**\n * Domain fields only — __kind is enforced by the parser via KindSchema.kind\n * (block slug). A kind with `root` set has NO field map (fields stays `{}`):\n * its value is the root field's type at the top level. See the module header.\n */\nexport type KindSchema = {\n  kind: string;\n  fields: Record<string, FieldSchema>;\n  /** Non-object root form — mutually exclusive with a non-empty `fields`. */\n  root?: FieldSchema;\n};\n\nexport function readObjectKind(value: Record<string, unknown>): string | null {\n  const kind = value[KIND_KEY];\n  return typeof kind === \"string\" ? kind : null;\n}\n\nexport function isScalarArrayType(\n  type: FieldSchema[\"type\"],\n): type is \"string[]\" | \"number[]\" | \"boolean[]\" {\n  return type === \"string[]\" || type === \"number[]\" || type === \"boolean[]\";\n}\n\nexport function scalarArrayItemType(\n  type: \"string[]\" | \"number[]\" | \"boolean[]\",\n): ArrayItemScalarType {\n  if (type === \"number[]\") return \"number\";\n  if (type === \"boolean[]\") return \"boolean\";\n  return \"string\";\n}\n\n/**\n * Does this field's value domain accept ANY JSON shape (object/array/scalar/\n * null alike)? True for `json` and `json[]` ITEMS — the parser treats the\n * subtree under such a field as opaque (no kind identification, no raw_object\n * degradation: unknown structure is the declared contract, not a failure).\n */\nexport function isJsonAnyField(field: FieldSchema): boolean {\n  return field.type === \"json\" || field.type === \"json[]\";\n}\n","/**\n * Kind Directives — the grammar, the shell, and the position law (kernel edition).\n *\n * ONE system (Arman, 2026-08-23): the Matrx Envelope/Directive protocol and the\n * Content IR kind system are one system. A directive is an ordinary kind\n * instance — `{ \"__kind\": \"directive_v1_<class>_<noun>\", \"items\": [...] }` —\n * whose registered shape additionally carries execution semantics on the\n * server. This module is the PURE half, ported verbatim from the aidream source\n * of record (`packages/matrx-graph/matrx_graph/content_ir/directives.py`) so\n * every UI parses the grammar identically. It lives in the KERNEL because a\n * host that can parse a kind must be able to recognize a directive without a\n * second copy of these rules (matrx-frontend carried the only copy until\n * 2026-09-08; Workflow Studio had none and rendered directives as raw text).\n *\n * THE SLUG GRAMMAR — `directive_v<version>_<class>_<noun>`:\n *  - `directive_v` is a RESERVED prefix; a hand-authored kind may never claim it.\n *  - `<class>` comes from a CLOSED vocabulary, so parsing is unambiguous even\n *    though nouns contain underscores: `directive_v1_reference_create_task` is\n *    `(reference, \"create_task\")`.\n *  - capability is DERIVED from the class, never stored twice.\n */\n\nimport { KIND_KEY } from \"../core/kind-schema.types\";\n\nexport { KIND_KEY };\n\n/** The reserved slug prefix. ANY kind slug starting with this belongs to the Kind Directives protocol. */\nexport const RESERVED_PREFIX = \"directive_v\" as const;\n\n/** Current directive grammar version. */\nexport const DIRECTIVE_VERSION = 1 as const;\n\n/** The full prefix of a v1 directive slug. */\nexport const SLUG_PREFIX = `${RESERVED_PREFIX}${DIRECTIVE_VERSION}_` as const;\n\n/** The CLOSED class vocabulary. Closed is what makes the grammar parseable. */\nexport const CLASSES = [\n  \"reference\",\n  \"view\",\n  \"create\",\n  \"update\",\n  \"delete\",\n  \"action\",\n  \"validation\",\n  \"secret\",\n] as const;\n\nexport type DirectiveClass = (typeof CLASSES)[number];\n\nexport type DirectiveCapability = \"pure\" | \"sensitive\" | \"side_effect\";\n\n/** class → capability. DERIVED, never stored on a shape. */\nexport const CAPABILITY_BY_CLASS: Readonly<Record<DirectiveClass, DirectiveCapability>> = {\n  reference: \"pure\",\n  view: \"pure\",\n  validation: \"pure\",\n  secret: \"sensitive\",\n  create: \"side_effect\",\n  update: \"side_effect\",\n  delete: \"side_effect\",\n  action: \"side_effect\",\n};\n\n/** The classes that EXECUTE at an agent's output root — a durable side effect. */\nexport const SIDE_EFFECT_CLASSES: ReadonlySet<DirectiveClass> = new Set(\n  CLASSES.filter((c) => CAPABILITY_BY_CLASS[c] === \"side_effect\"),\n);\n\n/**\n * The classes that resolve to a LIVE VALUE inside content. STRICT BY CHOICE,\n * mirroring the server: exactly `reference` + `secret`.\n */\nexport const IN_CONTENT_CLASSES: ReadonlySet<DirectiveClass> = new Set<DirectiveClass>([\n  \"reference\",\n  \"secret\",\n]);\n\n/** A parsed directive slug. `slug` round-trips through `buildDirectiveSlug`. */\nexport interface DirectiveSlug {\n  slug: string;\n  version: number;\n  directiveClass: DirectiveClass;\n  noun: string;\n  capability: DirectiveCapability;\n  /** Executes at an agent's output root (THE position law, half one). */\n  executes: boolean;\n  /** Resolves to a live value inside content (THE position law, half two). */\n  inContent: boolean;\n}\n\nexport function isDirectiveClass(value: unknown): value is DirectiveClass {\n  return (\n    typeof value === \"string\" &&\n    Object.prototype.hasOwnProperty.call(CAPABILITY_BY_CLASS, value)\n  );\n}\n\n/**\n * Whether `slug` sits in the reserved Kind Directives namespace. Deliberately\n * broader than {@link parseDirectiveSlug}: a MALFORMED `directive_v…` slug is\n * still reserved, so authoring gates reject it instead of letting a near-miss\n * through as an ordinary kind.\n */\nexport function isReservedDirectiveSlug(slug: unknown): slug is string {\n  return typeof slug === \"string\" && slug.startsWith(RESERVED_PREFIX);\n}\n\n/** A noun/token: starts with a lowercase letter, then `[a-z0-9_]`. */\nfunction isToken(value: string): boolean {\n  return /^[a-z][a-z0-9_]*$/.test(value);\n}\n\n/**\n * `(\"create\", \"task\") → \"directive_v1_create_task\"`. THROWS on a class outside\n * the closed vocabulary or an ill-formed noun — a slug that cannot be parsed\n * back must never be mintable.\n */\nexport function buildDirectiveSlug(\n  directiveClass: string,\n  noun: string,\n  version: number = DIRECTIVE_VERSION,\n): string {\n  if (!isDirectiveClass(directiveClass)) {\n    throw new Error(\n      `unknown directive class ${JSON.stringify(directiveClass)}; the vocabulary is CLOSED: ${CLASSES.join(\", \")}.`,\n    );\n  }\n  if (typeof noun !== \"string\" || !isToken(noun)) {\n    throw new Error(\n      `invalid directive noun ${JSON.stringify(noun)} for class ${JSON.stringify(directiveClass)}: a noun is lowercase [a-z0-9_], starts with a letter, and is non-empty.`,\n    );\n  }\n  return `${RESERVED_PREFIX}${version}_${directiveClass}_${noun}`;\n}\n\n/**\n * Parse a directive slug, or `null` when `slug` is not one. A slug that IS in\n * the reserved namespace but does not parse returns `null` too — pair with\n * {@link isReservedDirectiveSlug} to tell \"ordinary kind\" from \"malformed\n * directive\"; every such caller treats the malformed case as an ERROR.\n */\nexport function parseDirectiveSlug(slug: unknown): DirectiveSlug | null {\n  if (!isReservedDirectiveSlug(slug)) return null;\n  const rest = slug.slice(RESERVED_PREFIX.length);\n  const firstSep = rest.indexOf(\"_\");\n  if (firstSep <= 0) return null;\n  const versionDigits = rest.slice(0, firstSep);\n  if (!/^[0-9]+$/.test(versionDigits)) return null;\n  const remainder = rest.slice(firstSep + 1);\n  const classSep = remainder.indexOf(\"_\");\n  if (classSep <= 0) return null;\n  const directiveClass = remainder.slice(0, classSep);\n  const noun = remainder.slice(classSep + 1);\n  if (!isDirectiveClass(directiveClass) || !isToken(noun)) return null;\n  return {\n    slug,\n    version: Number.parseInt(versionDigits, 10),\n    directiveClass,\n    noun,\n    capability: CAPABILITY_BY_CLASS[directiveClass],\n    executes: executesAtOutputRoot(directiveClass),\n    inContent: resolvesInContent(directiveClass),\n  };\n}\n\nexport function capabilityOf(directiveClass: DirectiveClass): DirectiveCapability {\n  return CAPABILITY_BY_CLASS[directiveClass];\n}\n\n/** THE position law, half one: only a side-effect class executes at an agent's output root. */\nexport function executesAtOutputRoot(directiveClass: string): boolean {\n  return isDirectiveClass(directiveClass) && SIDE_EFFECT_CLASSES.has(directiveClass);\n}\n\n/** THE position law, half two: only a pointer or a sensitive value resolves to a live value inside content. */\nexport function resolvesInContent(directiveClass: string): boolean {\n  return isDirectiveClass(directiveClass) && IN_CONTENT_CLASSES.has(directiveClass);\n}\n\n/**\n * The `__kind` of `obj` when it is in the reserved namespace, else null. Reads\n * the RESERVED namespace, not the parsed grammar, so a malformed directive is\n * still recognized as a directive (and rejected downstream with a real message).\n */\nexport function directiveSlugOf(obj: unknown): string | null {\n  if (typeof obj !== \"object\" || obj === null || Array.isArray(obj)) return null;\n  const slug = (obj as Record<string, unknown>)[KIND_KEY];\n  return isReservedDirectiveSlug(slug) ? slug : null;\n}\n\n/** THE detector — a dict whose `__kind` is in the reserved namespace. */\nexport function isKindDirective(obj: unknown): boolean {\n  return directiveSlugOf(obj) !== null;\n}\n\n/**\n * The two-key shell, as it travels on the wire. A TYPE alias, not an interface,\n * so a shell is structurally assignable to `Record<string, unknown>`.\n */\nexport type KindDirectiveShell<Item = Record<string, unknown>> = {\n  /** The slug. Serialized FIRST — see the module doc. */\n  [KIND_KEY]: string;\n  items: Item[];\n};\n\n/**\n * Build the two-key shell with `__kind` FIRST. Never hand-assemble the object\n * literal elsewhere: JS preserves insertion order for string keys, and the\n * first-key rule is what lets the streaming detector type a directive early.\n */\nexport function buildKindDirective<Item>(slug: string, items: Item[]): KindDirectiveShell<Item> {\n  return { [KIND_KEY]: slug, items };\n}\n\n/**\n * Mid-stream recognition: the opening of a document whose FIRST key is a\n * reserved directive slug, before the closing brace has arrived. Used by\n * content splitters so a streaming envelope is typed early.\n */\nexport function looksLikeDirectiveHead(content: string): boolean {\n  const match = content.trimStart().match(/^\\{\\s*\"__kind\"\\s*:\\s*\"([^\"]*)/);\n  return !!match && isReservedDirectiveSlug(match[1]);\n}\n","/**\n * THE ONE LEGACY SURFACE of the Kind Directives protocol — read-only.\n *\n * Stored content written before 2026-08-23 carries the retired 4-key shell\n * (`matrx_version` / `kind` / `type` / `items`). This module translates it into\n * the current two-key shell so `decodeDirective` sees one shape, forever. It\n * never emits, never registers a shape, has no fallback branch, and every use\n * is counted so the containment can be measured. Only `decode.ts` may import\n * it (matrx-frontend's `check-legacy-shim-containment` and aidream's\n * `test_legacy_shim_containment.py` enforce the mirror).\n */\n\nimport { KIND_KEY, buildDirectiveSlug } from \"./grammar\";\n\nconst LEGACY_SENTINEL = \"matrx_version\";\n\nconst CLASS_BY_LEGACY_KIND: Readonly<Record<string, string>> = {\n  reference: \"reference\",\n  secret: \"secret\",\n  validation: \"validation\",\n};\n\nconst LEGACY_SIDE_EFFECT_KINDS: ReadonlySet<string> = new Set([\"output_directive\", \"function\"]);\n\nconst VERB_NOUN_RE = /^(create|update|delete):([a-z][a-z0-9_]*)$/;\n\n// USE COUNTER ON A globalThis SLOT — never a module-level variable. With\n// `splitting: false` dual ESM/CJS output this module is duplicated into the\n// root bundle and the `./directives` bundle; a module local would count per\n// graph and under-report. Never \"clean this up\" into a module local.\nconst USES_SLOT = Symbol.for(\"ai-matrx.content-ir.legacy-shell-uses\");\ntype UsesHolder = typeof globalThis & { [USES_SLOT]?: { count: number } };\nconst uses: { count: number } = ((globalThis as UsesHolder)[USES_SLOT] ??= { count: 0 });\n\nexport function legacyShellUses(): number {\n  return uses.count;\n}\n\nexport function resetLegacyShellUses(): void {\n  uses.count = 0;\n}\n\n/** True ONLY for a genuine retired-shell directive claim (sentinel + a retired kind token). */\nexport function isLegacyShell(obj: unknown): boolean {\n  if (typeof obj !== \"object\" || obj === null || Array.isArray(obj)) return false;\n  const record = obj as Record<string, unknown>;\n  if (!(LEGACY_SENTINEL in record)) return false;\n  const kind = record.kind;\n  return (\n    typeof kind === \"string\" &&\n    (kind in CLASS_BY_LEGACY_KIND || LEGACY_SIDE_EFFECT_KINDS.has(kind))\n  );\n}\n\nfunction slugForLegacy(kind: string, type: string): string | null {\n  let directiveClass: string;\n  let noun: string;\n  if (LEGACY_SIDE_EFFECT_KINDS.has(kind)) {\n    const match = VERB_NOUN_RE.exec(type);\n    if (match) {\n      directiveClass = match[1]!;\n      noun = match[2]!;\n    } else {\n      directiveClass = \"action\";\n      noun = type;\n    }\n  } else {\n    const mapped = CLASS_BY_LEGACY_KIND[kind];\n    if (!mapped) return null;\n    directiveClass = mapped;\n    noun = type;\n  }\n  try {\n    return buildDirectiveSlug(directiveClass, noun);\n  } catch {\n    return null;\n  }\n}\n\n/** The current two-key shell for a retired one, or null when it cannot be honored. */\nexport function translateLegacyShell(\n  obj: Record<string, unknown>,\n): Record<string, unknown> | null {\n  const kind = obj.kind;\n  const type = obj.type;\n  if (typeof kind !== \"string\" || typeof type !== \"string\") return null;\n  const slug = slugForLegacy(kind, type);\n  if (slug === null) return null;\n  const items = obj.items;\n  uses.count += 1;\n  return { [KIND_KEY]: slug, items: Array.isArray(items) ? [...items] : [] };\n}\n","/**\n * Decode a Kind Directive — THE one entry point on every client.\n *\n * `decodeDirective()` recognizes the shell (current OR, for stored content\n * only, the retired 4-key one), reads the slug, and derives class + noun. A\n * caller only ever sees a parsed {@link DecodedDirective}; nothing downstream\n * inspects a raw shell again.\n *\n * ITEM VALIDATION IS THE SERVER'S. The registered item models live in aidream\n * (`services/content_ir_directives/registry.py`) and validate on apply; a\n * client-side copy of ~120 item models is exactly the drift the merge exists\n * to kill. The client parses identity, routes, and renders. Mirror of aidream\n * `services/content_ir_directives/decode.py`.\n */\n\nimport {\n  type DirectiveClass,\n  type DirectiveSlug,\n  KIND_KEY,\n  isReservedDirectiveSlug,\n  parseDirectiveSlug,\n} from \"./grammar\";\nimport { isLegacyShell, translateLegacyShell } from \"./legacy-shell\";\n\n/**\n * A well-formed-looking directive that cannot be honored (a malformed slug, or\n * a retired shell that does not map onto the grammar). Never thrown for \"this\n * isn't a directive\" — that is `null`.\n */\nexport class DirectiveDecodeError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = \"DirectiveDecodeError\";\n  }\n}\n\nexport interface DecodedDirective {\n  /** The parsed slug — class, noun, capability and the position law. */\n  readonly parsed: DirectiveSlug;\n  readonly slug: string;\n  readonly directiveClass: DirectiveClass;\n  readonly noun: string;\n  readonly items: Record<string, unknown>[];\n  /** The two-key shell, normalized — what a confirm POST round-trips. */\n  readonly shell: Record<string, unknown>;\n  /** True when this arrived in the retired 4-key shell and was translated. */\n  readonly legacyShell: boolean;\n}\n\nfunction asObject(value: unknown): Record<string, unknown> | null {\n  if (typeof value !== \"object\" || value === null || Array.isArray(value)) return null;\n  return value as Record<string, unknown>;\n}\n\n/**\n * A typed directive, or `null` when `value` is not a directive at all. Throws\n * {@link DirectiveDecodeError} when it IS one but cannot be honored.\n */\nexport function decodeDirective(value: unknown): DecodedDirective | null {\n  let obj = asObject(value);\n  if (obj === null) return null;\n\n  let legacy = false;\n  if (isLegacyShell(obj)) {\n    const translated = translateLegacyShell(obj);\n    if (translated === null) {\n      throw new DirectiveDecodeError(\n        `a retired 4-key shell with kind=${JSON.stringify(obj.kind)} type=${JSON.stringify(obj.type)} does not map onto the Kind Directives grammar. Emit the current shell: {\"${KIND_KEY}\": \"directive_v1_<class>_<noun>\", \"items\": [...]}.`,\n      );\n    }\n    obj = translated;\n    legacy = true;\n  }\n\n  const rawSlug = obj[KIND_KEY];\n  if (!isReservedDirectiveSlug(rawSlug)) return null;\n\n  const parsed = parseDirectiveSlug(rawSlug);\n  if (parsed === null) {\n    throw new DirectiveDecodeError(\n      `malformed directive slug ${JSON.stringify(rawSlug)} — it claims the reserved \"directive_v\" namespace but does not parse as directive_v<version>_<class>_<noun>.`,\n    );\n  }\n\n  const rawItems = obj.items;\n  const items = Array.isArray(rawItems)\n    ? rawItems.filter((i): i is Record<string, unknown> => asObject(i) !== null)\n    : [];\n\n  return {\n    parsed,\n    slug: parsed.slug,\n    directiveClass: parsed.directiveClass,\n    noun: parsed.noun,\n    items,\n    shell: { [KIND_KEY]: parsed.slug, items },\n    legacyShell: legacy,\n  };\n}\n\n/**\n * The forgiving read used at render seams: `decodeDirective`, but a directive\n * that cannot be honored comes back as `null` after the reason is handed to\n * `onError`. A render seam must never take a whole message block down over one\n * bad fence — but it must never swallow the reason either.\n */\nexport function tryDecodeDirective(\n  value: unknown,\n  onError?: (message: string) => void,\n): DecodedDirective | null {\n  try {\n    return decodeDirective(value);\n  } catch (error) {\n    onError?.(error instanceof Error ? error.message : \"directive decode failed\");\n    return null;\n  }\n}\n\n/** `decodeDirective` over a JSON string or an already-parsed value. Non-JSON text is `null`. */\nexport function tryDecodeDirectiveContent(\n  content: unknown,\n  onError?: (message: string) => void,\n): DecodedDirective | null {\n  if (typeof content !== \"string\") return tryDecodeDirective(content, onError);\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(content);\n  } catch {\n    return null;\n  }\n  return tryDecodeDirective(parsed, onError);\n}\n","/**\n * THE AUTO-VIEW's naming half: every enrolled noun \"instantly has a view\" —\n * the prefix rule gives it a renderer, and this gives it a NAME. A shape the\n * client has never heard of must still read as \"Create Agent · Agents\", never\n * as the raw `agent` token and never as a slug.\n *\n * The catalog (`platform.entity_types` → the server's directive catalog) is the\n * authority for `label` / `family` / `title_column`; a host that mirrors it\n * passes a {@link DirectiveNounCatalog}. Without one — or for a noun the\n * catalog does not carry (a Kind Action like `plan_tree`) — the name degrades\n * to a title-cased token: legible, honestly derived, never blank.\n */\n\nimport type { DirectiveClass } from \"./grammar\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\n\nexport interface DirectiveNounEntry {\n  /** The noun's human name — \"Agent\", \"Plan tree\". */\n  label?: string | null;\n  /** The catalog family (\"Agents\"). */\n  family?: string | null;\n  /** Which field of a row names it (`name`, `title`, …). */\n  titleColumn?: string | null;\n}\n\n/** A host-supplied lookup over the mirrored catalog. `undefined` = not carried. */\nexport type DirectiveNounCatalog = (noun: string) => DirectiveNounEntry | undefined;\n\nexport interface DirectiveDisplay {\n  /** The noun's human name — \"Agent\", \"Plan tree\". */\n  noun: string;\n  /** The catalog family (\"Agents\"), or \"\" when the catalog has none. */\n  family: string;\n  /** What this directive DOES, in the user's words — \"Create\", \"Reference\". */\n  action: string;\n  /** One line: \"Create Agent\". */\n  title: string;\n}\n\n/** `plan_node_patch` → `Plan Node Patch` — THE humanizer, the honest last resort. */\nexport function titleCaseToken(token: string): string {\n  return humanizeIdentifier(token) || token;\n}\n\n/**\n * How a class reads to a human. `action` is deliberately \"Run\": a Kind Action\n * is a named procedure, and \"Action Plan tree\" reads like a noun phrase where a\n * verb belongs. Mirrored by the server's kind-catalog label.\n */\nexport const ACTION_BY_CLASS: Readonly<Record<DirectiveClass, string>> = {\n  reference: \"Reference\",\n  view: \"View\",\n  create: \"Create\",\n  update: \"Update\",\n  delete: \"Delete\",\n  action: \"Run\",\n  validation: \"Validate\",\n  secret: \"Secret\",\n};\n\nexport function nounLabel(noun: string, catalog?: DirectiveNounCatalog): string {\n  const label = catalog?.(noun)?.label;\n  return label && label.length > 0 ? label : titleCaseToken(noun);\n}\n\nexport function nounFamily(noun: string, catalog?: DirectiveNounCatalog): string {\n  return catalog?.(noun)?.family ?? \"\";\n}\n\nexport function nounTitleColumn(noun: string, catalog?: DirectiveNounCatalog): string | null {\n  return catalog?.(noun)?.titleColumn ?? null;\n}\n\n/** Everything a generic card needs to name a directive it cannot render. */\nexport function directiveDisplay(\n  directiveClass: DirectiveClass,\n  noun: string,\n  catalog?: DirectiveNounCatalog,\n): DirectiveDisplay {\n  const label = nounLabel(noun, catalog);\n  const action = ACTION_BY_CLASS[directiveClass];\n  return {\n    noun: label,\n    family: nounFamily(noun, catalog),\n    action,\n    title: `${action} ${label}`,\n  };\n}\n","/**\n * Naming and summarizing ONE item of a directive, for the compact card.\n *\n * THE RULE: a user is never asked to approve a write they cannot identify. The\n * card must say WHAT is about to be created/updated/deleted, derived from\n * authority rather than guesswork, in this order:\n *   1. the noun's catalog `title_column` — the server's own answer to \"what\n *      names a row of this table\";\n *   2. the conventional identity fields, in a fixed order;\n *   3. the honest last resort — \"Item 2 of 3\", never a blank chip and never a\n *      slug pretending to be a name.\n *\n * Facts are scalars ONLY. Nesting goes to the panel, never into the row.\n */\nimport { isUuidShape } from \"@ai-matrx/kit/uuid\";\n\n/** Identity fields, in the order a human would reach for them. */\nconst NAME_KEYS = [\"name\", \"title\", \"label\", \"heading\", \"slug\", \"key\", \"question\", \"summary\"] as const;\n\n/** Never shown as a fact chip — identity, plumbing, or already in the title. */\nconst FACT_EXCLUDE = new Set<string>([\n  \"__kind\",\n  ...NAME_KEYS,\n  \"id\",\n  \"description\",\n  \"about\",\n  \"notes\",\n  \"content\",\n  \"text\",\n  \"body\",\n  \"organization_id\",\n  \"user_id\",\n  \"created_by\",\n  \"resource_type\",\n]);\n\nfunction firstString(item: Record<string, unknown>, keys: readonly string[]): string | null {\n  for (const key of keys) {\n    const value = item[key];\n    if (typeof value === \"string\" && value.trim()) return value.trim();\n  }\n  return null;\n}\n\n/**\n * What to call this item. `titleColumn` is the noun's catalog title column\n * (consulted first); null when the catalog carries none.\n */\nexport function catalogItemTitle(\n  item: Record<string, unknown>,\n  titleColumn: string | null,\n  index: number,\n  total: number,\n): string {\n  const fromCatalog = titleColumn ? firstString(item, [titleColumn]) : null;\n  const name = fromCatalog ?? firstString(item, NAME_KEYS);\n  if (name) return name;\n  return total > 1 ? `Item ${index + 1} of ${total}` : \"Item\";\n}\n\n/** A one-line subtitle when the item carries prose about itself. */\nexport function itemSubtitle(item: Record<string, unknown>): string | null {\n  return firstString(item, [\"description\", \"about\", \"summary\", \"doc\"]);\n}\n\nexport interface ItemFact {\n  key: string;\n  label: string;\n  value: string;\n}\n\n/**\n * A UUID is never a fact. THE UUID RULE: an id is shown as its first segment\n * with a copy control and the full value on hover — which a dense fact chip\n * cannot do. Found in production 2026-09-08: `model_id` rendered as a chip.\n */\n\n/** `variable_definitions` → \"variables\". Underscores read as developer output. */\nconst FACT_LABEL_OVERRIDES: Readonly<Record<string, string>> = {\n  variable_definitions: \"variables\",\n  context_policies: \"context\",\n  custom_tools: \"custom tools\",\n};\n\nfunction factLabel(key: string): string {\n  return FACT_LABEL_OVERRIDES[key] ?? key.replace(/_/g, \" \");\n}\n\n/**\n * Up to `limit` scalar facts about the item — counts for collections, values\n * for scalars. Nested objects are deliberately absent (they belong in the\n * panel), and so is anything already carried by the title/subtitle.\n */\nexport function itemFacts(item: Record<string, unknown>, limit = 4): ItemFact[] {\n  const facts: ItemFact[] = [];\n  for (const [key, value] of Object.entries(item)) {\n    if (facts.length >= limit) break;\n    if (FACT_EXCLUDE.has(key)) continue;\n    if (Array.isArray(value)) {\n      if (value.length === 0) continue;\n      facts.push({ key, label: factLabel(key), value: String(value.length) });\n      continue;\n    }\n    if (typeof value === \"string\") {\n      const trimmed = value.trim();\n      if (!trimmed || trimmed.length > 40) continue;\n      if (isUuidShape(trimmed)) continue;\n      facts.push({ key, label: factLabel(key), value: trimmed });\n      continue;\n    }\n    if (typeof value === \"number\" || typeof value === \"boolean\") {\n      facts.push({ key, label: factLabel(key), value: String(value) });\n    }\n  }\n  return facts;\n}\n","/**\n * THE DIRECTIVE⇄KIND SEAM, client side.\n *\n * Arman, 2026-08-26: the envelope / Matrx-Actions system and the Shape (kind)\n * system are ONE system with several methods inside it. They meet at the ITEM.\n * A directive is a CONTAINER; its items are the payload, and when the server's\n * item model is already a `KindModel`, that payload IS a registered kind\n * instance — so the kind system already knows how to validate, render and copy\n * it.\n *\n * The seam is SERVER-DERIVED (`ShapeSpec.item_kind`). Since 2026-09-08 the ONE\n * kind endpoint publishes every directive shape as a KindDescriptor whose\n * `items` EDGE names the item kind, so a client reads it from the same\n * catalog it already holds — {@link directiveItemKindFromEdges}. A host that\n * mirrors the directive catalog manifest instead passes its map as a\n * {@link DirectiveItemKindLookup}. `null` is HONEST, never a gap-filler.\n */\n\nimport { KIND_KEY } from \"./grammar\";\n\n/** A host-supplied lookup: slug → the kind ONE item is, or null. */\nexport type DirectiveItemKindLookup = (slug: string) => string | null;\n\n/** The `items` edge of a directive KindDescriptor, as the kind catalog serves it. */\nexport interface DirectiveItemsEdge {\n  field_name?: string;\n  fieldPath?: string;\n  child_kind?: string;\n  childKind?: string;\n}\n\n/** The item kind named by a directive descriptor's `items` edge, or null. */\nexport function directiveItemKindFromEdges(\n  edges: readonly DirectiveItemsEdge[] | null | undefined,\n): string | null {\n  for (const edge of edges ?? []) {\n    const field = edge.field_name ?? edge.fieldPath;\n    const child = edge.child_kind ?? edge.childKind;\n    if (field === \"items\" && typeof child === \"string\" && child) return child;\n  }\n  return null;\n}\n\n/**\n * The item, presented the way the kind pipeline expects it: `__kind` FIRST so a\n * consumer types the object from its own first key. `__kind` is ADDED, never\n * overwritten: an item that already carries its marker keeps the value it was\n * emitted with. Null when no kind is known — the caller owns the generic floor.\n */\nexport function asKindInstance(\n  item: Record<string, unknown>,\n  kind: string | null,\n): Record<string, unknown> | null {\n  const existing = item[KIND_KEY];\n  const resolved = typeof existing === \"string\" && existing ? existing : kind;\n  if (!resolved) return null;\n  return { [KIND_KEY]: resolved, ...item };\n}\n"]}