@axiom-lattice/examples-deep_research 1.0.60 → 1.0.62
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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +18 -0
- package/Untitled +1 -0
- package/dist/index.js +972 -3
- package/dist/index.js.map +1 -1
- package/{jest.config.js → jest.config.cjs} +1 -0
- package/package.json +4 -4
- package/src/agents/index.ts +2 -1
- package/src/agents/sap_b1/XSM_ZSK_metadata.xml +37627 -0
- package/src/agents/sap_b1/XSM_ZSK_metadata_interfaces.md +1114 -0
- package/src/agents/sap_b1/__tests__/tools.test.ts +306 -0
- package/src/agents/sap_b1/index.ts +8 -0
- package/src/agents/sap_b1/tools.ts +809 -0
- package/src/index.ts +7 -2
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var require_package = __commonJS({
|
|
|
9
9
|
"package.json"(exports, module) {
|
|
10
10
|
module.exports = {
|
|
11
11
|
name: "@axiom-lattice/examples-deep_research",
|
|
12
|
-
version: "1.0.
|
|
12
|
+
version: "1.0.62",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "dist/index.js",
|
|
15
15
|
bin: {
|
|
@@ -745,6 +745,971 @@ var sandboxAgent = {
|
|
|
745
745
|
var tenantId4 = process.env.TENANT_ID || "default";
|
|
746
746
|
registerAgentLattices4(tenantId4, [sandboxAgent]);
|
|
747
747
|
|
|
748
|
+
// src/agents/sap_b1/tools.ts
|
|
749
|
+
import z4 from "zod";
|
|
750
|
+
import { registerToolLattice } from "@axiom-lattice/core";
|
|
751
|
+
var BASE_URL = process.env.SAP_SERVICE_LAYER_URL || "https://b1s.alphafina.cn/b1s/v1";
|
|
752
|
+
var API_LIST = [
|
|
753
|
+
// ========== Business Partner ==========
|
|
754
|
+
{
|
|
755
|
+
name: "BusinessPartners",
|
|
756
|
+
kind: "EntitySet",
|
|
757
|
+
entityType: "SAPB1.BusinessPartner",
|
|
758
|
+
primaryKey: "CardCode",
|
|
759
|
+
domain: "BusinessPartner",
|
|
760
|
+
description: "\u5BA2\u6237/\u4F9B\u5E94\u5546\u4E3B\u6570\u636E",
|
|
761
|
+
fields: [
|
|
762
|
+
"CardCode",
|
|
763
|
+
"CardName",
|
|
764
|
+
"CardType",
|
|
765
|
+
"GroupCode",
|
|
766
|
+
"Currency",
|
|
767
|
+
"Phone1",
|
|
768
|
+
"Phone2",
|
|
769
|
+
"EmailAddress",
|
|
770
|
+
"Address",
|
|
771
|
+
"City",
|
|
772
|
+
"Country",
|
|
773
|
+
"SalesPersonCode",
|
|
774
|
+
"PriceListNum",
|
|
775
|
+
"CreditLimit",
|
|
776
|
+
"Balance",
|
|
777
|
+
"PayTermsGrpCode",
|
|
778
|
+
"VatGroup",
|
|
779
|
+
"VatLiable",
|
|
780
|
+
"FederalTaxID",
|
|
781
|
+
"Valid",
|
|
782
|
+
"Frozen",
|
|
783
|
+
"CompanyPrivate",
|
|
784
|
+
"CreateDate",
|
|
785
|
+
"UpdateDate"
|
|
786
|
+
]
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
name: "BusinessPartnerGroups",
|
|
790
|
+
kind: "EntitySet",
|
|
791
|
+
entityType: "SAPB1.BusinessPartnerGroup",
|
|
792
|
+
primaryKey: "Code",
|
|
793
|
+
domain: "BusinessPartner",
|
|
794
|
+
description: "BP \u5206\u7EC4",
|
|
795
|
+
fields: ["Code", "Name", "Type"]
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
name: "SalesPersons",
|
|
799
|
+
kind: "EntitySet",
|
|
800
|
+
entityType: "SAPB1.SalesPerson",
|
|
801
|
+
primaryKey: "SalesEmployeeCode",
|
|
802
|
+
domain: "BusinessPartner",
|
|
803
|
+
description: "\u9500\u552E\u96C7\u5458",
|
|
804
|
+
fields: ["SalesEmployeeCode", "SalesEmployeeName", "CommissionGroup", "Valid"]
|
|
805
|
+
},
|
|
806
|
+
// ========== Item / Product ==========
|
|
807
|
+
{
|
|
808
|
+
name: "Items",
|
|
809
|
+
kind: "EntitySet",
|
|
810
|
+
entityType: "SAPB1.Item",
|
|
811
|
+
primaryKey: "ItemCode",
|
|
812
|
+
domain: "Item / Product",
|
|
813
|
+
description: "\u7269\u6599\u4E3B\u6570\u636E",
|
|
814
|
+
fields: [
|
|
815
|
+
"ItemCode",
|
|
816
|
+
"ItemName",
|
|
817
|
+
"ForeignName",
|
|
818
|
+
"ItemsGroupCode",
|
|
819
|
+
"BarCode",
|
|
820
|
+
"SalesItem",
|
|
821
|
+
"PurchaseItem",
|
|
822
|
+
"InventoryItem",
|
|
823
|
+
"SalesUnit",
|
|
824
|
+
"PurchaseUnit",
|
|
825
|
+
"InventoryUOM",
|
|
826
|
+
"QuantityOnStock",
|
|
827
|
+
"AvgStdPrice",
|
|
828
|
+
"DefaultWarehouse",
|
|
829
|
+
"ManageSerialNumbers",
|
|
830
|
+
"ManageBatchNumbers",
|
|
831
|
+
"SalesVATGroup",
|
|
832
|
+
"PurchaseVATGroup",
|
|
833
|
+
"Valid",
|
|
834
|
+
"Frozen",
|
|
835
|
+
"CreateDate",
|
|
836
|
+
"UpdateDate"
|
|
837
|
+
]
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
name: "ItemGroups",
|
|
841
|
+
kind: "EntitySet",
|
|
842
|
+
entityType: "SAPB1.ItemGroups",
|
|
843
|
+
primaryKey: "Number",
|
|
844
|
+
domain: "Item / Product",
|
|
845
|
+
description: "\u7269\u6599\u7EC4",
|
|
846
|
+
fields: ["Number", "GroupName", "CommissionGroup"]
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
name: "PriceLists",
|
|
850
|
+
kind: "EntitySet",
|
|
851
|
+
entityType: "SAPB1.PriceList",
|
|
852
|
+
primaryKey: "PriceListNo",
|
|
853
|
+
domain: "Item / Product",
|
|
854
|
+
description: "\u4EF7\u683C\u6E05\u5355",
|
|
855
|
+
fields: [
|
|
856
|
+
"PriceListNo",
|
|
857
|
+
"PriceListName",
|
|
858
|
+
"DefaultPrimeCurrency",
|
|
859
|
+
"DefaultAdditionalCurrency1",
|
|
860
|
+
"DefaultAdditionalCurrency2",
|
|
861
|
+
"BasePriceList",
|
|
862
|
+
"Factor",
|
|
863
|
+
"Active",
|
|
864
|
+
"IsGrossPrice",
|
|
865
|
+
"RoundingMethod",
|
|
866
|
+
"GroupNum"
|
|
867
|
+
]
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
name: "BarCodes",
|
|
871
|
+
kind: "EntitySet",
|
|
872
|
+
entityType: "SAPB1.BarCode",
|
|
873
|
+
primaryKey: "AbsEntry",
|
|
874
|
+
domain: "Item / Product",
|
|
875
|
+
description: "\u6761\u7801",
|
|
876
|
+
fields: ["AbsEntry", "ItemCode", "UoMEntry", "BarCode", "FreeText"]
|
|
877
|
+
},
|
|
878
|
+
// ========== Orders — Sales ==========
|
|
879
|
+
{
|
|
880
|
+
name: "Orders",
|
|
881
|
+
kind: "EntitySet",
|
|
882
|
+
entityType: "SAPB1.Document",
|
|
883
|
+
primaryKey: "DocEntry",
|
|
884
|
+
domain: "Document",
|
|
885
|
+
description: "\u9500\u552E\u8BA2\u5355",
|
|
886
|
+
fields: [
|
|
887
|
+
"DocEntry",
|
|
888
|
+
"DocNum",
|
|
889
|
+
"DocType",
|
|
890
|
+
"DocDate",
|
|
891
|
+
"DocDueDate",
|
|
892
|
+
"TaxDate",
|
|
893
|
+
"CardCode",
|
|
894
|
+
"CardName",
|
|
895
|
+
"Address",
|
|
896
|
+
"DocTotal",
|
|
897
|
+
"DocCurrency",
|
|
898
|
+
"SalesPersonCode",
|
|
899
|
+
"Confirmed",
|
|
900
|
+
"Cancelled",
|
|
901
|
+
"DocumentStatus",
|
|
902
|
+
"Comments",
|
|
903
|
+
"Reference1",
|
|
904
|
+
"Reference2",
|
|
905
|
+
"NumAtCard",
|
|
906
|
+
"VatSum",
|
|
907
|
+
"RoundDif",
|
|
908
|
+
"DiscountPercent",
|
|
909
|
+
"PaymentGroupCode",
|
|
910
|
+
"Project"
|
|
911
|
+
]
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
name: "DeliveryNotes",
|
|
915
|
+
kind: "EntitySet",
|
|
916
|
+
entityType: "SAPB1.Document",
|
|
917
|
+
primaryKey: "DocEntry",
|
|
918
|
+
domain: "Document",
|
|
919
|
+
description: "\u4EA4\u8D27\u5355",
|
|
920
|
+
fields: [
|
|
921
|
+
"DocEntry",
|
|
922
|
+
"DocNum",
|
|
923
|
+
"DocType",
|
|
924
|
+
"DocDate",
|
|
925
|
+
"DocDueDate",
|
|
926
|
+
"TaxDate",
|
|
927
|
+
"CardCode",
|
|
928
|
+
"CardName",
|
|
929
|
+
"DocTotal",
|
|
930
|
+
"DocCurrency",
|
|
931
|
+
"SalesPersonCode",
|
|
932
|
+
"Confirmed",
|
|
933
|
+
"Cancelled",
|
|
934
|
+
"DocumentStatus",
|
|
935
|
+
"Comments",
|
|
936
|
+
"NumAtCard"
|
|
937
|
+
]
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
name: "Invoices",
|
|
941
|
+
kind: "EntitySet",
|
|
942
|
+
entityType: "SAPB1.Document",
|
|
943
|
+
primaryKey: "DocEntry",
|
|
944
|
+
domain: "Document",
|
|
945
|
+
description: "\u9500\u552E\u53D1\u7968 (\u5E94\u6536)",
|
|
946
|
+
fields: [
|
|
947
|
+
"DocEntry",
|
|
948
|
+
"DocNum",
|
|
949
|
+
"DocType",
|
|
950
|
+
"DocDate",
|
|
951
|
+
"DocDueDate",
|
|
952
|
+
"TaxDate",
|
|
953
|
+
"CardCode",
|
|
954
|
+
"CardName",
|
|
955
|
+
"DocTotal",
|
|
956
|
+
"DocCurrency",
|
|
957
|
+
"SalesPersonCode",
|
|
958
|
+
"Confirmed",
|
|
959
|
+
"Cancelled",
|
|
960
|
+
"DocumentStatus",
|
|
961
|
+
"Comments",
|
|
962
|
+
"NumAtCard",
|
|
963
|
+
"VatSum"
|
|
964
|
+
]
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
name: "Quotations",
|
|
968
|
+
kind: "EntitySet",
|
|
969
|
+
entityType: "SAPB1.Document",
|
|
970
|
+
primaryKey: "DocEntry",
|
|
971
|
+
domain: "Document",
|
|
972
|
+
description: "\u9500\u552E\u62A5\u4EF7\u5355",
|
|
973
|
+
fields: [
|
|
974
|
+
"DocEntry",
|
|
975
|
+
"DocNum",
|
|
976
|
+
"DocType",
|
|
977
|
+
"DocDate",
|
|
978
|
+
"DocDueDate",
|
|
979
|
+
"CardCode",
|
|
980
|
+
"CardName",
|
|
981
|
+
"DocTotal",
|
|
982
|
+
"DocCurrency",
|
|
983
|
+
"SalesPersonCode",
|
|
984
|
+
"Comments",
|
|
985
|
+
"DocumentStatus"
|
|
986
|
+
]
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
name: "CreditNotes",
|
|
990
|
+
kind: "EntitySet",
|
|
991
|
+
entityType: "SAPB1.Document",
|
|
992
|
+
primaryKey: "DocEntry",
|
|
993
|
+
domain: "Document",
|
|
994
|
+
description: "\u9500\u552E\u8D37\u9879\u51ED\u8BC1",
|
|
995
|
+
fields: [
|
|
996
|
+
"DocEntry",
|
|
997
|
+
"DocNum",
|
|
998
|
+
"DocType",
|
|
999
|
+
"DocDate",
|
|
1000
|
+
"CardCode",
|
|
1001
|
+
"CardName",
|
|
1002
|
+
"DocTotal",
|
|
1003
|
+
"DocCurrency",
|
|
1004
|
+
"Comments"
|
|
1005
|
+
]
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
name: "Returns",
|
|
1009
|
+
kind: "EntitySet",
|
|
1010
|
+
entityType: "SAPB1.Document",
|
|
1011
|
+
primaryKey: "DocEntry",
|
|
1012
|
+
domain: "Document",
|
|
1013
|
+
description: "\u9500\u552E\u9000\u8D27",
|
|
1014
|
+
fields: [
|
|
1015
|
+
"DocEntry",
|
|
1016
|
+
"DocNum",
|
|
1017
|
+
"DocType",
|
|
1018
|
+
"DocDate",
|
|
1019
|
+
"CardCode",
|
|
1020
|
+
"CardName",
|
|
1021
|
+
"DocTotal",
|
|
1022
|
+
"DocCurrency",
|
|
1023
|
+
"Comments"
|
|
1024
|
+
]
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
name: "DownPayments",
|
|
1028
|
+
kind: "EntitySet",
|
|
1029
|
+
entityType: "SAPB1.Document",
|
|
1030
|
+
primaryKey: "DocEntry",
|
|
1031
|
+
domain: "Document",
|
|
1032
|
+
description: "\u9884\u6536\u6B3E",
|
|
1033
|
+
fields: [
|
|
1034
|
+
"DocEntry",
|
|
1035
|
+
"DocNum",
|
|
1036
|
+
"DocType",
|
|
1037
|
+
"DocDate",
|
|
1038
|
+
"CardCode",
|
|
1039
|
+
"CardName",
|
|
1040
|
+
"DocTotal",
|
|
1041
|
+
"DocCurrency",
|
|
1042
|
+
"DownPaymentType",
|
|
1043
|
+
"DownPaymentAmount"
|
|
1044
|
+
]
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
name: "Drafts",
|
|
1048
|
+
kind: "EntitySet",
|
|
1049
|
+
entityType: "SAPB1.Document",
|
|
1050
|
+
primaryKey: "DocEntry",
|
|
1051
|
+
domain: "Document",
|
|
1052
|
+
description: "\u9500\u552E\u8349\u7A3F",
|
|
1053
|
+
fields: [
|
|
1054
|
+
"DocEntry",
|
|
1055
|
+
"DocNum",
|
|
1056
|
+
"DocType",
|
|
1057
|
+
"DocDate",
|
|
1058
|
+
"CardCode",
|
|
1059
|
+
"CardName",
|
|
1060
|
+
"DocTotal",
|
|
1061
|
+
"Comments"
|
|
1062
|
+
]
|
|
1063
|
+
},
|
|
1064
|
+
// ========== Orders — Purchase ==========
|
|
1065
|
+
{
|
|
1066
|
+
name: "PurchaseOrders",
|
|
1067
|
+
kind: "EntitySet",
|
|
1068
|
+
entityType: "SAPB1.Document",
|
|
1069
|
+
primaryKey: "DocEntry",
|
|
1070
|
+
domain: "Document",
|
|
1071
|
+
description: "\u91C7\u8D2D\u8BA2\u5355",
|
|
1072
|
+
fields: [
|
|
1073
|
+
"DocEntry",
|
|
1074
|
+
"DocNum",
|
|
1075
|
+
"DocType",
|
|
1076
|
+
"DocDate",
|
|
1077
|
+
"DocDueDate",
|
|
1078
|
+
"TaxDate",
|
|
1079
|
+
"CardCode",
|
|
1080
|
+
"CardName",
|
|
1081
|
+
"DocTotal",
|
|
1082
|
+
"DocCurrency",
|
|
1083
|
+
"SalesPersonCode",
|
|
1084
|
+
"Confirmed",
|
|
1085
|
+
"Cancelled",
|
|
1086
|
+
"DocumentStatus",
|
|
1087
|
+
"Comments",
|
|
1088
|
+
"NumAtCard"
|
|
1089
|
+
]
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
name: "PurchaseDeliveryNotes",
|
|
1093
|
+
kind: "EntitySet",
|
|
1094
|
+
entityType: "SAPB1.Document",
|
|
1095
|
+
primaryKey: "DocEntry",
|
|
1096
|
+
domain: "Document",
|
|
1097
|
+
description: "\u91C7\u8D2D\u6536\u8D27\u5355",
|
|
1098
|
+
fields: [
|
|
1099
|
+
"DocEntry",
|
|
1100
|
+
"DocNum",
|
|
1101
|
+
"DocType",
|
|
1102
|
+
"DocDate",
|
|
1103
|
+
"CardCode",
|
|
1104
|
+
"CardName",
|
|
1105
|
+
"DocTotal",
|
|
1106
|
+
"Comments"
|
|
1107
|
+
]
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
name: "PurchaseInvoices",
|
|
1111
|
+
kind: "EntitySet",
|
|
1112
|
+
entityType: "SAPB1.Document",
|
|
1113
|
+
primaryKey: "DocEntry",
|
|
1114
|
+
domain: "Document",
|
|
1115
|
+
description: "\u91C7\u8D2D\u53D1\u7968 (\u5E94\u4ED8)",
|
|
1116
|
+
fields: [
|
|
1117
|
+
"DocEntry",
|
|
1118
|
+
"DocNum",
|
|
1119
|
+
"DocType",
|
|
1120
|
+
"DocDate",
|
|
1121
|
+
"DocDueDate",
|
|
1122
|
+
"CardCode",
|
|
1123
|
+
"CardName",
|
|
1124
|
+
"DocTotal",
|
|
1125
|
+
"DocCurrency",
|
|
1126
|
+
"Comments"
|
|
1127
|
+
]
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
name: "PurchaseReturns",
|
|
1131
|
+
kind: "EntitySet",
|
|
1132
|
+
entityType: "SAPB1.Document",
|
|
1133
|
+
primaryKey: "DocEntry",
|
|
1134
|
+
domain: "Document",
|
|
1135
|
+
description: "\u91C7\u8D2D\u9000\u8D27",
|
|
1136
|
+
fields: [
|
|
1137
|
+
"DocEntry",
|
|
1138
|
+
"DocNum",
|
|
1139
|
+
"DocType",
|
|
1140
|
+
"DocDate",
|
|
1141
|
+
"CardCode",
|
|
1142
|
+
"CardName",
|
|
1143
|
+
"DocTotal",
|
|
1144
|
+
"Comments"
|
|
1145
|
+
]
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
name: "PurchaseQuotations",
|
|
1149
|
+
kind: "EntitySet",
|
|
1150
|
+
entityType: "SAPB1.Document",
|
|
1151
|
+
primaryKey: "DocEntry",
|
|
1152
|
+
domain: "Document",
|
|
1153
|
+
description: "\u91C7\u8D2D\u62A5\u4EF7",
|
|
1154
|
+
fields: [
|
|
1155
|
+
"DocEntry",
|
|
1156
|
+
"DocNum",
|
|
1157
|
+
"DocType",
|
|
1158
|
+
"DocDate",
|
|
1159
|
+
"CardCode",
|
|
1160
|
+
"CardName",
|
|
1161
|
+
"DocTotal",
|
|
1162
|
+
"Comments"
|
|
1163
|
+
]
|
|
1164
|
+
},
|
|
1165
|
+
// ========== Inventory / Warehouse ==========
|
|
1166
|
+
{
|
|
1167
|
+
name: "InventoryGenEntries",
|
|
1168
|
+
kind: "EntitySet",
|
|
1169
|
+
entityType: "SAPB1.Document",
|
|
1170
|
+
primaryKey: "DocEntry",
|
|
1171
|
+
domain: "Inventory / Warehouse",
|
|
1172
|
+
description: "\u5E93\u5B58\u6536\u8D27",
|
|
1173
|
+
fields: [
|
|
1174
|
+
"DocEntry",
|
|
1175
|
+
"DocNum",
|
|
1176
|
+
"DocType",
|
|
1177
|
+
"DocDate",
|
|
1178
|
+
"Comments",
|
|
1179
|
+
"JournalMemo",
|
|
1180
|
+
"Reference1",
|
|
1181
|
+
"Reference2",
|
|
1182
|
+
"WareHouseUpdateType"
|
|
1183
|
+
]
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
name: "InventoryGenExits",
|
|
1187
|
+
kind: "EntitySet",
|
|
1188
|
+
entityType: "SAPB1.Document",
|
|
1189
|
+
primaryKey: "DocEntry",
|
|
1190
|
+
domain: "Inventory / Warehouse",
|
|
1191
|
+
description: "\u5E93\u5B58\u53D1\u8D27",
|
|
1192
|
+
fields: [
|
|
1193
|
+
"DocEntry",
|
|
1194
|
+
"DocNum",
|
|
1195
|
+
"DocType",
|
|
1196
|
+
"DocDate",
|
|
1197
|
+
"Comments",
|
|
1198
|
+
"JournalMemo",
|
|
1199
|
+
"Reference1",
|
|
1200
|
+
"Reference2"
|
|
1201
|
+
]
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
name: "StockTransfers",
|
|
1205
|
+
kind: "EntitySet",
|
|
1206
|
+
entityType: "SAPB1.StockTransfer",
|
|
1207
|
+
primaryKey: "DocEntry",
|
|
1208
|
+
domain: "Inventory / Warehouse",
|
|
1209
|
+
description: "\u5E93\u5B58\u8F6C\u50A8",
|
|
1210
|
+
fields: [
|
|
1211
|
+
"DocEntry",
|
|
1212
|
+
"DocNum",
|
|
1213
|
+
"DocDate",
|
|
1214
|
+
"DueDate",
|
|
1215
|
+
"FromWarehouse",
|
|
1216
|
+
"ToWarehouse",
|
|
1217
|
+
"Comments",
|
|
1218
|
+
"Reference1",
|
|
1219
|
+
"Reference2"
|
|
1220
|
+
]
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
name: "InventoryPostings",
|
|
1224
|
+
kind: "EntitySet",
|
|
1225
|
+
entityType: "SAPB1.InventoryPosting",
|
|
1226
|
+
primaryKey: "DocumentEntry",
|
|
1227
|
+
domain: "Inventory / Warehouse",
|
|
1228
|
+
description: "\u5E93\u5B58\u8FC7\u8D26",
|
|
1229
|
+
fields: [
|
|
1230
|
+
"DocumentEntry",
|
|
1231
|
+
"DocumentNumber",
|
|
1232
|
+
"PostingDate",
|
|
1233
|
+
"CountDate",
|
|
1234
|
+
"Remarks",
|
|
1235
|
+
"Reference2",
|
|
1236
|
+
"PriceList"
|
|
1237
|
+
]
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
name: "InventoryCountings",
|
|
1241
|
+
kind: "EntitySet",
|
|
1242
|
+
entityType: "SAPB1.InventoryCounting",
|
|
1243
|
+
primaryKey: "DocumentEntry",
|
|
1244
|
+
domain: "Inventory / Warehouse",
|
|
1245
|
+
description: "\u5E93\u5B58\u76D8\u70B9",
|
|
1246
|
+
fields: [
|
|
1247
|
+
"DocumentEntry",
|
|
1248
|
+
"DocumentNumber",
|
|
1249
|
+
"CountDate",
|
|
1250
|
+
"SingleCounterType",
|
|
1251
|
+
"SingleCounterID",
|
|
1252
|
+
"Remarks"
|
|
1253
|
+
]
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
name: "Warehouses",
|
|
1257
|
+
kind: "EntitySet",
|
|
1258
|
+
entityType: "SAPB1.Warehouse",
|
|
1259
|
+
primaryKey: "WarehouseCode",
|
|
1260
|
+
domain: "Inventory / Warehouse",
|
|
1261
|
+
description: "\u4ED3\u5E93\u5B9A\u4E49",
|
|
1262
|
+
fields: [
|
|
1263
|
+
"WarehouseCode",
|
|
1264
|
+
"WarehouseName",
|
|
1265
|
+
"Street",
|
|
1266
|
+
"City",
|
|
1267
|
+
"Country",
|
|
1268
|
+
"Location",
|
|
1269
|
+
"DropShip",
|
|
1270
|
+
"Nettable",
|
|
1271
|
+
"Inactive",
|
|
1272
|
+
"EnableBinLocations",
|
|
1273
|
+
"ManageSerialAndBatchNumbers"
|
|
1274
|
+
]
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
name: "BinLocations",
|
|
1278
|
+
kind: "EntitySet",
|
|
1279
|
+
entityType: "SAPB1.BinLocation",
|
|
1280
|
+
primaryKey: "AbsEntry",
|
|
1281
|
+
domain: "Inventory / Warehouse",
|
|
1282
|
+
description: "\u5E93\u4F4D",
|
|
1283
|
+
fields: [
|
|
1284
|
+
"AbsEntry",
|
|
1285
|
+
"Warehouse",
|
|
1286
|
+
"BinCode",
|
|
1287
|
+
"Description",
|
|
1288
|
+
"Sublevel1",
|
|
1289
|
+
"Sublevel2",
|
|
1290
|
+
"Sublevel3",
|
|
1291
|
+
"Sublevel4",
|
|
1292
|
+
"Inactive",
|
|
1293
|
+
"MinimumQty",
|
|
1294
|
+
"MaximumQty"
|
|
1295
|
+
]
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
name: "BatchNumberDetails",
|
|
1299
|
+
kind: "EntitySet",
|
|
1300
|
+
entityType: "SAPB1.BatchNumberDetail",
|
|
1301
|
+
primaryKey: "DocEntry",
|
|
1302
|
+
domain: "Inventory / Warehouse",
|
|
1303
|
+
description: "\u6279\u6B21\u53F7\u660E\u7EC6",
|
|
1304
|
+
fields: [
|
|
1305
|
+
"DocEntry",
|
|
1306
|
+
"ItemCode",
|
|
1307
|
+
"ItemDescription",
|
|
1308
|
+
"Batch",
|
|
1309
|
+
"BatchAttribute1",
|
|
1310
|
+
"BatchAttribute2",
|
|
1311
|
+
"AdmissionDate",
|
|
1312
|
+
"ExpirationDate",
|
|
1313
|
+
"ManufacturingDate"
|
|
1314
|
+
]
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
name: "SerialNumberDetails",
|
|
1318
|
+
kind: "EntitySet",
|
|
1319
|
+
entityType: "SAPB1.SerialNumberDetail",
|
|
1320
|
+
primaryKey: "DocEntry",
|
|
1321
|
+
domain: "Inventory / Warehouse",
|
|
1322
|
+
description: "\u5E8F\u5217\u53F7\u660E\u7EC6",
|
|
1323
|
+
fields: [
|
|
1324
|
+
"DocEntry",
|
|
1325
|
+
"ItemCode",
|
|
1326
|
+
"ItemDescription",
|
|
1327
|
+
"SerialNumber",
|
|
1328
|
+
"MfrSerialNo",
|
|
1329
|
+
"AdmissionDate",
|
|
1330
|
+
"ExpirationDate"
|
|
1331
|
+
]
|
|
1332
|
+
},
|
|
1333
|
+
// ========== Function Imports (常用) ==========
|
|
1334
|
+
{
|
|
1335
|
+
name: "ItemsService_InitData",
|
|
1336
|
+
kind: "FunctionImport",
|
|
1337
|
+
entityType: "SAPB1.Item",
|
|
1338
|
+
domain: "Item / Product",
|
|
1339
|
+
description: "\u521D\u59CB\u5316\u7269\u6599\u6570\u636E",
|
|
1340
|
+
fields: []
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
name: "BusinessPartnersService_InitData",
|
|
1344
|
+
kind: "FunctionImport",
|
|
1345
|
+
entityType: "SAPB1.BusinessPartner",
|
|
1346
|
+
domain: "BusinessPartner",
|
|
1347
|
+
description: "\u521D\u59CB\u5316 BP \u6570\u636E",
|
|
1348
|
+
fields: []
|
|
1349
|
+
},
|
|
1350
|
+
{
|
|
1351
|
+
name: "OrdersService_InitData",
|
|
1352
|
+
kind: "FunctionImport",
|
|
1353
|
+
entityType: "SAPB1.Document",
|
|
1354
|
+
domain: "Document",
|
|
1355
|
+
description: "\u521D\u59CB\u5316\u8BA2\u5355\u6570\u636E",
|
|
1356
|
+
fields: []
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
name: "InvoicesService_InitData",
|
|
1360
|
+
kind: "FunctionImport",
|
|
1361
|
+
entityType: "SAPB1.Document",
|
|
1362
|
+
domain: "Document",
|
|
1363
|
+
description: "\u521D\u59CB\u5316\u53D1\u7968\u6570\u636E",
|
|
1364
|
+
fields: []
|
|
1365
|
+
},
|
|
1366
|
+
// ========== Pricing / Cost / Rate ==========
|
|
1367
|
+
{
|
|
1368
|
+
name: "SpecialPrices",
|
|
1369
|
+
kind: "EntitySet",
|
|
1370
|
+
entityType: "SAPB1.SpecialPrice",
|
|
1371
|
+
primaryKey: "ItemCode+CardCode",
|
|
1372
|
+
domain: "Item / Product",
|
|
1373
|
+
description: "\u7279\u6B8A\u4EF7\u683C\uFF08BP/\u5BA2\u6237\u7279\u5B9A\u4EF7\u683C\uFF09",
|
|
1374
|
+
fields: [
|
|
1375
|
+
"ItemCode",
|
|
1376
|
+
"CardCode",
|
|
1377
|
+
"Price",
|
|
1378
|
+
"Currency",
|
|
1379
|
+
"DiscountPercent",
|
|
1380
|
+
"PriceListNum",
|
|
1381
|
+
"AutoUpdate",
|
|
1382
|
+
"SourcePrice"
|
|
1383
|
+
]
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
name: "LandedCosts",
|
|
1387
|
+
kind: "EntitySet",
|
|
1388
|
+
entityType: "SAPB1.LandedCost",
|
|
1389
|
+
primaryKey: "DocEntry",
|
|
1390
|
+
domain: "Document",
|
|
1391
|
+
description: "\u5230\u5CB8\u6210\u672C/\u9644\u52A0\u6210\u672C\u51ED\u8BC1",
|
|
1392
|
+
fields: ["DocEntry", "DocNum", "DocDate", "CardCode", "Comments"]
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
name: "LandedCostsCodes",
|
|
1396
|
+
kind: "EntitySet",
|
|
1397
|
+
entityType: "SAPB1.LandedCostsCode",
|
|
1398
|
+
primaryKey: "Code",
|
|
1399
|
+
domain: "Document",
|
|
1400
|
+
description: "\u5230\u5CB8\u6210\u672C\u4EE3\u7801\u5B9A\u4E49",
|
|
1401
|
+
fields: ["Code", "Name"]
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
name: "CompanyService_GetItemPrice",
|
|
1405
|
+
kind: "FunctionImport",
|
|
1406
|
+
entityType: "SAPB1.ItemPriceReturnParams",
|
|
1407
|
+
domain: "Item / Product",
|
|
1408
|
+
description: "\u6839\u636E\u53C2\u6570\u67E5\u8BE2\u7269\u6599\u4EF7\u683C\uFF08\u542B\u5386\u53F2\u660E\u7EC6\uFF09",
|
|
1409
|
+
fields: ["ItemPrices", "ItemUnitOfMeasurementCollection"]
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
name: "SBOBobService_GetCurrencyRate",
|
|
1413
|
+
kind: "FunctionImport",
|
|
1414
|
+
domain: "Finance / Accounting",
|
|
1415
|
+
description: "\u83B7\u53D6\u8D27\u5E01\u6C47\u7387",
|
|
1416
|
+
fields: []
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
name: "SBOBobService_GetIndexRate",
|
|
1420
|
+
kind: "FunctionImport",
|
|
1421
|
+
domain: "Finance / Accounting",
|
|
1422
|
+
description: "\u83B7\u53D6\u6307\u6570\u6C47\u7387",
|
|
1423
|
+
fields: []
|
|
1424
|
+
},
|
|
1425
|
+
{
|
|
1426
|
+
name: "SBOBobService_SetCurrencyRate",
|
|
1427
|
+
kind: "FunctionImport",
|
|
1428
|
+
domain: "Finance / Accounting",
|
|
1429
|
+
description: "\u8BBE\u7F6E\u8D27\u5E01\u6C47\u7387",
|
|
1430
|
+
fields: []
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
name: "Z20_COST",
|
|
1434
|
+
kind: "EntitySet",
|
|
1435
|
+
entityType: "SAPB1.Z20_COST",
|
|
1436
|
+
primaryKey: "DocEntry",
|
|
1437
|
+
domain: "Item / Product",
|
|
1438
|
+
description: "\u81EA\u5B9A\u4E49: \u6210\u672C\u8BB0\u5F55\u8868\uFF08\u542B\u5468\u671F/\u5B9E\u4F8B\u7EF4\u5EA6\u7684\u6210\u672C\u5386\u53F2\uFF09",
|
|
1439
|
+
fields: [
|
|
1440
|
+
"DocEntry",
|
|
1441
|
+
"DocNum",
|
|
1442
|
+
"Period",
|
|
1443
|
+
"Instance",
|
|
1444
|
+
"Series",
|
|
1445
|
+
"Status",
|
|
1446
|
+
"RequestStatus",
|
|
1447
|
+
"Creator",
|
|
1448
|
+
"Remark",
|
|
1449
|
+
"Canceled",
|
|
1450
|
+
"Object",
|
|
1451
|
+
"CreateDate",
|
|
1452
|
+
"CreateTime"
|
|
1453
|
+
]
|
|
1454
|
+
},
|
|
1455
|
+
{
|
|
1456
|
+
name: "Z20_CPAT",
|
|
1457
|
+
kind: "EntitySet",
|
|
1458
|
+
entityType: "SAPB1.Z20_CPAT",
|
|
1459
|
+
primaryKey: "DocEntry",
|
|
1460
|
+
domain: "Item / Product",
|
|
1461
|
+
description: "\u81EA\u5B9A\u4E49: \u6210\u672C/\u4EF7\u683C\u5206\u644A\u8BB0\u5F55",
|
|
1462
|
+
fields: [
|
|
1463
|
+
"DocEntry",
|
|
1464
|
+
"DocNum",
|
|
1465
|
+
"Period",
|
|
1466
|
+
"Instance",
|
|
1467
|
+
"Status",
|
|
1468
|
+
"Creator",
|
|
1469
|
+
"Remark",
|
|
1470
|
+
"CreateDate",
|
|
1471
|
+
"CreateTime"
|
|
1472
|
+
]
|
|
1473
|
+
},
|
|
1474
|
+
{
|
|
1475
|
+
name: "Z20_OINP",
|
|
1476
|
+
kind: "EntitySet",
|
|
1477
|
+
entityType: "SAPB1.Z20_OINP",
|
|
1478
|
+
primaryKey: "DocEntry",
|
|
1479
|
+
domain: "Document",
|
|
1480
|
+
description: "\u81EA\u5B9A\u4E49: \u91C7\u8D2D\u8BA2\u5355\u8F93\u5165\u4EF7\u683C\u8BB0\u5F55",
|
|
1481
|
+
fields: [
|
|
1482
|
+
"DocEntry",
|
|
1483
|
+
"DocNum",
|
|
1484
|
+
"Period",
|
|
1485
|
+
"Instance",
|
|
1486
|
+
"Status",
|
|
1487
|
+
"Creator",
|
|
1488
|
+
"Remark",
|
|
1489
|
+
"CreateDate",
|
|
1490
|
+
"CreateTime"
|
|
1491
|
+
]
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
name: "Z20_PWAG",
|
|
1495
|
+
kind: "EntitySet",
|
|
1496
|
+
entityType: "SAPB1.Z20_PWAG",
|
|
1497
|
+
primaryKey: "DocEntry",
|
|
1498
|
+
domain: "Item / Product",
|
|
1499
|
+
description: "\u81EA\u5B9A\u4E49: \u5DE5\u4EF7/\u5DE5\u5E8F\u4EF7\u683C\u8BB0\u5F55",
|
|
1500
|
+
fields: [
|
|
1501
|
+
"DocEntry",
|
|
1502
|
+
"DocNum",
|
|
1503
|
+
"Period",
|
|
1504
|
+
"Instance",
|
|
1505
|
+
"Status",
|
|
1506
|
+
"Creator",
|
|
1507
|
+
"Remark",
|
|
1508
|
+
"CreateDate",
|
|
1509
|
+
"CreateTime"
|
|
1510
|
+
]
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
name: "Z20_HOLD",
|
|
1514
|
+
kind: "EntitySet",
|
|
1515
|
+
entityType: "SAPB1.Z20_HOLD",
|
|
1516
|
+
primaryKey: "DocEntry",
|
|
1517
|
+
domain: "Inventory / Warehouse",
|
|
1518
|
+
description: "\u81EA\u5B9A\u4E49: \u6682\u5B58/\u51BB\u7ED3\u5E93\u5B58\u8BB0\u5F55",
|
|
1519
|
+
fields: [
|
|
1520
|
+
"DocEntry",
|
|
1521
|
+
"DocNum",
|
|
1522
|
+
"Period",
|
|
1523
|
+
"Instance",
|
|
1524
|
+
"Status",
|
|
1525
|
+
"Creator",
|
|
1526
|
+
"Remark",
|
|
1527
|
+
"CreateDate",
|
|
1528
|
+
"CreateTime"
|
|
1529
|
+
]
|
|
1530
|
+
},
|
|
1531
|
+
{
|
|
1532
|
+
name: "Z20_IMIT",
|
|
1533
|
+
kind: "EntitySet",
|
|
1534
|
+
entityType: "SAPB1.Z20_IMIT",
|
|
1535
|
+
primaryKey: "DocEntry",
|
|
1536
|
+
domain: "Inventory / Warehouse",
|
|
1537
|
+
description: "\u81EA\u5B9A\u4E49: \u5E93\u5B58\u521D\u59CB\u5316\u8BB0\u5F55",
|
|
1538
|
+
fields: [
|
|
1539
|
+
"DocEntry",
|
|
1540
|
+
"DocNum",
|
|
1541
|
+
"Period",
|
|
1542
|
+
"Instance",
|
|
1543
|
+
"Status",
|
|
1544
|
+
"Creator",
|
|
1545
|
+
"Remark",
|
|
1546
|
+
"CreateDate",
|
|
1547
|
+
"CreateTime"
|
|
1548
|
+
]
|
|
1549
|
+
}
|
|
1550
|
+
];
|
|
1551
|
+
registerToolLattice(
|
|
1552
|
+
"sap_api_search",
|
|
1553
|
+
{
|
|
1554
|
+
name: "sap_api_search",
|
|
1555
|
+
description: "\u641C\u7D22 SAP B1 Service Layer API \u63A5\u53E3\u3002\u8986\u76D6\u4E1A\u52A1\u4F19\u4F34(BP)\u3001\u7269\u6599(Item)\u3001\u9500\u552E/\u91C7\u8D2D\u8BA2\u5355(Document/Order)\u3001\u5E93\u5B58(Inventory/Warehouse) \u56DB\u5927\u9886\u57DF\u3002\u8FD4\u56DE\u63A5\u53E3\u540D\u79F0\u3001\u4E3B\u952E\u3001\u5E38\u7528\u5B57\u6BB5\u5217\u8868\u53CA\u63CF\u8FF0\u3002",
|
|
1556
|
+
needUserApprove: false,
|
|
1557
|
+
schema: z4.object({
|
|
1558
|
+
query: z4.string().describe(
|
|
1559
|
+
"\u641C\u7D22\u5173\u952E\u8BCD\u3002\u53EF\u4EE5\u662F API \u540D\u79F0\uFF08\u5982 'BusinessPartners', 'Orders', 'Items', 'PurchaseOrders'\uFF09\u6216\u4E1A\u52A1\u63CF\u8FF0\uFF08\u5982 '\u5BA2\u6237', '\u8BA2\u5355', '\u7269\u6599', '\u5E93\u5B58', '\u91C7\u8D2D', '\u4ED3\u5E93'\uFF09"
|
|
1560
|
+
),
|
|
1561
|
+
domain: z4.string().optional().describe(
|
|
1562
|
+
"\u6309\u9886\u57DF\u8FC7\u6EE4: 'BusinessPartner'(BP), 'Item / Product'(\u7269\u6599), 'Document'(\u8BA2\u5355/\u53D1\u7968), 'Inventory / Warehouse'(\u5E93\u5B58/\u4ED3\u5E93)"
|
|
1563
|
+
),
|
|
1564
|
+
maxResults: z4.number().optional().default(10).describe("\u6700\u5927\u8FD4\u56DE\u6761\u6570")
|
|
1565
|
+
})
|
|
1566
|
+
},
|
|
1567
|
+
async (input) => {
|
|
1568
|
+
const q = input.query.toLowerCase();
|
|
1569
|
+
const max = input.maxResults ?? 10;
|
|
1570
|
+
const domainHints = {
|
|
1571
|
+
"\u5BA2\u6237": "BusinessPartner",
|
|
1572
|
+
"\u4F9B\u5E94\u5546": "BusinessPartner",
|
|
1573
|
+
"bp": "BusinessPartner",
|
|
1574
|
+
"\u7269\u6599": "Item / Product",
|
|
1575
|
+
"\u4EA7\u54C1": "Item / Product",
|
|
1576
|
+
"\u5546\u54C1": "Item / Product",
|
|
1577
|
+
"\u8D27\u54C1": "Item / Product",
|
|
1578
|
+
"\u8BA2\u5355": "Document",
|
|
1579
|
+
"\u9500\u552E": "Document",
|
|
1580
|
+
"\u91C7\u8D2D": "Document",
|
|
1581
|
+
"\u53D1\u7968": "Document",
|
|
1582
|
+
"\u4EA4\u8D27": "Document",
|
|
1583
|
+
"\u62A5\u4EF7": "Document",
|
|
1584
|
+
"\u8349\u7A3F": "Document",
|
|
1585
|
+
"\u5E93\u5B58": "Inventory / Warehouse",
|
|
1586
|
+
"\u4ED3\u5E93": "Inventory / Warehouse",
|
|
1587
|
+
"\u5E93\u4F4D": "Inventory / Warehouse",
|
|
1588
|
+
"\u6279\u6B21": "Inventory / Warehouse",
|
|
1589
|
+
"\u5E8F\u5217\u53F7": "Inventory / Warehouse",
|
|
1590
|
+
"\u6536\u8D27": "Inventory / Warehouse",
|
|
1591
|
+
"\u53D1\u8D27": "Inventory / Warehouse",
|
|
1592
|
+
"\u8F6C\u50A8": "Inventory / Warehouse",
|
|
1593
|
+
"\u76D8\u70B9": "Inventory / Warehouse",
|
|
1594
|
+
"\u8FC7\u8D26": "Inventory / Warehouse",
|
|
1595
|
+
"\u4EF7\u683C": "Item / Product",
|
|
1596
|
+
"\u6210\u672C": "Item / Product",
|
|
1597
|
+
"\u6C47\u7387": "Finance / Accounting",
|
|
1598
|
+
"\u5230\u5CB8": "Document"
|
|
1599
|
+
};
|
|
1600
|
+
const hintedDomain = domainHints[q] || void 0;
|
|
1601
|
+
const effectiveDomain = input.domain || hintedDomain;
|
|
1602
|
+
const scored = API_LIST.filter((e) => {
|
|
1603
|
+
if (effectiveDomain && e.domain !== effectiveDomain) return false;
|
|
1604
|
+
return true;
|
|
1605
|
+
}).map((e) => {
|
|
1606
|
+
let score = 0;
|
|
1607
|
+
const nameLo = e.name.toLowerCase();
|
|
1608
|
+
const descLo = e.description.toLowerCase();
|
|
1609
|
+
const typeLo = (e.entityType || "").toLowerCase();
|
|
1610
|
+
if (nameLo === q) score += 100;
|
|
1611
|
+
else if (nameLo.startsWith(q)) score += 60;
|
|
1612
|
+
else if (nameLo.includes(q)) score += 30;
|
|
1613
|
+
if (descLo.includes(q)) score += 20;
|
|
1614
|
+
if (typeLo.includes(q)) score += 10;
|
|
1615
|
+
for (const word of q.split(/[\s_\-/]+/).filter((w) => w.length >= 2)) {
|
|
1616
|
+
if (nameLo.includes(word)) score += 10;
|
|
1617
|
+
if (descLo.includes(word)) score += 5;
|
|
1618
|
+
}
|
|
1619
|
+
return { ...e, score };
|
|
1620
|
+
});
|
|
1621
|
+
const top = scored.filter((e) => e.score > 0).sort((a, b) => b.score - a.score).slice(0, max);
|
|
1622
|
+
const domainCounts = {};
|
|
1623
|
+
for (const e of top) domainCounts[e.domain] = (domainCounts[e.domain] || 0) + 1;
|
|
1624
|
+
return {
|
|
1625
|
+
query: input.query,
|
|
1626
|
+
domainFilter: effectiveDomain || null,
|
|
1627
|
+
totalMatches: scored.filter((e) => e.score > 0).length,
|
|
1628
|
+
domainsFound: domainCounts,
|
|
1629
|
+
results: top.map((e) => ({
|
|
1630
|
+
name: e.name,
|
|
1631
|
+
kind: e.kind,
|
|
1632
|
+
domain: e.domain,
|
|
1633
|
+
description: e.description,
|
|
1634
|
+
primaryKey: e.primaryKey || null,
|
|
1635
|
+
fields: e.fields,
|
|
1636
|
+
hint: e.kind === "EntitySet" ? `${e.name} \u2014 ${e.description}\u3002\u4E3B\u952E: ${e.primaryKey}\u3002\u8C03\u7528 sap_api_call \u8FDB\u884C CRUD \u64CD\u4F5C\u3002` : `${e.name} \u2014 ${e.description}\u3002\u8C03\u7528 sap_api_call \u6267\u884C\u6B64\u65B9\u6CD5\u3002`
|
|
1637
|
+
})),
|
|
1638
|
+
suggestion: top.length === 0 ? `\u672A\u627E\u5230\u5339\u914D "${input.query}" \u7684\u63A5\u53E3\u3002\u53EF\u7528\u9886\u57DF: BusinessPartner(\u5BA2\u6237/\u4F9B\u5E94\u5546), Item / Product(\u7269\u6599), Document(\u8BA2\u5355/\u53D1\u7968), Inventory / Warehouse(\u5E93\u5B58/\u4ED3\u5E93)\u3002\u5C1D\u8BD5\u7528\u82F1\u6587\u540D\u79F0\u641C\u7D22\u3002` : void 0
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
);
|
|
1642
|
+
var SAP_COOKIE = process.env.SAP_B1SESSION ? `B1SESSION=${process.env.SAP_B1SESSION}; ROUTEID=.node0` : "";
|
|
1643
|
+
registerToolLattice(
|
|
1644
|
+
"sap_api_call",
|
|
1645
|
+
{
|
|
1646
|
+
name: "sap_api_call",
|
|
1647
|
+
description: `\u6267\u884C\u5BF9 SAP B1 Service Layer \u7684 OData API \u8C03\u7528\u3002\u76F4\u63A5\u53D1\u8D77 HTTP \u8BF7\u6C42\u5E76\u8FD4\u56DE\u54CD\u5E94\u6570\u636E\u3002\u5F53\u524D Base URL: ${BASE_URL}\u3002GET \u8BF7\u6C42\u901A\u5E38\u65E0\u9700\u8BA4\u8BC1\uFF0CPOST/PATCH/DELETE \u9700\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF SAP_B1SESSION\u3002`,
|
|
1648
|
+
needUserApprove: false,
|
|
1649
|
+
schema: z4.object({
|
|
1650
|
+
entitySet: z4.string().describe("EntitySet \u540D\u79F0\uFF0C\u5982 'BusinessPartners', 'Orders', 'Items', 'PurchaseOrders'"),
|
|
1651
|
+
method: z4.enum(["GET", "POST", "PATCH", "DELETE"]).describe("HTTP \u65B9\u6CD5"),
|
|
1652
|
+
id: z4.string().optional().describe("\u4E3B\u952E\u503C\uFF0CGET/PATCH/DELETE \u5355\u4E2A\u5B9E\u4F53\u65F6\u4F7F\u7528\u3002\u5982 /BusinessPartners('C001')"),
|
|
1653
|
+
queryOptions: z4.string().optional().describe(
|
|
1654
|
+
"OData \u67E5\u8BE2\u53C2\u6570\uFF08\u4E0D\u542B `?` \u524D\u7F00\uFF09\u3002\u5E38\u7528: $top=10, $skip=20, $select=CardCode,CardName, $filter=contains(CardName,'\u6E05\u534E'), $orderby=DocDate desc, $expand=DocumentLines"
|
|
1655
|
+
),
|
|
1656
|
+
body: z4.record(z4.unknown()).optional().describe("POST/PATCH \u65F6\u7684 JSON \u8BF7\u6C42\u4F53")
|
|
1657
|
+
})
|
|
1658
|
+
},
|
|
1659
|
+
async (input) => {
|
|
1660
|
+
const url = buildUrl(input.entitySet, input.method, input.id, input.queryOptions);
|
|
1661
|
+
const method = input.method;
|
|
1662
|
+
const headers = {
|
|
1663
|
+
"Content-Type": "application/json",
|
|
1664
|
+
Accept: "application/json"
|
|
1665
|
+
};
|
|
1666
|
+
if (SAP_COOKIE) headers.Cookie = SAP_COOKIE;
|
|
1667
|
+
const fetchOptions = { method, headers };
|
|
1668
|
+
if ((method === "POST" || method === "PATCH") && input.body) {
|
|
1669
|
+
fetchOptions.body = JSON.stringify(input.body);
|
|
1670
|
+
}
|
|
1671
|
+
try {
|
|
1672
|
+
const res = await fetch(url, fetchOptions);
|
|
1673
|
+
const text = await res.text();
|
|
1674
|
+
let data;
|
|
1675
|
+
try {
|
|
1676
|
+
data = JSON.parse(text);
|
|
1677
|
+
} catch {
|
|
1678
|
+
data = text;
|
|
1679
|
+
}
|
|
1680
|
+
const result = {
|
|
1681
|
+
ok: res.ok,
|
|
1682
|
+
status: res.status,
|
|
1683
|
+
statusText: res.statusText,
|
|
1684
|
+
data
|
|
1685
|
+
};
|
|
1686
|
+
if (!res.ok) {
|
|
1687
|
+
result.error = `HTTP ${res.status} ${res.statusText}`;
|
|
1688
|
+
result.hint = res.status === 401 ? "\u9700\u8981\u6709\u6548\u7684 B1SESSION Cookie\u3002\u8BF7\u5148\u901A\u8FC7 Login \u7AEF\u70B9\u83B7\u53D6\uFF0C\u6216\u8BBE\u7F6E SAP_B1SESSION \u73AF\u5883\u53D8\u91CF\u3002" : res.status === 404 ? "\u63A5\u53E3\u6216\u5B9E\u4F53\u4E0D\u5B58\u5728\uFF0C\u8BF7\u68C0\u67E5 entitySet \u540D\u79F0\u548C id\u3002" : void 0;
|
|
1689
|
+
}
|
|
1690
|
+
return result;
|
|
1691
|
+
} catch (err) {
|
|
1692
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1693
|
+
return {
|
|
1694
|
+
ok: false,
|
|
1695
|
+
error: `\u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
1696
|
+
url,
|
|
1697
|
+
hint: "\u7F51\u7EDC\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5 SAP_SERVICE_LAYER_URL \u662F\u5426\u6B63\u786E\u3002"
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
);
|
|
1702
|
+
function buildUrl(entitySet, method, id, queryOptions) {
|
|
1703
|
+
let url = `${BASE_URL}/${entitySet}`;
|
|
1704
|
+
if (id && method !== "POST") {
|
|
1705
|
+
url += `('${encodeURIComponent(id)}')`;
|
|
1706
|
+
}
|
|
1707
|
+
if (queryOptions) {
|
|
1708
|
+
url += `?${queryOptions}`;
|
|
1709
|
+
}
|
|
1710
|
+
return url;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
748
1713
|
// src/index.ts
|
|
749
1714
|
import {
|
|
750
1715
|
LoggerType,
|
|
@@ -808,7 +1773,7 @@ registerModelLattice(
|
|
|
808
1773
|
provider: "openai",
|
|
809
1774
|
streaming: true,
|
|
810
1775
|
apiKeyEnvName: "API_KEY3",
|
|
811
|
-
baseURL: "https://
|
|
1776
|
+
baseURL: "https://llm.alphafina.cn/v1",
|
|
812
1777
|
modelKwargs: {
|
|
813
1778
|
"enable_thinking": false
|
|
814
1779
|
}
|
|
@@ -823,7 +1788,7 @@ registerModelLattice(
|
|
|
823
1788
|
provider: "openai",
|
|
824
1789
|
streaming: true,
|
|
825
1790
|
apiKeyEnvName: "API_KEY3",
|
|
826
|
-
baseURL: "https://
|
|
1791
|
+
baseURL: "https://llm.alphafina.cn/v1"
|
|
827
1792
|
}
|
|
828
1793
|
);
|
|
829
1794
|
registerModelLattice(
|
|
@@ -995,6 +1960,10 @@ async function main() {
|
|
|
995
1960
|
serviceName: "lattice/deep_research",
|
|
996
1961
|
loggerName: "lattice/deep_research"
|
|
997
1962
|
};
|
|
1963
|
+
await LatticeGateway.configureSwagger(LatticeGateway.app);
|
|
1964
|
+
console.log(`\u{1F4DA} Swagger UI available at: http://localhost:${port}/api-docs`);
|
|
1965
|
+
console.log(`\u{1F4C4} OpenAPI JSON available at: http://localhost:${port}/api-docs/json
|
|
1966
|
+
`);
|
|
998
1967
|
LatticeGateway.startAsHttpEndpoint({
|
|
999
1968
|
port,
|
|
1000
1969
|
queueServiceConfig: { type: "memory", defaultStartPollingQueue: true },
|