export declare const UPSERT_KNOWLEDGE = "\n  INSERT INTO lt_knowledge (domain, key, data, tags)\n  VALUES ($1, $2, $3, $4)\n  ON CONFLICT (domain, key) DO UPDATE SET\n    data = CASE\n      WHEN jsonb_typeof(lt_knowledge.data) = 'object'\n      THEN lt_knowledge.data || EXCLUDED.data\n      ELSE EXCLUDED.data\n    END,\n    tags = ARRAY(SELECT DISTINCT unnest(lt_knowledge.tags || EXCLUDED.tags))\n  RETURNING id, domain, key, (xmax = 0) AS created, updated_at";
export declare const REPLACE_KNOWLEDGE = "\n  INSERT INTO lt_knowledge (domain, key, data, tags)\n  VALUES ($1, $2, $3, $4)\n  ON CONFLICT (domain, key) DO UPDATE SET\n    data = EXCLUDED.data,\n    tags = EXCLUDED.tags\n  RETURNING id, domain, key, (xmax = 0) AS created, updated_at";
export declare const GET_KNOWLEDGE = "\n  SELECT id, domain, key, data, tags, created_at, updated_at\n  FROM lt_knowledge WHERE domain = $1 AND key = $2";
export declare const SEARCH_KNOWLEDGE = "\n  SELECT id, domain, key, data, tags, created_at, updated_at\n  FROM lt_knowledge\n  WHERE domain = $1 AND data @> $2::jsonb";
export declare const COUNT_KNOWLEDGE_SEARCH = "\n  SELECT COUNT(*)::int AS total FROM lt_knowledge\n  WHERE domain = $1 AND data @> $2::jsonb";
export declare const LIST_KNOWLEDGE = "\n  SELECT id, domain, key, data, tags, created_at, updated_at\n  FROM lt_knowledge WHERE domain = $1";
export declare const COUNT_KNOWLEDGE_LIST = "\n  SELECT COUNT(*)::int AS total FROM lt_knowledge WHERE domain = $1";
export declare const DELETE_KNOWLEDGE = "\n  DELETE FROM lt_knowledge WHERE domain = $1 AND key = $2";
export declare const LIST_DOMAINS = "\n  SELECT domain, COUNT(*)::int AS count, MAX(updated_at) AS latest\n  FROM lt_knowledge GROUP BY domain ORDER BY latest DESC";
export declare const SET_KNOWLEDGE_FIELD = "\n  INSERT INTO lt_knowledge (domain, key, data, tags)\n  VALUES ($1, $2, $3::jsonb, $4)\n  ON CONFLICT (domain, key) DO UPDATE SET\n    data = jsonb_set(lt_knowledge.data, $5::text[], $6::jsonb, true),\n    tags = ARRAY(SELECT DISTINCT unnest(lt_knowledge.tags || EXCLUDED.tags))\n  RETURNING id, domain, key, (xmax = 0) AS created, updated_at";
export declare const REMOVE_KNOWLEDGE_FIELD = "\n  UPDATE lt_knowledge\n  SET data = data #- $3::text[]\n  WHERE domain = $1 AND key = $2\n  RETURNING id, domain, key, updated_at";
export declare const APPEND_KNOWLEDGE = "\n  INSERT INTO lt_knowledge (domain, key, data)\n  VALUES ($1, $2, $3::jsonb)\n  ON CONFLICT (domain, key) DO UPDATE SET\n    data = CASE\n      WHEN lt_knowledge.data #> $4::text[] IS NULL\n      THEN jsonb_set(lt_knowledge.data, $4::text[], jsonb_build_array($5::jsonb))\n      ELSE jsonb_set(lt_knowledge.data, $4::text[], (lt_knowledge.data #> $4::text[]) || jsonb_build_array($5::jsonb))\n    END\n  RETURNING id, domain, key, updated_at";
