@axiom-lattice/examples-deep_research 1.0.94 → 1.0.96
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 +20 -0
- package/dist/index.js +60 -60
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/agents/sap_b1/XSM_ZSK_metadata_interfaces.md +827 -827
- package/src/agents/sap_b1/__tests__/tools.test.ts +36 -36
- package/src/agents/sap_b1/index.ts +4 -4
- package/src/agents/sap_b1/tools.ts +64 -64
|
@@ -2,7 +2,7 @@ import z from "zod";
|
|
|
2
2
|
import { registerToolLattice } from "@axiom-lattice/core";
|
|
3
3
|
|
|
4
4
|
const BASE_URL =
|
|
5
|
-
process.env.
|
|
5
|
+
process.env.ERP_SERVICE_LAYER_URL || "https://b1s.alphafina.cn/b1s/v1";
|
|
6
6
|
|
|
7
7
|
// ============================================================
|
|
8
8
|
// API 元数据
|
|
@@ -45,7 +45,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
45
45
|
{
|
|
46
46
|
name: "BusinessPartners",
|
|
47
47
|
kind: "EntitySet",
|
|
48
|
-
entityType: "
|
|
48
|
+
entityType: "ERP.BusinessPartner",
|
|
49
49
|
primaryKey: "CardCode",
|
|
50
50
|
domain: "BusinessPartner",
|
|
51
51
|
description: "客户/供应商主数据",
|
|
@@ -62,7 +62,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
62
62
|
{
|
|
63
63
|
name: "BusinessPartnerGroups",
|
|
64
64
|
kind: "EntitySet",
|
|
65
|
-
entityType: "
|
|
65
|
+
entityType: "ERP.BusinessPartnerGroup",
|
|
66
66
|
primaryKey: "Code",
|
|
67
67
|
domain: "BusinessPartner",
|
|
68
68
|
description: "BP 分组",
|
|
@@ -71,7 +71,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
71
71
|
{
|
|
72
72
|
name: "SalesPersons",
|
|
73
73
|
kind: "EntitySet",
|
|
74
|
-
entityType: "
|
|
74
|
+
entityType: "ERP.SalesPerson",
|
|
75
75
|
primaryKey: "SalesEmployeeCode",
|
|
76
76
|
domain: "BusinessPartner",
|
|
77
77
|
description: "销售雇员",
|
|
@@ -82,7 +82,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
82
82
|
{
|
|
83
83
|
name: "Items",
|
|
84
84
|
kind: "EntitySet",
|
|
85
|
-
entityType: "
|
|
85
|
+
entityType: "ERP.Item",
|
|
86
86
|
primaryKey: "ItemCode",
|
|
87
87
|
domain: "Item / Product",
|
|
88
88
|
description: "物料主数据",
|
|
@@ -100,7 +100,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
100
100
|
{
|
|
101
101
|
name: "ItemGroups",
|
|
102
102
|
kind: "EntitySet",
|
|
103
|
-
entityType: "
|
|
103
|
+
entityType: "ERP.ItemGroups",
|
|
104
104
|
primaryKey: "Number",
|
|
105
105
|
domain: "Item / Product",
|
|
106
106
|
description: "物料组",
|
|
@@ -109,7 +109,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
109
109
|
{
|
|
110
110
|
name: "PriceLists",
|
|
111
111
|
kind: "EntitySet",
|
|
112
|
-
entityType: "
|
|
112
|
+
entityType: "ERP.PriceList",
|
|
113
113
|
primaryKey: "PriceListNo",
|
|
114
114
|
domain: "Item / Product",
|
|
115
115
|
description: "价格清单",
|
|
@@ -123,7 +123,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
123
123
|
{
|
|
124
124
|
name: "BarCodes",
|
|
125
125
|
kind: "EntitySet",
|
|
126
|
-
entityType: "
|
|
126
|
+
entityType: "ERP.BarCode",
|
|
127
127
|
primaryKey: "AbsEntry",
|
|
128
128
|
domain: "Item / Product",
|
|
129
129
|
description: "条码",
|
|
@@ -134,7 +134,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
134
134
|
{
|
|
135
135
|
name: "Orders",
|
|
136
136
|
kind: "EntitySet",
|
|
137
|
-
entityType: "
|
|
137
|
+
entityType: "ERP.Document",
|
|
138
138
|
primaryKey: "DocEntry",
|
|
139
139
|
domain: "Document",
|
|
140
140
|
description: "销售订单",
|
|
@@ -151,7 +151,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
151
151
|
{
|
|
152
152
|
name: "DeliveryNotes",
|
|
153
153
|
kind: "EntitySet",
|
|
154
|
-
entityType: "
|
|
154
|
+
entityType: "ERP.Document",
|
|
155
155
|
primaryKey: "DocEntry",
|
|
156
156
|
domain: "Document",
|
|
157
157
|
description: "交货单",
|
|
@@ -166,7 +166,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
166
166
|
{
|
|
167
167
|
name: "Invoices",
|
|
168
168
|
kind: "EntitySet",
|
|
169
|
-
entityType: "
|
|
169
|
+
entityType: "ERP.Document",
|
|
170
170
|
primaryKey: "DocEntry",
|
|
171
171
|
domain: "Document",
|
|
172
172
|
description: "销售发票 (应收)",
|
|
@@ -181,7 +181,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
181
181
|
{
|
|
182
182
|
name: "Quotations",
|
|
183
183
|
kind: "EntitySet",
|
|
184
|
-
entityType: "
|
|
184
|
+
entityType: "ERP.Document",
|
|
185
185
|
primaryKey: "DocEntry",
|
|
186
186
|
domain: "Document",
|
|
187
187
|
description: "销售报价单",
|
|
@@ -195,7 +195,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
195
195
|
{
|
|
196
196
|
name: "CreditNotes",
|
|
197
197
|
kind: "EntitySet",
|
|
198
|
-
entityType: "
|
|
198
|
+
entityType: "ERP.Document",
|
|
199
199
|
primaryKey: "DocEntry",
|
|
200
200
|
domain: "Document",
|
|
201
201
|
description: "销售贷项凭证",
|
|
@@ -209,7 +209,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
209
209
|
{
|
|
210
210
|
name: "Returns",
|
|
211
211
|
kind: "EntitySet",
|
|
212
|
-
entityType: "
|
|
212
|
+
entityType: "ERP.Document",
|
|
213
213
|
primaryKey: "DocEntry",
|
|
214
214
|
domain: "Document",
|
|
215
215
|
description: "销售退货",
|
|
@@ -223,7 +223,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
223
223
|
{
|
|
224
224
|
name: "DownPayments",
|
|
225
225
|
kind: "EntitySet",
|
|
226
|
-
entityType: "
|
|
226
|
+
entityType: "ERP.Document",
|
|
227
227
|
primaryKey: "DocEntry",
|
|
228
228
|
domain: "Document",
|
|
229
229
|
description: "预收款",
|
|
@@ -237,7 +237,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
237
237
|
{
|
|
238
238
|
name: "Drafts",
|
|
239
239
|
kind: "EntitySet",
|
|
240
|
-
entityType: "
|
|
240
|
+
entityType: "ERP.Document",
|
|
241
241
|
primaryKey: "DocEntry",
|
|
242
242
|
domain: "Document",
|
|
243
243
|
description: "销售草稿/采购草稿(支持创建、查询、更新、删除)",
|
|
@@ -254,7 +254,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
254
254
|
{
|
|
255
255
|
name: "PurchaseOrders",
|
|
256
256
|
kind: "EntitySet",
|
|
257
|
-
entityType: "
|
|
257
|
+
entityType: "ERP.Document",
|
|
258
258
|
primaryKey: "DocEntry",
|
|
259
259
|
domain: "Document",
|
|
260
260
|
description: "采购订单",
|
|
@@ -269,7 +269,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
269
269
|
{
|
|
270
270
|
name: "PurchaseDeliveryNotes",
|
|
271
271
|
kind: "EntitySet",
|
|
272
|
-
entityType: "
|
|
272
|
+
entityType: "ERP.Document",
|
|
273
273
|
primaryKey: "DocEntry",
|
|
274
274
|
domain: "Document",
|
|
275
275
|
description: "采购收货单",
|
|
@@ -282,7 +282,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
282
282
|
{
|
|
283
283
|
name: "PurchaseInvoices",
|
|
284
284
|
kind: "EntitySet",
|
|
285
|
-
entityType: "
|
|
285
|
+
entityType: "ERP.Document",
|
|
286
286
|
primaryKey: "DocEntry",
|
|
287
287
|
domain: "Document",
|
|
288
288
|
description: "采购发票 (应付)",
|
|
@@ -296,7 +296,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
296
296
|
{
|
|
297
297
|
name: "PurchaseReturns",
|
|
298
298
|
kind: "EntitySet",
|
|
299
|
-
entityType: "
|
|
299
|
+
entityType: "ERP.Document",
|
|
300
300
|
primaryKey: "DocEntry",
|
|
301
301
|
domain: "Document",
|
|
302
302
|
description: "采购退货",
|
|
@@ -309,7 +309,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
309
309
|
{
|
|
310
310
|
name: "PurchaseQuotations",
|
|
311
311
|
kind: "EntitySet",
|
|
312
|
-
entityType: "
|
|
312
|
+
entityType: "ERP.Document",
|
|
313
313
|
primaryKey: "DocEntry",
|
|
314
314
|
domain: "Document",
|
|
315
315
|
description: "采购报价",
|
|
@@ -324,7 +324,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
324
324
|
{
|
|
325
325
|
name: "InventoryGenEntries",
|
|
326
326
|
kind: "EntitySet",
|
|
327
|
-
entityType: "
|
|
327
|
+
entityType: "ERP.Document",
|
|
328
328
|
primaryKey: "DocEntry",
|
|
329
329
|
domain: "Inventory / Warehouse",
|
|
330
330
|
description: "库存收货",
|
|
@@ -338,7 +338,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
338
338
|
{
|
|
339
339
|
name: "InventoryGenExits",
|
|
340
340
|
kind: "EntitySet",
|
|
341
|
-
entityType: "
|
|
341
|
+
entityType: "ERP.Document",
|
|
342
342
|
primaryKey: "DocEntry",
|
|
343
343
|
domain: "Inventory / Warehouse",
|
|
344
344
|
description: "库存发货",
|
|
@@ -351,7 +351,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
351
351
|
{
|
|
352
352
|
name: "StockTransfers",
|
|
353
353
|
kind: "EntitySet",
|
|
354
|
-
entityType: "
|
|
354
|
+
entityType: "ERP.StockTransfer",
|
|
355
355
|
primaryKey: "DocEntry",
|
|
356
356
|
domain: "Inventory / Warehouse",
|
|
357
357
|
description: "库存转储",
|
|
@@ -364,7 +364,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
364
364
|
{
|
|
365
365
|
name: "InventoryPostings",
|
|
366
366
|
kind: "EntitySet",
|
|
367
|
-
entityType: "
|
|
367
|
+
entityType: "ERP.InventoryPosting",
|
|
368
368
|
primaryKey: "DocumentEntry",
|
|
369
369
|
domain: "Inventory / Warehouse",
|
|
370
370
|
description: "库存过账",
|
|
@@ -376,7 +376,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
376
376
|
{
|
|
377
377
|
name: "InventoryCountings",
|
|
378
378
|
kind: "EntitySet",
|
|
379
|
-
entityType: "
|
|
379
|
+
entityType: "ERP.InventoryCounting",
|
|
380
380
|
primaryKey: "DocumentEntry",
|
|
381
381
|
domain: "Inventory / Warehouse",
|
|
382
382
|
description: "库存盘点",
|
|
@@ -388,7 +388,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
388
388
|
{
|
|
389
389
|
name: "Warehouses",
|
|
390
390
|
kind: "EntitySet",
|
|
391
|
-
entityType: "
|
|
391
|
+
entityType: "ERP.Warehouse",
|
|
392
392
|
primaryKey: "WarehouseCode",
|
|
393
393
|
domain: "Inventory / Warehouse",
|
|
394
394
|
description: "仓库定义",
|
|
@@ -402,7 +402,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
402
402
|
{
|
|
403
403
|
name: "BinLocations",
|
|
404
404
|
kind: "EntitySet",
|
|
405
|
-
entityType: "
|
|
405
|
+
entityType: "ERP.BinLocation",
|
|
406
406
|
primaryKey: "AbsEntry",
|
|
407
407
|
domain: "Inventory / Warehouse",
|
|
408
408
|
description: "库位",
|
|
@@ -415,7 +415,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
415
415
|
{
|
|
416
416
|
name: "BatchNumberDetails",
|
|
417
417
|
kind: "EntitySet",
|
|
418
|
-
entityType: "
|
|
418
|
+
entityType: "ERP.BatchNumberDetail",
|
|
419
419
|
primaryKey: "DocEntry",
|
|
420
420
|
domain: "Inventory / Warehouse",
|
|
421
421
|
description: "批次号明细",
|
|
@@ -428,7 +428,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
428
428
|
{
|
|
429
429
|
name: "SerialNumberDetails",
|
|
430
430
|
kind: "EntitySet",
|
|
431
|
-
entityType: "
|
|
431
|
+
entityType: "ERP.SerialNumberDetail",
|
|
432
432
|
primaryKey: "DocEntry",
|
|
433
433
|
domain: "Inventory / Warehouse",
|
|
434
434
|
description: "序列号明细",
|
|
@@ -443,7 +443,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
443
443
|
{
|
|
444
444
|
name: "ItemsService_InitData",
|
|
445
445
|
kind: "FunctionImport",
|
|
446
|
-
entityType: "
|
|
446
|
+
entityType: "ERP.Item",
|
|
447
447
|
domain: "Item / Product",
|
|
448
448
|
description: "初始化物料数据",
|
|
449
449
|
fields: [],
|
|
@@ -451,7 +451,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
451
451
|
{
|
|
452
452
|
name: "BusinessPartnersService_InitData",
|
|
453
453
|
kind: "FunctionImport",
|
|
454
|
-
entityType: "
|
|
454
|
+
entityType: "ERP.BusinessPartner",
|
|
455
455
|
domain: "BusinessPartner",
|
|
456
456
|
description: "初始化 BP 数据",
|
|
457
457
|
fields: [],
|
|
@@ -459,7 +459,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
459
459
|
{
|
|
460
460
|
name: "OrdersService_InitData",
|
|
461
461
|
kind: "FunctionImport",
|
|
462
|
-
entityType: "
|
|
462
|
+
entityType: "ERP.Document",
|
|
463
463
|
domain: "Document",
|
|
464
464
|
description: "初始化订单数据",
|
|
465
465
|
fields: [],
|
|
@@ -467,7 +467,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
467
467
|
{
|
|
468
468
|
name: "InvoicesService_InitData",
|
|
469
469
|
kind: "FunctionImport",
|
|
470
|
-
entityType: "
|
|
470
|
+
entityType: "ERP.Document",
|
|
471
471
|
domain: "Document",
|
|
472
472
|
description: "初始化发票数据",
|
|
473
473
|
fields: [],
|
|
@@ -477,7 +477,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
477
477
|
{
|
|
478
478
|
name: "SpecialPrices",
|
|
479
479
|
kind: "EntitySet",
|
|
480
|
-
entityType: "
|
|
480
|
+
entityType: "ERP.SpecialPrice",
|
|
481
481
|
primaryKey: "ItemCode+CardCode",
|
|
482
482
|
domain: "Item / Product",
|
|
483
483
|
description: "特殊价格(BP/客户特定价格)",
|
|
@@ -489,7 +489,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
489
489
|
{
|
|
490
490
|
name: "LandedCosts",
|
|
491
491
|
kind: "EntitySet",
|
|
492
|
-
entityType: "
|
|
492
|
+
entityType: "ERP.LandedCost",
|
|
493
493
|
primaryKey: "DocEntry",
|
|
494
494
|
domain: "Document",
|
|
495
495
|
description: "到岸成本/附加成本凭证",
|
|
@@ -498,7 +498,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
498
498
|
{
|
|
499
499
|
name: "LandedCostsCodes",
|
|
500
500
|
kind: "EntitySet",
|
|
501
|
-
entityType: "
|
|
501
|
+
entityType: "ERP.LandedCostsCode",
|
|
502
502
|
primaryKey: "Code",
|
|
503
503
|
domain: "Document",
|
|
504
504
|
description: "到岸成本代码定义",
|
|
@@ -507,7 +507,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
507
507
|
{
|
|
508
508
|
name: "CompanyService_GetItemPrice",
|
|
509
509
|
kind: "FunctionImport",
|
|
510
|
-
entityType: "
|
|
510
|
+
entityType: "ERP.ItemPriceReturnParams",
|
|
511
511
|
domain: "Item / Product",
|
|
512
512
|
description: "根据参数查询物料价格(含历史明细)",
|
|
513
513
|
fields: ["ItemPrices", "ItemUnitOfMeasurementCollection"],
|
|
@@ -536,7 +536,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
536
536
|
{
|
|
537
537
|
name: "Z20_COST",
|
|
538
538
|
kind: "EntitySet",
|
|
539
|
-
entityType: "
|
|
539
|
+
entityType: "ERP.Z20_COST",
|
|
540
540
|
primaryKey: "DocEntry",
|
|
541
541
|
domain: "Item / Product",
|
|
542
542
|
description: "自定义: 成本记录表(含周期/实例维度的成本历史)",
|
|
@@ -549,7 +549,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
549
549
|
{
|
|
550
550
|
name: "Z20_CPAT",
|
|
551
551
|
kind: "EntitySet",
|
|
552
|
-
entityType: "
|
|
552
|
+
entityType: "ERP.Z20_CPAT",
|
|
553
553
|
primaryKey: "DocEntry",
|
|
554
554
|
domain: "Item / Product",
|
|
555
555
|
description: "自定义: 成本/价格分摊记录",
|
|
@@ -561,7 +561,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
561
561
|
{
|
|
562
562
|
name: "Z20_OINP",
|
|
563
563
|
kind: "EntitySet",
|
|
564
|
-
entityType: "
|
|
564
|
+
entityType: "ERP.Z20_OINP",
|
|
565
565
|
primaryKey: "DocEntry",
|
|
566
566
|
domain: "Document",
|
|
567
567
|
description: "自定义: 采购订单输入价格记录",
|
|
@@ -573,7 +573,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
573
573
|
{
|
|
574
574
|
name: "Z20_PWAG",
|
|
575
575
|
kind: "EntitySet",
|
|
576
|
-
entityType: "
|
|
576
|
+
entityType: "ERP.Z20_PWAG",
|
|
577
577
|
primaryKey: "DocEntry",
|
|
578
578
|
domain: "Item / Product",
|
|
579
579
|
description: "自定义: 工价/工序价格记录",
|
|
@@ -585,7 +585,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
585
585
|
{
|
|
586
586
|
name: "Z20_HOLD",
|
|
587
587
|
kind: "EntitySet",
|
|
588
|
-
entityType: "
|
|
588
|
+
entityType: "ERP.Z20_HOLD",
|
|
589
589
|
primaryKey: "DocEntry",
|
|
590
590
|
domain: "Inventory / Warehouse",
|
|
591
591
|
description: "自定义: 暂存/冻结库存记录",
|
|
@@ -597,7 +597,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
597
597
|
{
|
|
598
598
|
name: "Z20_IMIT",
|
|
599
599
|
kind: "EntitySet",
|
|
600
|
-
entityType: "
|
|
600
|
+
entityType: "ERP.Z20_IMIT",
|
|
601
601
|
primaryKey: "DocEntry",
|
|
602
602
|
domain: "Inventory / Warehouse",
|
|
603
603
|
description: "自定义: 库存初始化记录",
|
|
@@ -609,7 +609,7 @@ const API_LIST: ApiEntry[] = [
|
|
|
609
609
|
];
|
|
610
610
|
|
|
611
611
|
// ============================================================
|
|
612
|
-
// Tool 1:
|
|
612
|
+
// Tool 1: erp_api_search
|
|
613
613
|
// ============================================================
|
|
614
614
|
|
|
615
615
|
function mapResult(e: ApiEntry): Record<string, unknown> {
|
|
@@ -623,8 +623,8 @@ function mapResult(e: ApiEntry): Record<string, unknown> {
|
|
|
623
623
|
readySelect: e.fields.length > 0 ? `$select=${e.fields.join(",")}` : undefined,
|
|
624
624
|
hint:
|
|
625
625
|
e.kind === "EntitySet"
|
|
626
|
-
? `${e.name} — ${e.description}。主键: ${e.primaryKey}。调用
|
|
627
|
-
: `${e.name} — ${e.description}。调用
|
|
626
|
+
? `${e.name} — ${e.description}。主键: ${e.primaryKey}。调用 erp_api_call 进行 CRUD 操作。`
|
|
627
|
+
: `${e.name} — ${e.description}。调用 erp_api_call 执行此方法。`,
|
|
628
628
|
};
|
|
629
629
|
if (ENTITIES_WITH_LINES.has(e.name)) {
|
|
630
630
|
r.expand = ["DocumentLines", "DocumentAdditionalExpenses"];
|
|
@@ -640,11 +640,11 @@ function mapResult(e: ApiEntry): Record<string, unknown> {
|
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
registerToolLattice(
|
|
643
|
-
"
|
|
643
|
+
"erp_api_search",
|
|
644
644
|
{
|
|
645
|
-
name: "
|
|
645
|
+
name: "erp_api_search",
|
|
646
646
|
description:
|
|
647
|
-
"搜索
|
|
647
|
+
"搜索 ERP Service Layer API 接口元数据,覆盖 BP/物料/订单/库存四大领域。" +
|
|
648
648
|
"返回接口名、主键、字段列表、可选 expand 导航。" +
|
|
649
649
|
"可用 discover 模式发现关联接口(如搜 SalesPerson 也能找到 SalesPersons API)。" +
|
|
650
650
|
"搜索结果中的 readySelect 可直接复制到 $select。",
|
|
@@ -771,36 +771,36 @@ registerToolLattice(
|
|
|
771
771
|
);
|
|
772
772
|
|
|
773
773
|
// ============================================================
|
|
774
|
-
// Tool 2:
|
|
774
|
+
// Tool 2: erp_api_call
|
|
775
775
|
// ============================================================
|
|
776
776
|
|
|
777
|
-
const
|
|
778
|
-
? `B1SESSION=${process.env.
|
|
777
|
+
const ERP_COOKIE = process.env.ERP_SESSION
|
|
778
|
+
? `B1SESSION=${process.env.ERP_SESSION}; ROUTEID=.node0`
|
|
779
779
|
: "";
|
|
780
780
|
|
|
781
781
|
registerToolLattice(
|
|
782
|
-
"
|
|
782
|
+
"erp_api_call",
|
|
783
783
|
{
|
|
784
|
-
name: "
|
|
784
|
+
name: "erp_api_call",
|
|
785
785
|
description:
|
|
786
|
-
"执行
|
|
786
|
+
"执行 ERP Service Layer 的 OData API 查询/创建/更新/删除。" +
|
|
787
787
|
`Base: ${BASE_URL}。` +
|
|
788
|
-
"⚠️ 先确认是否已通过
|
|
788
|
+
"⚠️ 先确认是否已通过 erp_api_search 查过字段列表,勿凭记忆编字段名。\n" +
|
|
789
789
|
"⚠️ 草稿/draft/暂存 → 用 Drafts 接口,不是 Orders/Invoices 等正式单据。" +
|
|
790
790
|
"Drafts 通过 DocObjectCode 区分单据类型(17=订单,13=发票,16=交货单,23=采购订单)。\n" +
|
|
791
791
|
"$filter 操作符: eq/ne/gt/lt/ge/le/contains(f,'v')/startswith(f,'v')/endswith(f,'v'),多条件用 and/or。" +
|
|
792
792
|
"字符串值必须单引号包裹。$orderby=Field desc 排序。\n\n" +
|
|
793
|
-
"⚠️
|
|
793
|
+
"⚠️ ERP 实战经验:\n" +
|
|
794
794
|
"1. 不要用 $expand!$expand 极易触发 400/500。改用 $select 包含嵌套字段,如 $select=DocEntry,DocNum,DocumentLines,\n" +
|
|
795
795
|
" DocumentLines 会自动作为嵌套 JSON 返回。ItemPrices、BPAddresses 等同理。\n" +
|
|
796
796
|
"2. 不要用主键路径 /Orders('1173'),易 500。用 $filter=DocEntry eq 1173 代替。\n" +
|
|
797
797
|
"3. 查单条记录时优先 $filter,而非传 id 参数。\n" +
|
|
798
798
|
"400 多为特殊字符未编码(引号用 %27);500 多为字段不存在或用错了 $expand;无结果则放宽 filter。\n" +
|
|
799
|
-
"POST 创建:
|
|
799
|
+
"POST 创建: erp_api_search 返回的 lineFields 是 DocumentLines 子字段。" +
|
|
800
800
|
"body 必含 DocObjectCode(DocType)、CardCode、DocDate;DocumentLines 为数组,每项必含 ItemCode、Quantity。" +
|
|
801
801
|
"PATCH 只传变更字段;DELETE 需传 id。\n" +
|
|
802
802
|
"GET 自动注入 $select+$top=20,手动传入可覆盖。嵌套集合(DocumentLines等)自动裁剪只保留常用字段,防 token 爆炸。" +
|
|
803
|
-
"认证需
|
|
803
|
+
"认证需 ERP_SESSION 环境变量。",
|
|
804
804
|
needUserApprove: false,
|
|
805
805
|
schema: z.object({
|
|
806
806
|
entitySet: z
|
|
@@ -819,7 +819,7 @@ registerToolLattice(
|
|
|
819
819
|
"常用: $top=10, $select=CardCode,CardName, " +
|
|
820
820
|
"$filter=CardName eq 'xxx' or contains(CardName,'xxx'), " +
|
|
821
821
|
"$orderby=DocDate desc, $expand=DocumentLines。字符串值用单引号。" +
|
|
822
|
-
"
|
|
822
|
+
"erp_api_search 返回的 readySelect 可直接复制到 $select。"
|
|
823
823
|
),
|
|
824
824
|
body: z.record(z.unknown()).optional().describe("POST/PATCH 时的 JSON 请求体"),
|
|
825
825
|
}),
|
|
@@ -833,7 +833,7 @@ registerToolLattice(
|
|
|
833
833
|
"Content-Type": "application/json",
|
|
834
834
|
Accept: "application/json",
|
|
835
835
|
};
|
|
836
|
-
if (
|
|
836
|
+
if (ERP_COOKIE) headers.Cookie = ERP_COOKIE;
|
|
837
837
|
|
|
838
838
|
const fetchOptions: RequestInit = { method, headers };
|
|
839
839
|
if ((method === "POST" || method === "PATCH") && input.body) {
|
|
@@ -865,7 +865,7 @@ registerToolLattice(
|
|
|
865
865
|
result.error = `HTTP ${res.status} ${res.statusText}`;
|
|
866
866
|
result.hint =
|
|
867
867
|
res.status === 401
|
|
868
|
-
? "需要有效的 B1SESSION Cookie。请先通过 Login 端点获取,或设置
|
|
868
|
+
? "需要有效的 B1SESSION Cookie。请先通过 Login 端点获取,或设置 ERP_SESSION 环境变量。"
|
|
869
869
|
: res.status === 404
|
|
870
870
|
? "接口或实体不存在,请检查 entitySet 名称和 id。"
|
|
871
871
|
: undefined;
|
|
@@ -878,7 +878,7 @@ registerToolLattice(
|
|
|
878
878
|
ok: false,
|
|
879
879
|
error: `请求失败: ${message}`,
|
|
880
880
|
url,
|
|
881
|
-
hint: "网络连接失败,请检查
|
|
881
|
+
hint: "网络连接失败,请检查 ERP_SERVICE_LAYER_URL 是否正确。",
|
|
882
882
|
};
|
|
883
883
|
}
|
|
884
884
|
}
|