{"version":3,"sources":["../react-directives.ts","../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","../react-directives/registry.ts","../react-directives/ApplyDirectiveButton.tsx","../react-directives/item-changes.ts","../react-directives/record-values.ts","../react-directives/failure-words.ts","../react-directives/icons.tsx","../react-directives/SideEffectDirectiveCard.tsx","../react-directives/DirectiveFallbackCard.tsx","../react-directives/DirectiveProvisionalCard.tsx","../react-directives/DirectiveRender.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * `@ai-matrx/content-ir/react-directives` — the Kind Directives render tier:\n * the host seams (`DirectiveHostProvider`), the renderer registry with THE\n * PREFIX TIER, the side-effect card, the fallback floor, the Apply control, and\n * `DirectiveRender` — THE renderer every UI draws a directive through. Client\n * entry (stamped \"use client\").\n */\n// Named, not `export *`: this module is an external self-import (tsup.config.ts), and esbuild lowers an\n// external star re-export nested in a bundled module to `__reExport(ns, directive_host_star)` followed by\n// `import * as directive_host_star`, which reads the namespace before its import runs in any CommonJS\n// transform (guard: ../scripts/check-reexport-order.mjs).\nexport {\n  DirectiveScopeProvider,\n  useDirectiveScope,\n  DirectiveHostProvider,\n  useDirectiveHost,\n} from \"./react-directives/directive-host\";\nexport type {\n  DirectiveApplyResult,\n  DirectiveApplyState,\n  DirectiveRecordRef,\n  DirectiveRecordProps,\n  DirectiveAskRequest,\n  DirectiveShell,\n  DirectiveOpenItemOptions,\n  DirectiveCopyProps,\n  DirectiveHost,\n  DirectiveValueRef,\n  DirectiveFailure,\n  DirectiveFailureWords,\n  DirectiveScope,\n  DirectiveHostProviderProps,\n} from \"./react-directives/directive-host\";\nexport * from \"./react-directives/registry\";\nexport * from \"./react-directives/ApplyDirectiveButton\";\nexport * from \"./react-directives/SideEffectDirectiveCard\";\nexport * from \"./react-directives/DirectiveFallbackCard\";\nexport * from \"./react-directives/DirectiveProvisionalCard\";\nexport * from \"./react-directives/DirectiveRender\";\nexport * from \"./react-directives/item-changes\";\nexport * from \"./react-directives/failure-words\";\nexport * from \"./react-directives/record-values\";\n","/**\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","/**\n * Kind Directives — the renderer registry, and THE PREFIX TIER.\n *\n * A directive IS a kind instance, so the renderer for one is resolved from its\n * SLUG, in the same shape the kind component resolver uses:\n *\n *   getDirectiveRenderer(directive)\n *     → an exact-slug renderer            (directive_v1_action_plan_tree)\n *     → else the CLASS prefix rule        (every directive_v1_reference_*)\n *     → else null                         (DirectiveRender's own tier: the\n *                                          side-effect card, then the floor)\n *\n * THE PREFIX RULE is Arman's routing-language ruling made real: registering\n * `reference` once gives EVERY enrolled noun a renderer for free; a custom\n * renderer for one slug overrides it; a brand-new server noun renders with\n * ZERO client edits. Hosts register their bespoke renderers (reference chips,\n * plan trees) here; the package supplies the side-effect card and the floor.\n */\n\nimport type { ComponentType } from \"react\";\nimport { type DecodedDirective, type DirectiveClass, buildDirectiveSlug } from \"../directives\";\n\nexport interface DirectiveRendererProps {\n  /** The decoded two-key shell — slug, class, noun, items, position law. */\n  directive: DecodedDirective;\n}\n\nexport type DirectiveRenderer = ComponentType<DirectiveRendererProps>;\n\n// REGISTRY ON A globalThis SLOT — never module-level Maps. With `splitting:\n// false` dual ESM/CJS output this module is duplicated into the root bundle and\n// the `./directives` bundle, and a host registering a renderer through one\n// graph must be visible to a card rendering through the other.\nconst REGISTRY_SLOT = Symbol.for(\"ai-matrx.content-ir.directive-renderers\");\ninterface Registry {\n  bySlug: Map<string, DirectiveRenderer>;\n  byClass: Map<DirectiveClass, DirectiveRenderer>;\n}\ntype RegistryHolder = typeof globalThis & { [REGISTRY_SLOT]?: Registry };\nconst registry: Registry = ((globalThis as RegistryHolder)[REGISTRY_SLOT] ??= {\n  bySlug: new Map(),\n  byClass: new Map(),\n});\n\n/**\n * Register a renderer for a whole CLASS (the prefix rule), or for one exact\n * `(class, noun)` pair, which wins. `noun` is passed as a noun, never a\n * hand-typed slug: the slug is BUILT by the grammar, so a registration whose\n * slug could not be parsed back is unconstructable rather than unreachable.\n */\nexport function registerDirectiveRenderer(\n  directiveClass: DirectiveClass,\n  renderer: DirectiveRenderer,\n  noun?: string,\n): void {\n  if (noun) registry.bySlug.set(buildDirectiveSlug(directiveClass, noun), renderer);\n  else registry.byClass.set(directiveClass, renderer);\n}\n\n/** The renderer for a slug: exact → class prefix rule → null. */\nexport function getDirectiveRenderer(\n  directive: Pick<DecodedDirective, \"slug\" | \"directiveClass\">,\n): DirectiveRenderer | null {\n  return (\n    registry.bySlug.get(directive.slug) ?? registry.byClass.get(directive.directiveClass) ?? null\n  );\n}\n\n/** Tests only. */\nexport function resetDirectiveRenderers(): void {\n  registry.bySlug.clear();\n  registry.byClass.clear();\n}\n","\"use client\";\n\n/**\n * \"Apply\" for a side-effect Kind Directive that arrived as CONTENT.\n *\n * THE POSITION RULE, honored exactly: a directive inside content NEVER\n * auto-executes — that is the guard against untrusted content mutating things.\n * But \"does not auto-execute\" was never \"is inert\": the user seeing it must be\n * able to say yes. This button IS that yes, through the host's `confirm` seam\n * (`POST /directives/confirm`, re-validated server-side, run as the user).\n *\n * No `confirm` seam → NO button. A control that cannot do its job is absent,\n * never dead. Only a side-effect class is applicable at all (`parsed.executes`).\n */\n\nimport { useEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport { nounLabel, type DecodedDirective } from \"../directives\";\nimport {\n  useDirectiveHost,\n  useDirectiveScope,\n  type DirectiveRecordRef,\n  type DirectiveShell,\n} from \"./directive-host\";\nimport { TARGETING_CLASSES, itemRecordId, recordFallbackName } from \"./item-changes\";\nimport { noteRecordChanged } from \"./record-values\";\nimport { failureWords } from \"./failure-words\";\nimport { AlertIcon, CheckCircleIcon, LoaderIcon, PlayIcon, RotateCcwIcon } from \"./icons\";\n\n/** The records an update/delete names — re-read wherever they are shown once it ran. */\nfunction announceChangedRecords(directive: DecodedDirective, items: Record<string, unknown>[]): void {\n  if (!TARGETING_CLASSES.has(directive.directiveClass)) return;\n  for (const item of items) {\n    const id = itemRecordId(item);\n    if (id) noteRecordChanged(id);\n  }\n}\n\ntype ApplyState =\n  // Reading the server ledger on mount: has this block already run? Nothing\n  // offers a write until it answers (reviewer defect 5, 2026-10-02).\n  | { status: \"checking\" }\n  // The ledger has a claim but no result: another request is applying it now.\n  | { status: \"finishing\" }\n  | { status: \"idle\" }\n  // The host's `ask` dialog is up. NOTHING is applying yet, so nothing says so.\n  | { status: \"asking\" }\n  | { status: \"applying\"; startedAt: number }\n  | {\n      status: \"applied\";\n      applied: number;\n      failed: number;\n      message: string | null;\n      /** The LATEST apply's records — after \"Run again\", the newest copy. */\n      records: DirectiveRecordRef[];\n      /** How many times this block has applied (1 + every \"Run again\"). */\n      copies: number;\n      /** An update's replaced values, by item index — the record of the change. */\n      before: ReadonlyArray<Record<string, unknown> | null> | null;\n    }\n  | { status: \"error\"; message: string };\n\n/**\n * 🚨 AN APPLY BELONGS TO THE BLOCK, NOT TO THE COMPONENT (G6A review,\n * 2026-10-02). A note re-renders its blocks while a confirm dialog is open, so\n * the card that asked was unmounted and a fresh one mounted in its place. The\n * apply still ran — but its result was handed to the card that was gone, and\n * the new card, which had read the ledger BEFORE the write landed, offered\n * \"Apply\" for an update that had already run.\n *\n * So once a person says yes, the apply's progress and outcome are kept HERE,\n * per apply authority — the host's `confirm` function, which ran it (a host\n * object may be rebuilt on every render; its `confirm` is the stable seam) — keyed by the block's identity (slug + items + where it renders — the\n * same namespace the ledger keys in), and every card drawing that block shows\n * them, whenever it mounted. Component state keeps only what is the instance's own:\n * the ledger read and the open question.\n */\ntype ApplyOutcome = Extract<ApplyState, { status: \"applying\" | \"applied\" | \"error\" }>;\nconst applyOutcomes = new WeakMap<object, Map<string, ApplyOutcome>>();\n/** The key when a host has no `confirm`: nothing can apply, so nothing is ever held. */\nconst EMPTY_AUTHORITY = {};\nconst outcomeListeners = new Set<() => void>();\n\nfunction outcomesOf(host: object): Map<string, ApplyOutcome> {\n  let held = applyOutcomes.get(host);\n  if (!held) {\n    held = new Map();\n    applyOutcomes.set(host, held);\n  }\n  return held;\n}\n\nfunction publishOutcome(host: object, identity: string, outcome: ApplyOutcome): void {\n  outcomesOf(host).set(identity, outcome);\n  for (const listener of outcomeListeners) listener();\n}\n\nfunction subscribeOutcomes(listener: () => void): () => void {\n  outcomeListeners.add(listener);\n  return () => {\n    outcomeListeners.delete(listener);\n  };\n}\n\n/** The outcome this page holds for a block, or null. */\nfunction useApplyOutcome(host: object, identity: string): ApplyOutcome | null {\n  return useSyncExternalStore(\n    subscribeOutcomes,\n    () => applyOutcomes.get(host)?.get(identity) ?? null,\n    () => null,\n  );\n}\n\n/** How often a card re-reads a block another request is mid-applying. */\nconst FINISH_POLL_MS = 2_000;\n/** ~1 minute (the server's own claim wait is 45 s), then Apply is offered — idempotent. */\nconst FINISH_POLLS_MAX = 30;\n\n/**\n * What the Apply control knows about its block, for the rest of the card:\n *  - `pending` — the ledger has not answered yet;\n *  - `open`    — nothing applied: rows compare against the record as it is now;\n *  - `applied` — the change happened: rows draw it from `before` (the server's\n *                record of what it replaced), never from a live re-read, which\n *                now holds the NEW value.\n */\nexport type DirectiveApplyPhase =\n  | { phase: \"pending\" }\n  | { phase: \"open\" }\n  | { phase: \"applied\"; before: ReadonlyArray<Record<string, unknown> | null> | null };\n\n/** Does this card read the ledger before offering Apply? (One rule, card and control.) */\nexport function readsApplyLedger(\n  host: { applyState?: unknown; confirm?: unknown },\n  directive: DecodedDirective,\n): boolean {\n  return !!host.applyState && !!host.confirm && directive.parsed.executes && directive.items.length > 0;\n}\n\nexport interface ApplyDirectiveButtonProps {\n  directive: DecodedDirective;\n  label?: string;\n  /** How many things this will write — shown during the wait so a long apply reads as work, not a frozen spinner. */\n  itemCount?: number;\n  onApplied?: () => void;\n  /** Told whenever what the control knows about its block changes. */\n  onPhase?: (phase: DirectiveApplyPhase) => void;\n  /**\n   * The block would change nothing (an update that sets no field). Apply stays\n   * — validation offers, never blocks — but muted, with the reason beside it.\n   */\n  nothingToChange?: boolean;\n}\n\nexport function ApplyDirectiveButton({\n  directive,\n  label = \"Apply\",\n  itemCount,\n  onApplied,\n  onPhase,\n  nothingToChange = false,\n}: ApplyDirectiveButtonProps) {\n  const host = useDirectiveHost();\n  const scope = useDirectiveScope();\n  // WHERE the card sits is the namespace its apply keys in: a chat message's\n  // conversation (the SAME key the agent proposal's Approve uses — never two\n  // applies of one action), else the person's own content.\n  const conversationId = scope.conversationId || undefined;\n  const items = directive.items;\n  // The ledger read runs only where an apply could: a side effect, a confirm\n  // seam, something to write. Everything else starts (and stays) where it was.\n  const readsLedger = readsApplyLedger(host, directive);\n  const initial: ApplyState = readsLedger ? { status: \"checking\" } : { status: \"idle\" };\n  const [state, setState] = useState<ApplyState>(initial);\n  const [elapsed, setElapsed] = useState(0);\n  // \"Run again\" asks from the tally; the tally stays on screen while it asks\n  // (only its own button goes quiet), never swapped for a disabled Apply.\n  const [askingAgain, setAskingAgain] = useState(false);\n  const startedAt = useRef<number | null>(null);\n\n  // 🚨 THE STATE BELONGS TO THE BLOCK, NOT TO THE SLOT (reviewer, 2026-10-02).\n  // A host that keys its blocks by POSITION hands this same instance a\n  // DIFFERENT directive when a block is inserted above it. The state used to\n  // stay: an applied Update card flipped back to \"Apply\" (the instance that\n  // had been an idle card now held the Update, and the ledger's \"applied\"\n  // answer was ignored because the state was not \"checking\"), and the\n  // opposite — one card's tally drawn on another block — was one insert away.\n  // When the block this instance draws changes, everything it knew resets and\n  // the ledger is asked again about the block it now holds.\n  const identity = JSON.stringify([directive.slug, items, conversationId ?? null]);\n  const [stateFor, setStateFor] = useState(identity);\n  if (stateFor !== identity) {\n    setStateFor(identity);\n    setState(initial);\n    setAskingAgain(false);\n    setElapsed(0);\n  }\n  // What this page knows about the block's apply wins over this instance's own\n  // ledger read — except while this instance is asking its own question.\n  const shared = useApplyOutcome(host.confirm ?? EMPTY_AUTHORITY, identity);\n  const view: ApplyState = state.status === \"asking\" || !shared ? state : shared;\n  // An apply that finishes after its block left this slot must not land here.\n  const currentIdentity = useRef(identity);\n  useEffect(() => {\n    currentIdentity.current = identity;\n  }, [identity]);\n  const nounText = nounLabel(directive.noun, host.nouns);\n\n  // THE CARD SURVIVES A RELOAD. Component state dies with the page; the\n  // server's action ledger does not. Ask it once on mount — and every\n  // FINISH_POLL_MS while another request is mid-apply — and render exactly\n  // what a fresh apply would have left on screen.\n  const shellKey = readsLedger ? JSON.stringify([directive.slug, items, conversationId ?? null]) : \"\";\n  const read = host.applyState;\n  const report = host.reportError;\n  useEffect(() => {\n    if (!shellKey || !read) return;\n    // Parsed back from the key so the effect depends on the shell's CONTENT,\n    // never on the per-render identity of `directive.items`.\n    const [slug, shellItems, inConversation] = JSON.parse(shellKey) as [\n      string,\n      Record<string, unknown>[],\n      string | null,\n    ];\n    const shell: DirectiveShell = { __kind: slug, items: shellItems };\n    if (inConversation) shell.conversationId = inConversation;\n    let live = true;\n    let polls = 0;\n    let timer: ReturnType<typeof setTimeout> | null = null;\n    const ask = () => {\n      read(shell)\n        .then((answer) => {\n          if (!live) return;\n          if (answer.state === \"applied\") {\n            setState((prev) =>\n              prev.status === \"checking\" || prev.status === \"finishing\"\n                ? {\n                    status: \"applied\",\n                    applied: shellItems.length,\n                    failed: 0,\n                    message: answer.message?.trim() ? answer.message.trim() : null,\n                    records: answer.records ?? [],\n                    copies: Math.max(1, answer.copies ?? 1),\n                    before: answer.before ?? null,\n                  }\n                : prev,\n            );\n          } else if (answer.state === \"in_flight\" && polls < FINISH_POLLS_MAX) {\n            polls += 1;\n            setState((prev) => (prev.status === \"checking\" || prev.status === \"finishing\" ? { status: \"finishing\" } : prev));\n            timer = setTimeout(ask, FINISH_POLL_MS);\n          } else {\n            // Not applied — or still \"in flight\" after a minute, when Apply is\n            // the honest offer: confirm is idempotent and replays the receipt.\n            setState((prev) => (prev.status === \"checking\" || prev.status === \"finishing\" ? { status: \"idle\" } : prev));\n          }\n        })\n        .catch((error: unknown) => {\n          if (!live) return;\n          const why = error instanceof Error && error.message ? error.message : String(error);\n          (report ?? console.error)(\n            `[kind-directives] Could not read whether ${slug} was already applied: ${why}`,\n          );\n          setState((prev) => (prev.status === \"checking\" || prev.status === \"finishing\" ? { status: \"idle\" } : prev));\n        });\n    };\n    ask();\n    return () => {\n      live = false;\n      if (timer) clearTimeout(timer);\n    };\n  }, [shellKey, read, report]);\n\n  // The rest of the card draws its rows from what this control knows.\n  const appliedClean = view.status === \"applied\" && view.failed === 0 ? view : null;\n  const appliedBefore = appliedClean ? appliedClean.before : null;\n  const phaseKey =\n    view.status === \"checking\" || view.status === \"finishing\"\n      ? \"pending\"\n      : appliedClean\n        ? `applied:${JSON.stringify(appliedBefore)}`\n        : \"open\";\n  useEffect(() => {\n    if (!onPhase) return;\n    if (phaseKey === \"pending\") onPhase({ phase: \"pending\" });\n    else if (phaseKey === \"open\") onPhase({ phase: \"open\" });\n    else onPhase({ phase: \"applied\", before: appliedBefore });\n  }, [phaseKey, onPhase, appliedBefore]);\n\n  // An honest clock beats a fake progress bar — counted from when the apply\n  // started, so a card mounted mid-apply shows the true elapsed time.\n  const applyingSince = view.status === \"applying\" ? view.startedAt : null;\n  useEffect(() => {\n    if (applyingSince === null) return;\n    startedAt.current = applyingSince;\n    const id = setInterval(\n      () => setElapsed(Math.round((Date.now() - (startedAt.current ?? 0)) / 1000)),\n      1000,\n    );\n    return () => clearInterval(id);\n  }, [applyingSince]);\n\n  if (!directive.parsed.executes) return null;\n  const confirm = host.confirm;\n  if (!confirm) return null;\n\n  /**\n   * `again` = \"Run again\": the ledger already holds this block, so a plain\n   * confirm would only replay its receipt. The person is asked in words that\n   * say it runs a SECOND time, and a yes sends `force`.\n   */\n  async function handleApply(again = false) {\n    if (!confirm) return;\n    // A \"no\" to Run again leaves the tally exactly where it was.\n    const prior = view;\n    const askedFor = identity;\n    const stillHere = () => currentIdentity.current === askedFor;\n    const priorCopies = view.status === \"applied\" ? view.copies : 0;\n    // THE STATUS TELLS THE TRUTH (reviewer, 2026-09-30): the card used to read\n    // \"Applying 1 item…\" while the confirm dialog was still asking. Ask first,\n    // idle; only a yes moves the control to \"applying\".\n    if (host.ask) {\n      if (again) setAskingAgain(true);\n      else setState({ status: \"asking\" });\n      let ok = false;\n      try {\n        ok = await host.ask({\n          directive,\n          items,\n          nounLabel: nounText,\n          ...(again ? { again: true } : {}),\n        });\n      } catch (error) {\n        if (!stillHere()) return;\n        setAskingAgain(false);\n        setState({\n          status: \"error\",\n          message:\n            error instanceof Error && error.message\n              ? error.message\n              : \"We could not ask you to confirm this, so nothing was done.\",\n        });\n        return;\n      }\n      if (!stillHere()) return;\n      setAskingAgain(false);\n      if (!ok) {\n        // Declining is not an error: the card is exactly as it was.\n        setState(again ? prior : { status: \"idle\" });\n        return;\n      }\n    }\n    setElapsed(0);\n    // The question is answered: this instance stops asking.\n    setState((prev) => (prev.status === \"asking\" ? { status: \"idle\" } : prev));\n    // From the yes on, the apply is the BLOCK's: published by identity, so a\n    // card that re-mounts mid-apply (or after it) shows the true outcome.\n    publishOutcome(confirm, askedFor, { status: \"applying\", startedAt: Date.now() });\n    try {\n      const shell: DirectiveShell = { __kind: directive.slug, items };\n      if (conversationId) shell.conversationId = conversationId;\n      if (again) shell.force = true;\n      let result: Awaited<ReturnType<typeof confirm>>;\n      try {\n        result = await confirm(shell);\n      } finally {\n        // Every record this apply may have touched is re-read wherever it is\n        // shown — even a failed apply may have written some items.\n        announceChangedRecords(directive, items);\n      }\n      for (const record of result.records ?? []) noteRecordChanged(record.id);\n      publishOutcome(confirm, askedFor, {\n        status: \"applied\",\n        applied: result.applied,\n        failed: result.failed,\n        message: result.message?.trim() ? result.message.trim() : null,\n        records: result.records ?? [],\n        // \"Run again\" made one more; a first apply (or a replay of one) is one.\n        copies: again ? Math.max(1, priorCopies) + 1 : Math.max(1, priorCopies),\n        // \"Run again\" wrote the same values over themselves; what the FIRST\n        // apply replaced is still the change this block made.\n        before:\n          again && prior.status === \"applied\" && prior.before\n            ? prior.before\n            : (result.before ?? null),\n      });\n      if (stillHere()) onApplied?.();\n    } catch (error) {\n      publishOutcome(confirm, askedFor, {\n        status: \"error\",\n        message:\n          error instanceof Error && error.message\n            ? error.message\n            : \"That couldn't be applied just now. Please try again.\",\n      });\n    }\n  }\n\n  if (view.status === \"applied\") {\n    const bad = view.failed > 0;\n    const trashed = directive.directiveClass === \"delete\";\n    const label = nounText;\n    // THE TALLY IS A DOOR (no dead ends): the records the apply wrote, each by\n    // name and each opening, beside the server's own sentence when it sent one.\n    const records = host.renderRecord ? view.records : [];\n    return (\n      <span\n        className={`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs ${bad ? \"text-destructive\" : \"text-primary\"}`}\n        data-apply-state=\"applied\"\n      >\n        {/* The glyph rides WITH the sentence: a long server sentence wraps\n            beside it, never leaving the icon alone on a line (phone width). */}\n        <span className=\"inline-flex min-w-0 items-start gap-1\">\n          {bad ? (\n            <AlertIcon className=\"matrx-line-icon-sm\" />\n          ) : (\n            <CheckCircleIcon className=\"matrx-line-icon-sm\" />\n          )}\n          {bad ? (\n            <FailureNotice\n              words={failureWords(\n                {\n                  raw: view.message ?? `${view.failed} failed`,\n                  directiveClass: directive.directiveClass,\n                  noun: directive.noun,\n                  nounLabel: nounText,\n                  failed: view.failed,\n                  total: view.applied + view.failed,\n                },\n                host.explainFailure,\n              )}\n              raw={view.message}\n            />\n          ) : (\n            <span className=\"min-w-0\">{view.message ?? `Applied ${view.applied}`}</span>\n          )}\n        </span>\n        {view.copies > 1 ? (\n          <span\n            className=\"shrink-0 text-muted-foreground\"\n            data-apply-copies={view.copies}\n            title={\n              records.length > 0\n                ? directive.directiveClass === \"create\"\n                  ? \"Links to the latest copy.\"\n                  : \"Links to the latest run.\"\n                : undefined\n            }\n          >\n            {directive.directiveClass === \"create\" ? `${view.copies} copies` : `Ran ${view.copies} times`}\n          </span>\n        ) : null}\n        {records.map((record) => (\n          <span key={`${record.noun}:${record.id}`} className=\"inline-flex min-w-0 items-center\">\n            {host.renderRecord?.({\n              ...record,\n              fallback: recordFallbackName(label),\n              context: \"applied\",\n              trashed,\n            })}\n          </span>\n        ))}\n        {/* A failed item was never ledgered, so a plain re-apply retries only\n            it. A clean tally offers \"Run again\" — the one way past the\n            ledger's dedup, asked in words that say it runs a second time. */}\n        <button\n          type=\"button\"\n          disabled={askingAgain}\n          onClick={() => void handleApply(!bad)}\n          className=\"inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded px-1 py-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-50\"\n          data-apply-action={bad ? \"retry\" : \"run-again\"}\n        >\n          <RotateCcwIcon className=\"h-3 w-3\" />\n          {bad ? \"Retry\" : \"Run again\"}\n        </button>\n      </span>\n    );\n  }\n\n  if (view.status === \"checking\") {\n    return (\n      <span\n        className=\"inline-flex h-6 w-6 items-center justify-center text-muted-foreground\"\n        role=\"status\"\n        aria-label=\"Checking whether this already ran\"\n        data-apply-state=\"checking\"\n      >\n        <LoaderIcon className=\"h-3.5 w-3.5 animate-spin\" />\n      </span>\n    );\n  }\n\n  if (view.status === \"finishing\") {\n    return (\n      <span\n        className=\"inline-flex items-center gap-1 text-xs text-muted-foreground\"\n        role=\"status\"\n        data-apply-state=\"finishing\"\n      >\n        <LoaderIcon className=\"h-3.5 w-3.5 animate-spin\" />\n        Finishing…\n      </span>\n    );\n  }\n\n  // THE CONFIRM OPENS WITH THE RECORD IN HAND (G10B review, 2026-10-02: the\n  // first update confirm of a session took ~2 s). An update/delete's confirm\n  // reads the records it names; pointing at (or focusing) Apply starts that\n  // read through the host's `readRecord`, so a host that keeps a recent read\n  // hands the confirm the record instead of a second round trip.\n  const warm = () => {\n    const read = host.readRecord;\n    if (!read || !TARGETING_CLASSES.has(directive.directiveClass)) return;\n    for (const item of items) {\n      const id = itemRecordId(item);\n      if (id) void read({ noun: directive.noun, id }).catch(() => null);\n    }\n  };\n\n  // A delete LOOKS like one before the click, not only inside the confirm\n  // (reviewer, 2026-10-02: the Delete card's Apply was the same neutral gray\n  // as a create's).\n  const destructive = directive.directiveClass === \"delete\";\n  // NOTHING TO CHANGE, SHOWN BEFORE THE CLICK (G6A review, 2026-10-02): an\n  // update that sets no field still offered a full-weight \"Update\". The control\n  // stays live — validation offers, never blocks — but reads muted, with why.\n  const muted = nothingToChange && view.status === \"idle\";\n  return (\n    <span className=\"flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1\">\n      {/* A button never wraps its label: the REASON wraps, the button holds. */}\n      {muted ? (\n        <span className=\"min-w-0 text-xs text-muted-foreground\" data-apply-nothing=\"\">\n          Nothing to change\n        </span>\n      ) : null}\n      <button\n        type=\"button\"\n        onClick={() => void handleApply()}\n        onPointerEnter={warm}\n        onFocus={warm}\n        disabled={view.status === \"applying\" || view.status === \"asking\" || items.length === 0}\n        data-apply-tone={muted ? \"muted\" : destructive ? \"destructive\" : \"default\"}\n        title={muted ? \"Applying it changes nothing.\" : undefined}\n        className={`inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 py-1 text-xs font-medium disabled:opacity-50 ${\n          muted\n            ? \"border-border/60 bg-background text-muted-foreground hover:bg-accent\"\n            : destructive\n            ? \"border-destructive/50 bg-background text-destructive hover:bg-destructive/10\"\n            : \"border-border bg-background hover:bg-accent\"\n        }`}\n      >\n        {view.status === \"applying\" ? (\n          <LoaderIcon className=\"h-3.5 w-3.5 animate-spin\" />\n        ) : (\n          <PlayIcon className=\"h-3.5 w-3.5\" />\n        )}\n        {view.status === \"applying\"\n          ? `Applying${itemCount ? ` ${itemCount} ${itemCount === 1 ? \"item\" : \"items\"}` : \"\"}…${elapsed ? ` ${elapsed}s` : \"\"}`\n          : label}\n      </button>\n      {view.status === \"error\" ? (\n        <span\n          className=\"inline-flex max-w-sm items-start gap-1 text-xs text-destructive\"\n          data-apply-state=\"error\"\n        >\n          <AlertIcon className=\"matrx-line-icon-sm\" />\n          <FailureNotice\n            words={failureWords(\n              {\n                raw: view.message,\n                directiveClass: directive.directiveClass,\n                noun: directive.noun,\n                nounLabel: nounText,\n              },\n              host.explainFailure,\n            )}\n            raw={view.message}\n          />\n        </span>\n      ) : null}\n    </span>\n  );\n}\n\n/**\n * What failed and what to do, in plain words — and the technical text behind\n * \"Details\" for whoever debugs it. Never the raw text as the sentence.\n */\nfunction FailureNotice({\n  words,\n  raw,\n}: {\n  words: { what: string; next: string; details?: string };\n  raw: string | null;\n}) {\n  const [open, setOpen] = useState(false);\n  // The host's worded details replace the raw text only when there IS raw text.\n  const detail = raw?.trim() ? (words.details?.trim() || raw.trim()) : \"\";\n  return (\n    <span className=\"flex min-w-0 flex-col gap-0.5\" data-apply-failure>\n      <span className=\"min-w-0\">\n        {words.what} {words.next}\n        {detail ? (\n          <button\n            type=\"button\"\n            onClick={() => setOpen((v) => !v)}\n            aria-expanded={open}\n            className=\"ml-1 whitespace-nowrap underline underline-offset-2 hover:no-underline\"\n            data-apply-failure-details-toggle\n          >\n            {open ? \"Hide details\" : \"Details\"}\n          </button>\n        ) : null}\n      </span>\n      {open && detail ? (\n        <span\n          className=\"block max-w-sm select-text break-words font-mono text-[11px] text-muted-foreground\"\n          data-apply-failure-details\n        >\n          {detail}\n        </span>\n      ) : null}\n    </span>\n  );\n}\n\nexport default ApplyDirectiveButton;\n","/**\n * WHAT A DIRECTIVE ITEM WILL DO TO AN EXISTING RECORD — for the card, the\n * confirm dialog, and anything else that must say it before the click.\n *\n * WHY (reviewer, 2026-09-30): an Update card and a Delete card showed each item\n * as \"Item\" — they never named the record they would change, and an Update card\n * never said what it would change. The item-summary helpers name a thing to be\n * CREATED from its own fields; an update or delete item carries the TARGET's id\n * and, for an update, the NEW values — so its \"title\" field is the new title,\n * not the name of the record being changed. Naming the target is the host's\n * live lookup (`DirectiveHost.renderRecord`); what changes is right here.\n *\n * Law: common-docs/policies/no-dead-ends.md — the sentence\n * names what changes.\n */\n\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\nimport { catalogItemTitle } from \"../directives\";\n\n/** Classes whose items point at an EXISTING record by `id`. */\nexport const TARGETING_CLASSES: ReadonlySet<string> = new Set([\"update\", \"delete\"]);\n\n/** Never a change: identity and plumbing. */\nconst NOT_A_CHANGE = new Set<string>([\"__kind\", \"id\"]);\n\n/**\n * How long a changed value may read before it is shortened. A value someone\n * must judge — a title, a status, a date — is always whole (G8A review: a 60\n * cap plus CSS truncation cut \"Review4 tasks…\" on a phone); only a body of\n * prose longer than this is shortened, whole on hover and in View/Copy.\n */\nexport const CHANGE_VALUE_MAX = 280;\n\n/** The id of the existing record an update/delete item targets, or null. */\nexport function itemRecordId(item: Record<string, unknown>): string | null {\n  const id = item.id;\n  if (typeof id === \"string\" && id.trim()) return id.trim();\n  if (typeof id === \"number\") return String(id);\n  return null;\n}\n\n/** \"due_date\" → \"Due Date\" — THE humanizer; underscores read as developer output. */\nexport function fieldLabel(key: string): string {\n  return humanizeIdentifier(key) || key;\n}\n\n/**\n * THE ONE FIELD-LABEL RULE for a directive — card rows, card facts and the\n * host's confirm: the noun's title column reads \"Title\" whatever it is stored\n * as (a workbook's `workbook_name`, a note's `label`), every other field reads\n * through THE humanizer. A new workbook card said \"workbook name\" while its\n * confirm said \"Title\" (G8A review, 2026-10-02).\n */\nexport function directiveFieldLabel(key: string, titleColumn: string | null | undefined): string {\n  return titleColumn && key === titleColumn ? \"Title\" : fieldLabel(key);\n}\n\n/**\n * The app's word for ONE stored value of ONE field — \"incomplete\" on a task\n * reads \"Inbox\", \"high\" reads \"High\". The host answers it for its pick-list\n * fields; null → the value as stored.\n */\nexport type DirectiveValueWord = (field: string, value: string) => string | null;\n\n/**\n * The name a NEW item carries, or null when it has none — the one rule the card\n * and a host's confirm share. `catalogItemTitle`'s last resort (\"Item\", \"Item 2 of 3\")\n * is a placeholder, never a name: a create with an empty title used to ask\n * \"Create project Item?\" and its card row read \"Item\" (G10B review, 2026-10-02).\n */\nexport function itemOwnName(item: Record<string, unknown>, titleColumn: string | null): string | null {\n  // With two items the last resort is exactly \"Item 1 of 2\"; a real name wins first.\n  const probe = catalogItemTitle(item, titleColumn, 0, 2);\n  return probe === \"Item 1 of 2\" ? null : probe;\n}\n\n/** What a nameless new item is called — said as such, never a placeholder name. */\nexport const NO_TITLE_WORD = \"No title\";\n\n/** How an empty value reads — before or after, on the card and in the confirm. */\nexport const EMPTY_VALUE_WORD = \"None\";\n\n\n/**\n * What a record is called when its name cannot be read: its TYPE (\"Task\").\n * Never its id, in any slot — text, tooltip or screen-reader label. It used to\n * be \"Task a8a00001\", and a link to a record that no longer exists hovered\n * \"Open Task a8a00001\" (G10B review, 2026-10-02). The host says WHY the name is\n * missing (not found, no access) beside it.\n */\nexport function recordFallbackName(nounLabel: string): string {\n  return nounLabel.trim() || \"Record\";\n}\n\n/** One value as a row reads it: shortened, the whole of it, and whether it is empty. */\nexport interface ChangeValue {\n  value: string;\n  full: string;\n  clears: boolean;\n}\n\nexport interface ItemChange extends ChangeValue {\n  key: string;\n  /** \"Due date\". */\n  label: string;\n  /**\n   * What the field holds NOW, when the host could read the record — so an\n   * update reads \"old → new\", never just the new value (reviewer, 2026-10-02).\n   * Absent when the current record is unknown.\n   */\n  before?: ChangeValue;\n  /** True when the record already holds exactly this value — nothing changes. */\n  same?: boolean;\n}\n\n/** One value, described for a change row (`value` shortened, `full` whole). */\nexport function describeChangeValue(value: unknown, word?: (value: string) => string | null): ChangeValue {\n  return describeValue(value, word);\n}\n\nconst EMPTY: ChangeValue = { value: EMPTY_VALUE_WORD, full: EMPTY_VALUE_WORD, clears: true };\n\nfunction describeValue(value: unknown, word?: (value: string) => string | null): ChangeValue {\n  if (value === null || value === undefined) return EMPTY;\n  if (typeof value === \"string\") {\n    const trimmed = value.trim();\n    if (!trimmed) return EMPTY;\n    // ONE VALUE, ONE WORD (G8A review, 2026-10-02: \"Status incomplete →\n    // completed\"). A value of a pick-list field reads as the app's word for it\n    // — the host knows which fields are pick-lists and their words; anything\n    // else (free text, a slug) is shown exactly as written.\n    const named = word?.(trimmed) ?? null;\n    if (named) return { value: named, full: named, clears: false };\n    const oneLine = trimmed.replace(/\\s+/g, \" \");\n    const shown = oneLine.length > CHANGE_VALUE_MAX ? `${oneLine.slice(0, CHANGE_VALUE_MAX - 1)}…` : oneLine;\n    return { value: shown, full: trimmed, clears: false };\n  }\n  if (typeof value === \"number\" || typeof value === \"boolean\") {\n    return { value: String(value), full: String(value), clears: false };\n  }\n  if (Array.isArray(value)) {\n    const n = value.length;\n    const text = n === 0 ? EMPTY_VALUE_WORD : `${n} ${n === 1 ? \"entry\" : \"entries\"}`;\n    return { value: text, full: safeJson(value), clears: n === 0 };\n  }\n  const n = Object.keys(value as object).length;\n  const text = n === 0 ? EMPTY_VALUE_WORD : `${n} ${n === 1 ? \"field\" : \"fields\"}`;\n  return { value: text, full: safeJson(value), clears: n === 0 };\n}\n\nfunction safeJson(value: unknown): string {\n  try {\n    return JSON.stringify(value, null, 2);\n  } catch {\n    return String(value);\n  }\n}\n\nfunction sameValue(a: unknown, b: unknown): boolean {\n  if (a === b) return true;\n  if (a === null || a === undefined || b === null || b === undefined) {\n    // An empty string and a missing value both read \"None\".\n    const emptyA = a === null || a === undefined || a === \"\";\n    const emptyB = b === null || b === undefined || b === \"\";\n    return emptyA && emptyB;\n  }\n  if (typeof a === \"object\" || typeof b === \"object\") return safeJson(a) === safeJson(b);\n  return false;\n}\n\n/**\n * Every field an UPDATE item sets, in the order the item carries them — ALL of\n * them, never a sample: a person approving an overwrite sees the whole of it.\n *\n * Pass `current` — the record as it is now (`DirectiveHost.readRecord`) — and\n * each change also carries what it REPLACES (`before`) and whether it changes\n * anything at all (`same`). A field the record does not carry gets no `before`.\n */\nexport interface ItemChangesOptions {\n  /**\n   * The noun's title column (catalog `title_column` — `nounTitleColumn`). It is\n   * labeled \"Title\" whatever it is called: a note's title is stored in\n   * `label`, and the confirm said \"Label\" while the form said \"Title\"\n   * (reviewer, 2026-10-02). The same rule the directive builder's form uses.\n   */\n  titleColumn?: string | null;\n  /** The app's word for a stored value (`DirectiveHost.valueLabel`, bound to the noun). */\n  valueWord?: DirectiveValueWord | null;\n}\n\nexport function itemChanges(\n  item: Record<string, unknown>,\n  current?: Record<string, unknown> | null,\n  options: ItemChangesOptions = {},\n): ItemChange[] {\n  const out: ItemChange[] = [];\n  const titleColumn = options.titleColumn ?? null;\n  for (const [key, raw] of Object.entries(item)) {\n    if (NOT_A_CHANGE.has(key)) continue;\n    const label = directiveFieldLabel(key, titleColumn);\n    // The title is a name, never a token to translate.\n    const valueWord = options.valueWord;\n    const word =\n      key === titleColumn || !valueWord ? undefined : (v: string) => valueWord(key, v);\n    const change: ItemChange = { key, label, ...describeValue(raw, word) };\n    if (current && Object.prototype.hasOwnProperty.call(current, key)) {\n      change.before = describeValue(current[key], word);\n      change.same = sameValue(current[key], raw);\n    }\n    out.push(change);\n  }\n  return out;\n}\n\n/**\n * 🚨 AN UPDATE THAT WOULD CHANGE NOTHING SAYS SO (G11B review, 2026-10-07: the\n * confirm listed every field \"(no change)\", Apply stayed full-weight, and the\n * run ended \"Updated task. Ran 2 times\"). True when the item sets no field, or\n * when the record was read and EVERY field already holds its new value. A field\n * whose current value is unknown counts as a change — doubt never mutes Apply.\n * ONE rule for the card and the host's confirm.\n */\nexport function changesNothing(changes: ReadonlyArray<ItemChange>): boolean {\n  return changes.every((change) => change.same === true);\n}\n","\"use client\";\n\n/**\n * THE RECORD AS IT IS NOW — read through the host's `readRecord` seam, so an\n * update row (and the host's own confirm) can say what each field REPLACES.\n *\n * 🚨 RE-READ WHENEVER THE RECORD CHANGES (G7, 2026-10-02). It used to be read\n * ONCE per `noun:id`: after Update card A applied, Update card B naming the same\n * record — its row, and a confirm whose body stayed mounted between questions —\n * still said A's OLD value was the old value (\"G6A renamed target\" while the\n * database held \"G6A second rename\"). Every apply now announces the records it\n * touched (`noteRecordChanged`, also the host's door for its own writers) and\n * every read keyed on that record's revision runs again. A host reader that\n * shares in-flight reads keys them by `recordRevision(id)` too, so a read\n * started before the write is never handed to a reader asking after it.\n *\n * A pure hook over a reader FUNCTION rather than the directive-host context:\n * the confirm dialog renders in the host's global dialog layer, outside every\n * `DirectiveHostProvider`, and must read the same values the card does.\n */\n\nimport { useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { DirectiveRecordRef } from \"./directive-host\";\n\nexport type RecordValuesStatus = \"idle\" | \"loading\" | \"ready\" | \"unavailable\";\n\nexport interface RecordValues {\n  /** The record's fields now, or null until (or unless) they are read. */\n  values: Record<string, unknown> | null;\n  status: RecordValuesStatus;\n}\n\nexport type RecordReader = (ref: DirectiveRecordRef) => Promise<Record<string, unknown> | null>;\n\n/**\n * One change counter per record id — bumped by every write this page makes.\n * ONE store per page, not per bundle: every entry of this package (`.`,\n * `./directives`, …) is built self-contained, so module state would be a\n * SEPARATE counter per entry — an apply announced through one entry was never\n * seen by a reader imported through another (found adopting 0.19.0). The store\n * lives in a `Symbol.for` slot on `globalThis`, shared by every copy.\n */\ninterface RevisionStore {\n  revisions: Map<string, number>;\n  listeners: Set<() => void>;\n}\nconst STORE_SLOT = Symbol.for(\"ai-matrx.content-ir.record-revisions\");\nfunction revisionStore(): RevisionStore {\n  const slots = globalThis as unknown as Record<symbol, RevisionStore | undefined>;\n  let store = slots[STORE_SLOT];\n  if (!store) {\n    store = { revisions: new Map(), listeners: new Set() };\n    slots[STORE_SLOT] = store;\n  }\n  return store;\n}\nconst { revisions, listeners } = revisionStore();\n\n/** How many times this page has changed record `id` (0 = never). */\nexport function recordRevision(id: string): number {\n  return revisions.get(id) ?? 0;\n}\n\n/**\n * Record `id` just changed (an apply wrote it, or any other writer on the page).\n * Every `useRecordValues` naming it reads it again.\n */\nexport function noteRecordChanged(id: string): void {\n  if (!id) return;\n  revisions.set(id, recordRevision(id) + 1);\n  for (const listener of listeners) listener();\n}\n\nfunction subscribeRevisions(listener: () => void): () => void {\n  listeners.add(listener);\n  return () => {\n    listeners.delete(listener);\n  };\n}\n\n/** The live revision of record `id`, re-rendering when it changes. */\nexport function useRecordRevision(id: string): number {\n  return useSyncExternalStore(\n    subscribeRevisions,\n    () => recordRevision(id),\n    () => 0,\n  );\n}\n\nexport function useRecordValues(\n  read: RecordReader | undefined,\n  ref: DirectiveRecordRef | null,\n): RecordValues {\n  const revision = useRecordRevision(ref?.id ?? \"\");\n  // The revision is part of the key: a change to the record is a fresh read,\n  // and nothing read before it is shown as \"now\" while the new read runs.\n  const key = ref && read ? `${ref.noun}:${ref.id}#${revision}` : \"\";\n  const [result, setResult] = useState<{ key: string } & RecordValues>({\n    key: \"\",\n    values: null,\n    status: \"idle\",\n  });\n\n  useEffect(() => {\n    if (!key || !read) return;\n    const split = key.indexOf(\":\");\n    const target: DirectiveRecordRef = {\n      noun: key.slice(0, split),\n      id: key.slice(split + 1, key.lastIndexOf(\"#\")),\n    };\n    let live = true;\n    setResult({ key, values: null, status: \"loading\" });\n    read(target)\n      .then((values) => {\n        if (!live) return;\n        setResult({ key, values, status: values ? \"ready\" : \"unavailable\" });\n      })\n      .catch(() => {\n        if (!live) return;\n        // Not knowing the old value is not an error the person must handle:\n        // the row says only what changes, exactly as it did before this seam.\n        setResult({ key, values: null, status: \"unavailable\" });\n      });\n    return () => {\n      live = false;\n    };\n  }, [key, read]);\n\n  if (!key) return { values: null, status: \"idle\" };\n  if (result.key !== key) return { values: null, status: \"loading\" };\n  return { values: result.values, status: result.status };\n}\n","/**\n * THE WORDS A FAILED APPLY SHOWS A PERSON.\n *\n * A card used to print the server's text as its sentence — e.g.\n * \"unknown / non-writable noun 'task'. Writable: [...]\" (G5 review,\n * 2026-10-02). A person needs WHAT failed and WHAT TO DO, in plain words; the\n * technical text is for whoever debugs it, behind a Details toggle. The host\n * may name a failure it recognizes (`DirectiveHost.explainFailure`); otherwise\n * these verb-aware defaults answer.\n */\nimport type { DirectiveFailure, DirectiveFailureWords } from \"./directive-host\";\n\nconst PAST: Record<string, string> = {\n  create: \"created\",\n  update: \"updated\",\n  delete: \"deleted\",\n};\n\n/** The card's own words for a failure the host did not name. */\nexport function defaultFailureWords(failure: DirectiveFailure): DirectiveFailureWords {\n  const verbed = PAST[failure.directiveClass] ?? \"applied\";\n  const noun = failure.nounLabel.trim().toLowerCase() || \"item\";\n  if (failure.failed && failure.total && failure.total > 1) {\n    return {\n      what: `${failure.failed} of ${failure.total} weren't ${verbed}.`,\n      next: \"Retry to try those again.\",\n    };\n  }\n  return {\n    what: `The ${noun} wasn't ${verbed}.`,\n    next: \"Try again in a moment.\",\n  };\n}\n\n/** The host's words when it names this failure, else the default. */\nexport function failureWords(\n  failure: DirectiveFailure,\n  explain?: (failure: DirectiveFailure) => DirectiveFailureWords | null,\n): DirectiveFailureWords {\n  return explain?.(failure) ?? defaultFailureWords(failure);\n}\n","/**\n * content-ir-core/react-directives/icons.tsx — this package's glyph names, as aliases of the ONE glyph home,\n * `@ai-matrx/design-system/icons`. No path data lives here (policy C19: no icon library, and one drawing per\n * glyph); the alias only fixes this package's historical size and stroke. Exports are unchanged.\n */\n\nimport {\n  AlertTriangleIcon as GAlertTriangleIcon,\n  BoxesIcon as GBoxesIcon,\n  ChevronDownIcon as GChevronDownIcon,\n  ChevronRightIcon as GChevronRightIcon,\n  CircleCheckIcon as GCircleCheckIcon,\n  FilePlusIcon as GFilePlusIcon,\n  Loader2Icon as GLoader2Icon,\n  MaximizeIcon as GMaximizeIcon,\n  PencilIcon as GPencilIcon,\n  PlayIcon as GPlayIcon,\n  RotateCcwIcon as GRotateCcwIcon,\n  Trash2Icon as GTrash2Icon,\n  WebhookIcon as GWebhookIcon,\n  type GlyphComponent,\n} from \"@ai-matrx/design-system/icons\";\n\nimport type { ReactElement, SVGProps } from \"react\";\n\ntype IconProps = SVGProps<SVGSVGElement>;\n\nconst sized = (Glyph: GlyphComponent): GlyphComponent => Glyph;\n\nconst FilePlusIcon = sized(GFilePlusIcon);\nconst PencilIcon = sized(GPencilIcon);\nconst TrashIcon = sized(GTrash2Icon);\nconst PlayIcon = sized(GPlayIcon);\nconst WebhookIcon = sized(GWebhookIcon);\nconst BoxesIcon = sized(GBoxesIcon);\nconst ChevronDownIcon = sized(GChevronDownIcon);\nconst ChevronRightIcon = sized(GChevronRightIcon);\nconst MaximizeIcon = sized(GMaximizeIcon);\nconst LoaderIcon = sized(GLoader2Icon);\nconst RotateCcwIcon = sized(GRotateCcwIcon);\nconst CheckCircleIcon = sized(GCircleCheckIcon);\nconst AlertIcon = sized(GAlertTriangleIcon);\n\nexport {\n  FilePlusIcon,\n  PencilIcon,\n  TrashIcon,\n  PlayIcon,\n  WebhookIcon,\n  BoxesIcon,\n  ChevronDownIcon,\n  ChevronRightIcon,\n  MaximizeIcon,\n  LoaderIcon,\n  RotateCcwIcon,\n  CheckCircleIcon,\n  AlertIcon,\n};\n\n/**\n * The icon for a side-effect directive card. THE CLASS LEADS: on a card whose\n * job is \"authorize this write\", the first thing to see is whether this\n * CREATES, CHANGES, or DELETES. A noun override exists only where the platform\n * has a settled visual identity for the thing — agents are a Webhook.\n */\nconst AGENT_NOUNS = new Set([\"create_agent\", \"create_agent_definition\", \"agent\"]);\n\nexport function classIcon(directiveClass: string, noun: string): (p: IconProps) => ReactElement {\n  if (directiveClass === \"action\" && AGENT_NOUNS.has(noun)) return WebhookIcon;\n  switch (directiveClass) {\n    case \"create\":\n      return FilePlusIcon;\n    case \"update\":\n      return PencilIcon;\n    case \"delete\":\n      return TrashIcon;\n    default:\n      return PlayIcon;\n  }\n}\n","\"use client\";\n\n/**\n * The card for a SIDE-EFFECT directive in content — create / update / delete /\n * action. One card for every shape the server can register, so a person is\n * never asked to approve a write they cannot identify.\n *\n * WHY IT EXISTS (Arman, 2026-08-26): the floor it replaced gave \"a name and\n * then an apply button, which essentially tells the user to click apply and\n * conduct a potentially destructive action without any clue as to what this\n * thing is.\"\n *\n * THE DESIGN:\n *  - Say what it IS, from authority — the catalog's own words for the title,\n *    the noun's title column for each item, never a guess.\n *  - Facts, not prose — a few scalar chips; nesting goes to the panel.\n *  - Read before you approve — `View` opens the item through the host's seam,\n *    which wraps the item's OWN kind component (THE DIRECTIVE⇄KIND SEAM).\n *  - Copy is table stakes, at the batch and at the item (host chrome).\n *  - Apply stays exactly where it was — the host's confirm seam.\n *\n * NEVER RETURNS NULL — a shape with no items degrades to a stated line.\n */\n\nimport { useEffect, useState } from \"react\";\nimport { asKindInstance, directiveDisplay, itemFacts, itemSubtitle, nounLabel, nounTitleColumn, type DecodedDirective } from \"../directives\";\nimport {\n  ApplyDirectiveButton,\n  readsApplyLedger,\n  type DirectiveApplyPhase,\n} from \"./ApplyDirectiveButton\";\nimport {\n  TARGETING_CLASSES,\n  changesNothing,\n  directiveFieldLabel,\n  itemChanges,\n  itemOwnName,\n  itemRecordId,\n  NO_TITLE_WORD,\n  recordFallbackName,\n  type DirectiveValueWord,\n  type ItemChange,\n} from \"./item-changes\";\nimport { useRecordValues } from \"./record-values\";\nimport { useDirectiveHost, type DirectiveHost } from \"./directive-host\";\nimport { ChevronDownIcon, ChevronRightIcon, MaximizeIcon, classIcon } from \"./icons\";\n\nexport interface SideEffectDirectiveCardProps {\n  directive: DecodedDirective;\n}\n\n/** The host's value words for one record type, or null when it has none. */\nexport function directiveValueWord(\n  host: Pick<DirectiveHost, \"valueLabel\">,\n  noun: string,\n): DirectiveValueWord | null {\n  const valueLabel = host.valueLabel;\n  return valueLabel ? (field, value) => valueLabel({ noun, field, value }) : null;\n}\n\nfunction omitKey(item: Record<string, unknown>, key: string): Record<string, unknown> {\n  const { [key]: _omitted, ...rest } = item;\n  return rest;\n}\n\n/** How many items render as rows before the rest collapse behind a toggle. */\nconst ROWS_BEFORE_FOLD = 3;\n\nfunction ItemRow({\n  directive,\n  item,\n  index,\n  total,\n  phase,\n  onNothing,\n}: {\n  directive: DecodedDirective;\n  item: Record<string, unknown>;\n  index: number;\n  total: number;\n  phase: DirectiveApplyPhase;\n  onNothing?: ((index: number, nothing: boolean) => void) | undefined;\n}) {\n  const host = useDirectiveHost();\n  // An update/delete item points at a record that ALREADY EXISTS: name THAT\n  // record (its live name, through the host), never the item's own fields —\n  // an update's `title` is the NEW title — and never \"Item\".\n  const recordId = TARGETING_CLASSES.has(directive.directiveClass) ? itemRecordId(item) : null;\n  if (recordId) {\n    return (\n      <TargetRow\n        directive={directive}\n        item={item}\n        recordId={recordId}\n        index={index}\n        phase={phase}\n        onNothing={onNothing}\n      />\n    );\n  }\n  const titleColumn = nounTitleColumn(directive.noun, host.nouns);\n  // A nameless item SAYS it has no title — never \"Item\" posing as its name.\n  const ownName = itemOwnName(item, titleColumn);\n  const title = ownName ?? NO_TITLE_WORD;\n  const subtitle = itemSubtitle(item);\n  // The title column IS the title — never repeated as a fact — and every\n  // fact is labeled and worded exactly as the confirm and the forms do.\n  const valueWord = directiveValueWord(host, directive.noun);\n  const facts = itemFacts(titleColumn ? omitKey(item, titleColumn) : item).map((fact) => ({\n    ...fact,\n    label: directiveFieldLabel(fact.key, titleColumn),\n    value: valueWord?.(fact.key, fact.value) ?? fact.value,\n  }));\n  const kind = host.itemKind?.(directive.slug) ?? null;\n  const display = directiveDisplay(directive.directiveClass, directive.noun, host.nouns);\n  const openItem = host.openItem;\n\n  const body = (\n    <>\n      {/* THE IDENTITY WINS THE SPACE: the title keeps its intrinsic width and the facts give way; on a phone (no facts) it wraps to two lines, never cut to one (G11B). */}\n      <span\n        className={`min-w-0 line-clamp-2 font-medium [overflow-wrap:anywhere] sm:shrink-0 sm:truncate ${ownName ? \"text-foreground\" : \"italic text-muted-foreground\"}`}\n        data-item-name=\"\"\n        data-item-untitled={ownName ? undefined : \"\"}\n      >\n        {title}\n      </span>\n      <span className=\"hidden min-w-0 flex-1 items-baseline gap-2 overflow-hidden sm:flex\">\n        {facts.map((fact) => (\n          <span key={fact.key} className=\"truncate text-[11px] text-muted-foreground\" data-item-fact={fact.key}>\n            {fact.label} <span className=\"text-foreground/80\">{fact.value}</span>\n          </span>\n        ))}\n      </span>\n      {subtitle && facts.length === 0 ? (\n        <span className=\"hidden truncate text-[11px] text-muted-foreground sm:inline\">{subtitle}</span>\n      ) : null}\n      {openItem ? (\n        <MaximizeIcon className=\"ml-auto h-3 w-3 shrink-0 text-muted-foreground\" />\n      ) : null}\n    </>\n  );\n\n  return (\n    <div className=\"flex items-center gap-2 py-1 text-xs\">\n      {openItem ? (\n        <button\n          type=\"button\"\n          onClick={() =>\n            openItem({\n              // Stamped so the panel's kind pipeline types it from its own first key.\n              item: asKindInstance(item, kind) ?? item,\n              itemKind: kind,\n              title,\n              subtitle: `${display.title} · item ${index + 1} of ${total}`,\n              directive,\n              index,\n              total,\n            })\n          }\n          className=\"flex min-w-0 flex-1 items-center gap-2 rounded px-1 py-0.5 text-left hover:bg-accent hover:text-accent-foreground\"\n          title=\"Open to read it\"\n        >\n          {body}\n        </button>\n      ) : (\n        <span className=\"flex min-w-0 flex-1 items-center gap-2 px-1 py-0.5\">{body}</span>\n      )}\n      {host.renderCopy?.({\n        label: ownName ?? `this ${nounLabel(directive.noun, host.nouns)}`,\n        value: item,\n        kind,\n        size: \"xs\",\n      })}\n    </div>\n  );\n}\n\n/**\n * THE CHANGE LIST — every field an update sets, as \"Label  old → new\" when the\n * record's current value is known, \"Label → new\" when it is not. ONE component\n * for the card row and the host's confirm dialog, so the two can never read\n * differently (reviewer, 2026-10-02: the confirm showed only the new value).\n *\n * 🚨 A VALUE SOMEONE MUST JUDGE IS NEVER CUT (G8A review, 2026-10-02): on a\n * phone the card is ~230px and the row read \"Title Review… → Review4 tas…\".\n * Values wrap; below a 20rem container the label, the old value and the new\n * value stack, one per line. Measured on the list's own width (a container\n * query), so a narrow window panel on a desktop gets the same stacking.\n */\nexport function DirectiveChangeList({\n  changes,\n  className,\n}: {\n  changes: ItemChange[];\n  className?: string;\n}) {\n  if (changes.length === 0) {\n    return (\n      <p className={`text-[11px] text-muted-foreground${className ? ` ${className}` : \"\"}`}>\n        Sets no fields — nothing would change.\n      </p>\n    );\n  }\n  return (\n    <ul className={`@container space-y-1${className ? ` ${className}` : \"\"}`} data-directive-changes=\"\">\n      {changes.map((change) => {\n        const before = change.before && !change.same ? change.before : null;\n        return (\n          <li\n            key={change.key}\n            className=\"flex min-w-0 flex-col text-[11px] @xs:flex-row @xs:flex-wrap @xs:items-baseline @xs:gap-x-1.5\"\n            title={\n              before\n                ? `${change.label}: ${before.full} → ${change.full}`\n                : `${change.label} → ${change.full}`\n            }\n            data-change-key={change.key}\n          >\n            <span className=\"shrink-0 text-muted-foreground\">{change.label}</span>\n            {before ? (\n              <span\n                className=\"min-w-0 text-muted-foreground line-through [overflow-wrap:anywhere]\"\n                data-change-before=\"\"\n              >\n                {before.value}\n              </span>\n            ) : null}\n            <span className=\"flex min-w-0 items-baseline gap-1.5\">\n              <span aria-hidden className=\"shrink-0 text-muted-foreground\">\n                →\n              </span>\n              <span\n                className={`min-w-0 [overflow-wrap:anywhere] ${change.clears ? \"italic text-muted-foreground\" : \"text-foreground\"}`}\n                data-change-after=\"\"\n              >\n                {change.value}\n              </span>\n              {change.same ? <span className=\"shrink-0 text-muted-foreground\">(no change)</span> : null}\n            </span>\n          </li>\n        );\n      })}\n    </ul>\n  );\n}\n\n/**\n * ONE row for an item that changes an EXISTING record: the record by its live\n * name (a way to open it, through `renderRecord`), then — for an update —\n * every field it sets, \"Due date 2026-10-01 → 2026-10-15\" (the old value read\n * through `readRecord` when the host can).\n */\nfunction TargetRow({\n  directive,\n  item,\n  recordId,\n  index,\n  phase,\n  onNothing,\n}: {\n  directive: DecodedDirective;\n  item: Record<string, unknown>;\n  recordId: string;\n  index: number;\n  phase: DirectiveApplyPhase;\n  onNothing?: ((index: number, nothing: boolean) => void) | undefined;\n}) {\n  const host = useDirectiveHost();\n  const fallback = recordFallbackName(nounLabel(directive.noun, host.nouns));\n  const isUpdate = directive.directiveClass === \"update\";\n  // 🚨 THE OLD VALUE OF A CHANGE THAT HAPPENED COMES FROM THE RECORD OF THE\n  // CHANGE (G6A review, 2026-10-02). A live read after the apply answers the NEW\n  // value, so an applied card said \"Title → X (no change)\". Live values are read\n  // only while the block is still open; once applied, the server's `before` is\n  // the old value — and without it the row says only what each field was set to.\n  // Until the ledger answers, neither: no comparison is better than a wrong one.\n  const readsLive = isUpdate && phase.phase === \"open\";\n  const live = useRecordValues(\n    readsLive ? host.readRecord : undefined,\n    readsLive ? { noun: directive.noun, id: recordId } : null,\n  );\n  const compareTo =\n    phase.phase === \"applied\" ? (phase.before?.[index] ?? null) : readsLive ? live.values : null;\n  const changes = isUpdate\n    ? itemChanges(item, compareTo, {\n        titleColumn: nounTitleColumn(directive.noun, host.nouns),\n        valueWord: directiveValueWord(host, directive.noun),\n      })\n    : [];\n  // The card mutes Apply when every row would change nothing — known only once\n  // the record is read and the block is still open.\n  const nothing = readsLive && live.values !== null && changesNothing(changes);\n  useEffect(() => {\n    onNothing?.(index, nothing);\n  }, [onNothing, index, nothing]);\n  const name = host.renderRecord ? (\n    host.renderRecord({ noun: directive.noun, id: recordId, fallback, context: \"row\" })\n  ) : (\n    <span className=\"line-clamp-2 min-w-0 font-medium text-foreground [overflow-wrap:anywhere]\">{fallback}</span>\n  );\n\n  return (\n    <div className=\"py-1 text-xs\" data-directive-target={recordId}>\n      <div className=\"flex min-w-0 items-center gap-2\">\n        <span className=\"flex min-w-0 flex-1 items-center gap-1 px-1\">{name}</span>\n        {/* THE LABEL NEVER NAMES AN ID (G9): \"this task\" until the host reads the name. */}\n        {host.renderCopy?.({\n          label: `this ${nounLabel(directive.noun, host.nouns).toLowerCase()}`,\n          value: item,\n          size: \"xs\",\n          record: { noun: directive.noun, id: recordId },\n        })}\n      </div>\n      {isUpdate ? <DirectiveChangeList changes={changes} className=\"mt-0.5 px-1\" /> : null}\n    </div>\n  );\n}\n\nexport function SideEffectDirectiveCard({ directive }: SideEffectDirectiveCardProps) {\n  const host = useDirectiveHost();\n  const [expanded, setExpanded] = useState(false);\n  const items = directive.items;\n  const total = items.length;\n  const display = directiveDisplay(directive.directiveClass, directive.noun, host.nouns);\n  const Icon = classIcon(directive.directiveClass, directive.noun);\n\n  // What the Apply control knows about this block — the rows draw an applied\n  // change from its record, never from a live re-read.\n  const [phase, setPhase] = useState<DirectiveApplyPhase>(() =>\n    readsApplyLedger(host, directive) ? { phase: \"pending\" } : { phase: \"open\" },\n  );\n  // An update that changes nothing — it sets no field, or the record already\n  // holds every value (read by its row) — says so before the click (G11B).\n  const [nothingAt, setNothingAt] = useState<Readonly<Record<number, boolean>>>({});\n  const noteNothing = (index: number, nothing: boolean) =>\n    setNothingAt((prev) => (prev[index] === nothing ? prev : { ...prev, [index]: nothing }));\n  const nothingToChange =\n    directive.directiveClass === \"update\" &&\n    total > 0 &&\n    items.every((item, index) => itemChanges(item).length === 0 || nothingAt[index] === true);\n\n  const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);\n  const hidden = total - shown.length;\n\n  return (\n    <div className=\"my-3 rounded-md border border-border bg-card px-2.5 py-1.5\" data-directive={directive.slug}>\n      <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n        <Icon className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n        <span className=\"text-sm font-medium text-foreground\">{display.title}</span>\n        {display.family ? <span className=\"text-xs text-muted-foreground\">{display.family}</span> : null}\n        <span className=\"text-xs tabular-nums text-muted-foreground\">\n          {total} {total === 1 ? \"item\" : \"items\"}\n        </span>\n        {/* Copy and Apply share ONE row that never wraps: after a run the tally\n            wraps inside itself, so the copy icon never sits alone (G18). */}\n        <div className=\"ml-auto flex min-w-0 max-w-full items-start justify-end gap-1\" data-directive-actions=\"\">\n          {host.renderCopy?.({ label: display.title, value: directive.shell, size: \"icon\" })}\n          <ApplyDirectiveButton\n            directive={directive}\n            itemCount={total}\n            onPhase={setPhase}\n            nothingToChange={nothingToChange}\n          />\n        </div>\n      </div>\n\n      {total === 0 ? (\n        // Stated, never silent: an empty batch is a real (and suspicious) state.\n        <p className=\"mt-1 text-xs text-muted-foreground\">No items — nothing would be written.</p>\n      ) : (\n        <div className=\"mt-0.5 divide-y divide-border/60\">\n          {shown.map((item, i) => (\n            <ItemRow\n              key={i}\n              directive={directive}\n              item={item}\n              index={i}\n              total={total}\n              phase={phase}\n              onNothing={noteNothing}\n            />\n          ))}\n        </div>\n      )}\n\n      {hidden > 0 || expanded ? (\n        <button\n          type=\"button\"\n          onClick={() => setExpanded((v) => !v)}\n          className=\"mt-0.5 inline-flex items-center gap-1 whitespace-nowrap rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:text-foreground\"\n        >\n          {expanded ? <ChevronDownIcon className=\"h-3 w-3\" /> : <ChevronRightIcon className=\"h-3 w-3\" />}\n          {expanded ? \"Show less\" : `Show ${hidden} more`}\n        </button>\n      ) : null}\n    </div>\n  );\n}\n\nexport default SideEffectDirectiveCard;\n","\"use client\";\n\n/**\n * The neutral \"we could not render this, but we will NEVER hide it\" card —\n * THE PREFIX FLOOR of the Kind Directives route.\n *\n * THE RULE THIS ENFORCES: a registered directive renderer must never return\n * `null`. `DirectiveRender` renders a renderer's output verbatim, so a `null`\n * deletes the assistant's whole message block (2026-07-26: a 70KB content plan\n * vanished exactly that way). When a renderer cannot draw its rich view, it\n * renders THIS instead: named by class and noun, itemised by count, with Apply\n * when the class is a side effect and the host can apply.\n */\n\nimport { directiveDisplay, type DecodedDirective } from \"../directives\";\nimport { ApplyDirectiveButton } from \"./ApplyDirectiveButton\";\nimport { useDirectiveHost } from \"./directive-host\";\nimport { BoxesIcon } from \"./icons\";\n\nexport interface DirectiveFallbackCardProps {\n  directive: DecodedDirective;\n  /** Short, human explanation of why the rich renderer degraded. */\n  reason?: string;\n}\n\nexport function DirectiveFallbackCard({ directive, reason }: DirectiveFallbackCardProps) {\n  const host = useDirectiveHost();\n  const count = directive.items.length;\n  const display = directiveDisplay(directive.directiveClass, directive.noun, host.nouns);\n  return (\n    <div className=\"my-3 inline-flex flex-wrap items-center gap-2 rounded-md border border-border bg-muted px-2.5 py-1 text-sm\">\n      <BoxesIcon className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n      <span className=\"text-foreground\">{display.title}</span>\n      {display.family ? <span className=\"text-muted-foreground\">· {display.family}</span> : null}\n      <span className=\"text-muted-foreground\">\n        · {count} {count === 1 ? \"item\" : \"items\"}\n      </span>\n      {reason ? <span className=\"text-muted-foreground\">· {reason}</span> : null}\n      <ApplyDirectiveButton directive={directive} />\n    </div>\n  );\n}\n\nexport default DirectiveFallbackCard;\n","\"use client\";\n\n/**\n * The card for a directive whose JSON has NOT finished arriving — the\n * provisional tier of `DirectiveRender`.\n *\n * WHY IT EXISTS (found live 2026-09-25, the agent builder's\n * `directive_v1_action_create_agent_definition` in the agent run window): an\n * agent streams a directive as one JSON document, `__kind` first. Every splitter\n * already types the block as a directive from its first bytes\n * (`looksLikeDirectiveHead`), but the decoder can only honor a COMPLETE shell,\n * so for the whole stream `DirectiveRender` fell to its raw `<pre>` — the person\n * watched a wall of JSON grow and then snap into a card at the last byte.\n *\n * The head already says what this is (class + noun), so the card says it from\n * the first bytes, from the same catalog words the finished card uses:\n *\n *  - STREAMING — \"Create agent definition · writing…\". No Apply: nothing is\n *    applicable until the shell is whole.\n *  - NOT STREAMING, still undecodable — the document was cut off (a model hit\n *    its output limit, a stream died). Said plainly, never dressed as\n *    \"writing…\" forever, with what did arrive one click away.\n *\n * NEVER RETURNS NULL.\n */\n\nimport { directiveDisplay, parseDirectiveSlug } from \"../directives\";\nimport { useDirectiveHost } from \"./directive-host\";\nimport { BoxesIcon, classIcon } from \"./icons\";\n\n/** A head whose slug has fully arrived: `{\"__kind\":\"directive_v1_…\"` + closing quote. */\nconst COMPLETE_SLUG_RE = /^\\{\\s*\"__kind\"\\s*:\\s*\"([^\"]+)\"/;\n\n/** The directive slug of a partial document, once its closing quote has arrived. */\nexport function provisionalDirectiveSlug(content: string): string | null {\n  const match = content.trimStart().match(COMPLETE_SLUG_RE);\n  return match?.[1] ?? null;\n}\n\nexport interface DirectiveProvisionalCardProps {\n  /** The partial fence body as received so far. */\n  content: string;\n  /**\n   * Whether the document may still be arriving. `false` means the stream is\n   * over and the document never completed — the card says it was cut off.\n   */\n  streaming: boolean;\n  className?: string | undefined;\n}\n\nexport function DirectiveProvisionalCard({ content, streaming, className }: DirectiveProvisionalCardProps) {\n  const host = useDirectiveHost();\n  const slug = provisionalDirectiveSlug(content);\n  const known = slug ? parseDirectiveSlug(slug) : null;\n  const display = known ? directiveDisplay(known.directiveClass, known.noun, host.nouns) : null;\n  const Icon = known ? classIcon(known.directiveClass, known.noun) : BoxesIcon;\n  const title = display?.title ?? \"Structured action\";\n\n  return (\n    <div\n      className={`my-3 rounded-md border border-border bg-card px-2.5 py-1.5${className ? ` ${className}` : \"\"}`}\n      data-directive={slug ?? undefined}\n      data-directive-state={streaming ? \"streaming\" : \"incomplete\"}\n    >\n      <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n        <Icon className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n        <span className=\"text-sm font-medium text-foreground\">{title}</span>\n        {display?.family ? <span className=\"text-xs text-muted-foreground\">{display.family}</span> : null}\n        {streaming ? (\n          <span className=\"inline-flex items-center gap-1.5 text-xs text-muted-foreground\" role=\"status\">\n            <span className=\"h-1.5 w-1.5 animate-pulse rounded-full bg-primary\" aria-hidden />\n            Writing…\n          </span>\n        ) : (\n          <span className=\"text-xs text-destructive\" role=\"status\">\n            Cut off before it finished — nothing can be applied.\n          </span>\n        )}\n      </div>\n      {streaming ? null : (\n        <details className=\"mt-1 text-xs text-muted-foreground\">\n          <summary className=\"cursor-pointer select-none hover:text-foreground\">Show what arrived</summary>\n          <pre className=\"mt-1 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded bg-muted px-2 py-1 text-[11px]\">\n            {content}\n          </pre>\n        </details>\n      )}\n    </div>\n  );\n}\n\nexport default DirectiveProvisionalCard;\n","\"use client\";\n\n/**\n * DirectiveRender — THE renderer for anything whose `__kind` is a reserved\n * directive slug, on every AI Matrx UI.\n *\n * Pipeline (one pipeline, mirroring the backend):\n *   0. THE PROVISIONAL TIER — a head that names a directive but does not\n *      decode yet renders `DirectiveProvisionalCard` (\"writing…\" while\n *      streaming, \"cut off\" once the host says the stream ended).\n *   1. `tryDecodeDirectiveContent` → the two-key shell (a stored 4-key fence is\n *      translated inside the decoder). Not a directive (bad JSON / no reserved\n *      `__kind`) → raw <pre>, never throws. An unhonourable shell is REPORTED\n *      through the host and falls to raw — a render seam must not take a whole\n *      message block down over one fence, and must never go silent.\n *   2. `getDirectiveRenderer` → exact slug, else the CLASS prefix rule (the\n *      host's registrations). Found → render it.\n *   3. THE SIDE-EFFECT TIER — every create / update / delete / action shape\n *      renders the side-effect card, so a person is never asked to approve a\n *      write they cannot identify.\n *   4. THE FLOOR — a class nothing registers still shows the fallback card.\n *      Never null, never silent.\n *\n * Position decides capability: in content only `reference`/`secret` resolve;\n * a side-effect directive in prose is a card with an explicit Apply, never\n * executed on sight.\n */\n\nimport { looksLikeDirectiveHead, tryDecodeDirectiveContent } from \"../directives\";\nimport { DirectiveScopeProvider, useDirectiveHost } from \"./directive-host\";\nimport { DirectiveFallbackCard } from \"./DirectiveFallbackCard\";\nimport { DirectiveProvisionalCard } from \"./DirectiveProvisionalCard\";\nimport { getDirectiveRenderer } from \"./registry\";\nimport { SideEffectDirectiveCard } from \"./SideEffectDirectiveCard\";\n\nexport interface DirectiveRenderProps {\n  /** The fence body (JSON string) or an already-parsed shell / value. */\n  content: unknown;\n  className?: string;\n  /**\n   * Whether the document may still be arriving. A host that knows its stream\n   * has ended passes `false`, so an undecodable directive head is shown as CUT\n   * OFF rather than \"writing…\" forever. Omitted = it may still be arriving.\n   */\n  streaming?: boolean;\n  /**\n   * The conversation this directive renders in (a chat message). Applies and\n   * ledger reads key on it — the same namespace an agent proposal's Approve\n   * uses — so one action can never apply twice through two doors. Omit in a\n   * person's own content. Overrides any enclosing `DirectiveScopeProvider`.\n   */\n  conversationId?: string | null;\n}\n\n/**\n * A document that parses is WHOLE: if it still does not decode, it is a\n * malformed directive (already reported by the decoder), never one \"still\n * arriving\" — only a genuinely unfinished document gets the provisional tier.\n */\nfunction isWholeJson(content: string): boolean {\n  try {\n    JSON.parse(content);\n    return true;\n  } catch {\n    return false;\n  }\n}\n\nexport function DirectiveRender({ conversationId, ...props }: DirectiveRenderProps) {\n  if (conversationId === undefined) return <DirectiveRenderInner {...props} />;\n  return (\n    <DirectiveScopeProvider conversationId={conversationId}>\n      <DirectiveRenderInner {...props} />\n    </DirectiveScopeProvider>\n  );\n}\n\nfunction DirectiveRenderInner({ content, className, streaming }: Omit<DirectiveRenderProps, \"conversationId\">) {\n  const host = useDirectiveHost();\n  const directive = tryDecodeDirectiveContent(content, (message) => {\n    const line = `[kind-directives] ${message}`;\n    if (host.reportError) host.reportError(line);\n    else console.error(line);\n  });\n\n  if (!directive) {\n    // THE PROVISIONAL TIER: the head already names a directive but the shell is\n    // not whole yet (mid-stream) or never became whole (cut off). The class and\n    // noun are known from the first bytes — say what it is, never show the\n    // growing JSON as if it were the answer.\n    if (typeof content === \"string\" && looksLikeDirectiveHead(content) && !isWholeJson(content)) {\n      return (\n        <DirectiveProvisionalCard content={content} streaming={streaming !== false} className={className} />\n      );\n    }\n    const raw = typeof content === \"string\" ? content : JSON.stringify(content, null, 2);\n    return (\n      <pre\n        className={`my-3 overflow-x-auto rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground${className ? ` ${className}` : \"\"}`}\n      >\n        {raw}\n      </pre>\n    );\n  }\n\n  const Renderer = getDirectiveRenderer(directive);\n  if (Renderer) return <Renderer directive={directive} />;\n  if (directive.parsed.executes) return <SideEffectDirectiveCard directive={directive} />;\n  return <DirectiveFallbackCard directive={directive} />;\n}\n\nexport default DirectiveRender;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,IAAAA,yBAKO;;;ACoCA,IAAM,WAAW;;;AC3BjB,IAAM,kBAAkB;AAGxB,IAAM,oBAAoB;AAG1B,IAAM,cAAc,GAAG,eAAe,GAAG,iBAAiB;AAG1D,IAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,IAAM,sBAA6E;AAAA,EACxF,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AACV;AAGO,IAAM,sBAAmD,IAAI;AAAA,EAClE,QAAQ,OAAO,CAAC,MAAM,oBAAoB,CAAC,MAAM,aAAa;AAChE;AAMO,IAAM,qBAAkD,oBAAI,IAAoB;AAAA,EACrF;AAAA,EACA;AACF,CAAC;AAeM,SAAS,iBAAiB,OAAyC;AACxE,SACE,OAAO,UAAU,YACjB,OAAO,UAAU,eAAe,KAAK,qBAAqB,KAAK;AAEnE;AAQO,SAAS,wBAAwB,MAA+B;AACrE,SAAO,OAAO,SAAS,YAAY,KAAK,WAAW,eAAe;AACpE;AAGA,SAAS,QAAQ,OAAwB;AACvC,SAAO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OAAO,SAAU,QAAO,6CAAC,2BAAwB,WAAsB;AACrF,SAAO,6CAAC,yBAAsB,WAAsB;AACtD;","names":["import_directive_host","import_react","import_text_case","nounLabel","n","text","GFilePlusIcon","GPencilIcon","GTrash2Icon","GPlayIcon","GWebhookIcon","GBoxesIcon","GChevronDownIcon","GChevronRightIcon","GMaximizeIcon","GLoader2Icon","GRotateCcwIcon","GCircleCheckIcon","GAlertTriangleIcon","label","read","import_react","import_directive_host","import_jsx_runtime","import_directive_host","import_jsx_runtime","import_directive_host","import_jsx_runtime","import_directive_host","import_jsx_runtime"]}