WeLe Agentic AI: LangGraph multi-agent CRM assistant with voice
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import fs from 'node:fs';
|
||||
import ExcelJS from 'exceljs';
|
||||
|
||||
const out = 'C:/Users/HP/AppData/Local/Temp/claude/c--Users-HP-Desktop-Dev-Agentic-AI/8b30e040-7edd-46bd-97f0-c9d03d3965cf/scratchpad';
|
||||
|
||||
// ── PDF: header, page count, embedded images ──
|
||||
const pdf = fs.readFileSync(`${out}/report.pdf`);
|
||||
const pdfStr = pdf.toString('latin1');
|
||||
const pages = (pdfStr.match(/\/Type\s*\/Page[^s]/g) || []).length;
|
||||
const images = (pdfStr.match(/\/Subtype\s*\/Image/g) || []).length;
|
||||
console.log(`PDF header=${pdf.subarray(0, 5).toString()} pages=${pages} images=${images} hasEOF=${pdfStr.trimEnd().endsWith('%%EOF')}`);
|
||||
|
||||
// ── OOXML: valid zip + expected parts ──
|
||||
const zipParts = (buf) => {
|
||||
const s = buf.toString('latin1');
|
||||
const names = new Set();
|
||||
const rx = /PK\x03\x04[\s\S]{22}/g;
|
||||
let m;
|
||||
while ((m = rx.exec(s))) {
|
||||
const nameLen = buf.readUInt16LE(m.index + 26);
|
||||
const extraLen = buf.readUInt16LE(m.index + 28);
|
||||
names.add(buf.subarray(m.index + 30, m.index + 30 + nameLen).toString('utf8'));
|
||||
rx.lastIndex = m.index + 30 + nameLen + extraLen;
|
||||
}
|
||||
return [...names];
|
||||
};
|
||||
|
||||
for (const [name, must] of [
|
||||
['docx', 'word/document.xml'],
|
||||
['pptx', 'ppt/presentation.xml'],
|
||||
['xlsx', 'xl/workbook.xml'],
|
||||
]) {
|
||||
const buf = fs.readFileSync(`${out}/report.${name}`);
|
||||
const parts = zipParts(buf);
|
||||
const media = parts.filter((p) => /media\//.test(p));
|
||||
const slides = parts.filter((p) => /slides\/slide\d+\.xml$/.test(p));
|
||||
const sheets = parts.filter((p) => /worksheets\/sheet\d+\.xml$/.test(p));
|
||||
console.log(
|
||||
`${name.toUpperCase().padEnd(5)} zip=${buf.subarray(0, 2).toString() === 'PK'} parts=${parts.length} ` +
|
||||
`core=${parts.includes(must)} media=${media.length}` +
|
||||
(slides.length ? ` slides=${slides.length}` : '') +
|
||||
(sheets.length ? ` sheets=${sheets.length}` : ''),
|
||||
);
|
||||
}
|
||||
|
||||
// ── XLSX: read it back and confirm the data survived ──
|
||||
const wb = new ExcelJS.Workbook();
|
||||
await wb.xlsx.readFile(`${out}/report.xlsx`);
|
||||
console.log('XLSX sheets:', wb.worksheets.map((w) => `${w.name}(${w.rowCount}r)`).join(', '));
|
||||
const data = wb.getWorksheet('Top batches');
|
||||
if (data) {
|
||||
console.log('XLSX header:', data.getRow(1).values.slice(1).join(' | '));
|
||||
console.log('XLSX row2 :', data.getRow(2).values.slice(1).join(' | '));
|
||||
}
|
||||
process.exit(0);
|
||||
Reference in New Issue
Block a user