@zerocarbon/erp-config-sdk 1.0.31 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bulk-bill-agent.esm.js +1 -0
- package/dist/bulk-bill-agent.esm.js.map +1 -1
- package/dist/bulk-bill-agent.js +1 -0
- package/dist/bulk-bill-agent.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.esm.js +14 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-bill-agent.js","sources":["../src/config/bulk-bill-agent.ts"],"sourcesContent":["export type BulkBillAgentProfileId =\n | 'electricity'\n | 'fuel_combustion'\n | 'refrigerants'\n | 'industrial_gases'\n | 'employee_commuting'\n | 'business_travel'\n | 'lpg_usage'\n | 'fire_extinguisher'\n | 'sf6_usage'\n | 'water'\n | 'waste'\n | 'purchased_goods'\n | 'process_emissions'\n | 'generic_material';\n\nexport interface BulkBillAgentAllowedItem {\n itemKey?: string;\n sourceId?: string;\n itemName?: string;\n billCategory?: string;\n billSubCategory?: string;\n billNestedSubCategory?: string;\n billType?: string;\n unit?: string;\n emissionFactor?: number;\n requiresMassData?: boolean;\n}\n\nexport interface BulkBillAgentMappingContext {\n locked?: boolean;\n scope?: string;\n category?: string;\n route?: string;\n plant?: string;\n year?: number | string;\n month?: number | string;\n yearType?: string;\n allowedItems?: BulkBillAgentAllowedItem[];\n}\n\nexport interface BulkBillAgentProfile {\n id: BulkBillAgentProfileId;\n label: string;\n description: string;\n documentTypes: string[];\n itemSignals: string[];\n documentSignals: string[];\n preferredUnits: string[];\n extractionRules: string[];\n rejectRules: string[];\n}\n\nexport interface BulkBillAgentPromptConfig {\n profile: BulkBillAgentProfile;\n allowedItemCount: number;\n allowedItemSummaries: string[];\n uploadContext: {\n scope: string;\n category: string;\n plant: string;\n year: string;\n month: string;\n yearType: string;\n route: string;\n };\n}\n\nconst normalize = (value: unknown) =>\n String(value ?? '')\n .toLowerCase()\n .replace(/co₂/g, 'co2')\n .replace(/[^a-z0-9]+/g, ' ')\n .trim();\n\nconst includesAny = (text: string, signals: readonly string[]) =>\n signals.some((signal) => text.includes(signal));\n\nconst itemText = (item: BulkBillAgentAllowedItem) =>\n normalize([\n item.itemName,\n item.billCategory,\n item.billSubCategory,\n item.billNestedSubCategory,\n item.billType,\n item.unit,\n ].filter(Boolean).join(' '));\n\nconst mappingContextText = (context: BulkBillAgentMappingContext = {}) =>\n normalize([\n context.scope,\n context.category,\n ...(Array.isArray(context.allowedItems) ? context.allowedItems.map(itemText) : []),\n ].filter(Boolean).join(' '));\n\nexport const BULK_BILL_AGENT_PROFILES: Record<BulkBillAgentProfileId, BulkBillAgentProfile> = {\n electricity: {\n id: 'electricity',\n label: 'Electricity',\n description: 'Grid electricity, renewable electricity, kWh/kVAh/MWh utility bills.',\n documentTypes: ['electricity_bill'],\n itemSignals: ['electric', 'electricity', 'grid', 'renewable', 'solar', 'power', 'kwh', 'kvah', 'mwh', 'location based', 'market based', 'purchased electricity'],\n documentSignals: ['kwh', 'kvah', 'mwh', 'meter', 'discom', 'vidyut', 'billed units', 'net consumption', 'energy charge'],\n preferredUnits: ['kWh', 'kVAh', 'MWh'],\n extractionRules: [\n 'Prefer current-period bill-level or net billed consumption over charges, rates, TOD/slab rows, arrears, or historical meter rows.',\n 'For grid import or purchased electricity, use current-period import/from-grid consumption.',\n 'For solar or renewable electricity, use current-period generation or renewable energy consumption.',\n 'Treat “units” as kWh only for electricity documents.',\n ],\n rejectRules: ['Reject taxes, demand/fixed charges, tariff/rate rows, previous readings, arrears, and currency amounts.'],\n },\n fuel_combustion: {\n id: 'fuel_combustion',\n label: 'Fuel combustion',\n description: 'Diesel, HSD, petrol, furnace oil, coal, coke, CNG and other stationary/mobile combustion fuels.',\n documentTypes: ['fuel_invoice', 'material_invoice'],\n itemSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'furnace oil', 'coal', 'coke', 'cng', 'kerosene', 'ldo', 'mobile combustion', 'stationary combustion', 'operation'],\n documentSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'litre', 'liter', 'kl', 'furnace oil', 'coal', 'petcoke', 'cng'],\n preferredUnits: ['KL', 'Litre', 'Kg', 'Tonnes', 'M3', 'SCM'],\n extractionRules: [\n 'Extract physical fuel quantity, not invoice amount or rate.',\n 'Map vehicle fuel rows to mobile combustion items and generator/boiler/process fuel rows to stationary or operation items when the evidence supports it.',\n 'Preserve the bill unit; unit conversion belongs to validation unless the document states density or conversion explicitly.',\n ],\n rejectRules: ['Reject fuel rates, taxes, HSN/SAC codes, payment totals, and non-fuel services.'],\n },\n refrigerants: {\n id: 'refrigerants',\n label: 'Refrigerants',\n description: 'AC gas and refrigerant purchases/refills such as R-410A, R-32, R-134a, R-22.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['refrigerant', 'refrigerants', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'hfc', 'ac gas', 'chiller'],\n documentSignals: ['refrigerant', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'ac gas', 'chiller gas'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: [\n 'Extract refrigerant top-up, refill, or purchase quantity by refrigerant grade.',\n 'Repair OCR variants like R410, R-410, R 410A, R-410 A to the closest allowed ERP item.',\n 'Do not infer leakage; only extract documented physical quantity.',\n ],\n rejectRules: ['Reject service charges, labour, AC unit model numbers, invoice totals, and taxes.'],\n },\n industrial_gases: {\n id: 'industrial_gases',\n label: 'Industrial gases',\n description: 'Oxygen, CO2, nitrogen, argon, acetylene and cylinder gas invoices.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['oxygen', 'o2', 'co2', 'carbon dioxide', 'nitrogen', 'argon', 'acetylene', 'gas cylinder', 'industrial gas', 'welding'],\n documentSignals: ['oxygen', 'o2 gas', 'co2 gas', 'nitrogen', 'argon', 'acetylene', 'cylinder', 'scm', 'nm3', 'm3'],\n preferredUnits: ['M3', 'SCM', 'NM3', 'Kg', 'Cyl'],\n extractionRules: [\n 'Extract gas quantity from row-level item quantity, not cylinder deposit, rental, or amount.',\n 'Keep cylinder count only when the ERP item unit supports count-based activity.',\n 'Repair OCR variants such as 02/O2 and C02/CO2 using allowed ERP items.',\n ],\n rejectRules: ['Reject cylinder deposits, rent, returnable assets, rates, taxes, and empty cylinder rows.'],\n },\n employee_commuting: {\n id: 'employee_commuting',\n label: 'Employee commuting',\n description: 'Employee commute rosters and distance summaries grouped by transport mode.',\n documentTypes: ['transport_roster', 'material_invoice'],\n itemSignals: ['employee commuting', 'commute', 'commuting', 'motorcycle', 'scooter', 'hatchback', 'car', 'rail', 'train', 'metro', 'bus', 'cycle', 'passenger km'],\n documentSignals: ['employee', 'transport', 'mode', 'commute', 'bike', 'scooty', 'car', 'metro', 'bus', 'cycle', 'km'],\n preferredUnits: ['km', 'passenger-km'],\n extractionRules: [\n 'Treat roster files as activity evidence even when they have no invoice number, supplier, or amount.',\n 'Group by transport mode and sum current-period distance into one row per mapped ERP item.',\n 'Use the upload period as the bill period when the roster has no date.',\n ],\n rejectRules: ['Reject employee IDs, names, phone numbers, addresses, and non-distance row counts as activity quantities.'],\n },\n business_travel: {\n id: 'business_travel',\n label: 'Business travel',\n description: 'Flights, rail, hotel stays, and rental vehicle activity.',\n documentTypes: ['travel_invoice', 'material_invoice'],\n itemSignals: ['business travel', 'flight', 'air travel', 'rail', 'train', 'hotel', 'rental car', 'passenger km', 'room night'],\n documentSignals: ['flight', 'airline', 'pnr', 'hotel', 'room night', 'train', 'rail', 'passenger km', 'ticket'],\n preferredUnits: ['km', 'passenger-km', 'night', 'room-night'],\n extractionRules: ['Extract distance, passenger-km, room nights, or trip counts only when the ERP item supports the unit.'],\n rejectRules: ['Reject fares, taxes, booking fees, passenger names, and ticket numbers as activity quantities.'],\n },\n lpg_usage: {\n id: 'lpg_usage',\n label: 'LPG usage',\n description: 'LPG cylinder and bulk LPG invoices.',\n documentTypes: ['fuel_invoice', 'gas_invoice', 'material_invoice'],\n itemSignals: ['lpg', 'liquefied petroleum gas', 'cylinder'],\n documentSignals: ['lpg', 'liquefied petroleum', 'cylinder', 'kg', 'commercial gas'],\n preferredUnits: ['Kg', 'Tonnes', 'KL', 'Cyl'],\n extractionRules: ['Extract filled LPG quantity by kg/tonnes/KL/cylinder size; prefer net fill quantity over cylinder deposit count.'],\n rejectRules: ['Reject cylinder deposits, rental, delivery charges, and taxes.'],\n },\n fire_extinguisher: {\n id: 'fire_extinguisher',\n label: 'Fire extinguisher refilling',\n description: 'CO2 and other extinguisher refill activity.',\n documentTypes: ['material_invoice'],\n itemSignals: ['fire extinguisher', 'extinguisher', 'co2 fire', 'refilling'],\n documentSignals: ['fire extinguisher', 'extinguisher', 'co2', 'refill', 'refilling'],\n preferredUnits: ['Kg', 'Tonnes', 'Cyl'],\n extractionRules: ['Extract refill gas quantity, not extinguisher asset count unless the ERP item is count-based.'],\n rejectRules: ['Reject maintenance service charges, inspection fees, and asset serial numbers.'],\n },\n sf6_usage: {\n id: 'sf6_usage',\n label: 'SF6 usage',\n description: 'SF6 gas purchase, refill, and switchgear top-up activity.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride'],\n documentSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride', 'switchgear'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: ['Extract documented SF6 purchase/refill/top-up quantity only.'],\n rejectRules: ['Reject switchgear model numbers, pressure readings without refill quantity, and service charges.'],\n },\n water: {\n id: 'water',\n label: 'Water',\n description: 'Municipal, borewell, tanker, and wastewater quantities.',\n documentTypes: ['water_bill', 'material_invoice'],\n itemSignals: ['water', 'groundwater', 'municipal', 'tanker', 'wastewater', 'effluent'],\n documentSignals: ['water', 'kl', 'litre', 'liter', 'tanker', 'municipal', 'wastewater', 'effluent'],\n preferredUnits: ['KL', 'Litre', 'M3'],\n extractionRules: ['Extract physical water volume by source/disposal type where possible.'],\n rejectRules: ['Reject water charges, sewerage taxes, arrears, and meter numbers as quantities.'],\n },\n waste: {\n id: 'waste',\n label: 'Waste generated in operations',\n description: 'Waste disposal, recycling, composting, landfill, hazardous/non-hazardous waste.',\n documentTypes: ['waste_invoice', 'material_invoice'],\n itemSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal'],\n documentSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal', 'kg', 'tonne'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: ['Extract disposed/recycled physical waste mass by waste type and treatment route.'],\n rejectRules: ['Reject disposal fees, GST, container rental, and vehicle numbers.'],\n },\n purchased_goods: {\n id: 'purchased_goods',\n label: 'Purchased goods and services',\n description: 'Raw materials, consumables, and purchased product quantities.',\n documentTypes: ['material_invoice', 'purchase_order'],\n itemSignals: ['purchased goods', 'goods', 'services', 'material', 'raw material', 'consumable', 'packaging'],\n documentSignals: ['invoice', 'tax invoice', 'hsn', 'material', 'goods', 'quantity', 'qty', 'purchase order'],\n preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],\n extractionRules: ['Extract row-level material quantity only when the item maps to an allowed ERP item.'],\n rejectRules: ['Reject rates, taxes, HSN/SAC codes, payment terms, and unmatched non-emission materials.'],\n },\n process_emissions: {\n id: 'process_emissions',\n label: 'Process emissions',\n description: 'Cement clinker calcination, ironmaking/steelmaking, flux calcination and other process quantities.',\n documentTypes: ['production_log', 'material_invoice'],\n itemSignals: ['calcination', 'clinker', 'ironmaking', 'steelmaking', 'flux', 'process emissions', 'hot metal', 'limestone', 'dolomite'],\n documentSignals: ['clinker', 'calcination', 'limestone', 'dolomite', 'hot metal', 'steelmaking', 'production', 'tonne'],\n preferredUnits: ['Tonnes', 'Kg'],\n extractionRules: ['Extract production/process input quantity tied to the selected process item.'],\n rejectRules: ['Reject financial totals, quality percentages, and composition values unless explicitly configured as activity data.'],\n },\n generic_material: {\n id: 'generic_material',\n label: 'Generic material invoice',\n description: 'Fallback for material invoices that do not fit a narrower profile.',\n documentTypes: ['material_invoice', 'purchase_order', 'unknown'],\n itemSignals: ['material', 'goods', 'services', 'quantity', 'qty'],\n documentSignals: ['invoice', 'quantity', 'qty', 'unit', 'hsn', 'sac'],\n preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],\n extractionRules: ['Extract only row-level physical quantities that can be matched to allowed ERP items.'],\n rejectRules: ['Reject invoice metadata, rates, taxes, totals, and unmatched rows.'],\n },\n};\n\nconst ROUTING_PRIORITY: BulkBillAgentProfileId[] = [\n 'electricity',\n 'employee_commuting',\n 'refrigerants',\n 'sf6_usage',\n 'fire_extinguisher',\n 'lpg_usage',\n 'industrial_gases',\n 'fuel_combustion',\n 'business_travel',\n 'water',\n 'waste',\n 'process_emissions',\n 'purchased_goods',\n 'generic_material',\n];\n\nexport const getBulkBillAgentProfile = (profileId: BulkBillAgentProfileId) =>\n BULK_BILL_AGENT_PROFILES[profileId];\n\nexport const listBulkBillAgentProfiles = () =>\n ROUTING_PRIORITY.map((profileId) => BULK_BILL_AGENT_PROFILES[profileId]);\n\nexport const scoreBulkBillAgentProfile = (\n profile: BulkBillAgentProfile,\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const contextText = mappingContextText(context);\n const docText = normalize(documentText);\n const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];\n const itemMatches = allowedItems.filter((item) => includesAny(itemText(item), profile.itemSignals)).length;\n const contextMatch = includesAny(contextText, profile.itemSignals) ? 2 : 0;\n const categoryMatch = includesAny(normalize(context.category), profile.itemSignals) ? 3 : 0;\n const documentMatch = docText && includesAny(docText, profile.documentSignals) ? 2 : 0;\n const unitMatch = allowedItems.filter((item) => includesAny(normalize(item.unit), profile.preferredUnits.map(normalize))).length;\n return itemMatches * 3 + unitMatch + contextMatch + categoryMatch + documentMatch;\n};\n\nexport const getBulkBillAgentProfilesForMappingContext = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const scored = ROUTING_PRIORITY\n .map((profileId) => {\n const profile = BULK_BILL_AGENT_PROFILES[profileId];\n return { profile, score: scoreBulkBillAgentProfile(profile, context, documentText) };\n })\n .filter((entry) => entry.score > 0)\n .sort((left, right) => right.score - left.score);\n\n return scored.length ? scored : [{ profile: BULK_BILL_AGENT_PROFILES.generic_material, score: 0 }];\n};\n\nexport const getPrimaryBulkBillAgentProfile = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => getBulkBillAgentProfilesForMappingContext(context, documentText)[0].profile;\n\nconst formatAllowedItem = (item: BulkBillAgentAllowedItem) => {\n const hierarchy = [item.billCategory, item.billSubCategory, item.billNestedSubCategory]\n .filter(Boolean)\n .join(' > ');\n return `${item.itemName || item.billNestedSubCategory || 'Unnamed item'}${hierarchy ? ` (${hierarchy})` : ''}; expected unit: ${item.unit || 'not specified'}; key: ${item.itemKey || item.sourceId || 'not specified'}`;\n};\n\nexport const buildBulkBillAgentPromptConfig = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n): BulkBillAgentPromptConfig => {\n const profile = getPrimaryBulkBillAgentProfile(context, documentText);\n const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];\n return {\n profile,\n allowedItemCount: allowedItems.length,\n allowedItemSummaries: allowedItems.map(formatAllowedItem),\n uploadContext: {\n scope: String(context.scope || ''),\n category: String(context.category || ''),\n plant: String(context.plant || ''),\n year: String(context.year || ''),\n month: String(context.month || ''),\n yearType: String(context.yearType || ''),\n route: String(context.route || ''),\n },\n };\n};\n\nconst baseBulkBillAgentSystemPrompt = `You are a ZeroCarbon bulk bill processing agent running inside an open-ended tool harness.\n\nYou do not follow a fixed workflow. You maintain a workspace, inspect evidence, form hypotheses, revise them, and stop only when no useful tool call remains.\n\nNon-negotiable extraction contract:\n- First understand the document. For each bill/page group, stage pages and call classify_bill_group. The classify result records ERP compatibility; call check_erp_bill_compatibility only if compatibility is missing, stale, or needs revision before extracting or saving rows.\n- A PDF can contain mixed bill types. Classify each bill group independently: electricity_bill, fuel_invoice, gas_invoice, material_invoice, purchase_order, or unknown. Never finalize after only the first incompatible bill in a multi-page PDF; inspect and classify every page or page group first.\n- If a bill type is incompatible with the locked ERP page/allowed items, do not force mapping. Leave it for review with a clear reason.\n- After compatibility is recorded, call extract_activity_candidates to get typed physical candidates. Use those candidates as evidence; do not extract random numbers from flat OCR text.\n- If a specialized profile is listed below, treat it as the active sub-agent contract for this ERP page. Apply its extraction rules before generic extraction heuristics.\n- If extract_activity_candidates returns recommendedRows for electricity, use those rows directly with save_extracted_rows unless you can cite a concrete validation problem. Do not replace deterministic recommended rows with review rows.\n- Extract only physical activity rows: energy, mass, volume, distance, count only when the ERP item supports count-based activity. Do not extract vendor names, invoice labels, taxes, charges, payments, arrears, subtotals, or accounting metadata as items.\n- For each candidate row, classify doubtful rows and search the locked ERP items before deciding to save or review.\n- When more than one allowed ERP item can match, make an evidence-backed mapping decision when possible. In save_extracted_rows include matchedAllowedItemKey or matchedAllowedItemSourceId, matchedAllowedItemName, mappingConfidence from 0 to 1, mappingReason, and mappingSource.\n- If OCR is partial, use neighboring rows, repeated labels, row evidence, typed candidates, and ERP context to repair the candidate. Keep raw evidence in rowEvidenceText.\n- For electricity or any ambiguous utility bill, call select_activity_quantity on staged bill pages before save_extracted_rows. Prefer bill-level/billing consumption for generic grid bills. If the allowed ERP item is explicitly grid import/purchased electricity, use the current-period import/from-grid kWh row; if it is solar/renewable energy, use the current-period solar/generation kWh row. Do not use TOD, slab, charge, amount, rate, date, register, or historical rows. Never switch to a weaker component only to match ERP unit.\n- Never persist just because a row exists. Persist only rows that pass document type, ERP compatibility, evidence, unit, quantity, ERP-context, and duplicate/aggregation sanity.\n- It is acceptable to call the same tool multiple times with repaired inputs. It is acceptable to revise groups and rows.\n- If a group cannot be safely extracted or mapped, call save_review_rows with source pages, evidence, and a clear reason instead of saving an incomplete normal row.\n- Use persist_validated_rows after validation. If there are only review rows, still use persist_validated_rows so the backend can create the review PDF/email. Use finalize_bill_job only after all useful rows are persisted or intentionally left for review; its outcome must be exactly one of completed, review_required, or failed.\n- Do not invent emission factors, quantities, units, invoice numbers, or page evidence.\n\nYour output to the user is the job state and streamed tool activity, so keep tool arguments and notes specific and evidence-backed.`;\n\nconst promptBulletList = (items: readonly string[]) => items.map((item) => `- ${item}`).join('\\n');\n\nexport const buildBulkBillAgentSystemPrompt = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const config = buildBulkBillAgentPromptConfig(context, documentText);\n const allowedItems = config.allowedItemSummaries.slice(0, 40);\n return `${baseBulkBillAgentSystemPrompt}\n\nActive ERP extraction sub-agent contract:\nProfile: ${config.profile.label} (${config.profile.id})\nDescription: ${config.profile.description}\nExpected document types: ${config.profile.documentTypes.join(', ') || 'not specified'}\nPreferred units: ${config.profile.preferredUnits.join(', ') || 'not specified'}\n\nUpload context:\n- Scope: ${config.uploadContext.scope || 'not specified'}\n- Category: ${config.uploadContext.category || 'not specified'}\n- Plant: ${config.uploadContext.plant || 'not specified'}\n\nCritical document-period rule:\n- Do not assume the upload period is the bill period. Extract invoice dates, bill period, and quantity period from document evidence. Use upload context only when the document truly has no period evidence.\n\nCategory-specific extraction rules:\n${promptBulletList(config.profile.extractionRules)}\n\nCategory-specific reject rules:\n${promptBulletList(config.profile.rejectRules)}\n\nAllowed ERP items for this upload (${config.allowedItemCount} total, first ${allowedItems.length} shown):\n${promptBulletList(allowedItems)}\n\nFollow this profile unless page evidence clearly proves a different bill type; if evidence conflicts with the ERP page, send rows to review instead of forcing a mapping.`;\n};\n\nexport interface BulkBillAgentProfilePage {\n pageNumber: number | string;\n text?: string;\n}\n\nexport interface BulkBillAgentProfileGroup {\n groupId: string;\n pageNumbers: Array<number | string>;\n}\n\nexport interface BulkBillAgentProfileCandidate {\n candidateId: string;\n groupId: string;\n profileId: BulkBillAgentProfileId;\n itemName: string;\n quantity: string;\n unit: string;\n role: string;\n confidence: number;\n pageNumber: number;\n evidenceText: string;\n matchedAllowedItemName?: string;\n matchedAllowedItemKey?: string;\n matchedAllowedItemSourceId?: string;\n mappingConfidence?: number;\n}\n\nexport interface BulkBillAgentProfileExtractionInput {\n mappingContext?: BulkBillAgentMappingContext;\n pages?: BulkBillAgentProfilePage[];\n group: BulkBillAgentProfileGroup;\n documentText?: string;\n}\n\nconst numericPattern = /-?(?:(?:\\d{1,3}(?:,\\d{3})+)|\\d+)(?:\\.\\d+)?/g;\nconst physicalUnitPattern = /\\b(kwh|kw\\s*h|kvah|kva\\s*h|mwh|kg|kgs|kilograms?|tonnes?|tons?|mt|kl|litres?|liters?|ltr?s?|m3|m³|scm|ncm|nm3|km|passenger[-\\s]?km|room[-\\s]?nights?|nights?|cyl(?:inders?)?|nos?|pcs|pieces?)\\b/i;\nconst metadataOnlyPattern = /(?:₹|rs\\.?|inr|amount|payable|charge|tax|gst|duty|cess|rate|tariff|arrear|rebate|subsidy|surcharge|rent|total\\s+amount|invoice\\s*(?:no|number)|account\\s*(?:no|number)|consumer\\s*(?:no|number))/i;\n\nconst compactKey = (value: unknown) => normalize(value).replace(/\\s+/g, '');\n\nconst canonicalActivityUnit = (unit: string) => {\n const value = compactKey(unit);\n if (value === 'kwh' || value === 'unit' || value === 'units') return 'kWh';\n if (value === 'kvah') return 'kVAh';\n if (value === 'mwh') return 'MWh';\n if (value === 'kg' || value === 'kgs' || value === 'kilogram' || value === 'kilograms') return 'Kg';\n if (value === 'tonne' || value === 'tonnes' || value === 'ton' || value === 'tons' || value === 'mt') return 'Tonnes';\n if (value === 'litre' || value === 'litres' || value === 'liter' || value === 'liters' || value === 'ltr' || value === 'ltrs') return 'Litre';\n if (value === 'kl') return 'KL';\n if (value === 'm3' || value === 'm³' || value === 'scm' || value === 'ncm' || value === 'nm3') return 'M3';\n if (value === 'km') return 'km';\n if (value === 'passengerkm') return 'passenger-km';\n if (value === 'night' || value === 'nights' || value === 'roomnight' || value === 'roomnights') return 'night';\n if (value === 'cyl' || value === 'cylinder' || value === 'cylinders') return 'Cyl';\n if (value === 'nos' || value === 'no' || value === 'pcs' || value === 'pieces') return 'Nos';\n return unit;\n};\n\nconst parsePositiveNumbers = (line: string) =>\n [...line.matchAll(numericPattern)]\n .map((match) => ({\n value: match[0],\n index: match.index || 0,\n number: Number(match[0].replace(/,/g, '')),\n }))\n .filter((entry) => Number.isFinite(entry.number) && entry.number > 0 && !/[A-Za-z]/.test(line[entry.index - 1] || ''));\n\nconst adjacentActivityUnit = (line: string, numberIndex: number, valueLength: number) => {\n const after = line.slice(numberIndex + valueLength, numberIndex + valueLength + 18);\n const right = after.match(/^\\s*([A-Za-z³][-A-Za-z0-9³ ]{0,16})/i)?.[1] || '';\n const rightUnit = right.match(physicalUnitPattern)?.[1];\n if (rightUnit) return canonicalActivityUnit(rightUnit);\n const before = line.slice(Math.max(0, numberIndex - 18), numberIndex);\n const beforeUnit = before.match(new RegExp(`(${physicalUnitPattern.source})\\\\s*$`, 'i'))?.[1];\n return beforeUnit ? canonicalActivityUnit(beforeUnit) : '';\n};\n\nconst candidateAllowedScore = (query: string, item: BulkBillAgentAllowedItem) => {\n const queryKey = normalize(query);\n const text = itemText(item);\n if (!queryKey || !text) return 0;\n const itemNameKey = normalize(item.itemName);\n if (itemNameKey && (queryKey.includes(itemNameKey) || itemNameKey.includes(queryKey))) return 1;\n const queryTokens = queryKey.split(' ').filter((token) => token.length > 1);\n const itemTokens = text.split(' ').filter((token) => token.length > 1);\n if (!queryTokens.length || !itemTokens.length) return 0;\n const matched = itemTokens.filter((token) =>\n queryTokens.some((candidate) => token === candidate || token.includes(candidate) || candidate.includes(token)),\n ).length;\n return matched / itemTokens.length;\n};\n\nconst bestAllowedItemForQuery = (query: string, allowedItems: BulkBillAgentAllowedItem[]) => {\n const best = allowedItems\n .map((item) => ({ item, score: candidateAllowedScore(query, item) }))\n .sort((left, right) => right.score - left.score)[0];\n return best && best.score >= 0.34 ? best : null;\n};\n\nconst profileTextLines = (pages: BulkBillAgentProfilePage[] = [], group: BulkBillAgentProfileGroup, documentText = '') => {\n const wanted = new Set(group.pageNumbers.map(Number));\n const selectedPages = pages.filter((page) => wanted.has(Number(page.pageNumber)));\n if (!selectedPages.length && documentText) {\n return documentText.split(/\\n+/).map((text, lineIndex) => ({\n pageNumber: 1,\n lineIndex,\n text: text.replace(/\\s+/g, ' ').trim(),\n }));\n }\n return selectedPages.flatMap((page) =>\n String(page.text || '').split(/\\n+/).map((text, lineIndex) => ({\n pageNumber: Number(page.pageNumber),\n lineIndex,\n text: text.replace(/\\s+/g, ' ').trim(),\n })),\n );\n};\n\nconst buildProfileCandidate = ({\n group,\n profileId,\n pageNumber,\n lineIndex,\n numberIndex,\n itemName,\n quantity,\n unit,\n evidenceText,\n allowedMatch,\n role = 'item_table_quantity',\n confidence = 0.76,\n}: {\n group: BulkBillAgentProfileGroup;\n profileId: BulkBillAgentProfileId;\n pageNumber: number;\n lineIndex: number;\n numberIndex: number;\n itemName: string;\n quantity: string;\n unit: string;\n evidenceText: string;\n allowedMatch: { item: BulkBillAgentAllowedItem; score: number } | null;\n role?: string;\n confidence?: number;\n}): BulkBillAgentProfileCandidate => ({\n candidateId: `${group.groupId}-${profileId}-${pageNumber}-${lineIndex}-${numberIndex}-${compactKey(itemName).slice(0, 24)}`,\n groupId: group.groupId,\n profileId,\n itemName: allowedMatch?.item.itemName || itemName,\n quantity: quantity.replace(/,/g, ''),\n unit,\n role,\n confidence: Math.min(0.98, confidence + (allowedMatch?.score || 0) * 0.14),\n pageNumber,\n evidenceText,\n matchedAllowedItemName: allowedMatch?.item.itemName,\n matchedAllowedItemKey: allowedMatch?.item.itemKey,\n matchedAllowedItemSourceId: allowedMatch?.item.sourceId,\n mappingConfidence: allowedMatch?.score || undefined,\n});\n\nconst refrigerantLabel = (line: string) => {\n const match = line.match(/\\b(?:hfc[-\\s]*)?r[-\\s]?(?:410\\s*a?|32|134\\s*a?|22|404\\s*a?|125|407\\s*c?)\\b/i);\n if (!match) return '';\n return match[0].toUpperCase().replace(/\\s+/g, ' ').replace(/^R\\s*/, 'R-').replace(/R-410A$/, 'R-410 A');\n};\n\nconst industrialGasLabel = (line: string) => {\n if (/\\b(?:o2|0?2\\s*gas|oxygen)\\b/i.test(line)) return 'Oxygen Gas';\n if (/\\b(?:co2|c0?2|carbon\\s+dioxide)\\b/i.test(line)) return 'CO2 Gas';\n if (/\\bnitrogen\\b/i.test(line)) return 'Nitrogen Gas';\n if (/\\bargon\\b/i.test(line)) return 'Argon Gas';\n if (/\\bacetylene\\b/i.test(line)) return 'Acetylene';\n return '';\n};\n\nconst fuelLabel = (line: string) => {\n if (/\\b(?:hsd|diesel)\\b/i.test(line)) return 'Diesel';\n if (/\\bpetrol\\b/i.test(line)) return 'Petrol';\n if (/\\bcng\\b/i.test(line)) return 'CNG';\n if (/\\bfurnace\\s+oil\\b/i.test(line)) return 'Furnace Oil';\n if (/\\b(?:petroleum\\s+coke|petcoke|coke)\\b/i.test(line)) return 'Petroleum Coke';\n if (/\\bcoal\\b/i.test(line)) return 'Coal';\n if (/\\b(?:lpg|liquefied\\s+petroleum)\\b/i.test(line)) return 'LPG';\n if (/\\b(?:lubrication\\s+oil|lube\\s+oil|grease)\\b/i.test(line)) return 'Lubrication Oil';\n if (/\\bkerosene\\b/i.test(line)) return 'Kerosene';\n return '';\n};\n\nconst fireExtinguisherLabel = (line: string) =>\n /\\b(?:fire\\s+extinguisher|extinguisher|refill|refilling)\\b/i.test(line) ? 'Fire Extinguisher Refilling' : '';\n\nconst sf6Label = (line: string) =>\n /\\b(?:sf6|sulph?ur\\s+hexafluoride)\\b/i.test(line) ? 'SF6 Usage' : '';\n\nconst waterLabel = (line: string) => {\n if (/\\b(?:tanker)\\b/i.test(line)) return 'Tanker Water';\n if (/\\b(?:municipal|corporation|utility)\\b/i.test(line)) return 'Municipal Water';\n if (/\\b(?:ground\\s*water|borewell|bore\\s*well)\\b/i.test(line)) return 'Groundwater';\n if (/\\b(?:wastewater|effluent|sewage)\\b/i.test(line)) return 'Wastewater';\n return /\\bwater\\b/i.test(line) ? 'Water' : '';\n};\n\nconst wasteLabel = (line: string) => {\n if (/\\bhazardous\\b/i.test(line)) return 'Hazardous Waste';\n if (/\\b(?:recycl|scrap)\\b/i.test(line)) return 'Recycled Waste';\n if (/\\bcompost\\b/i.test(line)) return 'Composted Waste';\n if (/\\blandfill\\b/i.test(line)) return 'Landfill Waste';\n return /\\bwaste\\b/i.test(line) ? 'Waste Generated in Operations' : '';\n};\n\nconst businessTravelLabel = (line: string) => {\n if (/\\b(?:flight|airline|air\\s+travel)\\b/i.test(line)) return 'Air Travel';\n if (/\\b(?:train|rail|metro)\\b/i.test(line)) return 'Rail Travel';\n if (/\\b(?:hotel|room\\s*night|nights?)\\b/i.test(line)) return 'Hotel Stay';\n if (/\\b(?:taxi|cab|rental\\s+car|car\\s+rental)\\b/i.test(line)) return 'Rental Car';\n return '';\n};\n\nconst processEmissionLabel = (line: string) => {\n if (/\\bclinker\\b/i.test(line)) return 'Clinker';\n if (/\\bcalcination\\b/i.test(line)) return 'Calcination Process';\n if (/\\b(?:limestone|dolomite|flux)\\b/i.test(line)) return 'Flux calcination';\n if (/\\b(?:hot\\s+metal|ironmaking)\\b/i.test(line)) return 'Process Emissions- Ironmaking';\n if (/\\bsteelmaking\\b/i.test(line)) return 'Process Emissions- Steelmaking';\n return '';\n};\n\nconst genericMaterialLabel = (line: string, allowedItems: BulkBillAgentAllowedItem[]) => {\n if (metadataOnlyPattern.test(line) && !physicalUnitPattern.test(line)) return '';\n const best = bestAllowedItemForQuery(line, allowedItems);\n return best?.item.itemName || line.split('|').map((part) => part.trim()).find((part) => /[A-Za-z]/.test(part) && !metadataOnlyPattern.test(part)) || '';\n};\n\nconst commuteModeLabel = (line: string) => {\n const text = normalize(line);\n if (/\\b(bike|bikt|motorcycle)\\b/.test(text)) return 'Motorcycle';\n if (/\\b(scooty|scoow|scooter)\\b/.test(text)) return 'Scooter';\n if (/\\b(auto|byauto|auio)\\b/.test(text)) return 'Small Car Gasoline';\n if (/\\b(car|eycar|hatchback)\\b/.test(text)) return 'Hatchback Gasoline';\n if (/\\b(metro|14etro|train|rail)\\b/.test(text)) return 'Train Domestic Electric';\n if (/\\b(cycle|cycl|cyct)\\b/.test(text)) return 'Employee commute cycle';\n if (/\\b(bus)\\b/.test(text)) return 'Bus';\n return '';\n};\n\nconst extractNamedQuantityCandidates = ({\n profileId,\n group,\n lines,\n allowedItems,\n labelForLine,\n}: {\n profileId: BulkBillAgentProfileId;\n group: BulkBillAgentProfileGroup;\n lines: ReturnType<typeof profileTextLines>;\n allowedItems: BulkBillAgentAllowedItem[];\n labelForLine: (line: string, allowedItems: BulkBillAgentAllowedItem[]) => string;\n}) => lines.flatMap(({ pageNumber, lineIndex, text }) => {\n if (!text || (metadataOnlyPattern.test(text) && !physicalUnitPattern.test(text))) return [];\n const itemName = labelForLine(text, allowedItems);\n if (!itemName) return [];\n return parsePositiveNumbers(text).flatMap((entry, numberIndex) => {\n const unit = adjacentActivityUnit(text, entry.index, entry.value.length);\n if (!unit) return [];\n const allowedMatch = bestAllowedItemForQuery(`${itemName} ${text}`, allowedItems);\n return [buildProfileCandidate({\n group,\n profileId,\n pageNumber,\n lineIndex,\n numberIndex,\n itemName,\n quantity: entry.value,\n unit,\n evidenceText: text,\n allowedMatch,\n })];\n });\n});\n\nconst extractElectricityCandidates = (\n group: BulkBillAgentProfileGroup,\n lines: ReturnType<typeof profileTextLines>,\n allowedItems: BulkBillAgentAllowedItem[],\n) => {\n const electricityLine = /\\b(?:net\\s+cons\\.?\\s+for\\s+billing|billed\\s+units?|billing\\s+units?|units\\s+consumed|energy\\s+consumption|import|export|generation|solar|renewable)\\b/i;\n return lines.flatMap(({ pageNumber, lineIndex, text }) => {\n if (!electricityLine.test(text) || metadataOnlyPattern.test(text)) return [];\n return parsePositiveNumbers(text).flatMap((entry, numberIndex) => {\n const unit = adjacentActivityUnit(text, entry.index, entry.value.length) || (/\\bunits?\\b/i.test(text) ? 'kWh' : '');\n if (!unit || !/\\b(?:kwh|kvah|mwh)\\b/i.test(unit)) return [];\n const role = /\\b(?:solar|renewable|generation|export)\\b/i.test(text) ? 'component_consumption' : 'bill_level_consumption';\n const allowedMatch = bestAllowedItemForQuery(text, allowedItems);\n return [buildProfileCandidate({\n group,\n profileId: 'electricity',\n pageNumber,\n lineIndex,\n numberIndex,\n itemName: allowedMatch?.item.itemName || 'Electricity Purchased from Grid',\n quantity: entry.value,\n unit,\n evidenceText: text,\n allowedMatch,\n role,\n confidence: role === 'bill_level_consumption' ? 0.86 : 0.78,\n })];\n });\n });\n};\n\nconst extractEmployeeCommutingCandidates = (\n group: BulkBillAgentProfileGroup,\n lines: ReturnType<typeof profileTextLines>,\n allowedItems: BulkBillAgentAllowedItem[],\n) => {\n const totals = new Map<string, { total: number; evidence: string[]; pageNumber: number }>();\n for (const { pageNumber, text } of lines) {\n const mode = commuteModeLabel(text);\n if (!mode) continue;\n const distanceValues = parsePositiveNumbers(text)\n .filter((entry) => /\\bkm\\b/i.test(text.slice(entry.index, entry.index + 24)) || /\\bkm\\b/i.test(text));\n const value = distanceValues.length ? distanceValues[distanceValues.length - 1].number : null;\n if (!value) continue;\n const current = totals.get(mode) || { total: 0, evidence: [], pageNumber };\n current.total += value;\n if (current.evidence.length < 4) current.evidence.push(text);\n totals.set(mode, current);\n }\n return [...totals.entries()].map(([mode, aggregate], index) => {\n const allowedMatch = bestAllowedItemForQuery(mode, allowedItems);\n return buildProfileCandidate({\n group,\n profileId: 'employee_commuting',\n pageNumber: aggregate.pageNumber,\n lineIndex: index,\n numberIndex: 0,\n itemName: mode,\n quantity: String(Number(aggregate.total.toFixed(5))),\n unit: 'km',\n evidenceText: aggregate.evidence.join(' | '),\n allowedMatch,\n role: 'aggregated_distance',\n confidence: 0.88,\n });\n });\n};\n\nconst extractForProfile = (\n profileId: BulkBillAgentProfileId,\n group: BulkBillAgentProfileGroup,\n lines: ReturnType<typeof profileTextLines>,\n allowedItems: BulkBillAgentAllowedItem[],\n) => {\n if (profileId === 'electricity') return extractElectricityCandidates(group, lines, allowedItems);\n if (profileId === 'employee_commuting') return extractEmployeeCommutingCandidates(group, lines, allowedItems);\n\n const labelForProfile: Partial<Record<BulkBillAgentProfileId, (line: string, allowedItems: BulkBillAgentAllowedItem[]) => string>> = {\n fuel_combustion: (line) => fuelLabel(line),\n lpg_usage: (line) => fuelLabel(line),\n refrigerants: (line) => refrigerantLabel(line),\n industrial_gases: (line) => industrialGasLabel(line),\n business_travel: (line) => businessTravelLabel(line),\n fire_extinguisher: (line) => fireExtinguisherLabel(line),\n sf6_usage: (line) => sf6Label(line),\n water: (line) => waterLabel(line),\n waste: (line) => wasteLabel(line),\n process_emissions: (line) => processEmissionLabel(line),\n purchased_goods: genericMaterialLabel,\n generic_material: genericMaterialLabel,\n };\n\n const labelForLine = labelForProfile[profileId] || genericMaterialLabel;\n return extractNamedQuantityCandidates({ profileId, group, lines, allowedItems, labelForLine });\n};\n\nexport const extractBulkBillAgentProfileCandidates = ({\n mappingContext = {},\n pages = [],\n group,\n documentText = '',\n}: BulkBillAgentProfileExtractionInput) => {\n const allowedItems = Array.isArray(mappingContext.allowedItems) ? mappingContext.allowedItems : [];\n const lines = profileTextLines(pages, group, documentText);\n const groupText = documentText || lines.map((line) => line.text).join('\\n');\n const primaryProfile = getPrimaryBulkBillAgentProfile(mappingContext, groupText);\n const profiles = getBulkBillAgentProfilesForMappingContext(mappingContext, groupText)\n .map((entry) => entry.profile.id)\n .filter((profileId, index, profileIds) => profileIds.indexOf(profileId) === index);\n const extractionProfiles = profiles.length ? profiles : [primaryProfile.id];\n const candidates = extractionProfiles.flatMap((profileId) =>\n extractForProfile(profileId, group, lines, allowedItems),\n );\n const seen = new Set<string>();\n return candidates\n .sort((left, right) => right.confidence - left.confidence)\n .filter((candidate) => {\n const key = [candidate.profileId, candidate.matchedAllowedItemKey || candidate.itemName, candidate.quantity, candidate.unit, candidate.pageNumber].join('|');\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n })\n .slice(0, 30);\n};\n\nexport interface BulkBillAgentWorkerPromptInput {\n mappingContext?: BulkBillAgentMappingContext;\n groupId: string;\n pageNumbers: number[];\n documentType?: string;\n documentText?: string;\n}\n\nexport const buildBulkBillAgentRouterPrompt = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const config = buildBulkBillAgentPromptConfig(context, documentText);\n return `You are the ZeroCarbon bulk bill router and grouping supervisor.\n\nYour only job is to prepare worker-ready bill groups.\n\nResponsibilities:\n- inspect the ERP page context and allowed items\n- load document metadata\n- read OCR text in batches for the whole document\n- fingerprint pages when useful\n- compare neighboring page boundaries when useful\n- stage bill groups\n- classify each staged group\n- record ERP compatibility for each staged group\n\nDo not extract quantities, do not save extracted rows, do not validate rows, and do not persist rows.\n\nStop once every page is read and every staged group has both:\n- a document classification\n- an ERP compatibility decision\n\nLocked ERP page context:\n- profile: ${config.profile.label} (${config.profile.id})\n- scope: ${config.uploadContext.scope || 'not specified'}\n- category: ${config.uploadContext.category || 'not specified'}\n- plant: ${config.uploadContext.plant || 'not specified'}\n\nAllowed ERP items on this page (${config.allowedItemCount} total):\n${promptBulletList(config.allowedItemSummaries.slice(0, 30))}\n\nIf the document appears to contain multiple bills or mixed bill types, stage separate groups. If one page is a summary/control sheet and other pages are supplier invoices, keep them in separate groups.`;\n};\n\nexport const buildBulkBillAgentWorkerPrompt = ({\n mappingContext = {},\n groupId,\n pageNumbers,\n documentType = 'unknown',\n documentText = '',\n}: BulkBillAgentWorkerPromptInput) => {\n const config = buildBulkBillAgentPromptConfig(mappingContext, documentText);\n return `You are the ZeroCarbon ${config.profile.label} worker for one staged bill group.\n\nYou must only work on:\n- groupId: ${groupId}\n- pages: ${pageNumbers.join(', ')}\n- classified document type: ${documentType}\n\nYour job:\n- inspect only this group's evidence\n- extract physical activity candidates for this group\n- repair OCR issues when evidence supports it\n- search/inspect the locked ERP items for this group\n- save extracted rows for this group\n- save review rows for this group when a safe normal row cannot be produced\n\nDo not regroup the document. Do not validate all rows across the whole job. Do not persist validated rows. Do not finalize the whole job.\n\nActive extraction profile:\n- profile: ${config.profile.label} (${config.profile.id})\n- scope: ${config.uploadContext.scope || 'not specified'}\n- category: ${config.uploadContext.category || 'not specified'}\n- plant: ${config.uploadContext.plant || 'not specified'}\n\nCategory-specific extraction rules:\n${promptBulletList(config.profile.extractionRules)}\n\nCategory-specific reject rules:\n${promptBulletList(config.profile.rejectRules)}\n\nAllowed ERP items for this worker (${config.allowedItemCount} total):\n${promptBulletList(config.allowedItemSummaries.slice(0, 30))}\n\nCritical rules:\n- never save rows for any other group\n- never use another group's page evidence\n- if the group is incompatible with the ERP page, save review rows instead of forcing mapping\n- if the document has its own dates or period, use those instead of upload context`;\n};\n\nexport const buildBulkBillAgentFinalizerPrompt = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const config = buildBulkBillAgentPromptConfig(context, documentText);\n return `You are the ZeroCarbon finalizer and persistence worker.\n\nYour only job is to:\n- inspect the current workspace state\n- validate extracted rows against locked ERP items\n- persist validated rows to the backend\n- finalize the job with the correct outcome\n\nDo not read more pages. Do not restage groups. Do not perform new extraction unless there is a critical gap that prevents safe finalization.\n\nActive ERP page:\n- profile: ${config.profile.label} (${config.profile.id})\n- scope: ${config.uploadContext.scope || 'not specified'}\n- category: ${config.uploadContext.category || 'not specified'}\n\nFinalize rules:\n- use outcome completed when backend persistence succeeded, no review rows remain, and backend returned no blocking review/conflict rows\n- backend skipped duplicates are non-blocking if the mapped row was otherwise persisted or intentionally skipped as a duplicate\n- use outcome review_required when review rows remain or backend returned blocking review/conflict rows\n- use outcome failed only for unrecoverable execution errors`;\n};\n"],"names":[],"mappings":";;AAoEA,MAAM,SAAS,GAAG,CAAC,KAAc,KAC/B,MAAM,CAAC,KAAK,aAAL,KAAK,KAAA,MAAA,GAAL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kBillAgentProfileId =\n | 'electricity'\n | 'fuel_combustion'\n | 'refrigerants'\n | 'industrial_gases'\n | 'employee_commuting'\n | 'business_travel'\n | 'lpg_usage'\n | 'fire_extinguisher'\n | 'sf6_usage'\n | 'water'\n | 'waste'\n | 'purchased_goods'\n | 'process_emissions'\n | 'generic_material';\n\nexport interface BulkBillAgentAllowedItem {\n itemKey?: string;\n sourceId?: string;\n itemName?: string;\n billCategory?: string;\n billSubCategory?: string;\n billNestedSubCategory?: string;\n billType?: string;\n unit?: string;\n emissionFactor?: number;\n requiresMassData?: boolean;\n}\n\nexport interface BulkBillAgentMappingContext {\n locked?: boolean;\n scope?: string;\n category?: string;\n route?: string;\n plant?: string;\n year?: number | string;\n month?: number | string;\n yearType?: string;\n allowedItems?: BulkBillAgentAllowedItem[];\n}\n\nexport interface BulkBillAgentProfile {\n id: BulkBillAgentProfileId;\n label: string;\n description: string;\n documentTypes: string[];\n itemSignals: string[];\n documentSignals: string[];\n preferredUnits: string[];\n extractionRules: string[];\n rejectRules: string[];\n}\n\nexport interface BulkBillAgentPromptConfig {\n profile: BulkBillAgentProfile;\n allowedItemCount: number;\n allowedItemSummaries: string[];\n uploadContext: {\n scope: string;\n category: string;\n plant: string;\n year: string;\n month: string;\n yearType: string;\n route: string;\n };\n}\n\nconst normalize = (value: unknown) =>\n String(value ?? '')\n .toLowerCase()\n .replace(/co₂/g, 'co2')\n .replace(/[^a-z0-9]+/g, ' ')\n .trim();\n\nconst includesAny = (text: string, signals: readonly string[]) =>\n signals.some((signal) => text.includes(signal));\n\nconst itemText = (item: BulkBillAgentAllowedItem) =>\n normalize([\n item.itemName,\n item.billCategory,\n item.billSubCategory,\n item.billNestedSubCategory,\n item.billType,\n item.unit,\n ].filter(Boolean).join(' '));\n\nconst mappingContextText = (context: BulkBillAgentMappingContext = {}) =>\n normalize([\n context.scope,\n context.category,\n ...(Array.isArray(context.allowedItems) ? context.allowedItems.map(itemText) : []),\n ].filter(Boolean).join(' '));\n\nexport const BULK_BILL_AGENT_PROFILES: Record<BulkBillAgentProfileId, BulkBillAgentProfile> = {\n electricity: {\n id: 'electricity',\n label: 'Electricity',\n description: 'Grid electricity, renewable electricity, kWh/kVAh/MWh utility bills.',\n documentTypes: ['electricity_bill'],\n itemSignals: ['electric', 'electricity', 'grid', 'renewable', 'solar', 'power', 'kwh', 'kvah', 'mwh', 'location based', 'market based', 'purchased electricity'],\n documentSignals: ['kwh', 'kvah', 'mwh', 'meter', 'discom', 'vidyut', 'billed units', 'net consumption', 'energy charge'],\n preferredUnits: ['kWh', 'kVAh', 'MWh'],\n extractionRules: [\n 'Prefer current-period bill-level or net billed consumption over charges, rates, TOD/slab rows, arrears, or historical meter rows.',\n 'For grid import or purchased electricity, use current-period import/from-grid consumption.',\n 'When a purchased grid electricity bill does not explicitly distinguish national vs regional grid, default the ERP mapping to Regional Grid; do not send it to review for that ambiguity alone.',\n 'For solar or renewable electricity, use current-period generation or renewable energy consumption.',\n 'Treat “units” as kWh only for electricity documents.',\n ],\n rejectRules: ['Reject taxes, demand/fixed charges, tariff/rate rows, previous readings, arrears, and currency amounts.'],\n },\n fuel_combustion: {\n id: 'fuel_combustion',\n label: 'Fuel combustion',\n description: 'Diesel, HSD, petrol, furnace oil, coal, coke, CNG and other stationary/mobile combustion fuels.',\n documentTypes: ['fuel_invoice', 'material_invoice'],\n itemSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'furnace oil', 'coal', 'coke', 'cng', 'kerosene', 'ldo', 'mobile combustion', 'stationary combustion', 'operation'],\n documentSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'litre', 'liter', 'kl', 'furnace oil', 'coal', 'petcoke', 'cng'],\n preferredUnits: ['KL', 'Litre', 'Kg', 'Tonnes', 'M3', 'SCM'],\n extractionRules: [\n 'Extract physical fuel quantity, not invoice amount or rate.',\n 'Map vehicle fuel rows to mobile combustion items and generator/boiler/process fuel rows to stationary or operation items when the evidence supports it.',\n 'Preserve the bill unit; unit conversion belongs to validation unless the document states density or conversion explicitly.',\n ],\n rejectRules: ['Reject fuel rates, taxes, HSN/SAC codes, payment totals, and non-fuel services.'],\n },\n refrigerants: {\n id: 'refrigerants',\n label: 'Refrigerants',\n description: 'AC gas and refrigerant purchases/refills such as R-410A, R-32, R-134a, R-22.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['refrigerant', 'refrigerants', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'hfc', 'ac gas', 'chiller'],\n documentSignals: ['refrigerant', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'ac gas', 'chiller gas'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: [\n 'Extract refrigerant top-up, refill, or purchase quantity by refrigerant grade.',\n 'Repair OCR variants like R410, R-410, R 410A, R-410 A to the closest allowed ERP item.',\n 'Do not infer leakage; only extract documented physical quantity.',\n ],\n rejectRules: ['Reject service charges, labour, AC unit model numbers, invoice totals, and taxes.'],\n },\n industrial_gases: {\n id: 'industrial_gases',\n label: 'Industrial gases',\n description: 'Oxygen, CO2, nitrogen, argon, acetylene and cylinder gas invoices.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['oxygen', 'o2', 'co2', 'carbon dioxide', 'nitrogen', 'argon', 'acetylene', 'gas cylinder', 'industrial gas', 'welding'],\n documentSignals: ['oxygen', 'o2 gas', 'co2 gas', 'nitrogen', 'argon', 'acetylene', 'cylinder', 'scm', 'nm3', 'm3'],\n preferredUnits: ['M3', 'SCM', 'NM3', 'Kg', 'Cyl'],\n extractionRules: [\n 'Extract gas quantity from row-level item quantity, not cylinder deposit, rental, or amount.',\n 'Keep cylinder count only when the ERP item unit supports count-based activity.',\n 'Repair OCR variants such as 02/O2 and C02/CO2 using allowed ERP items.',\n ],\n rejectRules: ['Reject cylinder deposits, rent, returnable assets, rates, taxes, and empty cylinder rows.'],\n },\n employee_commuting: {\n id: 'employee_commuting',\n label: 'Employee commuting',\n description: 'Employee commute rosters and distance summaries grouped by transport mode.',\n documentTypes: ['transport_roster', 'material_invoice'],\n itemSignals: ['employee commuting', 'commute', 'commuting', 'motorcycle', 'scooter', 'hatchback', 'car', 'rail', 'train', 'metro', 'bus', 'cycle', 'passenger km'],\n documentSignals: ['employee', 'transport', 'mode', 'commute', 'bike', 'scooty', 'car', 'metro', 'bus', 'cycle', 'km'],\n preferredUnits: ['km', 'passenger-km'],\n extractionRules: [\n 'Treat roster files as activity evidence even when they have no invoice number, supplier, or amount.',\n 'Group by transport mode and sum current-period distance into one row per mapped ERP item.',\n 'Use the upload period as the bill period when the roster has no date.',\n ],\n rejectRules: ['Reject employee IDs, names, phone numbers, addresses, and non-distance row counts as activity quantities.'],\n },\n business_travel: {\n id: 'business_travel',\n label: 'Business travel',\n description: 'Flights, rail, hotel stays, and rental vehicle activity.',\n documentTypes: ['travel_invoice', 'material_invoice'],\n itemSignals: ['business travel', 'flight', 'air travel', 'rail', 'train', 'hotel', 'rental car', 'passenger km', 'room night'],\n documentSignals: ['flight', 'airline', 'pnr', 'hotel', 'room night', 'train', 'rail', 'passenger km', 'ticket'],\n preferredUnits: ['km', 'passenger-km', 'night', 'room-night'],\n extractionRules: ['Extract distance, passenger-km, room nights, or trip counts only when the ERP item supports the unit.'],\n rejectRules: ['Reject fares, taxes, booking fees, passenger names, and ticket numbers as activity quantities.'],\n },\n lpg_usage: {\n id: 'lpg_usage',\n label: 'LPG usage',\n description: 'LPG cylinder and bulk LPG invoices.',\n documentTypes: ['fuel_invoice', 'gas_invoice', 'material_invoice'],\n itemSignals: ['lpg', 'liquefied petroleum gas', 'cylinder'],\n documentSignals: ['lpg', 'liquefied petroleum', 'cylinder', 'kg', 'commercial gas'],\n preferredUnits: ['Kg', 'Tonnes', 'KL', 'Cyl'],\n extractionRules: ['Extract filled LPG quantity by kg/tonnes/KL/cylinder size; prefer net fill quantity over cylinder deposit count.'],\n rejectRules: ['Reject cylinder deposits, rental, delivery charges, and taxes.'],\n },\n fire_extinguisher: {\n id: 'fire_extinguisher',\n label: 'Fire extinguisher refilling',\n description: 'CO2 and other extinguisher refill activity.',\n documentTypes: ['material_invoice'],\n itemSignals: ['fire extinguisher', 'extinguisher', 'co2 fire', 'refilling'],\n documentSignals: ['fire extinguisher', 'extinguisher', 'co2', 'refill', 'refilling'],\n preferredUnits: ['Kg', 'Tonnes', 'Cyl'],\n extractionRules: ['Extract refill gas quantity, not extinguisher asset count unless the ERP item is count-based.'],\n rejectRules: ['Reject maintenance service charges, inspection fees, and asset serial numbers.'],\n },\n sf6_usage: {\n id: 'sf6_usage',\n label: 'SF6 usage',\n description: 'SF6 gas purchase, refill, and switchgear top-up activity.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride'],\n documentSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride', 'switchgear'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: ['Extract documented SF6 purchase/refill/top-up quantity only.'],\n rejectRules: ['Reject switchgear model numbers, pressure readings without refill quantity, and service charges.'],\n },\n water: {\n id: 'water',\n label: 'Water',\n description: 'Municipal, borewell, tanker, and wastewater quantities.',\n documentTypes: ['water_bill', 'material_invoice'],\n itemSignals: ['water', 'groundwater', 'municipal', 'tanker', 'wastewater', 'effluent'],\n documentSignals: ['water', 'kl', 'litre', 'liter', 'tanker', 'municipal', 'wastewater', 'effluent'],\n preferredUnits: ['KL', 'Litre', 'M3'],\n extractionRules: ['Extract physical water volume by source/disposal type where possible.'],\n rejectRules: ['Reject water charges, sewerage taxes, arrears, and meter numbers as quantities.'],\n },\n waste: {\n id: 'waste',\n label: 'Waste generated in operations',\n description: 'Waste disposal, recycling, composting, landfill, hazardous/non-hazardous waste.',\n documentTypes: ['waste_invoice', 'material_invoice'],\n itemSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal'],\n documentSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal', 'kg', 'tonne'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: ['Extract disposed/recycled physical waste mass by waste type and treatment route.'],\n rejectRules: ['Reject disposal fees, GST, container rental, and vehicle numbers.'],\n },\n purchased_goods: {\n id: 'purchased_goods',\n label: 'Purchased goods and services',\n description: 'Raw materials, consumables, and purchased product quantities.',\n documentTypes: ['material_invoice', 'purchase_order'],\n itemSignals: ['purchased goods', 'goods', 'services', 'material', 'raw material', 'consumable', 'packaging'],\n documentSignals: ['invoice', 'tax invoice', 'hsn', 'material', 'goods', 'quantity', 'qty', 'purchase order'],\n preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],\n extractionRules: ['Extract row-level material quantity only when the item maps to an allowed ERP item.'],\n rejectRules: ['Reject rates, taxes, HSN/SAC codes, payment terms, and unmatched non-emission materials.'],\n },\n process_emissions: {\n id: 'process_emissions',\n label: 'Process emissions',\n description: 'Cement clinker calcination, ironmaking/steelmaking, flux calcination and other process quantities.',\n documentTypes: ['production_log', 'material_invoice'],\n itemSignals: ['calcination', 'clinker', 'ironmaking', 'steelmaking', 'flux', 'process emissions', 'hot metal', 'limestone', 'dolomite'],\n documentSignals: ['clinker', 'calcination', 'limestone', 'dolomite', 'hot metal', 'steelmaking', 'production', 'tonne'],\n preferredUnits: ['Tonnes', 'Kg'],\n extractionRules: ['Extract production/process input quantity tied to the selected process item.'],\n rejectRules: ['Reject financial totals, quality percentages, and composition values unless explicitly configured as activity data.'],\n },\n generic_material: {\n id: 'generic_material',\n label: 'Generic material invoice',\n description: 'Fallback for material invoices that do not fit a narrower profile.',\n documentTypes: ['material_invoice', 'purchase_order', 'unknown'],\n itemSignals: ['material', 'goods', 'services', 'quantity', 'qty'],\n documentSignals: ['invoice', 'quantity', 'qty', 'unit', 'hsn', 'sac'],\n preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],\n extractionRules: ['Extract only row-level physical quantities that can be matched to allowed ERP items.'],\n rejectRules: ['Reject invoice metadata, rates, taxes, totals, and unmatched rows.'],\n },\n};\n\nconst ROUTING_PRIORITY: BulkBillAgentProfileId[] = [\n 'electricity',\n 'employee_commuting',\n 'refrigerants',\n 'sf6_usage',\n 'fire_extinguisher',\n 'lpg_usage',\n 'industrial_gases',\n 'fuel_combustion',\n 'business_travel',\n 'water',\n 'waste',\n 'process_emissions',\n 'purchased_goods',\n 'generic_material',\n];\n\nexport const getBulkBillAgentProfile = (profileId: BulkBillAgentProfileId) =>\n BULK_BILL_AGENT_PROFILES[profileId];\n\nexport const listBulkBillAgentProfiles = () =>\n ROUTING_PRIORITY.map((profileId) => BULK_BILL_AGENT_PROFILES[profileId]);\n\nexport const scoreBulkBillAgentProfile = (\n profile: BulkBillAgentProfile,\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const contextText = mappingContextText(context);\n const docText = normalize(documentText);\n const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];\n const itemMatches = allowedItems.filter((item) => includesAny(itemText(item), profile.itemSignals)).length;\n const contextMatch = includesAny(contextText, profile.itemSignals) ? 2 : 0;\n const categoryMatch = includesAny(normalize(context.category), profile.itemSignals) ? 3 : 0;\n const documentMatch = docText && includesAny(docText, profile.documentSignals) ? 2 : 0;\n const unitMatch = allowedItems.filter((item) => includesAny(normalize(item.unit), profile.preferredUnits.map(normalize))).length;\n return itemMatches * 3 + unitMatch + contextMatch + categoryMatch + documentMatch;\n};\n\nexport const getBulkBillAgentProfilesForMappingContext = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const scored = ROUTING_PRIORITY\n .map((profileId) => {\n const profile = BULK_BILL_AGENT_PROFILES[profileId];\n return { profile, score: scoreBulkBillAgentProfile(profile, context, documentText) };\n })\n .filter((entry) => entry.score > 0)\n .sort((left, right) => right.score - left.score);\n\n return scored.length ? scored : [{ profile: BULK_BILL_AGENT_PROFILES.generic_material, score: 0 }];\n};\n\nexport const getPrimaryBulkBillAgentProfile = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => getBulkBillAgentProfilesForMappingContext(context, documentText)[0].profile;\n\nconst formatAllowedItem = (item: BulkBillAgentAllowedItem) => {\n const hierarchy = [item.billCategory, item.billSubCategory, item.billNestedSubCategory]\n .filter(Boolean)\n .join(' > ');\n return `${item.itemName || item.billNestedSubCategory || 'Unnamed item'}${hierarchy ? ` (${hierarchy})` : ''}; expected unit: ${item.unit || 'not specified'}; key: ${item.itemKey || item.sourceId || 'not specified'}`;\n};\n\nexport const buildBulkBillAgentPromptConfig = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n): BulkBillAgentPromptConfig => {\n const profile = getPrimaryBulkBillAgentProfile(context, documentText);\n const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];\n return {\n profile,\n allowedItemCount: allowedItems.length,\n allowedItemSummaries: allowedItems.map(formatAllowedItem),\n uploadContext: {\n scope: String(context.scope || ''),\n category: String(context.category || ''),\n plant: String(context.plant || ''),\n year: String(context.year || ''),\n month: String(context.month || ''),\n yearType: String(context.yearType || ''),\n route: String(context.route || ''),\n },\n };\n};\n\nconst baseBulkBillAgentSystemPrompt = `You are a ZeroCarbon bulk bill processing agent running inside an open-ended tool harness.\n\nYou do not follow a fixed workflow. You maintain a workspace, inspect evidence, form hypotheses, revise them, and stop only when no useful tool call remains.\n\nNon-negotiable extraction contract:\n- First understand the document. For each bill/page group, stage pages and call classify_bill_group. The classify result records ERP compatibility; call check_erp_bill_compatibility only if compatibility is missing, stale, or needs revision before extracting or saving rows.\n- A PDF can contain mixed bill types. Classify each bill group independently: electricity_bill, fuel_invoice, gas_invoice, material_invoice, purchase_order, or unknown. Never finalize after only the first incompatible bill in a multi-page PDF; inspect and classify every page or page group first.\n- If a bill type is incompatible with the locked ERP page/allowed items, do not force mapping. Leave it for review with a clear reason.\n- After compatibility is recorded, call extract_activity_candidates to get typed physical candidates. Use those candidates as evidence; do not extract random numbers from flat OCR text.\n- If a specialized profile is listed below, treat it as the active sub-agent contract for this ERP page. Apply its extraction rules before generic extraction heuristics.\n- If extract_activity_candidates returns recommendedRows for electricity, use those rows directly with save_extracted_rows unless you can cite a concrete validation problem. Do not replace deterministic recommended rows with review rows.\n- Extract only physical activity rows: energy, mass, volume, distance, count only when the ERP item supports count-based activity. Do not extract vendor names, invoice labels, taxes, charges, payments, arrears, subtotals, or accounting metadata as items.\n- For each candidate row, classify doubtful rows and search the locked ERP items before deciding to save or review.\n- When more than one allowed ERP item can match, make an evidence-backed mapping decision when possible. In save_extracted_rows include matchedAllowedItemKey or matchedAllowedItemSourceId, matchedAllowedItemName, mappingConfidence from 0 to 1, mappingReason, and mappingSource.\n- If OCR is partial, use neighboring rows, repeated labels, row evidence, typed candidates, and ERP context to repair the candidate. Keep raw evidence in rowEvidenceText.\n- For electricity or any ambiguous utility bill, call select_activity_quantity on staged bill pages before save_extracted_rows. Prefer bill-level/billing consumption for generic grid bills. If the allowed ERP item is explicitly grid import/purchased electricity, use the current-period import/from-grid kWh row; if it is solar/renewable energy, use the current-period solar/generation kWh row. Do not use TOD, slab, charge, amount, rate, date, register, or historical rows. Never switch to a weaker component only to match ERP unit.\n- Never persist just because a row exists. Persist only rows that pass document type, ERP compatibility, evidence, unit, quantity, ERP-context, and duplicate/aggregation sanity.\n- It is acceptable to call the same tool multiple times with repaired inputs. It is acceptable to revise groups and rows.\n- If a group cannot be safely extracted or mapped, call save_review_rows with source pages, evidence, and a clear reason instead of saving an incomplete normal row.\n- Use persist_validated_rows after validation. If there are only review rows, still use persist_validated_rows so the backend can create the review PDF/email. Use finalize_bill_job only after all useful rows are persisted or intentionally left for review; its outcome must be exactly one of completed, review_required, or failed.\n- Do not invent emission factors, quantities, units, invoice numbers, or page evidence.\n\nYour output to the user is the job state and streamed tool activity, so keep tool arguments and notes specific and evidence-backed.`;\n\nconst promptBulletList = (items: readonly string[]) => items.map((item) => `- ${item}`).join('\\n');\n\nexport const buildBulkBillAgentSystemPrompt = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const config = buildBulkBillAgentPromptConfig(context, documentText);\n const allowedItems = config.allowedItemSummaries.slice(0, 40);\n return `${baseBulkBillAgentSystemPrompt}\n\nActive ERP extraction sub-agent contract:\nProfile: ${config.profile.label} (${config.profile.id})\nDescription: ${config.profile.description}\nExpected document types: ${config.profile.documentTypes.join(', ') || 'not specified'}\nPreferred units: ${config.profile.preferredUnits.join(', ') || 'not specified'}\n\nUpload context:\n- Scope: ${config.uploadContext.scope || 'not specified'}\n- Category: ${config.uploadContext.category || 'not specified'}\n- Plant: ${config.uploadContext.plant || 'not specified'}\n\nCritical document-period rule:\n- Do not assume the upload period is the bill period. Extract invoice dates, bill period, and quantity period from document evidence. Use upload context only when the document truly has no period evidence.\n\nCategory-specific extraction rules:\n${promptBulletList(config.profile.extractionRules)}\n\nCategory-specific reject rules:\n${promptBulletList(config.profile.rejectRules)}\n\nAllowed ERP items for this upload (${config.allowedItemCount} total, first ${allowedItems.length} shown):\n${promptBulletList(allowedItems)}\n\nFollow this profile unless page evidence clearly proves a different bill type; if evidence conflicts with the ERP page, send rows to review instead of forcing a mapping.`;\n};\n\nexport interface BulkBillAgentProfilePage {\n pageNumber: number | string;\n text?: string;\n}\n\nexport interface BulkBillAgentProfileGroup {\n groupId: string;\n pageNumbers: Array<number | string>;\n}\n\nexport interface BulkBillAgentProfileCandidate {\n candidateId: string;\n groupId: string;\n profileId: BulkBillAgentProfileId;\n itemName: string;\n quantity: string;\n unit: string;\n role: string;\n confidence: number;\n pageNumber: number;\n evidenceText: string;\n matchedAllowedItemName?: string;\n matchedAllowedItemKey?: string;\n matchedAllowedItemSourceId?: string;\n mappingConfidence?: number;\n}\n\nexport interface BulkBillAgentProfileExtractionInput {\n mappingContext?: BulkBillAgentMappingContext;\n pages?: BulkBillAgentProfilePage[];\n group: BulkBillAgentProfileGroup;\n documentText?: string;\n}\n\nconst numericPattern = /-?(?:(?:\\d{1,3}(?:,\\d{3})+)|\\d+)(?:\\.\\d+)?/g;\nconst physicalUnitPattern = /\\b(kwh|kw\\s*h|kvah|kva\\s*h|mwh|kg|kgs|kilograms?|tonnes?|tons?|mt|kl|litres?|liters?|ltr?s?|m3|m³|scm|ncm|nm3|km|passenger[-\\s]?km|room[-\\s]?nights?|nights?|cyl(?:inders?)?|nos?|pcs|pieces?)\\b/i;\nconst metadataOnlyPattern = /(?:₹|rs\\.?|inr|amount|payable|charge|tax|gst|duty|cess|rate|tariff|arrear|rebate|subsidy|surcharge|rent|total\\s+amount|invoice\\s*(?:no|number)|account\\s*(?:no|number)|consumer\\s*(?:no|number))/i;\n\nconst compactKey = (value: unknown) => normalize(value).replace(/\\s+/g, '');\n\nconst canonicalActivityUnit = (unit: string) => {\n const value = compactKey(unit);\n if (value === 'kwh' || value === 'unit' || value === 'units') return 'kWh';\n if (value === 'kvah') return 'kVAh';\n if (value === 'mwh') return 'MWh';\n if (value === 'kg' || value === 'kgs' || value === 'kilogram' || value === 'kilograms') return 'Kg';\n if (value === 'tonne' || value === 'tonnes' || value === 'ton' || value === 'tons' || value === 'mt') return 'Tonnes';\n if (value === 'litre' || value === 'litres' || value === 'liter' || value === 'liters' || value === 'ltr' || value === 'ltrs') return 'Litre';\n if (value === 'kl') return 'KL';\n if (value === 'm3' || value === 'm³' || value === 'scm' || value === 'ncm' || value === 'nm3') return 'M3';\n if (value === 'km') return 'km';\n if (value === 'passengerkm') return 'passenger-km';\n if (value === 'night' || value === 'nights' || value === 'roomnight' || value === 'roomnights') return 'night';\n if (value === 'cyl' || value === 'cylinder' || value === 'cylinders') return 'Cyl';\n if (value === 'nos' || value === 'no' || value === 'pcs' || value === 'pieces') return 'Nos';\n return unit;\n};\n\nconst parsePositiveNumbers = (line: string) =>\n [...line.matchAll(numericPattern)]\n .map((match) => ({\n value: match[0],\n index: match.index || 0,\n number: Number(match[0].replace(/,/g, '')),\n }))\n .filter((entry) => Number.isFinite(entry.number) && entry.number > 0 && !/[A-Za-z]/.test(line[entry.index - 1] || ''));\n\nconst adjacentActivityUnit = (line: string, numberIndex: number, valueLength: number) => {\n const after = line.slice(numberIndex + valueLength, numberIndex + valueLength + 18);\n const right = after.match(/^\\s*([A-Za-z³][-A-Za-z0-9³ ]{0,16})/i)?.[1] || '';\n const rightUnit = right.match(physicalUnitPattern)?.[1];\n if (rightUnit) return canonicalActivityUnit(rightUnit);\n const before = line.slice(Math.max(0, numberIndex - 18), numberIndex);\n const beforeUnit = before.match(new RegExp(`(${physicalUnitPattern.source})\\\\s*$`, 'i'))?.[1];\n return beforeUnit ? canonicalActivityUnit(beforeUnit) : '';\n};\n\nconst candidateAllowedScore = (query: string, item: BulkBillAgentAllowedItem) => {\n const queryKey = normalize(query);\n const text = itemText(item);\n if (!queryKey || !text) return 0;\n const itemNameKey = normalize(item.itemName);\n if (itemNameKey && (queryKey.includes(itemNameKey) || itemNameKey.includes(queryKey))) return 1;\n const queryTokens = queryKey.split(' ').filter((token) => token.length > 1);\n const itemTokens = text.split(' ').filter((token) => token.length > 1);\n if (!queryTokens.length || !itemTokens.length) return 0;\n const matched = itemTokens.filter((token) =>\n queryTokens.some((candidate) => token === candidate || token.includes(candidate) || candidate.includes(token)),\n ).length;\n return matched / itemTokens.length;\n};\n\nconst bestAllowedItemForQuery = (query: string, allowedItems: BulkBillAgentAllowedItem[]) => {\n const best = allowedItems\n .map((item) => ({ item, score: candidateAllowedScore(query, item) }))\n .sort((left, right) => right.score - left.score)[0];\n return best && best.score >= 0.34 ? best : null;\n};\n\nconst profileTextLines = (pages: BulkBillAgentProfilePage[] = [], group: BulkBillAgentProfileGroup, documentText = '') => {\n const wanted = new Set(group.pageNumbers.map(Number));\n const selectedPages = pages.filter((page) => wanted.has(Number(page.pageNumber)));\n if (!selectedPages.length && documentText) {\n return documentText.split(/\\n+/).map((text, lineIndex) => ({\n pageNumber: 1,\n lineIndex,\n text: text.replace(/\\s+/g, ' ').trim(),\n }));\n }\n return selectedPages.flatMap((page) =>\n String(page.text || '').split(/\\n+/).map((text, lineIndex) => ({\n pageNumber: Number(page.pageNumber),\n lineIndex,\n text: text.replace(/\\s+/g, ' ').trim(),\n })),\n );\n};\n\nconst buildProfileCandidate = ({\n group,\n profileId,\n pageNumber,\n lineIndex,\n numberIndex,\n itemName,\n quantity,\n unit,\n evidenceText,\n allowedMatch,\n role = 'item_table_quantity',\n confidence = 0.76,\n}: {\n group: BulkBillAgentProfileGroup;\n profileId: BulkBillAgentProfileId;\n pageNumber: number;\n lineIndex: number;\n numberIndex: number;\n itemName: string;\n quantity: string;\n unit: string;\n evidenceText: string;\n allowedMatch: { item: BulkBillAgentAllowedItem; score: number } | null;\n role?: string;\n confidence?: number;\n}): BulkBillAgentProfileCandidate => ({\n candidateId: `${group.groupId}-${profileId}-${pageNumber}-${lineIndex}-${numberIndex}-${compactKey(itemName).slice(0, 24)}`,\n groupId: group.groupId,\n profileId,\n itemName: allowedMatch?.item.itemName || itemName,\n quantity: quantity.replace(/,/g, ''),\n unit,\n role,\n confidence: Math.min(0.98, confidence + (allowedMatch?.score || 0) * 0.14),\n pageNumber,\n evidenceText,\n matchedAllowedItemName: allowedMatch?.item.itemName,\n matchedAllowedItemKey: allowedMatch?.item.itemKey,\n matchedAllowedItemSourceId: allowedMatch?.item.sourceId,\n mappingConfidence: allowedMatch?.score || undefined,\n});\n\nconst refrigerantLabel = (line: string) => {\n const match = line.match(/\\b(?:hfc[-\\s]*)?r[-\\s]?(?:410\\s*a?|32|134\\s*a?|22|404\\s*a?|125|407\\s*c?)\\b/i);\n if (!match) return '';\n return match[0].toUpperCase().replace(/\\s+/g, ' ').replace(/^R\\s*/, 'R-').replace(/R-410A$/, 'R-410 A');\n};\n\nconst industrialGasLabel = (line: string) => {\n if (/\\b(?:o2|0?2\\s*gas|oxygen)\\b/i.test(line)) return 'Oxygen Gas';\n if (/\\b(?:co2|c0?2|carbon\\s+dioxide)\\b/i.test(line)) return 'CO2 Gas';\n if (/\\bnitrogen\\b/i.test(line)) return 'Nitrogen Gas';\n if (/\\bargon\\b/i.test(line)) return 'Argon Gas';\n if (/\\bacetylene\\b/i.test(line)) return 'Acetylene';\n return '';\n};\n\nconst fuelLabel = (line: string) => {\n if (/\\b(?:hsd|diesel)\\b/i.test(line)) return 'Diesel';\n if (/\\bpetrol\\b/i.test(line)) return 'Petrol';\n if (/\\bcng\\b/i.test(line)) return 'CNG';\n if (/\\bfurnace\\s+oil\\b/i.test(line)) return 'Furnace Oil';\n if (/\\b(?:petroleum\\s+coke|petcoke|coke)\\b/i.test(line)) return 'Petroleum Coke';\n if (/\\bcoal\\b/i.test(line)) return 'Coal';\n if (/\\b(?:lpg|liquefied\\s+petroleum)\\b/i.test(line)) return 'LPG';\n if (/\\b(?:lubrication\\s+oil|lube\\s+oil|grease)\\b/i.test(line)) return 'Lubrication Oil';\n if (/\\bkerosene\\b/i.test(line)) return 'Kerosene';\n return '';\n};\n\nconst fireExtinguisherLabel = (line: string) =>\n /\\b(?:fire\\s+extinguisher|extinguisher|refill|refilling)\\b/i.test(line) ? 'Fire Extinguisher Refilling' : '';\n\nconst sf6Label = (line: string) =>\n /\\b(?:sf6|sulph?ur\\s+hexafluoride)\\b/i.test(line) ? 'SF6 Usage' : '';\n\nconst waterLabel = (line: string) => {\n if (/\\b(?:tanker)\\b/i.test(line)) return 'Tanker Water';\n if (/\\b(?:municipal|corporation|utility)\\b/i.test(line)) return 'Municipal Water';\n if (/\\b(?:ground\\s*water|borewell|bore\\s*well)\\b/i.test(line)) return 'Groundwater';\n if (/\\b(?:wastewater|effluent|sewage)\\b/i.test(line)) return 'Wastewater';\n return /\\bwater\\b/i.test(line) ? 'Water' : '';\n};\n\nconst wasteLabel = (line: string) => {\n if (/\\bhazardous\\b/i.test(line)) return 'Hazardous Waste';\n if (/\\b(?:recycl|scrap)\\b/i.test(line)) return 'Recycled Waste';\n if (/\\bcompost\\b/i.test(line)) return 'Composted Waste';\n if (/\\blandfill\\b/i.test(line)) return 'Landfill Waste';\n return /\\bwaste\\b/i.test(line) ? 'Waste Generated in Operations' : '';\n};\n\nconst businessTravelLabel = (line: string) => {\n if (/\\b(?:flight|airline|air\\s+travel)\\b/i.test(line)) return 'Air Travel';\n if (/\\b(?:train|rail|metro)\\b/i.test(line)) return 'Rail Travel';\n if (/\\b(?:hotel|room\\s*night|nights?)\\b/i.test(line)) return 'Hotel Stay';\n if (/\\b(?:taxi|cab|rental\\s+car|car\\s+rental)\\b/i.test(line)) return 'Rental Car';\n return '';\n};\n\nconst processEmissionLabel = (line: string) => {\n if (/\\bclinker\\b/i.test(line)) return 'Clinker';\n if (/\\bcalcination\\b/i.test(line)) return 'Calcination Process';\n if (/\\b(?:limestone|dolomite|flux)\\b/i.test(line)) return 'Flux calcination';\n if (/\\b(?:hot\\s+metal|ironmaking)\\b/i.test(line)) return 'Process Emissions- Ironmaking';\n if (/\\bsteelmaking\\b/i.test(line)) return 'Process Emissions- Steelmaking';\n return '';\n};\n\nconst genericMaterialLabel = (line: string, allowedItems: BulkBillAgentAllowedItem[]) => {\n if (metadataOnlyPattern.test(line) && !physicalUnitPattern.test(line)) return '';\n const best = bestAllowedItemForQuery(line, allowedItems);\n return best?.item.itemName || line.split('|').map((part) => part.trim()).find((part) => /[A-Za-z]/.test(part) && !metadataOnlyPattern.test(part)) || '';\n};\n\nconst commuteModeLabel = (line: string) => {\n const text = normalize(line);\n if (/\\b(bike|bikt|motorcycle)\\b/.test(text)) return 'Motorcycle';\n if (/\\b(scooty|scoow|scooter)\\b/.test(text)) return 'Scooter';\n if (/\\b(auto|byauto|auio)\\b/.test(text)) return 'Small Car Gasoline';\n if (/\\b(car|eycar|hatchback)\\b/.test(text)) return 'Hatchback Gasoline';\n if (/\\b(metro|14etro|train|rail)\\b/.test(text)) return 'Train Domestic Electric';\n if (/\\b(cycle|cycl|cyct)\\b/.test(text)) return 'Employee commute cycle';\n if (/\\b(bus)\\b/.test(text)) return 'Bus';\n return '';\n};\n\nconst extractNamedQuantityCandidates = ({\n profileId,\n group,\n lines,\n allowedItems,\n labelForLine,\n}: {\n profileId: BulkBillAgentProfileId;\n group: BulkBillAgentProfileGroup;\n lines: ReturnType<typeof profileTextLines>;\n allowedItems: BulkBillAgentAllowedItem[];\n labelForLine: (line: string, allowedItems: BulkBillAgentAllowedItem[]) => string;\n}) => lines.flatMap(({ pageNumber, lineIndex, text }) => {\n if (!text || (metadataOnlyPattern.test(text) && !physicalUnitPattern.test(text))) return [];\n const itemName = labelForLine(text, allowedItems);\n if (!itemName) return [];\n return parsePositiveNumbers(text).flatMap((entry, numberIndex) => {\n const unit = adjacentActivityUnit(text, entry.index, entry.value.length);\n if (!unit) return [];\n const allowedMatch = bestAllowedItemForQuery(`${itemName} ${text}`, allowedItems);\n return [buildProfileCandidate({\n group,\n profileId,\n pageNumber,\n lineIndex,\n numberIndex,\n itemName,\n quantity: entry.value,\n unit,\n evidenceText: text,\n allowedMatch,\n })];\n });\n});\n\nconst extractElectricityCandidates = (\n group: BulkBillAgentProfileGroup,\n lines: ReturnType<typeof profileTextLines>,\n allowedItems: BulkBillAgentAllowedItem[],\n) => {\n const electricityLine = /\\b(?:net\\s+cons\\.?\\s+for\\s+billing|billed\\s+units?|billing\\s+units?|units\\s+consumed|energy\\s+consumption|import|export|generation|solar|renewable)\\b/i;\n return lines.flatMap(({ pageNumber, lineIndex, text }) => {\n if (!electricityLine.test(text) || metadataOnlyPattern.test(text)) return [];\n return parsePositiveNumbers(text).flatMap((entry, numberIndex) => {\n const unit = adjacentActivityUnit(text, entry.index, entry.value.length) || (/\\bunits?\\b/i.test(text) ? 'kWh' : '');\n if (!unit || !/\\b(?:kwh|kvah|mwh)\\b/i.test(unit)) return [];\n const role = /\\b(?:solar|renewable|generation|export)\\b/i.test(text) ? 'component_consumption' : 'bill_level_consumption';\n const allowedMatch = bestAllowedItemForQuery(text, allowedItems);\n return [buildProfileCandidate({\n group,\n profileId: 'electricity',\n pageNumber,\n lineIndex,\n numberIndex,\n itemName: allowedMatch?.item.itemName || 'Electricity Purchased from Grid',\n quantity: entry.value,\n unit,\n evidenceText: text,\n allowedMatch,\n role,\n confidence: role === 'bill_level_consumption' ? 0.86 : 0.78,\n })];\n });\n });\n};\n\nconst extractEmployeeCommutingCandidates = (\n group: BulkBillAgentProfileGroup,\n lines: ReturnType<typeof profileTextLines>,\n allowedItems: BulkBillAgentAllowedItem[],\n) => {\n const totals = new Map<string, { total: number; evidence: string[]; pageNumber: number }>();\n for (const { pageNumber, text } of lines) {\n const mode = commuteModeLabel(text);\n if (!mode) continue;\n const distanceValues = parsePositiveNumbers(text)\n .filter((entry) => /\\bkm\\b/i.test(text.slice(entry.index, entry.index + 24)) || /\\bkm\\b/i.test(text));\n const value = distanceValues.length ? distanceValues[distanceValues.length - 1].number : null;\n if (!value) continue;\n const current = totals.get(mode) || { total: 0, evidence: [], pageNumber };\n current.total += value;\n if (current.evidence.length < 4) current.evidence.push(text);\n totals.set(mode, current);\n }\n return [...totals.entries()].map(([mode, aggregate], index) => {\n const allowedMatch = bestAllowedItemForQuery(mode, allowedItems);\n return buildProfileCandidate({\n group,\n profileId: 'employee_commuting',\n pageNumber: aggregate.pageNumber,\n lineIndex: index,\n numberIndex: 0,\n itemName: mode,\n quantity: String(Number(aggregate.total.toFixed(5))),\n unit: 'km',\n evidenceText: aggregate.evidence.join(' | '),\n allowedMatch,\n role: 'aggregated_distance',\n confidence: 0.88,\n });\n });\n};\n\nconst extractForProfile = (\n profileId: BulkBillAgentProfileId,\n group: BulkBillAgentProfileGroup,\n lines: ReturnType<typeof profileTextLines>,\n allowedItems: BulkBillAgentAllowedItem[],\n) => {\n if (profileId === 'electricity') return extractElectricityCandidates(group, lines, allowedItems);\n if (profileId === 'employee_commuting') return extractEmployeeCommutingCandidates(group, lines, allowedItems);\n\n const labelForProfile: Partial<Record<BulkBillAgentProfileId, (line: string, allowedItems: BulkBillAgentAllowedItem[]) => string>> = {\n fuel_combustion: (line) => fuelLabel(line),\n lpg_usage: (line) => fuelLabel(line),\n refrigerants: (line) => refrigerantLabel(line),\n industrial_gases: (line) => industrialGasLabel(line),\n business_travel: (line) => businessTravelLabel(line),\n fire_extinguisher: (line) => fireExtinguisherLabel(line),\n sf6_usage: (line) => sf6Label(line),\n water: (line) => waterLabel(line),\n waste: (line) => wasteLabel(line),\n process_emissions: (line) => processEmissionLabel(line),\n purchased_goods: genericMaterialLabel,\n generic_material: genericMaterialLabel,\n };\n\n const labelForLine = labelForProfile[profileId] || genericMaterialLabel;\n return extractNamedQuantityCandidates({ profileId, group, lines, allowedItems, labelForLine });\n};\n\nexport const extractBulkBillAgentProfileCandidates = ({\n mappingContext = {},\n pages = [],\n group,\n documentText = '',\n}: BulkBillAgentProfileExtractionInput) => {\n const allowedItems = Array.isArray(mappingContext.allowedItems) ? mappingContext.allowedItems : [];\n const lines = profileTextLines(pages, group, documentText);\n const groupText = documentText || lines.map((line) => line.text).join('\\n');\n const primaryProfile = getPrimaryBulkBillAgentProfile(mappingContext, groupText);\n const profiles = getBulkBillAgentProfilesForMappingContext(mappingContext, groupText)\n .map((entry) => entry.profile.id)\n .filter((profileId, index, profileIds) => profileIds.indexOf(profileId) === index);\n const extractionProfiles = profiles.length ? profiles : [primaryProfile.id];\n const candidates = extractionProfiles.flatMap((profileId) =>\n extractForProfile(profileId, group, lines, allowedItems),\n );\n const seen = new Set<string>();\n return candidates\n .sort((left, right) => right.confidence - left.confidence)\n .filter((candidate) => {\n const key = [candidate.profileId, candidate.matchedAllowedItemKey || candidate.itemName, candidate.quantity, candidate.unit, candidate.pageNumber].join('|');\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n })\n .slice(0, 30);\n};\n\nexport interface BulkBillAgentWorkerPromptInput {\n mappingContext?: BulkBillAgentMappingContext;\n groupId: string;\n pageNumbers: number[];\n documentType?: string;\n documentText?: string;\n}\n\nexport const buildBulkBillAgentRouterPrompt = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const config = buildBulkBillAgentPromptConfig(context, documentText);\n return `You are the ZeroCarbon bulk bill router and grouping supervisor.\n\nYour only job is to prepare worker-ready bill groups.\n\nResponsibilities:\n- inspect the ERP page context and allowed items\n- load document metadata\n- read OCR text in batches for the whole document\n- fingerprint pages when useful\n- compare neighboring page boundaries when useful\n- stage bill groups\n- classify each staged group\n- record ERP compatibility for each staged group\n\nDo not extract quantities, do not save extracted rows, do not validate rows, and do not persist rows.\n\nStop once every page is read and every staged group has both:\n- a document classification\n- an ERP compatibility decision\n\nLocked ERP page context:\n- profile: ${config.profile.label} (${config.profile.id})\n- scope: ${config.uploadContext.scope || 'not specified'}\n- category: ${config.uploadContext.category || 'not specified'}\n- plant: ${config.uploadContext.plant || 'not specified'}\n\nAllowed ERP items on this page (${config.allowedItemCount} total):\n${promptBulletList(config.allowedItemSummaries.slice(0, 30))}\n\nIf the document appears to contain multiple bills or mixed bill types, stage separate groups. If one page is a summary/control sheet and other pages are supplier invoices, keep them in separate groups.`;\n};\n\nexport const buildBulkBillAgentWorkerPrompt = ({\n mappingContext = {},\n groupId,\n pageNumbers,\n documentType = 'unknown',\n documentText = '',\n}: BulkBillAgentWorkerPromptInput) => {\n const config = buildBulkBillAgentPromptConfig(mappingContext, documentText);\n return `You are the ZeroCarbon ${config.profile.label} worker for one staged bill group.\n\nYou must only work on:\n- groupId: ${groupId}\n- pages: ${pageNumbers.join(', ')}\n- classified document type: ${documentType}\n\nYour job:\n- inspect only this group's evidence\n- extract physical activity candidates for this group\n- repair OCR issues when evidence supports it\n- search/inspect the locked ERP items for this group\n- save extracted rows for this group\n- save review rows for this group when a safe normal row cannot be produced\n\nDo not regroup the document. Do not validate all rows across the whole job. Do not persist validated rows. Do not finalize the whole job.\n\nActive extraction profile:\n- profile: ${config.profile.label} (${config.profile.id})\n- scope: ${config.uploadContext.scope || 'not specified'}\n- category: ${config.uploadContext.category || 'not specified'}\n- plant: ${config.uploadContext.plant || 'not specified'}\n\nCategory-specific extraction rules:\n${promptBulletList(config.profile.extractionRules)}\n\nCategory-specific reject rules:\n${promptBulletList(config.profile.rejectRules)}\n\nAllowed ERP items for this worker (${config.allowedItemCount} total):\n${promptBulletList(config.allowedItemSummaries.slice(0, 30))}\n\nCritical rules:\n- never save rows for any other group\n- never use another group's page evidence\n- if the group is incompatible with the ERP page, save review rows instead of forcing mapping\n- if the document has its own dates or period, use those instead of upload context`;\n};\n\nexport const buildBulkBillAgentFinalizerPrompt = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const config = buildBulkBillAgentPromptConfig(context, documentText);\n return `You are the ZeroCarbon finalizer and persistence worker.\n\nYour only job is to:\n- inspect the current workspace state\n- validate extracted rows against locked ERP items\n- persist validated rows to the backend\n- finalize the job with the correct outcome\n\nDo not read more pages. Do not restage groups. Do not perform new extraction unless there is a critical gap that prevents safe finalization.\n\nActive ERP page:\n- profile: ${config.profile.label} (${config.profile.id})\n- scope: ${config.uploadContext.scope || 'not specified'}\n- category: ${config.uploadContext.category || 'not specified'}\n\nFinalize rules:\n- use outcome completed when backend persistence succeeded, no review rows remain, and backend returned no blocking review/conflict rows\n- backend skipped duplicates are non-blocking if the mapped row was otherwise persisted or intentionally skipped as a duplicate\n- use outcome review_required when review rows remain or backend returned blocking review/conflict rows\n- use outcome failed only for unrecoverable execution errors`;\n};\n"],"names":[],"mappings":";;AAoEA,MAAM,SAAS,GAAG,CAAC,KAAc,KAC/B,MAAM,CAAC,KAAK,aAAL,KAAK,KAAA,MAAA,GAAL,KAAK,GAAI,EAAE;AACf,KAAA,WAAW;AACX,KAAA,OAAO,CAAC,MAAM,EAAE,KAAK;AACrB,KAAA,OAAO,CAAC,aAAa,EAAE,GAAG;AAC1B,KAAA,IAAI,EAAE;AAEX,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,OAA0B,KAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEjD,MAAM,QAAQ,GAAG,CAAC,IAA8B,KAC9C,SAAS,CAAC;AACR,IAAA,IAAI,CAAC,QAAQ;AACb,IAA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Q,IAAI,eAAe;AACnD,SAAA,EAAA,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,eAAe;;;AAGtD,EAAA,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;;;AAGhD,EAAA,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;;AAET,mCAAA,EAAA,MAAM,CAAC,gBAAgB,CAAA;EAC1D,gBAAgB,CAAC,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;;;;;;mFAMuB;AACnF;AAEO,MAAM,iCAAiC,GAAG,CAC/C,OAAA,GAAuC,EAAE,EACzC,YAAY,GAAG,EAAE,KACf;IACF,MAAM,MAAM,GAAG,8BAA8B,CAAC,OAAO,EAAE,YAAY,CAAC;IACpE,OAAO,CAAA;;;;;;;;;;;aAWI,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;AAC5C,SAAA,EAAA,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,eAAe;AAC1C,YAAA,EAAA,MAAM,CAAC,aAAa,CAAC,QAAQ,IAAI,eAAe;;;;;;6DAMD;AAC7D;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -163,11 +163,13 @@ interface Bill {
|
|
|
163
163
|
nestedSubCategory: string;
|
|
164
164
|
amountCalculated: number;
|
|
165
165
|
multiplicationFactor: number;
|
|
166
|
+
billAmount?: number;
|
|
166
167
|
massData?: number;
|
|
167
168
|
config?: {
|
|
168
169
|
type?: string;
|
|
169
170
|
id?: string;
|
|
170
171
|
name?: string;
|
|
172
|
+
[key: string]: any;
|
|
171
173
|
};
|
|
172
174
|
}
|
|
173
175
|
interface Meta {
|
|
@@ -1205,6 +1207,10 @@ interface BillMatchingConfig {
|
|
|
1205
1207
|
type: boolean;
|
|
1206
1208
|
};
|
|
1207
1209
|
}
|
|
1210
|
+
interface CreateBillOptions {
|
|
1211
|
+
billAmount?: number;
|
|
1212
|
+
config?: Record<string, any>;
|
|
1213
|
+
}
|
|
1208
1214
|
declare const BILL_CALCULATION_CONFIGS: BillCalculationConfig[];
|
|
1209
1215
|
declare const DEFAULT_BILL_MATCHING_CONFIG: BillMatchingConfig;
|
|
1210
1216
|
declare class BillManager {
|
|
@@ -1214,7 +1220,7 @@ declare class BillManager {
|
|
|
1214
1220
|
filterBills(options: BillFilterOptions): Bill[];
|
|
1215
1221
|
private matchField;
|
|
1216
1222
|
findBillsForEmissionItem(emissionItem: ProcessedEmissionItem, category: string, year: number, month: number, scope: string, plantId?: string): Bill[];
|
|
1217
|
-
createBill(userId: string, category: string, activityData: number, emissionItem: ProcessedEmissionItem, year: number, month: number, scope: string, industry?: string, vendorConfig?: any, massData?: number, plantId?: string): Omit<Bill, "_id">;
|
|
1223
|
+
createBill(userId: string, category: string, activityData: number, emissionItem: ProcessedEmissionItem, year: number, month: number, scope: string, industry?: string, vendorConfig?: any, massData?: number, plantId?: string, options?: CreateBillOptions): Omit<Bill, "_id">;
|
|
1218
1224
|
private getCalculationConfig;
|
|
1219
1225
|
private calculateEmissions;
|
|
1220
1226
|
private getMultiplicationFactor;
|
|
@@ -1257,6 +1263,7 @@ interface EmissionSource {
|
|
|
1257
1263
|
totalEmissions: number;
|
|
1258
1264
|
amount: string;
|
|
1259
1265
|
activityData: number;
|
|
1266
|
+
billAmount?: number;
|
|
1260
1267
|
isEditing: boolean;
|
|
1261
1268
|
tempActivityData?: number;
|
|
1262
1269
|
bill?: Bill;
|
|
@@ -6539,4 +6546,4 @@ declare namespace index {
|
|
|
6539
6546
|
}
|
|
6540
6547
|
|
|
6541
6548
|
export { ALL_SCOPES_3_RCO, API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BULK_BILL_AGENT_PROFILES, BillManager, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS$5 as WATER_PRODUCTS, addItemForUser, buildBulkBillAgentFinalizerPrompt, buildBulkBillAgentPromptConfig, buildBulkBillAgentRouterPrompt, buildBulkBillAgentSystemPrompt, buildBulkBillAgentWorkerPrompt, buildUserConfigItemKey, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractBulkBillAgentProfileCandidates, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getAllConfig, getApiIndustryType, getAvailableFieldsForIndustry, getBulkBillAgentProfile, getBulkBillAgentProfilesForMappingContext, getCombinedBackendConfig, getIndustryBackendConfig, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getItemsForUser, getPlantNameConfig, getPrimaryBulkBillAgentProfile, getRCOConfigByName, getScope3ConfigByName, getUserNameBackendConfig, getUserNameScopeConfig, hasIntensities, isUIFeatureEnabled, listBulkBillAgentProfiles, mapIndustryToApiType, mergeUserItemsIntoIndustryConfig, normalizeConfigKeyText, normalizeConfigText, resolveEmissionFactorsForUser, sameUserConfigText, sanitizeNumber, scoreBulkBillAgentProfile, supportsIntensityCalculations, updateItemEmissionFactorForUser, updateSdkItemEmissionFactorForUser, validateCarbonIntensityData };
|
|
6542
|
-
export type { AllConfigurations, AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BackendAdditionalScopeItem, BackendEmissionItem, BackendEmissions, BackendEquipmentCategory, BackendIndustries, BackendIndustryConfig, BackendProduct, BackendScope, BackendScope3Item, BackendUserConfig, BackendUserConfigs, BaseRequest, BaseResponse, Bill, BillCalculationConfig, BillFilterOptions, BillMatchingConfig, BulkBillAgentAllowedItem, BulkBillAgentMappingContext, BulkBillAgentProfile, BulkBillAgentProfileCandidate, BulkBillAgentProfileExtractionInput, BulkBillAgentProfileGroup, BulkBillAgentProfileId, BulkBillAgentProfilePage, BulkBillAgentPromptConfig, BulkBillAgentWorkerPromptInput, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, BillsAnalyzed$1 as CarbonIntensityBillsAnalyzed, Calculations$1 as CarbonIntensityCalculations, EmissionData$2 as CarbonIntensityEmissionData, ErrorResponse$1 as CarbonIntensityErrorResponse, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, DetailedCarbonIntensityResponse, EditableItem, EmissionData$3 as EmissionData, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FieldConfig, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, FrontendIndustryConfig, HospitalityRequest, HospitalityResponse, IndustryConfig$1 as IndustryConfig, EmissionData as IndustryEmissionData, IndustryFieldConfig, IndustryFieldSection, ProductionData as IndustryProductionData, IndustryType, IntensityCalculation, IntensityValue, LogisticsRequest, LogisticsResponse, ManufacturingRequest, ManufacturingResponse, Meta, MetalEnergyRequest, MetalEnergyResponse, PackagingRequest, PackagingResponse, Pagination, PetrochemicalRequest, PetrochemicalResponse, PharmaRequest, PharmaResponse, PlantNameConfig, ProcessedEmissionCategory, ProcessedEmissionItem, ProcessedScope3Data, RealEstateRequest, RealEstateResponse, BillsAnalyzed as ResponseBillsAnalyzed, Calculations as ResponseCalculations, EmissionData$1 as ResponseEmissionData, ErrorResponse as ResponseErrorResponse, ScopeConfig, ScopeProduct, ShippingRequest, ShippingResponse, SteelRequest, SteelResponse, StrapiItem, StrapiResponse, TelecommunicationRequest, TelecommunicationResponse, TextileRequest, TextileResponse, TransportationEmission, TransportationEmissionAttributes, TransportationEmissionsResponse, UserConfigApiClient, UserConfigItem, UserData, UserEmissionFactorApprovalResponse, UserEmissionFactorResolution, UtilitiesRequest, UtilitiesResponse, ValidationError, VehicleEmission, VehicleEmissionAttributes, VehicleEmissionsResponse };
|
|
6549
|
+
export type { AllConfigurations, AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BackendAdditionalScopeItem, BackendEmissionItem, BackendEmissions, BackendEquipmentCategory, BackendIndustries, BackendIndustryConfig, BackendProduct, BackendScope, BackendScope3Item, BackendUserConfig, BackendUserConfigs, BaseRequest, BaseResponse, Bill, BillCalculationConfig, BillFilterOptions, BillMatchingConfig, BulkBillAgentAllowedItem, BulkBillAgentMappingContext, BulkBillAgentProfile, BulkBillAgentProfileCandidate, BulkBillAgentProfileExtractionInput, BulkBillAgentProfileGroup, BulkBillAgentProfileId, BulkBillAgentProfilePage, BulkBillAgentPromptConfig, BulkBillAgentWorkerPromptInput, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, BillsAnalyzed$1 as CarbonIntensityBillsAnalyzed, Calculations$1 as CarbonIntensityCalculations, EmissionData$2 as CarbonIntensityEmissionData, ErrorResponse$1 as CarbonIntensityErrorResponse, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, CreateBillOptions, DetailedCarbonIntensityResponse, EditableItem, EmissionData$3 as EmissionData, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FieldConfig, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, FrontendIndustryConfig, HospitalityRequest, HospitalityResponse, IndustryConfig$1 as IndustryConfig, EmissionData as IndustryEmissionData, IndustryFieldConfig, IndustryFieldSection, ProductionData as IndustryProductionData, IndustryType, IntensityCalculation, IntensityValue, LogisticsRequest, LogisticsResponse, ManufacturingRequest, ManufacturingResponse, Meta, MetalEnergyRequest, MetalEnergyResponse, PackagingRequest, PackagingResponse, Pagination, PetrochemicalRequest, PetrochemicalResponse, PharmaRequest, PharmaResponse, PlantNameConfig, ProcessedEmissionCategory, ProcessedEmissionItem, ProcessedScope3Data, RealEstateRequest, RealEstateResponse, BillsAnalyzed as ResponseBillsAnalyzed, Calculations as ResponseCalculations, EmissionData$1 as ResponseEmissionData, ErrorResponse as ResponseErrorResponse, ScopeConfig, ScopeProduct, ShippingRequest, ShippingResponse, SteelRequest, SteelResponse, StrapiItem, StrapiResponse, TelecommunicationRequest, TelecommunicationResponse, TextileRequest, TextileResponse, TransportationEmission, TransportationEmissionAttributes, TransportationEmissionsResponse, UserConfigApiClient, UserConfigItem, UserData, UserEmissionFactorApprovalResponse, UserEmissionFactorResolution, UtilitiesRequest, UtilitiesResponse, ValidationError, VehicleEmission, VehicleEmissionAttributes, VehicleEmissionsResponse };
|
package/dist/index.esm.js
CHANGED
|
@@ -37669,6 +37669,7 @@ const BULK_BILL_AGENT_PROFILES = {
|
|
|
37669
37669
|
extractionRules: [
|
|
37670
37670
|
'Prefer current-period bill-level or net billed consumption over charges, rates, TOD/slab rows, arrears, or historical meter rows.',
|
|
37671
37671
|
'For grid import or purchased electricity, use current-period import/from-grid consumption.',
|
|
37672
|
+
'When a purchased grid electricity bill does not explicitly distinguish national vs regional grid, default the ERP mapping to Regional Grid; do not send it to review for that ambiguity alone.',
|
|
37672
37673
|
'For solar or renewable electricity, use current-period generation or renewable energy consumption.',
|
|
37673
37674
|
'Treat “units” as kWh only for electricity documents.',
|
|
37674
37675
|
],
|
|
@@ -38889,7 +38890,7 @@ class BillManager {
|
|
|
38889
38890
|
return matchingBills;
|
|
38890
38891
|
}
|
|
38891
38892
|
// Create a bill object with proper calculation
|
|
38892
|
-
createBill(userId, category, activityData, emissionItem, year, month, scope, industry = "cement", vendorConfig, massData, plantId) {
|
|
38893
|
+
createBill(userId, category, activityData, emissionItem, year, month, scope, industry = "cement", vendorConfig, massData, plantId, options = {}) {
|
|
38893
38894
|
const calculationConfig = this.getCalculationConfig(industry, scope, category);
|
|
38894
38895
|
const amountCalculated = this.calculateEmissions(activityData, emissionItem.emissionFactor, calculationConfig, massData);
|
|
38895
38896
|
const multiplicationFactor = this.getMultiplicationFactor(emissionItem.emissionFactor, calculationConfig);
|
|
@@ -38906,8 +38907,12 @@ class BillManager {
|
|
|
38906
38907
|
nestedSubCategory: emissionItem.item,
|
|
38907
38908
|
amountCalculated: amountCalculated,
|
|
38908
38909
|
multiplicationFactor: multiplicationFactor,
|
|
38910
|
+
billAmount: sanitizeNumber(options.billAmount),
|
|
38909
38911
|
massData: massData,
|
|
38910
|
-
config:
|
|
38912
|
+
config: {
|
|
38913
|
+
...(vendorConfig || {}),
|
|
38914
|
+
...(options.config || {}),
|
|
38915
|
+
},
|
|
38911
38916
|
};
|
|
38912
38917
|
}
|
|
38913
38918
|
// Get calculation configuration for specific context
|
|
@@ -39084,6 +39089,7 @@ const formatKPIEmission = (value) => {
|
|
|
39084
39089
|
}
|
|
39085
39090
|
};
|
|
39086
39091
|
|
|
39092
|
+
const sumBillAmounts = (bills) => bills.reduce((sum, bill) => sum + sanitizeNumber(bill.billAmount), 0);
|
|
39087
39093
|
class EmissionSourceGenerator {
|
|
39088
39094
|
constructor(billManager) {
|
|
39089
39095
|
this.billManager = billManager;
|
|
@@ -39107,6 +39113,7 @@ class EmissionSourceGenerator {
|
|
|
39107
39113
|
});
|
|
39108
39114
|
const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
|
|
39109
39115
|
const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
|
|
39116
|
+
const totalBillAmount = sumBillAmounts(matchingBills);
|
|
39110
39117
|
sources.push({
|
|
39111
39118
|
id: sourceId,
|
|
39112
39119
|
itemName: subProduct.name,
|
|
@@ -39117,6 +39124,7 @@ class EmissionSourceGenerator {
|
|
|
39117
39124
|
totalEmissions,
|
|
39118
39125
|
amount: totalActivityData.toString(),
|
|
39119
39126
|
activityData: totalActivityData,
|
|
39127
|
+
billAmount: totalBillAmount,
|
|
39120
39128
|
isEditing: false,
|
|
39121
39129
|
bill: matchingBills[0],
|
|
39122
39130
|
scope: scopeConfig.scope || "scope1",
|
|
@@ -39142,6 +39150,7 @@ class EmissionSourceGenerator {
|
|
|
39142
39150
|
const matchingBills = this.billManager.findBillsForEmissionItem(apiItem, scopeConfig.name, year, monthNumber, scopeConfig.scope || "scope3");
|
|
39143
39151
|
const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
|
|
39144
39152
|
const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
|
|
39153
|
+
const totalBillAmount = sumBillAmounts(matchingBills);
|
|
39145
39154
|
sources.push({
|
|
39146
39155
|
id: sourceId,
|
|
39147
39156
|
itemName: apiItem.item,
|
|
@@ -39152,6 +39161,7 @@ class EmissionSourceGenerator {
|
|
|
39152
39161
|
totalEmissions,
|
|
39153
39162
|
amount: totalActivityData.toString(),
|
|
39154
39163
|
activityData: totalActivityData,
|
|
39164
|
+
billAmount: totalBillAmount,
|
|
39155
39165
|
isEditing: false,
|
|
39156
39166
|
bill: matchingBills[0],
|
|
39157
39167
|
scope: scopeConfig.scope || "scope3",
|
|
@@ -39184,6 +39194,7 @@ class EmissionSourceGenerator {
|
|
|
39184
39194
|
});
|
|
39185
39195
|
const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
|
|
39186
39196
|
const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
|
|
39197
|
+
const totalBillAmount = sumBillAmounts(matchingBills);
|
|
39187
39198
|
sources.push({
|
|
39188
39199
|
id: sourceId,
|
|
39189
39200
|
itemName: item.item,
|
|
@@ -39194,6 +39205,7 @@ class EmissionSourceGenerator {
|
|
|
39194
39205
|
totalEmissions,
|
|
39195
39206
|
amount: totalActivityData.toString(),
|
|
39196
39207
|
activityData: totalActivityData,
|
|
39208
|
+
billAmount: totalBillAmount,
|
|
39197
39209
|
isEditing: false,
|
|
39198
39210
|
bill: matchingBills[0],
|
|
39199
39211
|
scope: scopeConfig.scope || "scope3",
|