{"version":3,"file":"ai-model/model-adapter/default-insight-protocol.mjs","sources":["../../../../src/ai-model/model-adapter/default-insight-protocol.ts"],"sourcesContent":["import { extractXMLTag } from '../shared/xml';\nimport type { InsightProtocolFactory } from './insight-protocol';\n\nconst dataOutputTagName = 'data-json';\n\nexport const createDefaultInsightProtocol: InsightProtocolFactory = ({\n  jsonParser,\n}) => ({\n  dataOutput: {\n    tagNames: [dataOutputTagName],\n    rules: '',\n    placeholder: `<${dataOutputTagName}>the extracted data as JSON. Make sure both the value and scheme meet the DATA_DEMAND. If you want to write some description in this field, use the same language as the DATA_DEMAND.</${dataOutputTagName}>`,\n    buildExample: (serializedData) => `<${dataOutputTagName}>\n${serializedData}\n</${dataOutputTagName}>`,\n    parse: <T>(content: string): T => {\n      const dataJsonContent = extractXMLTag(content, dataOutputTagName);\n      if (!dataJsonContent) {\n        throw new Error('Missing required field: data-json');\n      }\n\n      try {\n        return jsonParser(dataJsonContent, {\n          source: 'generic-object',\n        }) as T;\n      } catch (error) {\n        throw new Error(`Failed to parse data-json: ${error}`);\n      }\n    },\n  },\n});\n"],"names":["dataOutputTagName","createDefaultInsightProtocol","jsonParser","serializedData","content","dataJsonContent","extractXMLTag","Error","error"],"mappings":";AAGA,MAAMA,oBAAoB;AAEnB,MAAMC,+BAAuD,CAAC,EACnEC,UAAU,EACX,GAAM;QACL,YAAY;YACV,UAAU;gBAACF;aAAkB;YAC7B,OAAO;YACP,aAAa,CAAC,CAAC,EAAEA,kBAAkB,uLAAuL,EAAEA,kBAAkB,CAAC,CAAC;YAChP,cAAc,CAACG,iBAAmB,CAAC,CAAC,EAAEH,kBAAkB;AAC5D,EAAEG,eAAe;EACf,EAAEH,kBAAkB,CAAC,CAAC;YACpB,OAAO,CAAII;gBACT,MAAMC,kBAAkBC,cAAcF,SAASJ;gBAC/C,IAAI,CAACK,iBACH,MAAM,IAAIE,MAAM;gBAGlB,IAAI;oBACF,OAAOL,WAAWG,iBAAiB;wBACjC,QAAQ;oBACV;gBACF,EAAE,OAAOG,OAAO;oBACd,MAAM,IAAID,MAAM,CAAC,2BAA2B,EAAEC,OAAO;gBACvD;YACF;QACF;IACF"}