@carbonstopper/agent-mcp 0.1.47 → 0.1.48
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/AGENTS.md +2 -2
- package/README.md +34 -34
- package/dist/apipath.d.ts +31 -31
- package/dist/apipath.js +34 -33
- package/dist/apipath.js.map +1 -1
- package/dist/logger.js +4 -3
- package/dist/logger.js.map +1 -1
- package/dist/response.d.ts +1 -1
- package/dist/response.js +23 -0
- package/dist/response.js.map +1 -1
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +302 -297
- package/dist/tools.js.map +1 -1
- package/docs/{cbam2-agent-integration-guide.md → cbam-agent-integration-guide.md} +143 -143
- package/docs/schema-audit.md +19 -19
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -516,36 +516,36 @@ const enterpriseEmissionComputationUpdateSchema = z.object({
|
|
|
516
516
|
unit: z.string().optional().describe("Total emission unit. Agent normally should omit this unless backend requires a known display unit."),
|
|
517
517
|
sourceList: z.array(enterpriseEmissionSourceUpdateSchema).min(1).describe("Emission source updates under this computation. Every item must include sourceId."),
|
|
518
518
|
});
|
|
519
|
-
const
|
|
519
|
+
const cbamLanguage = z.enum(["zh", "en"])
|
|
520
520
|
.optional()
|
|
521
|
-
.describe("Response language for this
|
|
522
|
-
const
|
|
521
|
+
.describe("Response language for this CBAM call. Omit to use Chinese; supported values are zh and en.");
|
|
522
|
+
const cbamCode = z.union([
|
|
523
523
|
z.number().int().nonnegative(),
|
|
524
524
|
z.string().trim().regex(/^\d+$/, "Expected a numeric CBAM code"),
|
|
525
525
|
]);
|
|
526
|
-
const
|
|
526
|
+
const cbamZeroOne = z.union([
|
|
527
527
|
z.literal(0),
|
|
528
528
|
z.literal(1),
|
|
529
529
|
z.literal("0"),
|
|
530
530
|
z.literal("1"),
|
|
531
531
|
]);
|
|
532
|
-
const
|
|
532
|
+
const cbamDate = z.string().trim()
|
|
533
533
|
.regex(/^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/, "Expected yyyy-MM-dd")
|
|
534
534
|
.describe("Calendar date in yyyy-MM-dd format.");
|
|
535
|
-
const
|
|
535
|
+
const cbamReadFields = {
|
|
536
536
|
sessionId,
|
|
537
537
|
...skillTraceFields,
|
|
538
|
-
lang:
|
|
538
|
+
lang: cbamLanguage,
|
|
539
539
|
};
|
|
540
|
-
const
|
|
541
|
-
...
|
|
540
|
+
const cbamWriteFields = {
|
|
541
|
+
...cbamReadFields,
|
|
542
542
|
idempotencyKey: idempotencyKey.max(128),
|
|
543
543
|
};
|
|
544
|
-
const
|
|
545
|
-
...
|
|
544
|
+
const cbamConfirmedWriteFields = {
|
|
545
|
+
...cbamWriteFields,
|
|
546
546
|
...confirmedActionFields,
|
|
547
547
|
};
|
|
548
|
-
const
|
|
548
|
+
const cbamReferenceType = z.enum([
|
|
549
549
|
"ORGANIZATION",
|
|
550
550
|
"FACTORY",
|
|
551
551
|
"COUNTRY",
|
|
@@ -559,7 +559,7 @@ const cbam2ReferenceType = z.enum([
|
|
|
559
559
|
"DEFAULT_SALE",
|
|
560
560
|
"CARBON_TAX_CANDIDATE",
|
|
561
561
|
]);
|
|
562
|
-
const
|
|
562
|
+
const cbamSection = z.enum([
|
|
563
563
|
"GENERAL_INFO",
|
|
564
564
|
"PROCESS",
|
|
565
565
|
"PRECURSOR",
|
|
@@ -572,7 +572,7 @@ const cbam2Section = z.enum([
|
|
|
572
572
|
"DATA_QUALITY",
|
|
573
573
|
"RESULT_SUMMARY",
|
|
574
574
|
]);
|
|
575
|
-
const
|
|
575
|
+
const cbamItemType = z.enum([
|
|
576
576
|
"PROCESS",
|
|
577
577
|
"PRECURSOR",
|
|
578
578
|
"SOURCE_FLOW",
|
|
@@ -581,30 +581,30 @@ const cbam2ItemType = z.enum([
|
|
|
581
581
|
"CARBON_TAX",
|
|
582
582
|
"DATA_QUALITY",
|
|
583
583
|
]);
|
|
584
|
-
function
|
|
584
|
+
function cbamCoordinate(minimum, maximum, name) {
|
|
585
585
|
return z.string().trim().min(1).max(50)
|
|
586
586
|
.refine((value) => Number.isFinite(Number(value)), `${name} must be a decimal number`)
|
|
587
587
|
.refine((value) => Number(value) >= minimum && Number(value) <= maximum, `${name} must be between ${minimum} and ${maximum}`);
|
|
588
588
|
}
|
|
589
|
-
const
|
|
589
|
+
const cbamFactoryForm = z.object({
|
|
590
590
|
factorName: z.string().trim().min(1).max(100).describe("Factory Chinese or local name."),
|
|
591
|
-
orgId: longId.describe("Organization id returned by
|
|
591
|
+
orgId: longId.describe("Organization id returned by cbam_reference_search with type ORGANIZATION."),
|
|
592
592
|
factoryCode: z.string().max(100).optional().describe("Optional globally unique factory code. Omit it on create to let the backend generate one; preserve the returned value on update."),
|
|
593
593
|
factoryNameEn: z.string().trim().min(1).max(200).describe("Factory English name."),
|
|
594
|
-
country: z.string().trim().min(1).max(100).describe("Country dictionary value returned by
|
|
594
|
+
country: z.string().trim().min(1).max(100).describe("Country dictionary value returned by cbam_reference_search with type COUNTRY."),
|
|
595
595
|
locationCode: z.string().trim().min(1).max(100).describe("UN/LOCODE or supported location code."),
|
|
596
596
|
city: z.string().trim().min(1).max(100),
|
|
597
597
|
detailedAddress: z.string().trim().min(1).max(500),
|
|
598
598
|
postalCode: z.string().trim().min(1).max(30),
|
|
599
599
|
postOfficeBox: z.string().trim().min(1).max(100),
|
|
600
|
-
longitude:
|
|
601
|
-
latitude:
|
|
600
|
+
longitude: cbamCoordinate(-180, 180, "longitude"),
|
|
601
|
+
latitude: cbamCoordinate(-90, 90, "latitude"),
|
|
602
602
|
economicActivity: z.string().max(1000).optional(),
|
|
603
603
|
authorizedRepresentative: z.string().max(100).optional(),
|
|
604
604
|
email: z.union([z.string().email().max(100), z.literal("")]).optional(),
|
|
605
605
|
mobile: z.string().max(50).optional(),
|
|
606
606
|
});
|
|
607
|
-
const
|
|
607
|
+
const cbamVerification = z.object({
|
|
608
608
|
corporateName: z.string().max(200).optional(),
|
|
609
609
|
detailedAddress: z.string().max(500).optional(),
|
|
610
610
|
city: z.string().max(100).optional(),
|
|
@@ -618,39 +618,39 @@ const cbam2Verification = z.object({
|
|
|
618
618
|
certificationName: z.string().max(200).optional(),
|
|
619
619
|
registrationNo: z.string().max(100).optional(),
|
|
620
620
|
});
|
|
621
|
-
const
|
|
621
|
+
const cbamReportForm = z.object({
|
|
622
622
|
reportName: z.string().trim().min(1).max(200),
|
|
623
623
|
orgId: longId.describe("Organization id for the report. It must be visible to the current user."),
|
|
624
|
-
startDate:
|
|
625
|
-
endDate:
|
|
626
|
-
factoryId: longId.describe("Factory id returned by
|
|
627
|
-
include:
|
|
628
|
-
verification:
|
|
624
|
+
startDate: cbamDate,
|
|
625
|
+
endDate: cbamDate,
|
|
626
|
+
factoryId: longId.describe("Factory id returned by cbam_reference_search or cbam_factory_save."),
|
|
627
|
+
include: cbamZeroOne.describe("Heat-power cogeneration flag. 0=include heat-power data; 1=do not include it, matching the migrated CBAM convention."),
|
|
628
|
+
verification: cbamVerification.optional().describe("Optional verification organization information. Omit on update to preserve the current verification record."),
|
|
629
629
|
});
|
|
630
|
-
const
|
|
630
|
+
const cbamProcessDefinition = z.object({
|
|
631
631
|
id: longId.optional().describe("Existing process id for update. Omit to create a new process."),
|
|
632
632
|
processName: z.string().trim().min(1).max(200),
|
|
633
|
-
productCategoryId: longId.describe("Product category id returned by
|
|
633
|
+
productCategoryId: longId.describe("Product category id returned by cbam_reference_search."),
|
|
634
634
|
preId: z.string().optional().describe("Comma-separated preceding process ids from this report. Use an empty string to clear."),
|
|
635
635
|
elseProduct: z.string().optional().describe("Comma-separated default-product ids for the selected category. Use an empty string to clear."),
|
|
636
636
|
preProcess: z.string().optional().describe("Comma-separated precursor ids from this report. Use an empty string to clear."),
|
|
637
637
|
orderNum: z.number().int().min(1).max(10).optional(),
|
|
638
|
-
productRoute: z.string().optional().describe("Comma-separated default-process route ids returned by
|
|
639
|
-
includeType:
|
|
638
|
+
productRoute: z.string().optional().describe("Comma-separated default-process route ids returned by cbam_reference_search."),
|
|
639
|
+
includeType: cbamZeroOne.optional().describe("Production-route selection mode: 0=automatic, 1=manual."),
|
|
640
640
|
});
|
|
641
|
-
const
|
|
641
|
+
const cbamPrecursorDefinition = z.object({
|
|
642
642
|
id: longId.optional().describe("Existing precursor id for update. Omit to create a new precursor."),
|
|
643
643
|
preName: z.string().trim().min(1).max(200),
|
|
644
|
-
productCategoryId: longId.describe("Product category id returned by
|
|
645
|
-
countryCode: z.string().max(100).optional().describe("Country dictionary value returned by
|
|
644
|
+
productCategoryId: longId.describe("Product category id returned by cbam_reference_search."),
|
|
645
|
+
countryCode: z.string().max(100).optional().describe("Country dictionary value returned by cbam_reference_search; omit or clear when not yet known."),
|
|
646
646
|
orderNum: z.number().int().min(1).max(20).optional(),
|
|
647
|
-
productRoute: z.string().optional().describe("Comma-separated default-process route ids returned by
|
|
647
|
+
productRoute: z.string().optional().describe("Comma-separated default-process route ids returned by cbam_reference_search."),
|
|
648
648
|
});
|
|
649
|
-
const
|
|
649
|
+
const cbamSourceFlow = z.object({
|
|
650
650
|
id: longId.optional().describe("Existing source-flow id for update. Omit to create a new row."),
|
|
651
651
|
productProcessId: longId.describe("Owning process id from the same report."),
|
|
652
|
-
processMethod:
|
|
653
|
-
sourceType:
|
|
652
|
+
processMethod: cbamCode.describe("Process-method code returned by CBAM_ENUM reference data."),
|
|
653
|
+
sourceType: cbamCode.describe("Source-flow type code returned by CBAM_ENUM reference data."),
|
|
654
654
|
sourceName: z.string().trim().min(1).max(200),
|
|
655
655
|
activityData: nonNegativeNumericValue.optional().describe("Activity amount. Required for sourceType=1 with processMethod 1/2/3 and for sourceType=2 with processMethod 4/5."),
|
|
656
656
|
activityUnit: z.string().max(100).optional().describe("Unit of activityData."),
|
|
@@ -660,7 +660,7 @@ const cbam2SourceFlow = z.object({
|
|
|
660
660
|
emissionCoefficientUnit: z.string().max(100).optional().describe("Emission-coefficient unit. For sourceType=1, value tCO2/TJ additionally requires lowHeat."),
|
|
661
661
|
conversionRate: nonNegativeNumericValue.optional().describe("Conversion factor for sourceType=1/processMethod=2; slope coefficient for sourceType=2/processMethod=4; average flue-gas flow for sourceType=3."),
|
|
662
662
|
oxRate: nonNegativeNumericValue.optional().describe("Oxidation rate for sourceType=1/processMethod=1; C2F6 fraction for sourceType=2/processMethod=4/5."),
|
|
663
|
-
carbon: nonNegativeNumericValue.optional().describe("Carbon content for sourceType=1/processMethod=3; PFC collection efficiency for sourceType=2. It is required and must be greater than zero for sourceType=2/processMethod=5. The backend defaults it only where the
|
|
663
|
+
carbon: nonNegativeNumericValue.optional().describe("Carbon content for sourceType=1/processMethod=3; PFC collection efficiency for sourceType=2. It is required and must be greater than zero for sourceType=2/processMethod=5. The backend defaults it only where the CBAM formula allows."),
|
|
664
664
|
carbonUnit: z.string().max(100).optional(),
|
|
665
665
|
conversionRateUnit: z.string().max(100).optional(),
|
|
666
666
|
biomassContent: nonNegativeNumericValue.optional().describe("Biomass content for sourceType=1; anode-effect overvoltage AEO for sourceType=2/processMethod=5; biomass share for sourceType=3."),
|
|
@@ -668,7 +668,7 @@ const cbam2SourceFlow = z.object({
|
|
|
668
668
|
carbonFossil: nonNegativeNumericValue.optional().describe("Non-zero anode-effect CE denominator, required only for sourceType=2/processMethod=5."),
|
|
669
669
|
carbonBiological: nonNegativeNumericValue.optional().describe("Overvoltage coefficient, required only for sourceType=2/processMethod=5."),
|
|
670
670
|
}).describe("Editable source-flow inputs. Valid combinations are sourceType=1 with processMethod=1/2/3, sourceType=2 with processMethod=4/5, or sourceType=3 with processMethod=6/7. energyFossil and attachments are backend-owned and are never accepted.");
|
|
671
|
-
const
|
|
671
|
+
const cbamHeatPowerData = z.object({
|
|
672
672
|
fuelIn: positiveNumericValue.describe("Fuel input; must be greater than zero."),
|
|
673
673
|
hotPer: positiveNumericValue.describe("Heat allocation parameter; must be greater than zero."),
|
|
674
674
|
elePer: positiveNumericValue.describe("Electricity allocation parameter; must be greater than zero."),
|
|
@@ -678,54 +678,54 @@ const cbam2HeatPowerData = z.object({
|
|
|
678
678
|
smokeOut: nonNegativeNumericValue,
|
|
679
679
|
inputFactor: nonNegativeNumericValue.optional(),
|
|
680
680
|
});
|
|
681
|
-
const
|
|
681
|
+
const cbamActivityRow = z.object({
|
|
682
682
|
relationId: longId.describe("Default-process id or related process id selected from the current item route."),
|
|
683
|
-
isDefault:
|
|
683
|
+
isDefault: cbamZeroOne.describe("0=default-process route row; 1=related in-report process row."),
|
|
684
684
|
emission: nonNegativeNumericValue.describe("Activity amount for this route row."),
|
|
685
685
|
});
|
|
686
|
-
const
|
|
687
|
-
id: longId.optional().describe("Existing attribution id returned by
|
|
688
|
-
emissionElement:
|
|
689
|
-
isExists:
|
|
686
|
+
const cbamProductAttribution = z.object({
|
|
687
|
+
id: longId.optional().describe("Existing attribution id returned by cbam_report_read. Omit for a new row."),
|
|
688
|
+
emissionElement: cbamCode.describe("Emission-element code returned by CBAM_ENUM reference data."),
|
|
689
|
+
isExists: cbamCode.describe("Whether this emission element is included; use the exact CBAM_ENUM code."),
|
|
690
690
|
inputPower: nonNegativeNumericValue.optional(),
|
|
691
691
|
inputFactor: nonNegativeNumericValue.optional(),
|
|
692
692
|
outPower: nonNegativeNumericValue.optional(),
|
|
693
693
|
outFactor: nonNegativeNumericValue.optional(),
|
|
694
|
-
emissionSource:
|
|
694
|
+
emissionSource: cbamCode.optional(),
|
|
695
695
|
eleSource: z.string().max(100).optional(),
|
|
696
|
-
eleChoose:
|
|
696
|
+
eleChoose: cbamCode.optional(),
|
|
697
697
|
defaultCnId: longId.optional(),
|
|
698
698
|
cnCode: z.string().max(100).optional(),
|
|
699
699
|
});
|
|
700
|
-
const
|
|
700
|
+
const cbamElectricityCalculator = z.object({
|
|
701
701
|
id: longId.optional(),
|
|
702
702
|
eleValue: nonNegativeNumericValue,
|
|
703
703
|
coefficient: nonNegativeNumericValue,
|
|
704
704
|
});
|
|
705
|
-
const
|
|
705
|
+
const cbamProcessProductData = z.object({
|
|
706
706
|
id: longId.describe("Existing process id from the same report."),
|
|
707
707
|
totalVolume: nonNegativeNumericValue.describe("Total output. Must satisfy totalVolume - salesVolume - nonProduct - sum(processList emission where isDefault=1) = 0 at six-decimal precision."),
|
|
708
708
|
salesVolume: nonNegativeNumericValue.describe("Sold output used in the process balance equation."),
|
|
709
709
|
nonProduct: nonNegativeNumericValue.optional().describe("Non-product output used in the process balance equation; omit to treat it as zero."),
|
|
710
|
-
processList: z.array(
|
|
711
|
-
productAttributionList: z.array(
|
|
712
|
-
eleCalculatorList: z.array(
|
|
710
|
+
processList: z.array(cbamActivityRow).max(100).optional().describe("Activity route rows. Rows with isDefault=1 are subtracted in the process balance equation."),
|
|
711
|
+
productAttributionList: z.array(cbamProductAttribution).max(100).optional(),
|
|
712
|
+
eleCalculatorList: z.array(cbamElectricityCalculator).max(100).optional(),
|
|
713
713
|
}).describe("Complete product activity/emission data for one existing process. The backend rejects an unbalanced item.");
|
|
714
|
-
const
|
|
714
|
+
const cbamPrecursorProductData = z.object({
|
|
715
715
|
id: longId.describe("Existing precursor id from the same report."),
|
|
716
716
|
purchaseVolume: nonNegativeNumericValue.optional(),
|
|
717
717
|
nonProduct: nonNegativeNumericValue.optional().describe("Non-product amount subtracted in the precursor balance equation."),
|
|
718
|
-
defaultReason:
|
|
719
|
-
isDefault:
|
|
720
|
-
processList: z.array(
|
|
721
|
-
productAttributionList: z.array(
|
|
718
|
+
defaultReason: cbamCode.optional(),
|
|
719
|
+
isDefault: cbamZeroOne.optional(),
|
|
720
|
+
processList: z.array(cbamActivityRow).max(100).optional().describe("Must satisfy sum(emission where isDefault=0) - sum(emission where isDefault=1) - nonProduct = 0 at six-decimal precision."),
|
|
721
|
+
productAttributionList: z.array(cbamProductAttribution).max(100).optional(),
|
|
722
722
|
}).describe("Complete activity/emission data for one existing precursor. The backend rejects an unbalanced item.");
|
|
723
|
-
const
|
|
723
|
+
const cbamSaleProduct = z.object({
|
|
724
724
|
id: longId.optional().describe("Existing sale-product id for update. Omit to create."),
|
|
725
725
|
cnCode: z.string().trim().min(1).max(100).describe("CN code valid for the selected process product category."),
|
|
726
726
|
processId: longId.describe("Owning process id from the same report."),
|
|
727
727
|
productName: z.string().trim().min(1).max(200),
|
|
728
|
-
reducing:
|
|
728
|
+
reducing: cbamCode.optional(),
|
|
729
729
|
steelCode: z.string().max(100).optional(),
|
|
730
730
|
mnPer: nonNegativeNumericValue.optional(),
|
|
731
731
|
crPer: nonNegativeNumericValue.optional(),
|
|
@@ -737,9 +737,9 @@ const cbam2SaleProduct = z.object({
|
|
|
737
737
|
wasteMaterial: nonNegativeNumericValue.optional(),
|
|
738
738
|
alUse: nonNegativeNumericValue.optional(),
|
|
739
739
|
nonAl: nonNegativeNumericValue.optional(),
|
|
740
|
-
clinker: nonNegativeNumericValue.describe("Cement clinker value required by the migrated
|
|
741
|
-
calcine:
|
|
742
|
-
solution: nonNegativeNumericValue.describe("Aqueous-solution concentration required by the migrated
|
|
740
|
+
clinker: nonNegativeNumericValue.describe("Cement clinker value required by the migrated CBAM form contract."),
|
|
741
|
+
calcine: cbamCode.describe("Calcination flag code required by the migrated CBAM form contract."),
|
|
742
|
+
solution: nonNegativeNumericValue.describe("Aqueous-solution concentration required by the migrated CBAM form contract."),
|
|
743
743
|
nitric: nonNegativeNumericValue.optional(),
|
|
744
744
|
urea: nonNegativeNumericValue.optional(),
|
|
745
745
|
nitrogen: nonNegativeNumericValue.optional(),
|
|
@@ -748,31 +748,31 @@ const cbam2SaleProduct = z.object({
|
|
|
748
748
|
urPer: nonNegativeNumericValue.optional(),
|
|
749
749
|
organic: nonNegativeNumericValue.optional(),
|
|
750
750
|
});
|
|
751
|
-
const
|
|
751
|
+
const cbamCarbonTax = z.object({
|
|
752
752
|
id: longId.optional().describe("Existing carbon-tax row id for update. Omit to create."),
|
|
753
753
|
saleProductId: longId.describe("Sale-product id from the same report."),
|
|
754
|
-
reportSelected:
|
|
755
|
-
emissionValueType:
|
|
756
|
-
emissionSourceType:
|
|
754
|
+
reportSelected: cbamZeroOne.optional(),
|
|
755
|
+
emissionValueType: cbamCode.optional(),
|
|
756
|
+
emissionSourceType: cbamCode.optional(),
|
|
757
757
|
emissionSourceSaleProductId: longId.optional(),
|
|
758
758
|
emissionSourceDefaultCnId: longId.optional(),
|
|
759
759
|
emissionSourceYear: z.number().int().min(1900).max(9999).optional(),
|
|
760
760
|
productBenchmarkId: longId.optional(),
|
|
761
|
-
productBenchmarkType:
|
|
761
|
+
productBenchmarkType: cbamCode.optional(),
|
|
762
762
|
cbamAdjustmentFactor: nonNegativeNumericValue.optional(),
|
|
763
763
|
paidCarbonPrice: nonNegativeNumericValue.optional(),
|
|
764
|
-
taxType:
|
|
764
|
+
taxType: cbamCode.optional(),
|
|
765
765
|
emissionPer: nonNegativeNumericValue.optional(),
|
|
766
|
-
currencyType: z.string().trim().min(1).max(100).describe("Currency dictionary value returned by
|
|
766
|
+
currencyType: z.string().trim().min(1).max(100).describe("Currency dictionary value returned by cbam_reference_search."),
|
|
767
767
|
taxValue: nonNegativeNumericValue.optional(),
|
|
768
|
-
offsetMethod:
|
|
768
|
+
offsetMethod: cbamCode.optional(),
|
|
769
769
|
offsetPer: nonNegativeNumericValue.optional(),
|
|
770
770
|
offsetPrice: nonNegativeNumericValue.optional(),
|
|
771
771
|
});
|
|
772
|
-
const
|
|
773
|
-
generalInformation:
|
|
774
|
-
defaultReason:
|
|
775
|
-
qualityAssurance:
|
|
772
|
+
const cbamDataQuality = z.object({
|
|
773
|
+
generalInformation: cbamCode.optional(),
|
|
774
|
+
defaultReason: cbamCode.optional(),
|
|
775
|
+
qualityAssurance: cbamCode.optional(),
|
|
776
776
|
carbonPrice: z.string().max(5000).optional(),
|
|
777
777
|
supplement: z.string().max(5000).optional(),
|
|
778
778
|
});
|
|
@@ -780,13 +780,13 @@ export const schemas = {
|
|
|
780
780
|
session_carbon_objects: z.object({
|
|
781
781
|
sessionId,
|
|
782
782
|
module: z
|
|
783
|
-
.enum(["all", "footprint3", "enterprise", "
|
|
783
|
+
.enum(["all", "footprint3", "enterprise", "cbam"])
|
|
784
784
|
.optional()
|
|
785
|
-
.describe("Optional module filter. Omit it or use all to return product-carbon, enterprise-carbon, and
|
|
785
|
+
.describe("Optional module filter. Omit it or use all to return product-carbon, enterprise-carbon, and CBAM objects."),
|
|
786
786
|
}),
|
|
787
|
-
|
|
788
|
-
...
|
|
789
|
-
types: z.array(
|
|
787
|
+
cbam_reference_search: z.object({
|
|
788
|
+
...cbamReadFields,
|
|
789
|
+
types: z.array(cbamReferenceType).min(1).max(12)
|
|
790
790
|
.describe("Only the reference-data families needed for the current step. CARBON_TAX_CANDIDATE additionally requires reportId."),
|
|
791
791
|
keyword: z.string().trim().max(200).optional(),
|
|
792
792
|
orgId: longId.optional(),
|
|
@@ -795,8 +795,8 @@ export const schemas = {
|
|
|
795
795
|
pageNum: z.number().int().min(1).optional(),
|
|
796
796
|
pageSize: z.number().int().min(1).max(200).optional(),
|
|
797
797
|
}),
|
|
798
|
-
|
|
799
|
-
...
|
|
798
|
+
cbam_report_search: z.object({
|
|
799
|
+
...cbamReadFields,
|
|
800
800
|
reportName: z.string().trim().max(200).optional(),
|
|
801
801
|
orgId: longId.optional(),
|
|
802
802
|
factoryId: longId.optional(),
|
|
@@ -804,94 +804,94 @@ export const schemas = {
|
|
|
804
804
|
pageNum: z.number().int().min(1).optional(),
|
|
805
805
|
pageSize: z.number().int().min(1).max(100).optional(),
|
|
806
806
|
}),
|
|
807
|
-
|
|
808
|
-
...
|
|
809
|
-
reportId: longId.describe("Exact
|
|
807
|
+
cbam_report_read: z.object({
|
|
808
|
+
...cbamReadFields,
|
|
809
|
+
reportId: longId.describe("Exact CBAM report id returned by cbam_report_search, cbam_report_save, or session_carbon_objects."),
|
|
810
810
|
view: z.enum(["snapshot", "section", "item", "result", "readiness", "carbon_tax_status"])
|
|
811
811
|
.describe("Read mode. snapshot=whole workflow overview; section=one form section; item=one child record; result=result summary; readiness=generation blockers; carbon_tax_status=asynchronous tax calculation status."),
|
|
812
|
-
section:
|
|
813
|
-
itemType:
|
|
812
|
+
section: cbamSection.optional().describe("Required only when view=section."),
|
|
813
|
+
itemType: cbamItemType.optional().describe("Required only when view=item."),
|
|
814
814
|
itemId: longId.optional().describe("Required only when view=item; must belong to reportId."),
|
|
815
815
|
}),
|
|
816
|
-
|
|
817
|
-
...
|
|
818
|
-
factoryId: longId.describe("Exact factory id returned by
|
|
816
|
+
cbam_factory_read: z.object({
|
|
817
|
+
...cbamReadFields,
|
|
818
|
+
factoryId: longId.describe("Exact factory id returned by cbam_reference_search or cbam_factory_save."),
|
|
819
819
|
}),
|
|
820
|
-
|
|
821
|
-
...
|
|
820
|
+
cbam_factory_save: z.object({
|
|
821
|
+
...cbamConfirmedWriteFields,
|
|
822
822
|
action: z.enum(["create", "update"]),
|
|
823
823
|
factoryId: longId.optional().describe("Required for action=update and omitted for action=create."),
|
|
824
|
-
factory:
|
|
824
|
+
factory: cbamFactoryForm.describe("Complete factory form. For update, first call cbam_factory_read and preserve unchanged fields and orgId."),
|
|
825
825
|
}),
|
|
826
|
-
|
|
827
|
-
...
|
|
826
|
+
cbam_report_save: z.object({
|
|
827
|
+
...cbamWriteFields,
|
|
828
828
|
action: z.enum(["create", "update"]),
|
|
829
829
|
reportId: longId.optional().describe("Required for action=update and omitted for action=create."),
|
|
830
|
-
report:
|
|
830
|
+
report: cbamReportForm.describe("Complete CBAM general-information form."),
|
|
831
831
|
}),
|
|
832
|
-
|
|
833
|
-
...
|
|
832
|
+
cbam_process_manage: z.object({
|
|
833
|
+
...cbamConfirmedWriteFields,
|
|
834
834
|
reportId: longId,
|
|
835
835
|
action: z.enum(["save", "delete", "reorder"]).describe("save requires items and forbids ids; delete requires ids and uses WAIT_CONFIRM; reorder requires the complete ordered ids list and forbids items."),
|
|
836
|
-
items: z.array(
|
|
836
|
+
items: z.array(cbamProcessDefinition).min(1).max(10).optional()
|
|
837
837
|
.describe("Required only for action=save. The report can contain at most 10 processes."),
|
|
838
838
|
ids: z.array(longId).min(1).max(10).optional()
|
|
839
839
|
.describe("Required for delete/reorder. Reorder must contain every report process exactly once in target order."),
|
|
840
840
|
}),
|
|
841
|
-
|
|
842
|
-
...
|
|
841
|
+
cbam_precursor_manage: z.object({
|
|
842
|
+
...cbamConfirmedWriteFields,
|
|
843
843
|
reportId: longId,
|
|
844
844
|
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids and uses WAIT_CONFIRM."),
|
|
845
|
-
items: z.array(
|
|
845
|
+
items: z.array(cbamPrecursorDefinition).min(1).max(20).optional()
|
|
846
846
|
.describe("Required only for action=save. The report can contain at most 20 manually entered precursors."),
|
|
847
847
|
ids: z.array(longId).min(1).max(20).optional().describe("Required only for action=delete."),
|
|
848
848
|
}),
|
|
849
|
-
|
|
850
|
-
...
|
|
849
|
+
cbam_source_flow_manage: z.object({
|
|
850
|
+
...cbamConfirmedWriteFields,
|
|
851
851
|
reportId: longId,
|
|
852
852
|
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids and uses WAIT_CONFIRM."),
|
|
853
|
-
items: z.array(
|
|
853
|
+
items: z.array(cbamSourceFlow).min(1).max(200).optional().describe("Required only for action=save."),
|
|
854
854
|
ids: z.array(longId).min(1).max(100).optional().describe("Required only for action=delete."),
|
|
855
855
|
}),
|
|
856
|
-
|
|
857
|
-
...
|
|
856
|
+
cbam_heat_power_update: z.object({
|
|
857
|
+
...cbamWriteFields,
|
|
858
858
|
reportId: longId,
|
|
859
|
-
data:
|
|
859
|
+
data: cbamHeatPowerData.describe("Complete heat-power input form. The backend calculates outPower and outFactor; never submit calculated outputs."),
|
|
860
860
|
}),
|
|
861
|
-
|
|
862
|
-
...
|
|
861
|
+
cbam_product_data_update: z.object({
|
|
862
|
+
...cbamWriteFields,
|
|
863
863
|
reportId: longId,
|
|
864
864
|
dataType: z.enum(["process", "precursor"])
|
|
865
865
|
.describe("Select process for self-produced process activity data or precursor for purchased-precursor activity/emission data."),
|
|
866
|
-
items: z.array(z.union([
|
|
866
|
+
items: z.array(z.union([cbamProcessProductData, cbamPrecursorProductData])).min(1).max(100),
|
|
867
867
|
}),
|
|
868
|
-
|
|
869
|
-
...
|
|
868
|
+
cbam_sale_product_manage: z.object({
|
|
869
|
+
...cbamConfirmedWriteFields,
|
|
870
870
|
reportId: longId,
|
|
871
871
|
action: z.enum(["save", "delete"]).describe("save requires items and forbids ids; delete requires ids and uses WAIT_CONFIRM."),
|
|
872
|
-
items: z.array(
|
|
872
|
+
items: z.array(cbamSaleProduct).min(1).max(100).optional().describe("Required only for action=save."),
|
|
873
873
|
ids: z.array(longId).min(1).max(100).optional().describe("Required only for action=delete."),
|
|
874
874
|
}),
|
|
875
|
-
|
|
876
|
-
...
|
|
875
|
+
cbam_carbon_tax_manage: z.object({
|
|
876
|
+
...cbamConfirmedWriteFields,
|
|
877
877
|
reportId: longId,
|
|
878
878
|
action: z.enum(["save", "delete", "calculate"]).describe("save requires items; delete requires ids and WAIT_CONFIRM; calculate forbids items/ids and uses WAIT_CONFIRM."),
|
|
879
|
-
items: z.array(
|
|
879
|
+
items: z.array(cbamCarbonTax).min(1).max(100).optional().describe("Required only for action=save."),
|
|
880
880
|
ids: z.array(longId).min(1).max(100).optional().describe("Required only for action=delete."),
|
|
881
881
|
}),
|
|
882
|
-
|
|
883
|
-
...
|
|
882
|
+
cbam_data_quality_update: z.object({
|
|
883
|
+
...cbamWriteFields,
|
|
884
884
|
reportId: longId,
|
|
885
|
-
data:
|
|
885
|
+
data: cbamDataQuality.describe("Complete data-quality form. Read DATA_QUALITY first and preserve fields the user did not change."),
|
|
886
886
|
}),
|
|
887
|
-
|
|
888
|
-
...
|
|
889
|
-
reportId: longId.describe("
|
|
887
|
+
cbam_report_generate: z.object({
|
|
888
|
+
...cbamConfirmedWriteFields,
|
|
889
|
+
reportId: longId.describe("CBAM report id to generate. Basic general information is sufficient to start; readiness reports optional missing sections separately."),
|
|
890
890
|
}),
|
|
891
|
-
|
|
892
|
-
...
|
|
891
|
+
cbam_report_generation_status: z.object({
|
|
892
|
+
...cbamReadFields,
|
|
893
893
|
reportId: longId,
|
|
894
|
-
generationId: longId.describe("Generation task id returned by
|
|
894
|
+
generationId: longId.describe("Generation task id returned by cbam_report_generate."),
|
|
895
895
|
}),
|
|
896
896
|
user_memory_recall: z.object({
|
|
897
897
|
sessionId,
|
|
@@ -1344,22 +1344,22 @@ export const schemas = {
|
|
|
1344
1344
|
schemas.enterprise_report_regenerate = schemas.enterprise_report_generate;
|
|
1345
1345
|
export const exposedToolNames = [
|
|
1346
1346
|
"session_carbon_objects",
|
|
1347
|
-
"
|
|
1348
|
-
"
|
|
1349
|
-
"
|
|
1350
|
-
"
|
|
1351
|
-
"
|
|
1352
|
-
"
|
|
1353
|
-
"
|
|
1354
|
-
"
|
|
1355
|
-
"
|
|
1356
|
-
"
|
|
1357
|
-
"
|
|
1358
|
-
"
|
|
1359
|
-
"
|
|
1360
|
-
"
|
|
1361
|
-
"
|
|
1362
|
-
"
|
|
1347
|
+
"cbam_reference_search",
|
|
1348
|
+
"cbam_report_search",
|
|
1349
|
+
"cbam_report_read",
|
|
1350
|
+
"cbam_factory_read",
|
|
1351
|
+
"cbam_factory_save",
|
|
1352
|
+
"cbam_report_save",
|
|
1353
|
+
"cbam_process_manage",
|
|
1354
|
+
"cbam_precursor_manage",
|
|
1355
|
+
"cbam_source_flow_manage",
|
|
1356
|
+
"cbam_heat_power_update",
|
|
1357
|
+
"cbam_product_data_update",
|
|
1358
|
+
"cbam_sale_product_manage",
|
|
1359
|
+
"cbam_carbon_tax_manage",
|
|
1360
|
+
"cbam_data_quality_update",
|
|
1361
|
+
"cbam_report_generate",
|
|
1362
|
+
"cbam_report_generation_status",
|
|
1363
1363
|
"user_memory_recall",
|
|
1364
1364
|
"user_memory_get",
|
|
1365
1365
|
"user_memory_upsert",
|
|
@@ -1416,23 +1416,23 @@ export const exposedToolNames = [
|
|
|
1416
1416
|
"enterprise_emission_batch_delete",
|
|
1417
1417
|
];
|
|
1418
1418
|
export const descriptions = {
|
|
1419
|
-
session_carbon_objects: "Recover product-carbon accounts, enterprise-carbon computations, and
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1419
|
+
session_carbon_objects: "Recover product-carbon accounts, enterprise-carbon computations, and CBAM reports bound to the current Agent session. Call this before guessing a lost business id. Omit module or use all for every family; module=footprint3 returns productCarbonAccounts, module=enterprise returns enterpriseCarbonComputations, and module=cbam returns cbamReports. One session may contain multiple CBAM reports, so match by reportName/org/factory and then pass the exact cbamReports[].reportId to every report-specific tool. Never substitute an enterprise year, product accountId, or another report id. This tool is read-only and requires sessionId.",
|
|
1420
|
+
cbam_reference_search: "Read CBAM reference data needed for the current step: accessible organizations and factories, countries, currencies, enum codes, product categories, default processes/precursors/products/CN/sale data, or report-scoped carbon-tax candidates. Request only needed types. Use returned ids/codes exactly and never invent dictionary or organization values. CARBON_TAX_CANDIDATE requires reportId. Large reference tables are paginated with pageNum/pageSize. Read-only.",
|
|
1421
|
+
cbam_report_search: "Search CBAM reports accessible to the current user by optional name, organization, factory, year, and pagination. Use this or session_carbon_objects to resolve an exact reportId. A single Agent session can create and work with multiple CBAM reports; never silently select the first result when several reports match. Read-only.",
|
|
1422
|
+
cbam_report_read: "Unified read-only CBAM report inspection. view=snapshot returns workflow overview/counts/readiness; section returns one complete editable section and requires section; item reads one child record and requires itemType+itemId; result returns result analysis; readiness returns generation blockers/warnings; carbon_tax_status returns asynchronous carbon-tax calculation state. itemId must belong to reportId. Call the corresponding read view before a full-form update so unchanged fields are preserved.",
|
|
1423
|
+
cbam_factory_read: "Read the complete accessible CBAM factory form by exact factoryId. Call before updating a shared factory because factory updates are full-form writes and orgId is immutable. Read-only.",
|
|
1424
|
+
cbam_factory_save: "Create or fully update a shared CBAM factory. action=create omits factoryId; action=update requires factoryId and must follow cbam_factory_read, preserving unchanged fields and orgId. Country and orgId must come from cbam_reference_search. Both actions are shared-data mutations and use the backend WAIT_CONFIRM two-step flow: first call without confirmed, then repeat the identical payload/idempotencyKey with confirmed=true and the returned pendingActionId after user confirmation. MCP never automatically retries this write.",
|
|
1425
|
+
cbam_report_save: "Create or fully update CBAM report general information. action=create omits reportId; every create call creates a NEW report and binds it to the same Agent session without replacing earlier CBAM reports. One session may therefore contain multiple reports. action=update requires an explicit reportId and should follow cbam_report_read view=section section=GENERAL_INFO. After more than one report exists, always pass the intended reportId to subsequent tools and ask the user when context is ambiguous. Basic general information is enough to create a report and later generate it; other sections are progressive supplements. Requires idempotencyKey.",
|
|
1426
|
+
cbam_process_manage: "Manage self-produced CBAM process definitions for one report. action=save batch-creates/updates complete definition rows; action=delete removes exact ids; action=reorder requires every current process id exactly once in target order. Read PROCESS before updates/deletes/reorder. A report supports at most 10 processes. Delete uses WAIT_CONFIRM and must repeat the identical request with returned pendingActionId after confirmation. Requires idempotencyKey; MCP never automatically retries.",
|
|
1427
|
+
cbam_precursor_manage: "Manage manually entered purchased-precursor definitions. action=save batch-creates/updates complete rows; action=delete removes exact precursor ids. Read PRECURSOR first, and resolve category/country/route values through cbam_reference_search. A report supports at most 20 precursors. Delete uses WAIT_CONFIRM. Requires idempotencyKey; MCP never automatically retries.",
|
|
1428
|
+
cbam_source_flow_manage: "Manage direct-emission source-flow rows under report processes. action=save creates/updates rows and the backend recalculates direct emissions; action=delete removes exact ids. Read SOURCE_FLOW first, use process ids from the same report, and use CBAM_ENUM codes for processMethod/sourceType. Calculated results and support files are backend-owned and are not accepted by this tool. Delete uses WAIT_CONFIRM. Requires idempotencyKey.",
|
|
1429
|
+
cbam_heat_power_update: "Update complete heat-power cogeneration inputs for a report whose include flag enables this section. Read HEAT_POWER first. Submit only input fields; the backend calculates outPower/outFactor and invalidates dependent sale calculations. Requires idempotencyKey.",
|
|
1430
|
+
cbam_product_data_update: "Update product activity/emission data for existing process or precursor rows. dataType=process requires process items with totalVolume and salesVolume; dataType=precursor requires precursor items. Read PROCESS_PRODUCT_DATA or PRECURSOR_PRODUCT_DATA first. The backend preserves definitions, validates report ownership and activity balances, replaces route rows transactionally, calculates dependent fields, and rejects server-owned result fields. Requires idempotencyKey.",
|
|
1431
|
+
cbam_sale_product_manage: "Manage sale products for one CBAM report. action=save batch-creates/updates complete form rows tied to exact report process ids; action=delete removes exact ids and dependent tax rows. Read SALE_PRODUCT first and use CN/category data from cbam_reference_search. Calculated emissions, versions, fill status, and payTax are backend-owned. Delete uses WAIT_CONFIRM. Requires idempotencyKey.",
|
|
1432
|
+
cbam_carbon_tax_manage: "Manage or calculate report carbon tax. action=save batch-creates/updates rows using exact saleProductId, currency, benchmark, and source candidates returned by CBAM reads/reference search; action=delete removes exact ids; action=calculate starts asynchronous calculation. Read CARBON_TAX and carbon-tax candidates first. delete and calculate use WAIT_CONFIRM; after calculate succeeds, poll cbam_report_read with view=carbon_tax_status. Requires idempotencyKey and is never automatically retried.",
|
|
1433
|
+
cbam_data_quality_update: "Update the complete CBAM data-quality form. First call cbam_report_read view=section section=DATA_QUALITY and preserve fields the user did not change. Use CBAM_ENUM codes for enum fields. Requires idempotencyKey.",
|
|
1434
|
+
cbam_report_generate: "Start backend generation of the selected CBAM report file. General information alone is sufficient to request generation; optional missing sections remain visible through cbam_report_read view=readiness and may produce warnings or incomplete content according to backend rules. The backend creates the file, uploads it, and records it in Carbon Cloud download management; the Agent must not create a parallel spreadsheet. This costly asynchronous action uses WAIT_CONFIRM. After confirmation repeat the identical payload/idempotencyKey with confirmed=true and pendingActionId, then poll cbam_report_generation_status using returned generationId. Timeout/network/5xx failures are not automatically retried.",
|
|
1435
|
+
cbam_report_generation_status: "Poll one CBAM report-generation task using the exact reportId and generationId returned by cbam_report_generate. Returns RUNNING, COMPLETED, or FAILED plus the generated download record/path when available. Read-only.",
|
|
1436
1436
|
user_memory_recall: "Recall the current user's stored cross-session preferences, long-term constraints, carbon-domain habits, and response-style preferences. Call this when stable prior preferences can materially improve the current task, when the user asks what was remembered, and before user_memory_upsert or user_memory_forget if this turn has not already recalled the same target topic. A direct write or forget needs this lookup even when the current request supplies the new value, so the Agent can reuse an existing memoryKey and memoryId instead of creating a semantic duplicate. Do not repeatedly recall the same topic in one turn. Write query as a concise question about the preference or constraint needed now; never copy the full user message or include unrelated sensitive business data. Optional memoryTypes: preference=general preference, constraint=persistent rule or boundary, domain_habit=carbon-accounting/modeling/reporting workflow habit, format_habit=response language/structure/length/file-format habit. The response contains rules and items with memoryId, scope, type, memoryKey, normalized content, recallMode, version, and relevance metadata. count=0 is a successful empty recall; continue the task using current context. The current user request always overrides recalled memory, and current business data is authoritative. Treat recalled items as guidance, not authoritative business facts. Never reveal memory ids, versions, scores, source metadata, or internal implementation details to the user. Requires sessionId, a messageId belonging to that session, and query.",
|
|
1437
1437
|
user_memory_get: "Read exactly one current-user memory by the stable memoryId returned by user_memory_recall or a previous write. Use this immediately before updating or forgetting a memory to obtain its latest version and avoid stale writes. Do not enumerate, guess, or probe memory ids, and do not use this tool to access another user or project: authorization is derived from sessionId and messageId. The response is reduced to Agent-safe fields and must not be displayed as internal metadata to the user. Requires sessionId, a messageId belonging to that session, and memoryId.",
|
|
1438
1438
|
user_memory_upsert: "Create or update one stable long-term user memory. Call only when the user explicitly asks the Agent to remember a lasting preference/constraint, or after the user clearly confirms it; ordinary observations, one-off task details, sensitive data, changing business facts, account ids, emission values, and unconfirmed model inferences must not be stored. Before writing, call user_memory_recall once for the target topic unless the same topic was already recalled in this turn. If recall finds the same independently updatable slot, reuse its exact memoryKey; for an exact update, also reuse its memoryId, call user_memory_get, and preferably pass the latest positive version as expectedVersion. If recall finds no matching slot, omit memoryId and create by a new stable memoryKey. memoryId determines the operation: omit it or pass a blank value to create/upsert by memoryKey; pass a valid memoryId to update that exact item. For compatibility, expectedVersion may be omitted or 0 and the backend will use the latest version read at update time; never blindly retry a version conflict. expectedVersion is ignored when memoryId is absent. memoryKey represents one independently updatable slot: never include mutable attitude/state such as like/dislike or enabled/disabled. A single-valued attribute uses one fixed key without the changing value, such as preference.favorite_color or format.response.language. A multi-valued collection includes a canonical lowercase English object so values can coexist, such as preference.color.white and preference.color.red; liking and disliking white both reuse preference.color.white. Different wording or languages for the same slot or object must reuse the recalled key. USER applies across sessions; USER_PROJECT applies only to the current session project, which the backend derives automatically. Prefer source=EXPLICIT_USER for a direct request or CONFIRMED_CONVERSATION after confirmation. Use ALWAYS for persistent constraints/response-style rules and SEMANTIC for context-dependent preferences, or omit recallMode for the backend default. Requires sessionId, messageId, scope, type, memoryKey, and normalized content no longer than 120 characters. MCP never automatically retries this write.",
|
|
@@ -1501,134 +1501,135 @@ export const toolRoutes = {
|
|
|
1501
1501
|
method: "POST",
|
|
1502
1502
|
path: apipath.SessionBusinessRefs(),
|
|
1503
1503
|
bodyKind: "sessionContext",
|
|
1504
|
+
responseKind: "sessionCarbonObjects",
|
|
1504
1505
|
},
|
|
1505
|
-
|
|
1506
|
+
cbam_reference_search: {
|
|
1506
1507
|
method: "POST",
|
|
1507
|
-
path: apipath.
|
|
1508
|
-
bodyKind: "
|
|
1508
|
+
path: apipath.CbamReferenceSearch(),
|
|
1509
|
+
bodyKind: "cbam",
|
|
1509
1510
|
},
|
|
1510
|
-
|
|
1511
|
+
cbam_report_search: {
|
|
1511
1512
|
method: "POST",
|
|
1512
|
-
path: apipath.
|
|
1513
|
-
bodyKind: "
|
|
1513
|
+
path: apipath.CbamReportSearch(),
|
|
1514
|
+
bodyKind: "cbam",
|
|
1514
1515
|
},
|
|
1515
|
-
|
|
1516
|
+
cbam_report_read: {
|
|
1516
1517
|
method: "POST",
|
|
1517
1518
|
path: (args) => {
|
|
1518
1519
|
if (args.view === "section")
|
|
1519
|
-
return apipath.
|
|
1520
|
+
return apipath.CbamSectionSnapshot();
|
|
1520
1521
|
if (args.view === "item")
|
|
1521
|
-
return apipath.
|
|
1522
|
+
return apipath.CbamItemDetail();
|
|
1522
1523
|
if (args.view === "result")
|
|
1523
|
-
return apipath.
|
|
1524
|
+
return apipath.CbamResultSummary();
|
|
1524
1525
|
if (args.view === "readiness")
|
|
1525
|
-
return apipath.
|
|
1526
|
+
return apipath.CbamReportReadiness();
|
|
1526
1527
|
if (args.view === "carbon_tax_status")
|
|
1527
|
-
return apipath.
|
|
1528
|
-
return apipath.
|
|
1528
|
+
return apipath.CbamCarbonTaxStatus();
|
|
1529
|
+
return apipath.CbamReportSnapshot();
|
|
1529
1530
|
},
|
|
1530
|
-
bodyKind: "
|
|
1531
|
+
bodyKind: "cbam",
|
|
1531
1532
|
},
|
|
1532
|
-
|
|
1533
|
+
cbam_factory_read: {
|
|
1533
1534
|
method: "POST",
|
|
1534
|
-
path: apipath.
|
|
1535
|
-
bodyKind: "
|
|
1535
|
+
path: apipath.CbamFactoryDetail(),
|
|
1536
|
+
bodyKind: "cbam",
|
|
1536
1537
|
},
|
|
1537
|
-
|
|
1538
|
+
cbam_factory_save: {
|
|
1538
1539
|
method: "POST",
|
|
1539
1540
|
path: (args) => args.action === "update"
|
|
1540
|
-
? apipath.
|
|
1541
|
-
: apipath.
|
|
1542
|
-
bodyKind: "
|
|
1541
|
+
? apipath.CbamFactoryUpdate()
|
|
1542
|
+
: apipath.CbamFactoryCreate(),
|
|
1543
|
+
bodyKind: "cbam",
|
|
1543
1544
|
maxRetries: 0,
|
|
1544
1545
|
},
|
|
1545
|
-
|
|
1546
|
+
cbam_report_save: {
|
|
1546
1547
|
method: "POST",
|
|
1547
1548
|
path: (args) => args.action === "update"
|
|
1548
|
-
? apipath.
|
|
1549
|
-
: apipath.
|
|
1550
|
-
bodyKind: "
|
|
1549
|
+
? apipath.CbamReportUpdate()
|
|
1550
|
+
: apipath.CbamReportCreate(),
|
|
1551
|
+
bodyKind: "cbam",
|
|
1551
1552
|
maxRetries: 0,
|
|
1552
1553
|
},
|
|
1553
|
-
|
|
1554
|
+
cbam_process_manage: {
|
|
1554
1555
|
method: "POST",
|
|
1555
1556
|
path: (args) => {
|
|
1556
1557
|
if (args.action === "delete")
|
|
1557
|
-
return apipath.
|
|
1558
|
+
return apipath.CbamProcessBatchDelete();
|
|
1558
1559
|
if (args.action === "reorder")
|
|
1559
|
-
return apipath.
|
|
1560
|
-
return apipath.
|
|
1560
|
+
return apipath.CbamProcessReorder();
|
|
1561
|
+
return apipath.CbamProcessBatchSave();
|
|
1561
1562
|
},
|
|
1562
|
-
bodyKind: "
|
|
1563
|
+
bodyKind: "cbam",
|
|
1563
1564
|
maxRetries: 0,
|
|
1564
1565
|
},
|
|
1565
|
-
|
|
1566
|
+
cbam_precursor_manage: {
|
|
1566
1567
|
method: "POST",
|
|
1567
1568
|
path: (args) => args.action === "delete"
|
|
1568
|
-
? apipath.
|
|
1569
|
-
: apipath.
|
|
1570
|
-
bodyKind: "
|
|
1569
|
+
? apipath.CbamPrecursorBatchDelete()
|
|
1570
|
+
: apipath.CbamPrecursorBatchSave(),
|
|
1571
|
+
bodyKind: "cbam",
|
|
1571
1572
|
maxRetries: 0,
|
|
1572
1573
|
},
|
|
1573
|
-
|
|
1574
|
+
cbam_source_flow_manage: {
|
|
1574
1575
|
method: "POST",
|
|
1575
1576
|
path: (args) => args.action === "delete"
|
|
1576
|
-
? apipath.
|
|
1577
|
-
: apipath.
|
|
1578
|
-
bodyKind: "
|
|
1577
|
+
? apipath.CbamSourceFlowBatchDelete()
|
|
1578
|
+
: apipath.CbamSourceFlowBatchSave(),
|
|
1579
|
+
bodyKind: "cbam",
|
|
1579
1580
|
maxRetries: 0,
|
|
1580
1581
|
},
|
|
1581
|
-
|
|
1582
|
+
cbam_heat_power_update: {
|
|
1582
1583
|
method: "POST",
|
|
1583
|
-
path: apipath.
|
|
1584
|
-
bodyKind: "
|
|
1584
|
+
path: apipath.CbamHeatPowerUpdate(),
|
|
1585
|
+
bodyKind: "cbam",
|
|
1585
1586
|
maxRetries: 0,
|
|
1586
1587
|
},
|
|
1587
|
-
|
|
1588
|
+
cbam_product_data_update: {
|
|
1588
1589
|
method: "POST",
|
|
1589
1590
|
path: (args) => args.dataType === "precursor"
|
|
1590
|
-
? apipath.
|
|
1591
|
-
: apipath.
|
|
1592
|
-
bodyKind: "
|
|
1591
|
+
? apipath.CbamPrecursorProductBatchUpdate()
|
|
1592
|
+
: apipath.CbamProcessProductBatchUpdate(),
|
|
1593
|
+
bodyKind: "cbam",
|
|
1593
1594
|
maxRetries: 0,
|
|
1594
1595
|
},
|
|
1595
|
-
|
|
1596
|
+
cbam_sale_product_manage: {
|
|
1596
1597
|
method: "POST",
|
|
1597
1598
|
path: (args) => args.action === "delete"
|
|
1598
|
-
? apipath.
|
|
1599
|
-
: apipath.
|
|
1600
|
-
bodyKind: "
|
|
1599
|
+
? apipath.CbamSaleProductBatchDelete()
|
|
1600
|
+
: apipath.CbamSaleProductBatchSave(),
|
|
1601
|
+
bodyKind: "cbam",
|
|
1601
1602
|
maxRetries: 0,
|
|
1602
1603
|
},
|
|
1603
|
-
|
|
1604
|
+
cbam_carbon_tax_manage: {
|
|
1604
1605
|
method: "POST",
|
|
1605
1606
|
path: (args) => {
|
|
1606
1607
|
if (args.action === "delete")
|
|
1607
|
-
return apipath.
|
|
1608
|
+
return apipath.CbamCarbonTaxBatchDelete();
|
|
1608
1609
|
if (args.action === "calculate")
|
|
1609
|
-
return apipath.
|
|
1610
|
-
return apipath.
|
|
1610
|
+
return apipath.CbamCarbonTaxCalculate();
|
|
1611
|
+
return apipath.CbamCarbonTaxBatchSave();
|
|
1611
1612
|
},
|
|
1612
|
-
bodyKind: "
|
|
1613
|
+
bodyKind: "cbam",
|
|
1613
1614
|
maxRetries: 0,
|
|
1614
1615
|
},
|
|
1615
|
-
|
|
1616
|
+
cbam_data_quality_update: {
|
|
1616
1617
|
method: "POST",
|
|
1617
|
-
path: apipath.
|
|
1618
|
-
bodyKind: "
|
|
1618
|
+
path: apipath.CbamDataQualityUpdate(),
|
|
1619
|
+
bodyKind: "cbam",
|
|
1619
1620
|
maxRetries: 0,
|
|
1620
1621
|
},
|
|
1621
|
-
|
|
1622
|
+
cbam_report_generate: {
|
|
1622
1623
|
method: "POST",
|
|
1623
|
-
path: apipath.
|
|
1624
|
-
bodyKind: "
|
|
1624
|
+
path: apipath.CbamReportGenerate(),
|
|
1625
|
+
bodyKind: "cbam",
|
|
1625
1626
|
timeoutSeconds: 120,
|
|
1626
1627
|
maxRetries: 0,
|
|
1627
1628
|
},
|
|
1628
|
-
|
|
1629
|
+
cbam_report_generation_status: {
|
|
1629
1630
|
method: "POST",
|
|
1630
|
-
path: apipath.
|
|
1631
|
-
bodyKind: "
|
|
1631
|
+
path: apipath.CbamReportGenerationStatus(),
|
|
1632
|
+
bodyKind: "cbam",
|
|
1632
1633
|
},
|
|
1633
1634
|
user_memory_recall: {
|
|
1634
1635
|
method: "POST",
|
|
@@ -1942,7 +1943,7 @@ export const toolRoutes = {
|
|
|
1942
1943
|
},
|
|
1943
1944
|
};
|
|
1944
1945
|
export function buildBody(route, args) {
|
|
1945
|
-
if (route.bodyKind === "
|
|
1946
|
+
if (route.bodyKind === "cbam") {
|
|
1946
1947
|
const body = { ...args };
|
|
1947
1948
|
const action = body.action;
|
|
1948
1949
|
const view = body.view;
|
|
@@ -1971,18 +1972,22 @@ export function buildBody(route, args) {
|
|
|
1971
1972
|
delete body.items;
|
|
1972
1973
|
delete body.ids;
|
|
1973
1974
|
}
|
|
1974
|
-
const confirmationRequired = route === toolRoutes.
|
|
1975
|
-
|| route === toolRoutes.
|
|
1975
|
+
const confirmationRequired = route === toolRoutes.cbam_factory_save
|
|
1976
|
+
|| route === toolRoutes.cbam_report_generate
|
|
1976
1977
|
|| action === "delete"
|
|
1977
1978
|
|| action === "calculate";
|
|
1978
1979
|
if (!confirmationRequired) {
|
|
1979
1980
|
delete body.confirmed;
|
|
1980
1981
|
delete body.pendingActionId;
|
|
1981
1982
|
}
|
|
1982
|
-
return
|
|
1983
|
+
return normalizeCbamCodes(normalizeIds(pickDefined(body)));
|
|
1983
1984
|
}
|
|
1984
1985
|
if (route.bodyKind === "sessionContext") {
|
|
1985
|
-
return pickDefined({
|
|
1986
|
+
return pickDefined({
|
|
1987
|
+
sessionId: args.sessionId,
|
|
1988
|
+
// The Agent-facing module is CBAM; the existing Java contract still uses cbam2.
|
|
1989
|
+
module: args.module === "cbam" ? "cbam2" : args.module,
|
|
1990
|
+
});
|
|
1986
1991
|
}
|
|
1987
1992
|
if (route.bodyKind === "projectRead") {
|
|
1988
1993
|
const projectTaskId = typeof args.projectTaskId === "string"
|
|
@@ -2228,7 +2233,7 @@ function normalizeEnterpriseEmissionSource(source, gasListField) {
|
|
|
2228
2233
|
function normalizeNumericCode(value) {
|
|
2229
2234
|
return typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
|
|
2230
2235
|
}
|
|
2231
|
-
const
|
|
2236
|
+
const cbamNumericCodeFields = new Set([
|
|
2232
2237
|
"include",
|
|
2233
2238
|
"includeType",
|
|
2234
2239
|
"processMethod",
|
|
@@ -2252,22 +2257,22 @@ const cbam2NumericCodeFields = new Set([
|
|
|
2252
2257
|
"qualityAssurance",
|
|
2253
2258
|
"orderNum",
|
|
2254
2259
|
]);
|
|
2255
|
-
const
|
|
2256
|
-
function
|
|
2260
|
+
const cbamGenericIdFields = new Set(["id"]);
|
|
2261
|
+
function normalizeCbamCodes(value) {
|
|
2257
2262
|
if (Array.isArray(value))
|
|
2258
|
-
return value.map(
|
|
2263
|
+
return value.map(normalizeCbamCodes);
|
|
2259
2264
|
if (!value || typeof value !== "object")
|
|
2260
2265
|
return value;
|
|
2261
2266
|
const result = {};
|
|
2262
2267
|
for (const [key, childValue] of Object.entries(value)) {
|
|
2263
|
-
if (
|
|
2268
|
+
if (cbamNumericCodeFields.has(key)) {
|
|
2264
2269
|
result[key] = normalizeNumericCode(childValue);
|
|
2265
2270
|
}
|
|
2266
|
-
else if (
|
|
2271
|
+
else if (cbamGenericIdFields.has(key) && typeof childValue === "string" && /^\d+$/.test(childValue)) {
|
|
2267
2272
|
result[key] = normalizeNumericId(childValue);
|
|
2268
2273
|
}
|
|
2269
2274
|
else {
|
|
2270
|
-
result[key] =
|
|
2275
|
+
result[key] = normalizeCbamCodes(childValue);
|
|
2271
2276
|
}
|
|
2272
2277
|
}
|
|
2273
2278
|
return result;
|
|
@@ -2281,8 +2286,8 @@ function normalizeDecimalValue(value) {
|
|
|
2281
2286
|
return Number(normalized);
|
|
2282
2287
|
}
|
|
2283
2288
|
export function validateToolArgs(name, args) {
|
|
2284
|
-
if (name.startsWith("
|
|
2285
|
-
|
|
2289
|
+
if (name.startsWith("cbam_")) {
|
|
2290
|
+
validateCbamArgs(name, args);
|
|
2286
2291
|
return;
|
|
2287
2292
|
}
|
|
2288
2293
|
if (name === "enterprise_emission_batch_save" && Array.isArray(args.orgList)) {
|
|
@@ -2293,122 +2298,122 @@ export function validateToolArgs(name, args) {
|
|
|
2293
2298
|
validateEnterpriseEmissionUpdateArgs(args.computationList);
|
|
2294
2299
|
}
|
|
2295
2300
|
}
|
|
2296
|
-
function
|
|
2297
|
-
if (name === "
|
|
2301
|
+
function validateCbamArgs(name, args) {
|
|
2302
|
+
if (name === "cbam_reference_search") {
|
|
2298
2303
|
const types = Array.isArray(args.types) ? args.types.map(String) : [];
|
|
2299
2304
|
requireUniqueValues(types, "types");
|
|
2300
2305
|
if (types.includes("CARBON_TAX_CANDIDATE") && args.reportId === undefined) {
|
|
2301
|
-
|
|
2306
|
+
cbamInputError("REPORT_ID_REQUIRED", "reportId", "reportId is required when types contains CARBON_TAX_CANDIDATE");
|
|
2302
2307
|
}
|
|
2303
2308
|
return;
|
|
2304
2309
|
}
|
|
2305
|
-
if (name === "
|
|
2310
|
+
if (name === "cbam_report_read") {
|
|
2306
2311
|
if (args.view === "section" && args.section === undefined) {
|
|
2307
|
-
|
|
2312
|
+
cbamInputError("SECTION_REQUIRED", "section", "section is required when view=section");
|
|
2308
2313
|
}
|
|
2309
2314
|
if (args.view === "item") {
|
|
2310
2315
|
if (args.itemType === undefined)
|
|
2311
|
-
|
|
2316
|
+
cbamInputError("ITEM_TYPE_REQUIRED", "itemType", "itemType is required when view=item");
|
|
2312
2317
|
if (args.itemId === undefined)
|
|
2313
|
-
|
|
2318
|
+
cbamInputError("ITEM_ID_REQUIRED", "itemId", "itemId is required when view=item");
|
|
2314
2319
|
}
|
|
2315
2320
|
return;
|
|
2316
2321
|
}
|
|
2317
|
-
if (name === "
|
|
2322
|
+
if (name === "cbam_factory_save") {
|
|
2318
2323
|
validateCreateUpdateId(args, "factoryId");
|
|
2319
|
-
|
|
2324
|
+
validateCbamConfirmation(args, true);
|
|
2320
2325
|
return;
|
|
2321
2326
|
}
|
|
2322
|
-
if (name === "
|
|
2327
|
+
if (name === "cbam_report_save") {
|
|
2323
2328
|
validateCreateUpdateId(args, "reportId");
|
|
2324
2329
|
const report = args.report;
|
|
2325
2330
|
if (report)
|
|
2326
|
-
|
|
2331
|
+
validateCbamDateRange(report.startDate, report.endDate);
|
|
2327
2332
|
return;
|
|
2328
2333
|
}
|
|
2329
|
-
if (name === "
|
|
2330
|
-
|
|
2334
|
+
if (name === "cbam_process_manage") {
|
|
2335
|
+
validateCbamActionPayload(args, ["save", "delete", "reorder"]);
|
|
2331
2336
|
if (args.action === "reorder" || args.action === "delete")
|
|
2332
2337
|
requireUniqueIdArray(args.ids, "ids");
|
|
2333
2338
|
if (args.action === "save")
|
|
2334
2339
|
requireUniqueItemIds(args.items);
|
|
2335
|
-
|
|
2340
|
+
validateCbamConfirmation(args, args.action === "delete");
|
|
2336
2341
|
return;
|
|
2337
2342
|
}
|
|
2338
|
-
if (["
|
|
2339
|
-
|
|
2343
|
+
if (["cbam_precursor_manage", "cbam_source_flow_manage", "cbam_sale_product_manage"].includes(name)) {
|
|
2344
|
+
validateCbamActionPayload(args, ["save", "delete"]);
|
|
2340
2345
|
if (args.action === "delete")
|
|
2341
2346
|
requireUniqueIdArray(args.ids, "ids");
|
|
2342
2347
|
if (args.action === "save")
|
|
2343
2348
|
requireUniqueItemIds(args.items);
|
|
2344
|
-
if (name === "
|
|
2345
|
-
|
|
2349
|
+
if (name === "cbam_source_flow_manage" && args.action === "save") {
|
|
2350
|
+
validateCbamSourceFlows(args.items);
|
|
2346
2351
|
}
|
|
2347
|
-
|
|
2352
|
+
validateCbamConfirmation(args, args.action === "delete");
|
|
2348
2353
|
return;
|
|
2349
2354
|
}
|
|
2350
|
-
if (name === "
|
|
2351
|
-
|
|
2355
|
+
if (name === "cbam_carbon_tax_manage") {
|
|
2356
|
+
validateCbamActionPayload(args, ["save", "delete", "calculate"]);
|
|
2352
2357
|
if (args.action === "delete")
|
|
2353
2358
|
requireUniqueIdArray(args.ids, "ids");
|
|
2354
2359
|
if (args.action === "save")
|
|
2355
2360
|
requireUniqueItemIds(args.items);
|
|
2356
|
-
|
|
2361
|
+
validateCbamConfirmation(args, args.action === "delete" || args.action === "calculate");
|
|
2357
2362
|
return;
|
|
2358
2363
|
}
|
|
2359
|
-
if (name === "
|
|
2364
|
+
if (name === "cbam_product_data_update") {
|
|
2360
2365
|
const itemSchema = args.dataType === "precursor"
|
|
2361
|
-
?
|
|
2362
|
-
:
|
|
2366
|
+
? cbamPrecursorProductData
|
|
2367
|
+
: cbamProcessProductData;
|
|
2363
2368
|
const items = Array.isArray(args.items) ? args.items : [];
|
|
2364
2369
|
for (let index = 0; index < items.length; index++) {
|
|
2365
2370
|
if (!itemSchema.safeParse(items[index]).success) {
|
|
2366
|
-
|
|
2371
|
+
cbamInputError("PRODUCT_DATA_TYPE_MISMATCH", `items[${index}]`, `item does not match dataType=${String(args.dataType)}`);
|
|
2367
2372
|
}
|
|
2368
2373
|
}
|
|
2369
2374
|
requireUniqueItemIds(items);
|
|
2370
2375
|
return;
|
|
2371
2376
|
}
|
|
2372
|
-
if (name === "
|
|
2373
|
-
|
|
2377
|
+
if (name === "cbam_report_generate") {
|
|
2378
|
+
validateCbamConfirmation(args, true);
|
|
2374
2379
|
}
|
|
2375
2380
|
}
|
|
2376
2381
|
function validateCreateUpdateId(args, idField) {
|
|
2377
2382
|
if (args.action === "update" && args[idField] === undefined) {
|
|
2378
|
-
|
|
2383
|
+
cbamInputError("ID_REQUIRED", idField, `${idField} is required when action=update`);
|
|
2379
2384
|
}
|
|
2380
2385
|
if (args.action === "create" && args[idField] !== undefined) {
|
|
2381
|
-
|
|
2386
|
+
cbamInputError("ID_NOT_ALLOWED", idField, `${idField} must be omitted when action=create`);
|
|
2382
2387
|
}
|
|
2383
2388
|
}
|
|
2384
|
-
function
|
|
2389
|
+
function validateCbamActionPayload(args, supported) {
|
|
2385
2390
|
const action = String(args.action || "");
|
|
2386
2391
|
if (!supported.includes(action))
|
|
2387
|
-
|
|
2392
|
+
cbamInputError("INVALID_ACTION", "action", `unsupported action: ${action}`);
|
|
2388
2393
|
if (action === "save") {
|
|
2389
2394
|
requireNonEmptyArray(args.items, "items");
|
|
2390
2395
|
if (args.ids !== undefined)
|
|
2391
|
-
|
|
2396
|
+
cbamInputError("UNEXPECTED_IDS", "ids", "ids must be omitted when action=save");
|
|
2392
2397
|
}
|
|
2393
2398
|
else if (action === "delete" || action === "reorder") {
|
|
2394
2399
|
requireNonEmptyArray(args.ids, "ids");
|
|
2395
2400
|
if (args.items !== undefined)
|
|
2396
|
-
|
|
2401
|
+
cbamInputError("UNEXPECTED_ITEMS", "items", `items must be omitted when action=${action}`);
|
|
2397
2402
|
}
|
|
2398
2403
|
else if (action === "calculate") {
|
|
2399
2404
|
if (args.items !== undefined || args.ids !== undefined) {
|
|
2400
|
-
|
|
2405
|
+
cbamInputError("UNEXPECTED_PAYLOAD", "items", "items and ids must be omitted when action=calculate");
|
|
2401
2406
|
}
|
|
2402
2407
|
}
|
|
2403
2408
|
}
|
|
2404
|
-
function
|
|
2409
|
+
function validateCbamConfirmation(args, required) {
|
|
2405
2410
|
if (!required || args.confirmed !== true)
|
|
2406
2411
|
return;
|
|
2407
2412
|
if (typeof args.pendingActionId !== "string" || args.pendingActionId.trim().length === 0) {
|
|
2408
|
-
|
|
2413
|
+
cbamInputError("PENDING_ACTION_ID_REQUIRED", "pendingActionId", "pendingActionId returned by WAIT_CONFIRM is required when confirmed=true");
|
|
2409
2414
|
}
|
|
2410
2415
|
}
|
|
2411
|
-
function
|
|
2416
|
+
function validateCbamSourceFlows(value) {
|
|
2412
2417
|
if (!Array.isArray(value))
|
|
2413
2418
|
return;
|
|
2414
2419
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -2420,45 +2425,45 @@ function validateCbam2SourceFlows(value) {
|
|
|
2420
2425
|
const processMethod = numericCode(source.processMethod);
|
|
2421
2426
|
const path = `items[${index}]`;
|
|
2422
2427
|
if (![1, 2, 3].includes(sourceType)) {
|
|
2423
|
-
|
|
2428
|
+
cbamInputError("INVALID_SOURCE_FLOW_TYPE", `${path}.sourceType`, "sourceType must be 1, 2, or 3");
|
|
2424
2429
|
}
|
|
2425
2430
|
if (![1, 2, 3, 4, 5, 6, 7].includes(processMethod)) {
|
|
2426
|
-
|
|
2431
|
+
cbamInputError("INVALID_PROCESS_METHOD", `${path}.processMethod`, "processMethod must be between 1 and 7");
|
|
2427
2432
|
}
|
|
2428
2433
|
if (sourceType === 1 && ![1, 2, 3].includes(processMethod)) {
|
|
2429
|
-
|
|
2434
|
+
cbamInputError("INVALID_SOURCE_FLOW_COMBINATION", `${path}.processMethod`, "sourceType=1 supports processMethod 1, 2, or 3");
|
|
2430
2435
|
}
|
|
2431
2436
|
if (sourceType === 2 && ![4, 5].includes(processMethod)) {
|
|
2432
|
-
|
|
2437
|
+
cbamInputError("INVALID_SOURCE_FLOW_COMBINATION", `${path}.processMethod`, "sourceType=2 supports processMethod 4 or 5");
|
|
2433
2438
|
}
|
|
2434
2439
|
if (sourceType === 3 && ![6, 7].includes(processMethod)) {
|
|
2435
|
-
|
|
2440
|
+
cbamInputError("INVALID_SOURCE_FLOW_COMBINATION", `${path}.processMethod`, "sourceType=3 supports processMethod 6 or 7");
|
|
2436
2441
|
}
|
|
2437
2442
|
if (sourceType === 1 && processMethod === 1) {
|
|
2438
|
-
|
|
2443
|
+
requireCbamFields(source, path, ["activityData", "emissionCoefficient", "oxRate"]);
|
|
2439
2444
|
requireLowHeatForEnergyUnit(source, path);
|
|
2440
2445
|
}
|
|
2441
2446
|
else if (sourceType === 1 && processMethod === 2) {
|
|
2442
|
-
|
|
2447
|
+
requireCbamFields(source, path, ["activityData", "emissionCoefficient", "conversionRate"]);
|
|
2443
2448
|
requireLowHeatForEnergyUnit(source, path);
|
|
2444
2449
|
}
|
|
2445
2450
|
else if (sourceType === 1 && processMethod === 3) {
|
|
2446
|
-
|
|
2451
|
+
requireCbamFields(source, path, ["activityData", "carbon", "biomassContent"]);
|
|
2447
2452
|
}
|
|
2448
2453
|
else if (sourceType === 2 && processMethod === 4) {
|
|
2449
|
-
|
|
2454
|
+
requireCbamFields(source, path, ["activityData", "lowHeat", "emissionCoefficient", "conversionRate", "oxRate"]);
|
|
2450
2455
|
}
|
|
2451
2456
|
else if (sourceType === 2 && processMethod === 5) {
|
|
2452
|
-
|
|
2457
|
+
requireCbamFields(source, path, ["activityData", "biomassContent", "carbon", "carbonFossil", "carbonBiological", "oxRate"]);
|
|
2453
2458
|
if (Number(source.carbonFossil) === 0) {
|
|
2454
|
-
|
|
2459
|
+
cbamInputError("INVALID_SOURCE_FLOW_VALUE", `${path}.carbonFossil`, "carbonFossil must be greater than zero for sourceType=2/processMethod=5");
|
|
2455
2460
|
}
|
|
2456
2461
|
if (Number(source.carbon) === 0) {
|
|
2457
|
-
|
|
2462
|
+
cbamInputError("INVALID_SOURCE_FLOW_VALUE", `${path}.carbon`, "carbon must be greater than zero for sourceType=2/processMethod=5");
|
|
2458
2463
|
}
|
|
2459
2464
|
}
|
|
2460
2465
|
else if (sourceType === 3 && [6, 7].includes(processMethod)) {
|
|
2461
|
-
|
|
2466
|
+
requireCbamFields(source, path, ["lowHeat", "emissionCoefficient", "conversionRate", "biomassContent"]);
|
|
2462
2467
|
}
|
|
2463
2468
|
}
|
|
2464
2469
|
}
|
|
@@ -2469,27 +2474,27 @@ function numericCode(value) {
|
|
|
2469
2474
|
return Number(value.trim());
|
|
2470
2475
|
return Number.NaN;
|
|
2471
2476
|
}
|
|
2472
|
-
function
|
|
2477
|
+
function requireCbamFields(item, path, fields) {
|
|
2473
2478
|
for (const field of fields) {
|
|
2474
2479
|
if (item[field] === undefined || item[field] === null || item[field] === "") {
|
|
2475
|
-
|
|
2480
|
+
cbamInputError("SOURCE_FLOW_FIELD_REQUIRED", `${path}.${field}`, `${field} is required for the selected sourceType/processMethod formula`);
|
|
2476
2481
|
}
|
|
2477
2482
|
}
|
|
2478
2483
|
}
|
|
2479
2484
|
function requireLowHeatForEnergyUnit(item, path) {
|
|
2480
2485
|
if (item.emissionCoefficientUnit === "tCO2/TJ") {
|
|
2481
|
-
|
|
2486
|
+
requireCbamFields(item, path, ["lowHeat"]);
|
|
2482
2487
|
}
|
|
2483
2488
|
}
|
|
2484
|
-
function
|
|
2489
|
+
function validateCbamDateRange(startValue, endValue) {
|
|
2485
2490
|
const start = String(startValue || "");
|
|
2486
2491
|
const end = String(endValue || "");
|
|
2487
2492
|
if (!isExactCalendarDate(start))
|
|
2488
|
-
|
|
2493
|
+
cbamInputError("INVALID_DATE", "report.startDate", "startDate must be a valid yyyy-MM-dd date");
|
|
2489
2494
|
if (!isExactCalendarDate(end))
|
|
2490
|
-
|
|
2495
|
+
cbamInputError("INVALID_DATE", "report.endDate", "endDate must be a valid yyyy-MM-dd date");
|
|
2491
2496
|
if (start > end)
|
|
2492
|
-
|
|
2497
|
+
cbamInputError("INVALID_PERIOD", "report.startDate", "startDate must not be after endDate");
|
|
2493
2498
|
}
|
|
2494
2499
|
function isExactCalendarDate(value) {
|
|
2495
2500
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
@@ -2505,7 +2510,7 @@ function isExactCalendarDate(value) {
|
|
|
2505
2510
|
}
|
|
2506
2511
|
function requireNonEmptyArray(value, path) {
|
|
2507
2512
|
if (!Array.isArray(value) || value.length === 0) {
|
|
2508
|
-
|
|
2513
|
+
cbamInputError("NON_EMPTY_ARRAY_REQUIRED", path, `${path} must be a non-empty array`);
|
|
2509
2514
|
}
|
|
2510
2515
|
}
|
|
2511
2516
|
function requireUniqueIdArray(value, path) {
|
|
@@ -2527,11 +2532,11 @@ function requireUniqueValues(values, path) {
|
|
|
2527
2532
|
const seen = new Set();
|
|
2528
2533
|
for (const value of values) {
|
|
2529
2534
|
if (seen.has(value))
|
|
2530
|
-
|
|
2535
|
+
cbamInputError("DUPLICATE_VALUE", path, `${path} must not contain duplicate values`);
|
|
2531
2536
|
seen.add(value);
|
|
2532
2537
|
}
|
|
2533
2538
|
}
|
|
2534
|
-
function
|
|
2539
|
+
function cbamInputError(code, path, message) {
|
|
2535
2540
|
throw new ToolInputValidationError(code, path, message);
|
|
2536
2541
|
}
|
|
2537
2542
|
function validateEnterpriseEmissionSaveArgs(orgList) {
|