@burdenoff/mcp-libs 2026.1030.5 → 2026.1031.1

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.
@@ -79,21 +79,22 @@ var VEHICLE_FIELDS = `
79
79
  id vehicleNumber type status make model year licensePlate capacity
80
80
  currentLocation fuelLevel mileage ownershipType ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
81
81
  `;
82
- var PRODUCT_FIELDS = `
82
+ var CARGO_ITEM_FIELDS = `
83
83
  id name sku description category brand weight value dimensions fragile
84
84
  hazardous temperatureControlled ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
85
85
  `;
86
- var ORDER_STATUS_HISTORY_FIELDS = `
87
- id orderId status previousStatus notes location createdAt
86
+ var DELIVERY_JOB_STATUS_HISTORY_FIELDS = `
87
+ id deliveryJobId status previousStatus notes location createdAt
88
88
  `;
89
- var ORDER_FIELDS = `
90
- id orderNumber customerId driverId vehicleId orderType status priority
91
- pickupAddress deliveryAddress items pricing trackingNumber scheduledDelivery
92
- specialInstructions ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
89
+ var DELIVERY_JOB_FIELDS = `
90
+ id deliveryJobNumber customerId driverId vehicleId routeId storeOrderId status
91
+ priority pickupAddress deliveryAddress cargoItems pricing trackingNumber
92
+ scheduledDelivery specialInstructions ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
93
93
  `;
94
94
  var SHIPMENT_FIELDS = `
95
- id shipmentNumber orderId customerId carrierId origin destination status
96
- trackingNumber cargoDetails estimatedDelivery actualDelivery
95
+ id shipmentNumber deliveryJobId storeOrderId customerId carrierId origin
96
+ destination status statusRevision primaryMode isMultiModal trackingNumber
97
+ cargoDetails estimatedDelivery actualDelivery totalFreightCost freightCurrency
97
98
  ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
98
99
  `;
99
100
  var TRACKING_EVENT_FIELDS = `
@@ -102,7 +103,7 @@ var TRACKING_EVENT_FIELDS = `
102
103
  ${CONTEXT_FIELDS}
103
104
  `;
104
105
  var TRACKING_ALERT_FIELDS = `
105
- shipmentId shipmentNumber alertType message
106
+ shipmentId shipmentNumber alertType message predictedDelivery riskScore signals
106
107
  `;
107
108
  var ROUTE_FIELDS = `
108
109
  id name status shipmentId driverId vehicleId waypoints estimatedDistance
@@ -118,11 +119,11 @@ var WAREHOUSE_FIELDS = `
118
119
  totalCapacity usedCapacity ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
119
120
  `;
120
121
  var INVENTORY_ITEM_FIELDS = `
121
- id productId warehouseId locationId onHand available allocated damaged
122
+ id cargoItemId warehouseId locationId onHand available allocated damaged
122
123
  reorderPoint safetyStock unitCost ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
123
124
  `;
124
125
  var INVENTORY_TRANSACTION_FIELDS = `
125
- id transactionNumber type productId warehouseId inventoryItemId quantity
126
+ id transactionNumber type cargoItemId warehouseId inventoryItemId quantity
126
127
  unitCost referenceType referenceId notes ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
127
128
  `;
128
129
  var MARKETPLACE_AUDIT_FIELDS = `workspaceId createdBy onBehalfOf updatedBy createdAt updatedAt deletedAt`;
@@ -134,10 +135,6 @@ var SERVICE_PROVIDER_FIELDS = `
134
135
  id name type description rating contactInfo services serviceAreas isVerified isActive
135
136
  offeringsCount ${MARKETPLACE_AUDIT_FIELDS}
136
137
  `;
137
- var REPORT_FIELDS = `
138
- id name type status description configuration schedule lastGenerated
139
- ${AUDIT_FIELDS} ${CONTEXT_FIELDS}
140
- `;
141
138
  var GET_CUSTOMER = `
142
139
  query MovethewheelsGetCustomer($id: ID!) {
143
140
  customer(id: $id) { ${CUSTOMER_FIELDS} }
@@ -233,76 +230,84 @@ var DELETE_VEHICLE = `
233
230
  deleteVehicle(id: $id)
234
231
  }
235
232
  `;
236
- var GET_PRODUCT = `
237
- query MovethewheelsGetProduct($id: ID!) {
238
- product(id: $id) { ${PRODUCT_FIELDS} }
233
+ var GET_CARGO_ITEM = `
234
+ query MovethewheelsGetCargoItem($id: ID!) {
235
+ cargoItem(id: $id) { ${CARGO_ITEM_FIELDS} }
239
236
  }
240
237
  `;
241
- var LIST_PRODUCTS = `
242
- query MovethewheelsListProducts($filter: ProductFilterInput, $pagination: PaginationInput) {
243
- products(filter: $filter, pagination: $pagination) { ${PRODUCT_FIELDS} }
238
+ var LIST_CARGO_ITEMS = `
239
+ query MovethewheelsListCargoItems($filter: CargoItemFilterInput, $pagination: PaginationInput) {
240
+ cargoItems(filter: $filter, pagination: $pagination) { ${CARGO_ITEM_FIELDS} }
244
241
  }
245
242
  `;
246
- var CREATE_PRODUCT = `
247
- mutation MovethewheelsCreateProduct($input: CreateProductInput!) {
248
- createProduct(input: $input) { ${PRODUCT_FIELDS} }
243
+ var CREATE_CARGO_ITEM = `
244
+ mutation MovethewheelsCreateCargoItem($input: CreateCargoItemInput!) {
245
+ createCargoItem(input: $input) { ${CARGO_ITEM_FIELDS} }
249
246
  }
250
247
  `;
251
- var UPDATE_PRODUCT = `
252
- mutation MovethewheelsUpdateProduct($id: ID!, $input: UpdateProductInput!) {
253
- updateProduct(id: $id, input: $input) { ${PRODUCT_FIELDS} }
248
+ var UPDATE_CARGO_ITEM = `
249
+ mutation MovethewheelsUpdateCargoItem($id: ID!, $input: UpdateCargoItemInput!) {
250
+ updateCargoItem(id: $id, input: $input) { ${CARGO_ITEM_FIELDS} }
254
251
  }
255
252
  `;
256
- var DELETE_PRODUCT = `
257
- mutation MovethewheelsDeleteProduct($id: ID!) {
258
- deleteProduct(id: $id)
253
+ var DELETE_CARGO_ITEM = `
254
+ mutation MovethewheelsDeleteCargoItem($id: ID!) {
255
+ deleteCargoItem(id: $id)
259
256
  }
260
257
  `;
261
- var GET_ORDER = `
262
- query MovethewheelsGetOrder($id: ID!) {
263
- movethewheelsOrder(id: $id) {
264
- ${ORDER_FIELDS}
258
+ var GET_DELIVERY_JOB = `
259
+ query MovethewheelsGetDeliveryJob($id: ID!) {
260
+ deliveryJob(id: $id) {
261
+ ${DELIVERY_JOB_FIELDS}
265
262
  customer { id name email phone }
266
263
  driver { id firstName lastName status }
267
264
  vehicle { id vehicleNumber type status }
265
+ route { id name status }
268
266
  shipment { id shipmentNumber status }
269
- statusHistory { ${ORDER_STATUS_HISTORY_FIELDS} }
267
+ statusHistory { ${DELIVERY_JOB_STATUS_HISTORY_FIELDS} }
270
268
  }
271
269
  }
272
270
  `;
273
- var LIST_ORDERS = `
274
- query MovethewheelsListOrders($filter: OrderFilterInput, $pagination: PaginationInput) {
275
- movethewheelsOrders(filter: $filter, pagination: $pagination) { ${ORDER_FIELDS} }
271
+ var LIST_DELIVERY_JOBS = `
272
+ query MovethewheelsListDeliveryJobs(
273
+ $filter: DeliveryJobFilterInput
274
+ $pagination: PaginationInput
275
+ ) {
276
+ deliveryJobs(filter: $filter, pagination: $pagination) { ${DELIVERY_JOB_FIELDS} }
276
277
  }
277
278
  `;
278
- var CREATE_ORDER = `
279
- mutation MovethewheelsCreateOrder($input: CreateOrderInput!) {
280
- createMovethewheelsOrder(input: $input) { ${ORDER_FIELDS} }
279
+ var CREATE_DELIVERY_JOB = `
280
+ mutation MovethewheelsCreateDeliveryJob($input: CreateDeliveryJobInput!) {
281
+ createDeliveryJob(input: $input) { ${DELIVERY_JOB_FIELDS} }
281
282
  }
282
283
  `;
283
- var UPDATE_ORDER = `
284
- mutation MovethewheelsUpdateOrder($id: ID!, $input: UpdateOrderInput!) {
285
- updateMovethewheelsOrder(id: $id, input: $input) { ${ORDER_FIELDS} }
284
+ var UPDATE_DELIVERY_JOB = `
285
+ mutation MovethewheelsUpdateDeliveryJob($id: ID!, $input: UpdateDeliveryJobInput!) {
286
+ updateDeliveryJob(id: $id, input: $input) { ${DELIVERY_JOB_FIELDS} }
286
287
  }
287
288
  `;
288
- var UPDATE_ORDER_STATUS = `
289
- mutation MovethewheelsUpdateOrderStatus($id: ID!, $input: UpdateOrderStatusInput!) {
290
- updateMovethewheelsOrderStatus(id: $id, input: $input) {
291
- ${ORDER_FIELDS}
292
- statusHistory { ${ORDER_STATUS_HISTORY_FIELDS} }
289
+ var UPDATE_DELIVERY_JOB_STATUS = `
290
+ mutation MovethewheelsUpdateDeliveryJobStatus(
291
+ $id: ID!
292
+ $input: UpdateDeliveryJobStatusInput!
293
+ ) {
294
+ updateDeliveryJobStatus(id: $id, input: $input) {
295
+ ${DELIVERY_JOB_FIELDS}
296
+ statusHistory { ${DELIVERY_JOB_STATUS_HISTORY_FIELDS} }
293
297
  }
294
298
  }
295
299
  `;
296
- var DELETE_ORDER = `
297
- mutation MovethewheelsDeleteOrder($id: ID!) {
298
- deleteMovethewheelsOrder(id: $id)
300
+ var DELETE_DELIVERY_JOB = `
301
+ mutation MovethewheelsDeleteDeliveryJob($id: ID!) {
302
+ deleteDeliveryJob(id: $id)
299
303
  }
300
304
  `;
301
305
  var GET_SHIPMENT = `
302
306
  query MovethewheelsGetShipment($id: ID!) {
303
307
  shipment(id: $id) {
304
308
  ${SHIPMENT_FIELDS}
305
- order { id orderNumber status }
309
+ deliveryJob { id deliveryJobNumber status }
310
+ serviceProvider { id name type isVerified isActive }
306
311
  trackingEvents { ${TRACKING_EVENT_FIELDS} }
307
312
  }
308
313
  }
@@ -332,9 +337,11 @@ var DELETE_SHIPMENT = `
332
337
  deleteShipment(id: $id)
333
338
  }
334
339
  `;
335
- var GET_ORDER_TRACKING = `
336
- query MovethewheelsOrderTracking($orderId: ID!, $pagination: PaginationInput) {
337
- orderTracking(orderId: $orderId, pagination: $pagination) { ${TRACKING_EVENT_FIELDS} }
340
+ var GET_DELIVERY_JOB_TRACKING = `
341
+ query MovethewheelsDeliveryJobTracking($deliveryJobId: ID!, $pagination: PaginationInput) {
342
+ deliveryJobTracking(deliveryJobId: $deliveryJobId, pagination: $pagination) {
343
+ ${TRACKING_EVENT_FIELDS}
344
+ }
338
345
  }
339
346
  `;
340
347
  var GET_SHIPMENT_TRACKING = `
@@ -429,7 +436,7 @@ var GET_INVENTORY_ITEM = `
429
436
  query MovethewheelsGetInventoryItem($id: ID!) {
430
437
  inventoryItem(id: $id) {
431
438
  ${INVENTORY_ITEM_FIELDS}
432
- product { id name sku }
439
+ cargoItem { id name sku }
433
440
  warehouse { id name code }
434
441
  location { id locationCode }
435
442
  }
@@ -476,6 +483,14 @@ var ADJUST_INVENTORY_STOCK = `
476
483
  adjustInventoryStock(input: $input) { ${INVENTORY_ITEM_FIELDS} }
477
484
  }
478
485
  `;
486
+ var TRANSFER_INVENTORY_STOCK = `
487
+ mutation MovethewheelsTransferInventoryStock($input: TransferInventoryStockInput!) {
488
+ transferInventoryStock(input: $input) {
489
+ source { ${INVENTORY_ITEM_FIELDS} }
490
+ destination { ${INVENTORY_ITEM_FIELDS} }
491
+ }
492
+ }
493
+ `;
479
494
  var DELETE_INVENTORY_ITEM = `
480
495
  mutation MovethewheelsDeleteInventoryItem($id: ID!) {
481
496
  deleteInventoryItem(id: $id)
@@ -564,65 +579,6 @@ var ASSIGN_SHIPMENT_SERVICE_PROVIDER = `
564
579
  }
565
580
  }
566
581
  `;
567
- var GET_REPORT = `
568
- query MovethewheelsGetReport($id: ID!) {
569
- movethewheelsReport(id: $id) { ${REPORT_FIELDS} }
570
- }
571
- `;
572
- var LIST_REPORTS = `
573
- query MovethewheelsListReports(
574
- $filter: MovethewheelsReportFilterInput
575
- $pagination: PaginationInput
576
- ) {
577
- movethewheelsReports(filter: $filter, pagination: $pagination) { ${REPORT_FIELDS} }
578
- }
579
- `;
580
- var CREATE_REPORT = `
581
- mutation MovethewheelsCreateReport($input: CreateMovethewheelsReportInput!) {
582
- createMovethewheelsReport(input: $input) { ${REPORT_FIELDS} }
583
- }
584
- `;
585
- var UPDATE_REPORT = `
586
- mutation MovethewheelsUpdateReport($id: ID!, $input: UpdateMovethewheelsReportInput!) {
587
- updateMovethewheelsReport(id: $id, input: $input) { ${REPORT_FIELDS} }
588
- }
589
- `;
590
- var DELETE_REPORT = `
591
- mutation MovethewheelsDeleteReport($id: ID!) {
592
- deleteMovethewheelsReport(id: $id)
593
- }
594
- `;
595
- var GENERATE_REPORT = `
596
- mutation MovethewheelsGenerateReport($input: GenerateMovethewheelsReportInput!) {
597
- generateMovethewheelsReport(input: $input) {
598
- generatedAt
599
- result
600
- report { ${REPORT_FIELDS} }
601
- }
602
- }
603
- `;
604
- var GET_MODULE_SETTINGS = `
605
- query MovethewheelsModuleSettings {
606
- moduleSettings { workspaceId preferences updatedAt }
607
- }
608
- `;
609
- var UPDATE_MODULE_SETTINGS = `
610
- mutation MovethewheelsUpdateModuleSettings(
611
- $input: UpdateMovethewheelsModuleSettingsInput!
612
- ) {
613
- updateModuleSettings(input: $input) { workspaceId preferences updatedAt }
614
- }
615
- `;
616
- var EXPORT_DATA = `
617
- mutation MovethewheelsExportData($input: MovethewheelsExportDataInput!) {
618
- exportData(input: $input) { success message payload }
619
- }
620
- `;
621
- var IMPORT_DATA = `
622
- mutation MovethewheelsImportData($input: MovethewheelsImportDataInput!) {
623
- importData(input: $input) { success message payload }
624
- }
625
- `;
626
582
  var GET_ANALYTICS = `
627
583
  query MovethewheelsAnalytics {
628
584
  analytics {
@@ -635,19 +591,33 @@ var GET_ANALYTICS = `
635
591
  var GET_DASHBOARD_METRICS = `
636
592
  query MovethewheelsDashboardMetrics {
637
593
  dashboardMetrics {
638
- totalOrders
594
+ totalDeliveryJobs
639
595
  activeDeliveries
640
596
  activeVehicles
641
597
  availableDrivers
642
598
  lowStockItems
643
599
  totalRevenue
644
- recentOrders { id orderNumber status priority createdAt }
600
+ onTimeDeliveryRate
601
+ customerSatisfaction
602
+ recentDeliveryJobs { id deliveryJobNumber status priority createdAt }
645
603
  }
646
604
  }
647
605
  `;
648
- var GET_ORDER_STATS = `
649
- query MovethewheelsOrderStats {
650
- orderStats { total pending inTransit delivered cancelled failed }
606
+ var GET_DELIVERY_JOB_STATS = `
607
+ query MovethewheelsDeliveryJobStats {
608
+ deliveryJobStats {
609
+ total
610
+ pending
611
+ confirmed
612
+ assigned
613
+ pickedUp
614
+ inTransit
615
+ outForDelivery
616
+ delivered
617
+ cancelled
618
+ failed
619
+ returned
620
+ }
651
621
  }
652
622
  `;
653
623
  var GET_FLEET_STATS = `
@@ -660,6 +630,7 @@ var GET_FLEET_STATS = `
660
630
  totalDrivers
661
631
  availableDrivers
662
632
  onDeliveryDrivers
633
+ avgDriverRating
663
634
  }
664
635
  }
665
636
  `;
@@ -674,8 +645,8 @@ var GET_FINANCE_METRICS = `
674
645
  `;
675
646
  var DriverStatusEnum = zod.z.enum(["AVAILABLE", "INACTIVE", "OFF_DUTY", "ON_BREAK", "ON_DELIVERY"]).describe("Availability/duty status of a driver");
676
647
  var InventoryTransactionTypeEnum = zod.z.enum(["ADJUSTMENT", "ISSUE", "RECEIPT", "RETURN", "TRANSFER"]).describe("Type of inventory ledger movement");
677
- var OrderPriorityEnum = zod.z.enum(["CRITICAL", "HIGH", "LOW", "MEDIUM", "URGENT"]).describe("Fulfilment priority of an order");
678
- var OrderStatusEnum = zod.z.enum([
648
+ var DeliveryPriorityEnum = zod.z.enum(["CRITICAL", "HIGH", "LOW", "MEDIUM", "URGENT"]).describe("Dispatch priority of a delivery job");
649
+ var DeliveryJobStatusEnum = zod.z.enum([
679
650
  "ASSIGNED",
680
651
  "CANCELLED",
681
652
  "CONFIRMED",
@@ -686,8 +657,7 @@ var OrderStatusEnum = zod.z.enum([
686
657
  "PENDING",
687
658
  "PICKED_UP",
688
659
  "RETURNED"
689
- ]).describe("Fulfilment status of an order");
690
- var OrderTypeEnum = zod.z.enum(["B2B", "B2C", "MARKETPLACE", "SUBSCRIPTION"]).describe("Commercial type of an order");
660
+ ]).describe("Lifecycle status of a delivery job");
691
661
  var RouteStatusEnum = zod.z.enum(["CANCELLED", "COMPLETED", "IN_PROGRESS", "PLANNED"]).describe("Lifecycle status of a route");
692
662
  var ShipmentStatusEnum = zod.z.enum(["DELIVERED", "FAILED", "IN_TRANSIT", "PICKED_UP", "PLANNED", "RETURNED"]).describe("Lifecycle status of a shipment");
693
663
  var TrackingEventTypeEnum = zod.z.enum([
@@ -737,6 +707,8 @@ var ServiceOfferingCategoryEnum = zod.z.enum([
737
707
  "OTHER"
738
708
  ]).describe("What a marketplace service offering provides");
739
709
  var ServiceAvailabilityEnum = zod.z.enum(["AVAILABLE", "LIMITED", "UNAVAILABLE"]).describe("Whether the provider currently has capacity for an offering");
710
+ var IsoDateTime = zod.z.string().datetime({ offset: true }).describe("ISO 8601 date-time, e.g. 2026-10-31T09:30:00Z");
711
+ var StockQuantity = zod.z.number().int().min(0).max(2147483647);
740
712
  var JsonObject = zod.z.record(zod.z.string(), zod.z.unknown());
741
713
  var JsonValue = zod.z.union([JsonObject, zod.z.array(zod.z.unknown())]);
742
714
 
@@ -965,7 +937,7 @@ function registerDriverTools(server, ctx, track) {
965
937
  status: DriverStatusEnum.optional().describe("Initial status (default AVAILABLE)"),
966
938
  licenseNumber: zod.z.string().optional().describe("Driving license number"),
967
939
  licenseClass: zod.z.string().optional().describe("Driving license class"),
968
- licenseExpiry: zod.z.string().optional().describe("License expiry (ISO 8601 DateTime)"),
940
+ licenseExpiry: IsoDateTime.optional().describe("License expiry (ISO 8601 date-time)"),
969
941
  certifications: JsonObject.optional().describe("Certifications JSON"),
970
942
  currentLocation: JsonObject.optional().describe("Current location JSON ({ lat, lng })"),
971
943
  performanceMetrics: JsonObject.optional().describe("Performance metrics JSON"),
@@ -1029,7 +1001,9 @@ function registerDriverTools(server, ctx, track) {
1029
1001
  status: DriverStatusEnum.optional().describe("Updated status"),
1030
1002
  licenseNumber: zod.z.string().optional().describe("Updated license number"),
1031
1003
  licenseClass: zod.z.string().optional().describe("Updated license class"),
1032
- licenseExpiry: zod.z.string().optional().describe("Updated license expiry (ISO 8601)"),
1004
+ licenseExpiry: IsoDateTime.optional().describe(
1005
+ "Updated license expiry (ISO 8601 date-time)"
1006
+ ),
1033
1007
  certifications: JsonObject.optional().describe("Updated certifications JSON"),
1034
1008
  currentLocation: JsonObject.optional().describe("Updated location JSON"),
1035
1009
  performanceMetrics: JsonObject.optional().describe("Updated performance metrics JSON"),
@@ -1387,23 +1361,23 @@ function registerVehicleTools(server, ctx, track) {
1387
1361
  }
1388
1362
  );
1389
1363
  }
1390
- function registerProductTools(server, ctx, track) {
1364
+ function registerCargoTools(server, ctx, track) {
1391
1365
  server.registerTool(
1392
1366
  track(mcpToolName(ctx.productName, "cargo_get")),
1393
1367
  {
1394
- title: "Get Product",
1395
- description: "Fetch a single product (cargo SKU) by ID.",
1396
- inputSchema: { id: zod.z.string().describe("Product ID") }
1368
+ title: "Get Cargo Item",
1369
+ description: "Fetch a single cargo item (cargo SKU) by ID.",
1370
+ inputSchema: { id: zod.z.string().describe("Cargo item ID") }
1397
1371
  },
1398
1372
  async ({ id }) => {
1399
1373
  try {
1400
- const data = await ctx.gql.workspace.request(GET_PRODUCT, { id });
1401
- if (!data.product) return errorResult(`Product ${id} not found`);
1402
- return jsonResult(data.product);
1374
+ const data = await ctx.gql.workspace.request(GET_CARGO_ITEM, { id });
1375
+ if (!data.cargoItem) return errorResult(`Cargo item ${id} not found`);
1376
+ return jsonResult(data.cargoItem);
1403
1377
  } catch (error) {
1404
1378
  ctx.logger.error("movethewheels cargo_get failed", { error: String(error) });
1405
1379
  return errorResult(
1406
- `Failed to get product: ${error instanceof Error ? error.message : String(error)}`
1380
+ `Failed to get cargo item: ${error instanceof Error ? error.message : String(error)}`
1407
1381
  );
1408
1382
  }
1409
1383
  }
@@ -1411,8 +1385,8 @@ function registerProductTools(server, ctx, track) {
1411
1385
  server.registerTool(
1412
1386
  track(mcpToolName(ctx.productName, "cargo_list")),
1413
1387
  {
1414
- title: "List Products",
1415
- description: "List products with optional category/sku/text filters and pagination.",
1388
+ title: "List Cargo Items",
1389
+ description: "List cargo items with optional category/sku/text filters and pagination.",
1416
1390
  inputSchema: {
1417
1391
  search: zod.z.string().optional().describe("Free-text search across name/description"),
1418
1392
  category: zod.z.string().optional().describe("Filter by category"),
@@ -1427,15 +1401,15 @@ function registerProductTools(server, ctx, track) {
1427
1401
  if (search !== void 0) filter.search = search;
1428
1402
  if (category !== void 0) filter.category = category;
1429
1403
  if (sku !== void 0) filter.sku = sku;
1430
- const data = await ctx.gql.workspace.request(LIST_PRODUCTS, {
1404
+ const data = await ctx.gql.workspace.request(LIST_CARGO_ITEMS, {
1431
1405
  filter: Object.keys(filter).length > 0 ? filter : void 0,
1432
1406
  pagination: { limit: limit ?? 50, offset: offset ?? 0 }
1433
1407
  });
1434
- return jsonResult(data.products);
1408
+ return jsonResult(data.cargoItems);
1435
1409
  } catch (error) {
1436
1410
  ctx.logger.error("movethewheels cargo_list failed", { error: String(error) });
1437
1411
  return errorResult(
1438
- `Failed to list products: ${error instanceof Error ? error.message : String(error)}`
1412
+ `Failed to list cargo items: ${error instanceof Error ? error.message : String(error)}`
1439
1413
  );
1440
1414
  }
1441
1415
  }
@@ -1443,10 +1417,10 @@ function registerProductTools(server, ctx, track) {
1443
1417
  server.registerTool(
1444
1418
  track(mcpToolName(ctx.productName, "cargo_create")),
1445
1419
  {
1446
- title: "Create Product",
1447
- description: "Create a product (cargo SKU). `name` and `sku` are required.",
1420
+ title: "Create Cargo Item",
1421
+ description: "Create a cargo item (cargo SKU). `name` and `sku` are required; `sku` must be unique in the workspace.",
1448
1422
  inputSchema: {
1449
- name: zod.z.string().min(1).describe("Product name"),
1423
+ name: zod.z.string().min(1).describe("Cargo item name"),
1450
1424
  sku: zod.z.string().min(1).describe("Stock-keeping unit (unique)"),
1451
1425
  description: zod.z.string().optional().describe("Description"),
1452
1426
  category: zod.z.string().optional().describe("Category"),
@@ -1485,12 +1459,12 @@ function registerProductTools(server, ctx, track) {
1485
1459
  if (temperatureControlled !== void 0) {
1486
1460
  input.temperatureControlled = temperatureControlled;
1487
1461
  }
1488
- const data = await ctx.gql.workspace.request(CREATE_PRODUCT, { input });
1489
- return jsonResult(data.createProduct);
1462
+ const data = await ctx.gql.workspace.request(CREATE_CARGO_ITEM, { input });
1463
+ return jsonResult(data.createCargoItem);
1490
1464
  } catch (error) {
1491
1465
  ctx.logger.error("movethewheels cargo_create failed", { error: String(error) });
1492
1466
  return errorResult(
1493
- `Failed to create product: ${error instanceof Error ? error.message : String(error)}`
1467
+ `Failed to create cargo item: ${error instanceof Error ? error.message : String(error)}`
1494
1468
  );
1495
1469
  }
1496
1470
  }
@@ -1498,10 +1472,10 @@ function registerProductTools(server, ctx, track) {
1498
1472
  server.registerTool(
1499
1473
  track(mcpToolName(ctx.productName, "cargo_update")),
1500
1474
  {
1501
- title: "Update Product",
1502
- description: "Update a product. At least one mutable field must be provided.",
1475
+ title: "Update Cargo Item",
1476
+ description: "Update a cargo item. At least one mutable field must be provided.",
1503
1477
  inputSchema: {
1504
- id: zod.z.string().describe("Product ID"),
1478
+ id: zod.z.string().describe("Cargo item ID"),
1505
1479
  name: zod.z.string().optional().describe("Updated name"),
1506
1480
  sku: zod.z.string().optional().describe("Updated SKU"),
1507
1481
  description: zod.z.string().optional().describe("Updated description"),
@@ -1547,12 +1521,12 @@ function registerProductTools(server, ctx, track) {
1547
1521
  if (Object.keys(input).length === 0) {
1548
1522
  return errorResult("No updates specified \u2014 provide at least one mutable field.");
1549
1523
  }
1550
- const data = await ctx.gql.workspace.request(UPDATE_PRODUCT, { id, input });
1551
- return jsonResult(data.updateProduct);
1524
+ const data = await ctx.gql.workspace.request(UPDATE_CARGO_ITEM, { id, input });
1525
+ return jsonResult(data.updateCargoItem);
1552
1526
  } catch (error) {
1553
1527
  ctx.logger.error("movethewheels cargo_update failed", { error: String(error) });
1554
1528
  return errorResult(
1555
- `Failed to update product: ${error instanceof Error ? error.message : String(error)}`
1529
+ `Failed to update cargo item: ${error instanceof Error ? error.message : String(error)}`
1556
1530
  );
1557
1531
  }
1558
1532
  }
@@ -1560,62 +1534,63 @@ function registerProductTools(server, ctx, track) {
1560
1534
  server.registerTool(
1561
1535
  track(mcpToolName(ctx.productName, "cargo_delete")),
1562
1536
  {
1563
- title: "Delete Product",
1564
- description: "Soft-delete a product by ID.",
1565
- inputSchema: { id: zod.z.string().describe("Product ID") }
1537
+ title: "Delete Cargo Item",
1538
+ description: "Soft-delete a cargo item by ID.",
1539
+ inputSchema: { id: zod.z.string().describe("Cargo item ID") }
1566
1540
  },
1567
1541
  async ({ id }) => {
1568
1542
  try {
1569
1543
  const data = await ctx.gql.workspace.request(
1570
- DELETE_PRODUCT,
1544
+ DELETE_CARGO_ITEM,
1571
1545
  { id }
1572
1546
  );
1573
- return jsonResult({ deleted: data.deleteProduct, id });
1547
+ return jsonResult({ deleted: data.deleteCargoItem, id });
1574
1548
  } catch (error) {
1575
1549
  ctx.logger.error("movethewheels cargo_delete failed", { error: String(error) });
1576
1550
  return errorResult(
1577
- `Failed to delete product: ${error instanceof Error ? error.message : String(error)}`
1551
+ `Failed to delete cargo item: ${error instanceof Error ? error.message : String(error)}`
1578
1552
  );
1579
1553
  }
1580
1554
  }
1581
1555
  );
1582
1556
  }
1583
- function registerOrderTools(server, ctx, track) {
1557
+ var errorMessage = (error) => error instanceof Error ? error.message : String(error);
1558
+ function registerDeliveryJobTools(server, ctx, track) {
1584
1559
  server.registerTool(
1585
- track(mcpToolName(ctx.productName, "orders_get")),
1560
+ track(mcpToolName(ctx.productName, "delivery_jobs_get")),
1586
1561
  {
1587
- title: "Get Order",
1588
- description: "Fetch a single delivery order by ID, including customer/driver/vehicle/shipment links and status history.",
1589
- inputSchema: { id: zod.z.string().describe("Order ID") }
1562
+ title: "Get Delivery Job",
1563
+ description: "Fetch a single delivery job by ID, including its customer, driver, vehicle, route and shipment links and its status history.",
1564
+ inputSchema: { id: zod.z.string().describe("Delivery job ID") }
1590
1565
  },
1591
1566
  async ({ id }) => {
1592
1567
  try {
1593
- const data = await ctx.gql.workspace.request(GET_ORDER, { id });
1594
- if (!data.movethewheelsOrder) return errorResult(`Order ${id} not found`);
1595
- return jsonResult(data.movethewheelsOrder);
1568
+ const data = await ctx.gql.workspace.request(GET_DELIVERY_JOB, { id });
1569
+ if (!data.deliveryJob) return errorResult(`Delivery job ${id} not found`);
1570
+ return jsonResult(data.deliveryJob);
1596
1571
  } catch (error) {
1597
- ctx.logger.error("movethewheels orders_get failed", { error: String(error) });
1598
- return errorResult(
1599
- `Failed to get order: ${error instanceof Error ? error.message : String(error)}`
1600
- );
1572
+ ctx.logger.error("movethewheels delivery_jobs_get failed", { error: String(error) });
1573
+ return errorResult(`Failed to get delivery job: ${errorMessage(error)}`);
1601
1574
  }
1602
1575
  }
1603
1576
  );
1604
1577
  server.registerTool(
1605
- track(mcpToolName(ctx.productName, "orders_list")),
1578
+ track(mcpToolName(ctx.productName, "delivery_jobs_list")),
1606
1579
  {
1607
- title: "List Orders",
1608
- description: "List delivery orders with optional customer/driver/vehicle/type/priority/status/text filters and pagination.",
1580
+ title: "List Delivery Jobs",
1581
+ description: "List delivery jobs with optional customer/driver/vehicle/route/store-order/priority/status/text filters and pagination. Set `unassigned` to true to find jobs with no driver yet.",
1609
1582
  inputSchema: {
1610
- search: zod.z.string().optional().describe("Free-text search across orderNumber"),
1583
+ search: zod.z.string().optional().describe("Free-text search across deliveryJobNumber"),
1611
1584
  customerId: zod.z.string().optional().describe("Filter by customer ID"),
1612
1585
  driverId: zod.z.string().optional().describe("Filter by driver ID"),
1613
1586
  vehicleId: zod.z.string().optional().describe("Filter by vehicle ID"),
1614
- orderType: OrderTypeEnum.optional().describe("Filter by order type"),
1615
- priority: OrderPriorityEnum.optional().describe("Filter by priority"),
1616
- status: OrderStatusEnum.optional().describe("Filter by status"),
1617
- limit: zod.z.number().int().optional().describe("Page size (default 50)"),
1618
- offset: zod.z.number().int().optional().describe("Pagination offset (default 0)")
1587
+ routeId: zod.z.string().optional().describe("Filter by route ID"),
1588
+ storeOrderId: zod.z.string().optional().describe("Filter by global-store order ID"),
1589
+ priority: DeliveryPriorityEnum.optional().describe("Filter by priority"),
1590
+ status: DeliveryJobStatusEnum.optional().describe("Filter by status"),
1591
+ unassigned: zod.z.boolean().optional().describe("Only jobs with no driver assigned"),
1592
+ limit: zod.z.number().int().min(1).max(100).optional().describe("Page size (default 50)"),
1593
+ offset: zod.z.number().int().min(0).optional().describe("Pagination offset (default 0)")
1619
1594
  }
1620
1595
  },
1621
1596
  async ({
@@ -1623,9 +1598,11 @@ function registerOrderTools(server, ctx, track) {
1623
1598
  customerId,
1624
1599
  driverId,
1625
1600
  vehicleId,
1626
- orderType,
1601
+ routeId,
1602
+ storeOrderId,
1627
1603
  priority,
1628
1604
  status,
1605
+ unassigned,
1629
1606
  limit,
1630
1607
  offset
1631
1608
  }) => {
@@ -1635,55 +1612,61 @@ function registerOrderTools(server, ctx, track) {
1635
1612
  if (customerId !== void 0) filter.customerId = customerId;
1636
1613
  if (driverId !== void 0) filter.driverId = driverId;
1637
1614
  if (vehicleId !== void 0) filter.vehicleId = vehicleId;
1638
- if (orderType !== void 0) filter.orderType = orderType;
1615
+ if (routeId !== void 0) filter.routeId = routeId;
1616
+ if (storeOrderId !== void 0) filter.storeOrderId = storeOrderId;
1639
1617
  if (priority !== void 0) filter.priority = priority;
1640
1618
  if (status !== void 0) filter.status = status;
1641
- const data = await ctx.gql.workspace.request(LIST_ORDERS, {
1619
+ if (unassigned !== void 0) filter.unassigned = unassigned;
1620
+ const data = await ctx.gql.workspace.request(LIST_DELIVERY_JOBS, {
1642
1621
  filter: Object.keys(filter).length > 0 ? filter : void 0,
1643
1622
  pagination: { limit: limit ?? 50, offset: offset ?? 0 }
1644
1623
  });
1645
- return jsonResult(data.movethewheelsOrders);
1624
+ return jsonResult(data.deliveryJobs);
1646
1625
  } catch (error) {
1647
- ctx.logger.error("movethewheels orders_list failed", { error: String(error) });
1648
- return errorResult(
1649
- `Failed to list orders: ${error instanceof Error ? error.message : String(error)}`
1650
- );
1626
+ ctx.logger.error("movethewheels delivery_jobs_list failed", { error: String(error) });
1627
+ return errorResult(`Failed to list delivery jobs: ${errorMessage(error)}`);
1651
1628
  }
1652
1629
  }
1653
1630
  );
1654
1631
  server.registerTool(
1655
- track(mcpToolName(ctx.productName, "orders_create")),
1632
+ track(mcpToolName(ctx.productName, "delivery_jobs_create")),
1656
1633
  {
1657
- title: "Create Order",
1658
- description: "Create a delivery order. `customerId`, `orderNumber`, `pickupAddress`, `deliveryAddress`, and `items` are required. `orderType` defaults to B2C, `priority` to MEDIUM, `status` to PENDING.",
1634
+ title: "Create Delivery Job",
1635
+ description: "Create a delivery job. `customerId`, `deliveryJobNumber`, `pickupAddress`, `deliveryAddress` and `cargoItems` are required. `priority` defaults to MEDIUM and `status` to PENDING.",
1659
1636
  inputSchema: {
1660
- customerId: zod.z.string().min(1).describe("Ordering customer ID"),
1661
- orderNumber: zod.z.string().min(1).describe("Human-readable order number (unique)"),
1637
+ customerId: zod.z.string().min(1).describe("Customer the job is delivered for"),
1638
+ deliveryJobNumber: zod.z.string().min(1).describe("Human-readable delivery job number (unique in the workspace)"),
1662
1639
  pickupAddress: JsonObject.describe("Pickup address JSON"),
1663
1640
  deliveryAddress: JsonObject.describe("Delivery address JSON"),
1664
- items: JsonValue.describe("Order items JSON (array of line items)"),
1665
- orderType: OrderTypeEnum.optional().describe("Order type (default B2C)"),
1666
- priority: OrderPriorityEnum.optional().describe("Priority (default MEDIUM)"),
1667
- status: OrderStatusEnum.optional().describe("Initial status (default PENDING)"),
1641
+ cargoItems: JsonValue.describe(
1642
+ "Cargo carried by the job (JSON, usually an array of { cargoItemId or sku, quantity })"
1643
+ ),
1644
+ priority: DeliveryPriorityEnum.optional().describe("Priority (default MEDIUM)"),
1645
+ status: DeliveryJobStatusEnum.optional().describe("Initial status (default PENDING)"),
1668
1646
  driverId: zod.z.string().optional().describe("Assigned driver ID"),
1669
1647
  vehicleId: zod.z.string().optional().describe("Assigned vehicle ID"),
1648
+ routeId: zod.z.string().optional().describe("Route the job runs on"),
1649
+ storeOrderId: zod.z.string().optional().describe("Global-store order this job fulfils, when it came from checkout"),
1670
1650
  pricing: JsonObject.optional().describe("Pricing breakdown JSON"),
1671
- scheduledDelivery: zod.z.string().optional().describe("Scheduled delivery (ISO 8601 DateTime)"),
1651
+ scheduledDelivery: IsoDateTime.optional().describe(
1652
+ "Scheduled delivery (ISO 8601 date-time)"
1653
+ ),
1672
1654
  specialInstructions: zod.z.string().optional().describe("Special handling instructions"),
1673
1655
  trackingNumber: zod.z.string().optional().describe("Tracking number")
1674
1656
  }
1675
1657
  },
1676
1658
  async ({
1677
1659
  customerId,
1678
- orderNumber,
1660
+ deliveryJobNumber,
1679
1661
  pickupAddress,
1680
1662
  deliveryAddress,
1681
- items,
1682
- orderType,
1663
+ cargoItems,
1683
1664
  priority,
1684
1665
  status,
1685
1666
  driverId,
1686
1667
  vehicleId,
1668
+ routeId,
1669
+ storeOrderId,
1687
1670
  pricing,
1688
1671
  scheduledDelivery,
1689
1672
  specialInstructions,
@@ -1692,48 +1675,49 @@ function registerOrderTools(server, ctx, track) {
1692
1675
  try {
1693
1676
  const input = {
1694
1677
  customerId,
1695
- orderNumber,
1678
+ deliveryJobNumber,
1696
1679
  pickupAddress,
1697
1680
  deliveryAddress,
1698
- items
1681
+ cargoItems
1699
1682
  };
1700
- if (orderType !== void 0) input.orderType = orderType;
1701
1683
  if (priority !== void 0) input.priority = priority;
1702
1684
  if (status !== void 0) input.status = status;
1703
1685
  if (driverId !== void 0) input.driverId = driverId;
1704
1686
  if (vehicleId !== void 0) input.vehicleId = vehicleId;
1687
+ if (routeId !== void 0) input.routeId = routeId;
1688
+ if (storeOrderId !== void 0) input.storeOrderId = storeOrderId;
1705
1689
  if (pricing !== void 0) input.pricing = pricing;
1706
1690
  if (scheduledDelivery !== void 0) input.scheduledDelivery = scheduledDelivery;
1707
1691
  if (specialInstructions !== void 0) input.specialInstructions = specialInstructions;
1708
1692
  if (trackingNumber !== void 0) input.trackingNumber = trackingNumber;
1709
- const data = await ctx.gql.workspace.request(CREATE_ORDER, { input });
1710
- return jsonResult(data.createMovethewheelsOrder);
1693
+ const data = await ctx.gql.workspace.request(CREATE_DELIVERY_JOB, { input });
1694
+ return jsonResult(data.createDeliveryJob);
1711
1695
  } catch (error) {
1712
- ctx.logger.error("movethewheels orders_create failed", { error: String(error) });
1713
- return errorResult(
1714
- `Failed to create order: ${error instanceof Error ? error.message : String(error)}`
1715
- );
1696
+ ctx.logger.error("movethewheels delivery_jobs_create failed", { error: String(error) });
1697
+ return errorResult(`Failed to create delivery job: ${errorMessage(error)}`);
1716
1698
  }
1717
1699
  }
1718
1700
  );
1719
1701
  server.registerTool(
1720
- track(mcpToolName(ctx.productName, "orders_update")),
1702
+ track(mcpToolName(ctx.productName, "delivery_jobs_update")),
1721
1703
  {
1722
- title: "Update Order",
1723
- description: "Update a delivery order. At least one mutable field must be provided.",
1704
+ title: "Update Delivery Job",
1705
+ description: "Update a delivery job (assignment, addresses, cargo, schedule). At least one mutable field must be provided. Use delivery_jobs_update_status to move it through its lifecycle so the change is recorded in the status history.",
1724
1706
  inputSchema: {
1725
- id: zod.z.string().describe("Order ID"),
1707
+ id: zod.z.string().describe("Delivery job ID"),
1726
1708
  customerId: zod.z.string().optional().describe("Updated customer ID"),
1727
1709
  driverId: zod.z.string().optional().describe("Updated driver ID"),
1728
1710
  vehicleId: zod.z.string().optional().describe("Updated vehicle ID"),
1729
- orderType: OrderTypeEnum.optional().describe("Updated order type"),
1730
- priority: OrderPriorityEnum.optional().describe("Updated priority"),
1731
- status: OrderStatusEnum.optional().describe("Updated status"),
1711
+ routeId: zod.z.string().optional().describe("Updated route ID"),
1712
+ storeOrderId: zod.z.string().optional().describe("Updated global-store order ID"),
1713
+ priority: DeliveryPriorityEnum.optional().describe("Updated priority"),
1732
1714
  pickupAddress: JsonObject.optional().describe("Updated pickup address JSON"),
1733
1715
  deliveryAddress: JsonObject.optional().describe("Updated delivery address JSON"),
1734
- items: JsonValue.optional().describe("Updated items JSON"),
1716
+ cargoItems: JsonValue.optional().describe("Updated cargo JSON"),
1735
1717
  pricing: JsonObject.optional().describe("Updated pricing JSON"),
1736
- scheduledDelivery: zod.z.string().optional().describe("Updated scheduled delivery (ISO 8601)"),
1718
+ scheduledDelivery: IsoDateTime.optional().describe(
1719
+ "Updated scheduled delivery (ISO 8601 date-time)"
1720
+ ),
1737
1721
  specialInstructions: zod.z.string().optional().describe("Updated special instructions"),
1738
1722
  trackingNumber: zod.z.string().optional().describe("Updated tracking number")
1739
1723
  }
@@ -1743,12 +1727,12 @@ function registerOrderTools(server, ctx, track) {
1743
1727
  customerId,
1744
1728
  driverId,
1745
1729
  vehicleId,
1746
- orderType,
1730
+ routeId,
1731
+ storeOrderId,
1747
1732
  priority,
1748
- status,
1749
1733
  pickupAddress,
1750
1734
  deliveryAddress,
1751
- items,
1735
+ cargoItems,
1752
1736
  pricing,
1753
1737
  scheduledDelivery,
1754
1738
  specialInstructions,
@@ -1759,12 +1743,12 @@ function registerOrderTools(server, ctx, track) {
1759
1743
  if (customerId !== void 0) input.customerId = customerId;
1760
1744
  if (driverId !== void 0) input.driverId = driverId;
1761
1745
  if (vehicleId !== void 0) input.vehicleId = vehicleId;
1762
- if (orderType !== void 0) input.orderType = orderType;
1746
+ if (routeId !== void 0) input.routeId = routeId;
1747
+ if (storeOrderId !== void 0) input.storeOrderId = storeOrderId;
1763
1748
  if (priority !== void 0) input.priority = priority;
1764
- if (status !== void 0) input.status = status;
1765
1749
  if (pickupAddress !== void 0) input.pickupAddress = pickupAddress;
1766
1750
  if (deliveryAddress !== void 0) input.deliveryAddress = deliveryAddress;
1767
- if (items !== void 0) input.items = items;
1751
+ if (cargoItems !== void 0) input.cargoItems = cargoItems;
1768
1752
  if (pricing !== void 0) input.pricing = pricing;
1769
1753
  if (scheduledDelivery !== void 0) input.scheduledDelivery = scheduledDelivery;
1770
1754
  if (specialInstructions !== void 0) input.specialInstructions = specialInstructions;
@@ -1772,26 +1756,24 @@ function registerOrderTools(server, ctx, track) {
1772
1756
  if (Object.keys(input).length === 0) {
1773
1757
  return errorResult("No updates specified \u2014 provide at least one mutable field.");
1774
1758
  }
1775
- const data = await ctx.gql.workspace.request(UPDATE_ORDER, { id, input });
1776
- return jsonResult(data.updateMovethewheelsOrder);
1759
+ const data = await ctx.gql.workspace.request(UPDATE_DELIVERY_JOB, { id, input });
1760
+ return jsonResult(data.updateDeliveryJob);
1777
1761
  } catch (error) {
1778
- ctx.logger.error("movethewheels orders_update failed", { error: String(error) });
1779
- return errorResult(
1780
- `Failed to update order: ${error instanceof Error ? error.message : String(error)}`
1781
- );
1762
+ ctx.logger.error("movethewheels delivery_jobs_update failed", { error: String(error) });
1763
+ return errorResult(`Failed to update delivery job: ${errorMessage(error)}`);
1782
1764
  }
1783
1765
  }
1784
1766
  );
1785
1767
  server.registerTool(
1786
- track(mcpToolName(ctx.productName, "orders_update_status")),
1768
+ track(mcpToolName(ctx.productName, "delivery_jobs_update_status")),
1787
1769
  {
1788
- title: "Update Order Status",
1789
- description: "Advance an order through its delivery lifecycle (e.g. PENDING \u2192 CONFIRMED \u2192 ASSIGNED \u2192 PICKED_UP \u2192 IN_TRANSIT \u2192 OUT_FOR_DELIVERY \u2192 DELIVERED, or CANCELLED/FAILED/RETURNED). Records a status-history entry.",
1770
+ title: "Update Delivery Job Status",
1771
+ description: "Advance a delivery job through its lifecycle (PENDING \u2192 CONFIRMED \u2192 ASSIGNED \u2192 PICKED_UP \u2192 IN_TRANSIT \u2192 OUT_FOR_DELIVERY \u2192 DELIVERED, or CANCELLED / FAILED / RETURNED). Records a status-history entry.",
1790
1772
  inputSchema: {
1791
- id: zod.z.string().describe("Order ID"),
1792
- status: OrderStatusEnum.describe("New order status"),
1773
+ id: zod.z.string().describe("Delivery job ID"),
1774
+ status: DeliveryJobStatusEnum.describe("New delivery job status"),
1793
1775
  notes: zod.z.string().optional().describe("Status-change notes"),
1794
- location: JsonObject.optional().describe("Location JSON at time of status change")
1776
+ location: JsonObject.optional().describe("Location JSON at the time of the change")
1795
1777
  }
1796
1778
  },
1797
1779
  async ({ id, status, notes, location }) => {
@@ -1799,35 +1781,33 @@ function registerOrderTools(server, ctx, track) {
1799
1781
  const input = { status };
1800
1782
  if (notes !== void 0) input.notes = notes;
1801
1783
  if (location !== void 0) input.location = location;
1802
- const data = await ctx.gql.workspace.request(UPDATE_ORDER_STATUS, { id, input });
1803
- return jsonResult(data.updateMovethewheelsOrderStatus);
1784
+ const data = await ctx.gql.workspace.request(UPDATE_DELIVERY_JOB_STATUS, { id, input });
1785
+ return jsonResult(data.updateDeliveryJobStatus);
1804
1786
  } catch (error) {
1805
- ctx.logger.error("movethewheels orders_update_status failed", { error: String(error) });
1806
- return errorResult(
1807
- `Failed to update order status: ${error instanceof Error ? error.message : String(error)}`
1808
- );
1787
+ ctx.logger.error("movethewheels delivery_jobs_update_status failed", {
1788
+ error: String(error)
1789
+ });
1790
+ return errorResult(`Failed to update delivery job status: ${errorMessage(error)}`);
1809
1791
  }
1810
1792
  }
1811
1793
  );
1812
1794
  server.registerTool(
1813
- track(mcpToolName(ctx.productName, "orders_delete")),
1795
+ track(mcpToolName(ctx.productName, "delivery_jobs_delete")),
1814
1796
  {
1815
- title: "Delete Order",
1816
- description: "Soft-delete a delivery order by ID.",
1817
- inputSchema: { id: zod.z.string().describe("Order ID") }
1797
+ title: "Delete Delivery Job",
1798
+ description: "Soft-delete a delivery job by ID.",
1799
+ inputSchema: { id: zod.z.string().describe("Delivery job ID") }
1818
1800
  },
1819
1801
  async ({ id }) => {
1820
1802
  try {
1821
1803
  const data = await ctx.gql.workspace.request(
1822
- DELETE_ORDER,
1804
+ DELETE_DELIVERY_JOB,
1823
1805
  { id }
1824
1806
  );
1825
- return jsonResult({ deleted: data.deleteMovethewheelsOrder, id });
1807
+ return jsonResult({ deleted: data.deleteDeliveryJob, id });
1826
1808
  } catch (error) {
1827
- ctx.logger.error("movethewheels orders_delete failed", { error: String(error) });
1828
- return errorResult(
1829
- `Failed to delete order: ${error instanceof Error ? error.message : String(error)}`
1830
- );
1809
+ ctx.logger.error("movethewheels delivery_jobs_delete failed", { error: String(error) });
1810
+ return errorResult(`Failed to delete delivery job: ${errorMessage(error)}`);
1831
1811
  }
1832
1812
  }
1833
1813
  );
@@ -1837,7 +1817,7 @@ function registerShipmentTools(server, ctx, track) {
1837
1817
  track(mcpToolName(ctx.productName, "shipments_get")),
1838
1818
  {
1839
1819
  title: "Get Shipment",
1840
- description: "Fetch a single shipment by ID, including its linked order and tracking events.",
1820
+ description: "Fetch a single shipment by ID, including its delivery job, marketplace carrier and tracking events.",
1841
1821
  inputSchema: { id: zod.z.string().describe("Shipment ID") }
1842
1822
  },
1843
1823
  async ({ id }) => {
@@ -1857,24 +1837,38 @@ function registerShipmentTools(server, ctx, track) {
1857
1837
  track(mcpToolName(ctx.productName, "shipments_list")),
1858
1838
  {
1859
1839
  title: "List Shipments",
1860
- description: "List shipments with optional order/customer/carrier/status/text filters and pagination.",
1840
+ description: "List shipments with optional delivery-job/customer/carrier/driver/vehicle/status/text filters and pagination.",
1861
1841
  inputSchema: {
1862
1842
  search: zod.z.string().optional().describe("Free-text search across shipmentNumber"),
1863
- orderId: zod.z.string().optional().describe("Filter by order ID"),
1843
+ deliveryJobId: zod.z.string().optional().describe("Filter by delivery job ID"),
1864
1844
  customerId: zod.z.string().optional().describe("Filter by customer ID"),
1865
1845
  carrierId: zod.z.string().optional().describe("Filter by carrier ID"),
1846
+ driverId: zod.z.string().optional().describe("Filter by assigned driver ID"),
1847
+ vehicleId: zod.z.string().optional().describe("Filter by assigned vehicle ID"),
1866
1848
  status: ShipmentStatusEnum.optional().describe("Filter by shipment status"),
1867
1849
  limit: zod.z.number().int().optional().describe("Page size (default 50)"),
1868
1850
  offset: zod.z.number().int().optional().describe("Pagination offset (default 0)")
1869
1851
  }
1870
1852
  },
1871
- async ({ search, orderId, customerId, carrierId, status, limit, offset }) => {
1853
+ async ({
1854
+ search,
1855
+ deliveryJobId,
1856
+ customerId,
1857
+ carrierId,
1858
+ driverId,
1859
+ vehicleId,
1860
+ status,
1861
+ limit,
1862
+ offset
1863
+ }) => {
1872
1864
  try {
1873
1865
  const filter = {};
1874
1866
  if (search !== void 0) filter.search = search;
1875
- if (orderId !== void 0) filter.orderId = orderId;
1867
+ if (deliveryJobId !== void 0) filter.deliveryJobId = deliveryJobId;
1876
1868
  if (customerId !== void 0) filter.customerId = customerId;
1877
1869
  if (carrierId !== void 0) filter.carrierId = carrierId;
1870
+ if (driverId !== void 0) filter.driverId = driverId;
1871
+ if (vehicleId !== void 0) filter.vehicleId = vehicleId;
1878
1872
  if (status !== void 0) filter.status = status;
1879
1873
  const data = await ctx.gql.workspace.request(LIST_SHIPMENTS, {
1880
1874
  filter: Object.keys(filter).length > 0 ? filter : void 0,
@@ -1919,27 +1913,31 @@ function registerShipmentTools(server, ctx, track) {
1919
1913
  track(mcpToolName(ctx.productName, "shipments_create")),
1920
1914
  {
1921
1915
  title: "Create Shipment",
1922
- description: "Create a shipment for an order. `orderId`, `shipmentNumber`, `origin`, and `destination` are required. `status` defaults to PLANNED.",
1916
+ description: "Create a shipment. `shipmentNumber`, `origin`, and `destination` are required; link it to the delivery job it carries with `deliveryJobId`. `status` defaults to PLANNED.",
1923
1917
  inputSchema: {
1924
- orderId: zod.z.string().min(1).describe("Source order ID"),
1925
1918
  shipmentNumber: zod.z.string().min(1).describe("Human-readable shipment number (unique)"),
1926
1919
  origin: JsonObject.describe("Origin address JSON"),
1927
1920
  destination: JsonObject.describe("Destination address JSON"),
1928
1921
  status: ShipmentStatusEnum.optional().describe("Initial status (default PLANNED)"),
1922
+ deliveryJobId: zod.z.string().optional().describe("Delivery job this shipment carries"),
1923
+ storeOrderId: zod.z.string().optional().describe("Global-store order this shipment fulfils"),
1929
1924
  customerId: zod.z.string().optional().describe("Customer ID"),
1930
1925
  carrierId: zod.z.string().optional().describe("Carrier ID"),
1931
1926
  trackingNumber: zod.z.string().optional().describe("Carrier tracking number"),
1932
1927
  cargoDetails: JsonObject.optional().describe("Cargo details JSON"),
1933
- estimatedDelivery: zod.z.string().optional().describe("Estimated delivery (ISO 8601 DateTime)"),
1934
- actualDelivery: zod.z.string().optional().describe("Actual delivery (ISO 8601 DateTime)")
1928
+ estimatedDelivery: IsoDateTime.optional().describe(
1929
+ "Estimated delivery (ISO 8601 date-time)"
1930
+ ),
1931
+ actualDelivery: IsoDateTime.optional().describe("Actual delivery (ISO 8601 date-time)")
1935
1932
  }
1936
1933
  },
1937
1934
  async ({
1938
- orderId,
1939
1935
  shipmentNumber,
1940
1936
  origin,
1941
1937
  destination,
1942
1938
  status,
1939
+ deliveryJobId,
1940
+ storeOrderId,
1943
1941
  customerId,
1944
1942
  carrierId,
1945
1943
  trackingNumber,
@@ -1948,8 +1946,10 @@ function registerShipmentTools(server, ctx, track) {
1948
1946
  actualDelivery
1949
1947
  }) => {
1950
1948
  try {
1951
- const input = { orderId, shipmentNumber, origin, destination };
1949
+ const input = { shipmentNumber, origin, destination };
1952
1950
  if (status !== void 0) input.status = status;
1951
+ if (deliveryJobId !== void 0) input.deliveryJobId = deliveryJobId;
1952
+ if (storeOrderId !== void 0) input.storeOrderId = storeOrderId;
1953
1953
  if (customerId !== void 0) input.customerId = customerId;
1954
1954
  if (carrierId !== void 0) input.carrierId = carrierId;
1955
1955
  if (trackingNumber !== void 0) input.trackingNumber = trackingNumber;
@@ -1974,19 +1974,31 @@ function registerShipmentTools(server, ctx, track) {
1974
1974
  inputSchema: {
1975
1975
  id: zod.z.string().describe("Shipment ID"),
1976
1976
  status: ShipmentStatusEnum.optional().describe("Updated status"),
1977
+ statusReason: zod.z.string().optional().describe("Why the status changed (kept with the status decision)"),
1978
+ expectedStatusRevision: zod.z.number().int().min(0).optional().describe(
1979
+ "statusRevision you last read; the update is refused if the shipment changed since"
1980
+ ),
1981
+ deliveryJobId: zod.z.string().optional().describe("Updated delivery job ID"),
1977
1982
  customerId: zod.z.string().optional().describe("Updated customer ID"),
1978
1983
  carrierId: zod.z.string().optional().describe("Updated carrier ID"),
1979
1984
  origin: JsonObject.optional().describe("Updated origin JSON"),
1980
1985
  destination: JsonObject.optional().describe("Updated destination JSON"),
1981
1986
  trackingNumber: zod.z.string().optional().describe("Updated tracking number"),
1982
1987
  cargoDetails: JsonObject.optional().describe("Updated cargo details JSON"),
1983
- estimatedDelivery: zod.z.string().optional().describe("Updated estimated delivery (ISO 8601)"),
1984
- actualDelivery: zod.z.string().optional().describe("Updated actual delivery (ISO 8601)")
1988
+ estimatedDelivery: IsoDateTime.optional().describe(
1989
+ "Updated estimated delivery (ISO 8601 date-time)"
1990
+ ),
1991
+ actualDelivery: IsoDateTime.optional().describe(
1992
+ "Updated actual delivery (ISO 8601 date-time)"
1993
+ )
1985
1994
  }
1986
1995
  },
1987
1996
  async ({
1988
1997
  id,
1989
1998
  status,
1999
+ statusReason,
2000
+ expectedStatusRevision,
2001
+ deliveryJobId,
1990
2002
  customerId,
1991
2003
  carrierId,
1992
2004
  origin,
@@ -1999,6 +2011,11 @@ function registerShipmentTools(server, ctx, track) {
1999
2011
  try {
2000
2012
  const input = {};
2001
2013
  if (status !== void 0) input.status = status;
2014
+ if (statusReason !== void 0) input.statusReason = statusReason;
2015
+ if (expectedStatusRevision !== void 0) {
2016
+ input.expectedStatusRevision = expectedStatusRevision;
2017
+ }
2018
+ if (deliveryJobId !== void 0) input.deliveryJobId = deliveryJobId;
2002
2019
  if (customerId !== void 0) input.customerId = customerId;
2003
2020
  if (carrierId !== void 0) input.carrierId = carrierId;
2004
2021
  if (origin !== void 0) input.origin = origin;
@@ -2045,27 +2062,29 @@ function registerShipmentTools(server, ctx, track) {
2045
2062
  }
2046
2063
  function registerTrackingTools(server, ctx, track) {
2047
2064
  server.registerTool(
2048
- track(mcpToolName(ctx.productName, "tracking_order_events")),
2065
+ track(mcpToolName(ctx.productName, "tracking_delivery_job_events")),
2049
2066
  {
2050
- title: "Order Tracking Timeline",
2051
- description: "List tracking events for an order (across its shipments), most recent first.",
2067
+ title: "Delivery Job Tracking Timeline",
2068
+ description: "List tracking events for a delivery job (across its shipments), most recent first.",
2052
2069
  inputSchema: {
2053
- orderId: zod.z.string().describe("Order ID"),
2070
+ deliveryJobId: zod.z.string().describe("Delivery job ID"),
2054
2071
  limit: zod.z.number().int().optional().describe("Page size (default 50)"),
2055
2072
  offset: zod.z.number().int().optional().describe("Pagination offset (default 0)")
2056
2073
  }
2057
2074
  },
2058
- async ({ orderId, limit, offset }) => {
2075
+ async ({ deliveryJobId, limit, offset }) => {
2059
2076
  try {
2060
- const data = await ctx.gql.workspace.request(GET_ORDER_TRACKING, {
2061
- orderId,
2077
+ const data = await ctx.gql.workspace.request(GET_DELIVERY_JOB_TRACKING, {
2078
+ deliveryJobId,
2062
2079
  pagination: { limit: limit ?? 50, offset: offset ?? 0 }
2063
2080
  });
2064
- return jsonResult(data.orderTracking);
2081
+ return jsonResult(data.deliveryJobTracking);
2065
2082
  } catch (error) {
2066
- ctx.logger.error("movethewheels tracking_order_events failed", { error: String(error) });
2083
+ ctx.logger.error("movethewheels tracking_delivery_job_events failed", {
2084
+ error: String(error)
2085
+ });
2067
2086
  return errorResult(
2068
- `Failed to get order tracking: ${error instanceof Error ? error.message : String(error)}`
2087
+ `Failed to get delivery job tracking: ${error instanceof Error ? error.message : String(error)}`
2069
2088
  );
2070
2089
  }
2071
2090
  }
@@ -2100,7 +2119,7 @@ function registerTrackingTools(server, ctx, track) {
2100
2119
  track(mcpToolName(ctx.productName, "tracking_alerts")),
2101
2120
  {
2102
2121
  title: "Tracking Alerts",
2103
- description: "List active tracking alerts (delayed / exception shipments needing attention).",
2122
+ description: "List tracking alerts: DELAYED once a promised delivery has passed, AT_RISK when the forecast predicts the promise will be missed (with riskScore and signals).",
2104
2123
  inputSchema: {
2105
2124
  limit: zod.z.number().int().optional().describe("Page size (default 50)"),
2106
2125
  offset: zod.z.number().int().optional().describe("Pagination offset (default 0)")
@@ -2130,7 +2149,7 @@ function registerTrackingTools(server, ctx, track) {
2130
2149
  eventType: TrackingEventTypeEnum.describe("Type of tracking event"),
2131
2150
  details: zod.z.string().optional().describe("Free-text event details"),
2132
2151
  location: JsonObject.optional().describe("Location JSON ({ lat, lng, address })"),
2133
- timestamp: zod.z.string().optional().describe("Event timestamp (ISO 8601; defaults to now)")
2152
+ timestamp: IsoDateTime.optional().describe("Event timestamp (ISO 8601; defaults to now)")
2134
2153
  }
2135
2154
  },
2136
2155
  async ({ shipmentId, eventType, details, location, timestamp }) => {
@@ -2644,7 +2663,7 @@ function registerInventoryTools(server, ctx, track) {
2644
2663
  track(mcpToolName(ctx.productName, "inventory_get_item")),
2645
2664
  {
2646
2665
  title: "Get Inventory Item",
2647
- description: "Fetch a single inventory item by ID, including its product, warehouse, and location.",
2666
+ description: "Fetch a single inventory item by ID, including its cargo item, warehouse, and location.",
2648
2667
  inputSchema: { id: zod.z.string().describe("Inventory item ID") }
2649
2668
  },
2650
2669
  async ({ id }) => {
@@ -2664,23 +2683,25 @@ function registerInventoryTools(server, ctx, track) {
2664
2683
  track(mcpToolName(ctx.productName, "inventory_list_items")),
2665
2684
  {
2666
2685
  title: "List Inventory Items",
2667
- description: "List inventory items with optional product/warehouse/location/text filters and pagination.",
2686
+ description: "List inventory items with optional cargo-item/warehouse/location/text filters and pagination. Set `lowStock` to true to list only items at or below their reorder point.",
2668
2687
  inputSchema: {
2669
2688
  search: zod.z.string().optional().describe("Free-text search"),
2670
- productId: zod.z.string().optional().describe("Filter by product ID"),
2689
+ cargoItemId: zod.z.string().optional().describe("Filter by cargo item ID"),
2671
2690
  warehouseId: zod.z.string().optional().describe("Filter by warehouse ID"),
2672
2691
  locationId: zod.z.string().optional().describe("Filter by location ID"),
2692
+ lowStock: zod.z.boolean().optional().describe("Only items at or below their reorder point"),
2673
2693
  limit: zod.z.number().int().optional().describe("Page size (default 50)"),
2674
2694
  offset: zod.z.number().int().optional().describe("Pagination offset (default 0)")
2675
2695
  }
2676
2696
  },
2677
- async ({ search, productId, warehouseId, locationId, limit, offset }) => {
2697
+ async ({ search, cargoItemId, warehouseId, locationId, lowStock, limit, offset }) => {
2678
2698
  try {
2679
2699
  const filter = {};
2680
2700
  if (search !== void 0) filter.search = search;
2681
- if (productId !== void 0) filter.productId = productId;
2701
+ if (cargoItemId !== void 0) filter.cargoItemId = cargoItemId;
2682
2702
  if (warehouseId !== void 0) filter.warehouseId = warehouseId;
2683
2703
  if (locationId !== void 0) filter.locationId = locationId;
2704
+ if (lowStock !== void 0) filter.lowStock = lowStock;
2684
2705
  const data = await ctx.gql.workspace.request(LIST_INVENTORY_ITEMS, {
2685
2706
  filter: Object.keys(filter).length > 0 ? filter : void 0,
2686
2707
  pagination: { limit: limit ?? 50, offset: offset ?? 0 }
@@ -2717,23 +2738,25 @@ function registerInventoryTools(server, ctx, track) {
2717
2738
  track(mcpToolName(ctx.productName, "inventory_list_transactions")),
2718
2739
  {
2719
2740
  title: "List Inventory Transactions",
2720
- description: "List inventory ledger transactions (receipts/issues/transfers/adjustments/returns) with optional product/warehouse/location/text filters.",
2741
+ description: "List inventory ledger transactions (receipts/issues/transfers/adjustments/returns) with optional cargo-item/warehouse/location/inventory-item/text filters.",
2721
2742
  inputSchema: {
2722
2743
  search: zod.z.string().optional().describe("Free-text search"),
2723
- productId: zod.z.string().optional().describe("Filter by product ID"),
2744
+ cargoItemId: zod.z.string().optional().describe("Filter by cargo item ID"),
2724
2745
  warehouseId: zod.z.string().optional().describe("Filter by warehouse ID"),
2725
2746
  locationId: zod.z.string().optional().describe("Filter by location ID"),
2747
+ inventoryItemId: zod.z.string().optional().describe("Filter by inventory item ID"),
2726
2748
  limit: zod.z.number().int().optional().describe("Page size (default 50)"),
2727
2749
  offset: zod.z.number().int().optional().describe("Pagination offset (default 0)")
2728
2750
  }
2729
2751
  },
2730
- async ({ search, productId, warehouseId, locationId, limit, offset }) => {
2752
+ async ({ search, cargoItemId, warehouseId, locationId, inventoryItemId, limit, offset }) => {
2731
2753
  try {
2732
2754
  const filter = {};
2733
2755
  if (search !== void 0) filter.search = search;
2734
- if (productId !== void 0) filter.productId = productId;
2756
+ if (cargoItemId !== void 0) filter.cargoItemId = cargoItemId;
2735
2757
  if (warehouseId !== void 0) filter.warehouseId = warehouseId;
2736
2758
  if (locationId !== void 0) filter.locationId = locationId;
2759
+ if (inventoryItemId !== void 0) filter.inventoryItemId = inventoryItemId;
2737
2760
  const data = await ctx.gql.workspace.request(LIST_INVENTORY_TRANSACTIONS, {
2738
2761
  filter: Object.keys(filter).length > 0 ? filter : void 0,
2739
2762
  pagination: { limit: limit ?? 50, offset: offset ?? 0 }
@@ -2753,22 +2776,22 @@ function registerInventoryTools(server, ctx, track) {
2753
2776
  track(mcpToolName(ctx.productName, "inventory_create_item")),
2754
2777
  {
2755
2778
  title: "Create Inventory Item",
2756
- description: "Create an inventory item for a product at a warehouse. `productId` and `warehouseId` are required; stock counts default to 0.",
2779
+ description: "Create an inventory item for a cargo item at a warehouse. `cargoItemId` and `warehouseId` are required; stock counts default to 0 and must satisfy available + allocated + damaged = onHand.",
2757
2780
  inputSchema: {
2758
- productId: zod.z.string().min(1).describe("Product ID"),
2781
+ cargoItemId: zod.z.string().min(1).describe("Cargo item ID"),
2759
2782
  warehouseId: zod.z.string().min(1).describe("Warehouse ID"),
2760
2783
  locationId: zod.z.string().optional().describe("Storage location ID"),
2761
- onHand: zod.z.number().int().optional().describe("On-hand quantity (default 0)"),
2762
- available: zod.z.number().int().optional().describe("Available quantity (default 0)"),
2763
- allocated: zod.z.number().int().optional().describe("Allocated quantity (default 0)"),
2764
- damaged: zod.z.number().int().optional().describe("Damaged quantity (default 0)"),
2765
- reorderPoint: zod.z.number().int().optional().describe("Reorder point"),
2766
- safetyStock: zod.z.number().int().optional().describe("Safety stock"),
2767
- unitCost: zod.z.number().optional().describe("Unit cost")
2784
+ onHand: StockQuantity.optional().describe("On-hand quantity (default 0)"),
2785
+ available: StockQuantity.optional().describe("Available quantity (default 0)"),
2786
+ allocated: StockQuantity.optional().describe("Allocated quantity (default 0)"),
2787
+ damaged: StockQuantity.optional().describe("Damaged quantity (default 0)"),
2788
+ reorderPoint: StockQuantity.optional().describe("Reorder point"),
2789
+ safetyStock: StockQuantity.optional().describe("Safety stock"),
2790
+ unitCost: zod.z.number().nonnegative().optional().describe("Unit cost")
2768
2791
  }
2769
2792
  },
2770
2793
  async ({
2771
- productId,
2794
+ cargoItemId,
2772
2795
  warehouseId,
2773
2796
  locationId,
2774
2797
  onHand,
@@ -2780,7 +2803,7 @@ function registerInventoryTools(server, ctx, track) {
2780
2803
  unitCost
2781
2804
  }) => {
2782
2805
  try {
2783
- const input = { productId, warehouseId };
2806
+ const input = { cargoItemId, warehouseId };
2784
2807
  if (locationId !== void 0) input.locationId = locationId;
2785
2808
  if (onHand !== void 0) input.onHand = onHand;
2786
2809
  if (available !== void 0) input.available = available;
@@ -2789,6 +2812,17 @@ function registerInventoryTools(server, ctx, track) {
2789
2812
  if (reorderPoint !== void 0) input.reorderPoint = reorderPoint;
2790
2813
  if (safetyStock !== void 0) input.safetyStock = safetyStock;
2791
2814
  if (unitCost !== void 0) input.unitCost = unitCost;
2815
+ const counts = {
2816
+ onHand: onHand ?? 0,
2817
+ available: available ?? 0,
2818
+ allocated: allocated ?? 0,
2819
+ damaged: damaged ?? 0
2820
+ };
2821
+ if (counts.available + counts.allocated + counts.damaged !== counts.onHand) {
2822
+ return errorResult(
2823
+ `Stock counts do not balance: available (${counts.available}) + allocated (${counts.allocated}) + damaged (${counts.damaged}) must equal onHand (${counts.onHand}).`
2824
+ );
2825
+ }
2792
2826
  const data = await ctx.gql.workspace.request(CREATE_INVENTORY_ITEM, { input });
2793
2827
  return jsonResult(data.createInventoryItem);
2794
2828
  } catch (error) {
@@ -2803,17 +2837,17 @@ function registerInventoryTools(server, ctx, track) {
2803
2837
  track(mcpToolName(ctx.productName, "inventory_update_item")),
2804
2838
  {
2805
2839
  title: "Update Inventory Item",
2806
- description: "Update an inventory item. At least one mutable field must be provided.",
2840
+ description: "Update an inventory item. At least one mutable field must be provided. Counts left out keep their current value, and the result must satisfy available + allocated + damaged = onHand. A stocked line cannot be moved to another location; use inventory_transfer_stock.",
2807
2841
  inputSchema: {
2808
2842
  id: zod.z.string().describe("Inventory item ID"),
2809
2843
  locationId: zod.z.string().optional().describe("Updated location ID"),
2810
- onHand: zod.z.number().int().optional().describe("Updated on-hand quantity"),
2811
- available: zod.z.number().int().optional().describe("Updated available quantity"),
2812
- allocated: zod.z.number().int().optional().describe("Updated allocated quantity"),
2813
- damaged: zod.z.number().int().optional().describe("Updated damaged quantity"),
2814
- reorderPoint: zod.z.number().int().optional().describe("Updated reorder point"),
2815
- safetyStock: zod.z.number().int().optional().describe("Updated safety stock"),
2816
- unitCost: zod.z.number().optional().describe("Updated unit cost")
2844
+ onHand: StockQuantity.optional().describe("Updated on-hand quantity"),
2845
+ available: StockQuantity.optional().describe("Updated available quantity"),
2846
+ allocated: StockQuantity.optional().describe("Updated allocated quantity"),
2847
+ damaged: StockQuantity.optional().describe("Updated damaged quantity"),
2848
+ reorderPoint: StockQuantity.optional().describe("Updated reorder point"),
2849
+ safetyStock: StockQuantity.optional().describe("Updated safety stock"),
2850
+ unitCost: zod.z.number().nonnegative().optional().describe("Updated unit cost")
2817
2851
  }
2818
2852
  },
2819
2853
  async ({
@@ -2854,13 +2888,13 @@ function registerInventoryTools(server, ctx, track) {
2854
2888
  track(mcpToolName(ctx.productName, "inventory_adjust_stock")),
2855
2889
  {
2856
2890
  title: "Adjust Inventory Stock",
2857
- description: "Directly set one or more stock counts (onHand/available/allocated/damaged) for an inventory item. Provide the item id and at least one count.",
2891
+ description: "Directly set one or more stock counts (onHand/available/allocated/damaged) for an inventory item. Provide the item id and at least one count; counts left out keep their current value, and the result must satisfy available + allocated + damaged = onHand. The change is written to the inventory ledger as an ADJUSTMENT.",
2858
2892
  inputSchema: {
2859
2893
  id: zod.z.string().describe("Inventory item ID"),
2860
- onHand: zod.z.number().int().optional().describe("New on-hand quantity"),
2861
- available: zod.z.number().int().optional().describe("New available quantity"),
2862
- allocated: zod.z.number().int().optional().describe("New allocated quantity"),
2863
- damaged: zod.z.number().int().optional().describe("New damaged quantity")
2894
+ onHand: StockQuantity.optional().describe("New on-hand quantity"),
2895
+ available: StockQuantity.optional().describe("New available quantity"),
2896
+ allocated: StockQuantity.optional().describe("New allocated quantity"),
2897
+ damaged: StockQuantity.optional().describe("New damaged quantity")
2864
2898
  }
2865
2899
  },
2866
2900
  async ({ id, onHand, available, allocated, damaged }) => {
@@ -2885,20 +2919,50 @@ function registerInventoryTools(server, ctx, track) {
2885
2919
  }
2886
2920
  }
2887
2921
  );
2922
+ server.registerTool(
2923
+ track(mcpToolName(ctx.productName, "inventory_transfer_stock")),
2924
+ {
2925
+ title: "Transfer Inventory Stock",
2926
+ description: "Move available stock from one inventory item to another of the same cargo item (for example between warehouses or bins). Both sides are updated atomically and the move is recorded as a TRANSFER pair in the ledger. Fails if the source does not have enough available stock.",
2927
+ inputSchema: {
2928
+ sourceInventoryItemId: zod.z.string().min(1).describe("Inventory item to take stock from"),
2929
+ destinationInventoryItemId: zod.z.string().min(1).describe("Inventory item to add stock to"),
2930
+ quantity: zod.z.number().int().min(1).max(2147483647).describe("Units to move (taken from the source available count)")
2931
+ }
2932
+ },
2933
+ async ({ sourceInventoryItemId, destinationInventoryItemId, quantity }) => {
2934
+ if (sourceInventoryItemId === destinationInventoryItemId) {
2935
+ return errorResult("Source and destination inventory items must be different.");
2936
+ }
2937
+ try {
2938
+ const data = await ctx.gql.workspace.request(TRANSFER_INVENTORY_STOCK, {
2939
+ input: { sourceInventoryItemId, destinationInventoryItemId, quantity }
2940
+ });
2941
+ return jsonResult(data.transferInventoryStock);
2942
+ } catch (error) {
2943
+ ctx.logger.error("movethewheels inventory_transfer_stock failed", {
2944
+ error: String(error)
2945
+ });
2946
+ return errorResult(
2947
+ `Failed to transfer inventory stock: ${error instanceof Error ? error.message : String(error)}`
2948
+ );
2949
+ }
2950
+ }
2951
+ );
2888
2952
  server.registerTool(
2889
2953
  track(mcpToolName(ctx.productName, "inventory_create_transaction")),
2890
2954
  {
2891
2955
  title: "Create Inventory Transaction",
2892
- description: "Record an inventory ledger transaction (RECEIPT/ISSUE/TRANSFER/ADJUSTMENT/RETURN). `transactionNumber`, `type`, `productId`, `warehouseId`, and `quantity` are required.",
2956
+ description: "Record an inventory ledger transaction (RECEIPT/ISSUE/TRANSFER/ADJUSTMENT/RETURN). `transactionNumber`, `type`, `cargoItemId`, `warehouseId`, and `quantity` are required.",
2893
2957
  inputSchema: {
2894
2958
  transactionNumber: zod.z.string().min(1).describe("Transaction number (unique)"),
2895
2959
  type: InventoryTransactionTypeEnum.describe("Transaction type"),
2896
- productId: zod.z.string().min(1).describe("Product ID"),
2960
+ cargoItemId: zod.z.string().min(1).describe("Cargo item ID"),
2897
2961
  warehouseId: zod.z.string().min(1).describe("Warehouse ID"),
2898
2962
  quantity: zod.z.number().int().describe("Quantity moved (sign per transaction semantics)"),
2899
2963
  inventoryItemId: zod.z.string().optional().describe("Affected inventory item ID"),
2900
- unitCost: zod.z.number().optional().describe("Unit cost"),
2901
- referenceType: zod.z.string().optional().describe('Reference type, e.g. "order", "shipment"'),
2964
+ unitCost: zod.z.number().nonnegative().optional().describe("Unit cost"),
2965
+ referenceType: zod.z.string().optional().describe('Reference type, e.g. "delivery_job", "shipment"'),
2902
2966
  referenceId: zod.z.string().optional().describe("Reference ID"),
2903
2967
  notes: zod.z.string().optional().describe("Notes")
2904
2968
  }
@@ -2906,7 +2970,7 @@ function registerInventoryTools(server, ctx, track) {
2906
2970
  async ({
2907
2971
  transactionNumber,
2908
2972
  type,
2909
- productId,
2973
+ cargoItemId,
2910
2974
  warehouseId,
2911
2975
  quantity,
2912
2976
  inventoryItemId,
@@ -2919,7 +2983,7 @@ function registerInventoryTools(server, ctx, track) {
2919
2983
  const input = {
2920
2984
  transactionNumber,
2921
2985
  type,
2922
- productId,
2986
+ cargoItemId,
2923
2987
  warehouseId,
2924
2988
  quantity
2925
2989
  };
@@ -3262,260 +3326,6 @@ function registerMarketplaceTools(server, ctx, track) {
3262
3326
  }
3263
3327
  );
3264
3328
  }
3265
- function registerReportTools(server, ctx, track) {
3266
- server.registerTool(
3267
- track(mcpToolName(ctx.productName, "reports_get")),
3268
- {
3269
- title: "Get Report",
3270
- description: "Fetch a single report definition by ID.",
3271
- inputSchema: { id: zod.z.string().describe("Report ID") }
3272
- },
3273
- async ({ id }) => {
3274
- try {
3275
- const data = await ctx.gql.workspace.request(GET_REPORT, { id });
3276
- if (!data.movethewheelsReport) return errorResult(`Report ${id} not found`);
3277
- return jsonResult(data.movethewheelsReport);
3278
- } catch (error) {
3279
- ctx.logger.error("movethewheels reports_get failed", { error: String(error) });
3280
- return errorResult(
3281
- `Failed to get report: ${error instanceof Error ? error.message : String(error)}`
3282
- );
3283
- }
3284
- }
3285
- );
3286
- server.registerTool(
3287
- track(mcpToolName(ctx.productName, "reports_list")),
3288
- {
3289
- title: "List Reports",
3290
- description: "List report definitions with optional type/status/text filters and pagination.",
3291
- inputSchema: {
3292
- search: zod.z.string().optional().describe("Free-text search across name"),
3293
- type: zod.z.string().optional().describe("Filter by report type"),
3294
- status: zod.z.string().optional().describe('Filter by status, e.g. "DRAFT", "ACTIVE"'),
3295
- limit: zod.z.number().int().optional().describe("Page size (default 50)"),
3296
- offset: zod.z.number().int().optional().describe("Pagination offset (default 0)")
3297
- }
3298
- },
3299
- async ({ search, type, status, limit, offset }) => {
3300
- try {
3301
- const filter = {};
3302
- if (search !== void 0) filter.search = search;
3303
- if (type !== void 0) filter.type = type;
3304
- if (status !== void 0) filter.status = status;
3305
- const data = await ctx.gql.workspace.request(LIST_REPORTS, {
3306
- filter: Object.keys(filter).length > 0 ? filter : void 0,
3307
- pagination: { limit: limit ?? 50, offset: offset ?? 0 }
3308
- });
3309
- return jsonResult(data.movethewheelsReports);
3310
- } catch (error) {
3311
- ctx.logger.error("movethewheels reports_list failed", { error: String(error) });
3312
- return errorResult(
3313
- `Failed to list reports: ${error instanceof Error ? error.message : String(error)}`
3314
- );
3315
- }
3316
- }
3317
- );
3318
- server.registerTool(
3319
- track(mcpToolName(ctx.productName, "reports_create")),
3320
- {
3321
- title: "Create Report",
3322
- description: 'Create a report definition. `name` and `type` are required; `status` defaults to "DRAFT".',
3323
- inputSchema: {
3324
- name: zod.z.string().min(1).describe("Report name"),
3325
- type: zod.z.string().min(1).describe("Report type"),
3326
- status: zod.z.string().optional().describe('Status (default "DRAFT")'),
3327
- description: zod.z.string().optional().describe("Description"),
3328
- configuration: JsonObject.optional().describe("Report configuration JSON"),
3329
- schedule: zod.z.string().optional().describe("Schedule (e.g. cron string)")
3330
- }
3331
- },
3332
- async ({ name, type, status, description, configuration, schedule }) => {
3333
- try {
3334
- const input = { name, type };
3335
- if (status !== void 0) input.status = status;
3336
- if (description !== void 0) input.description = description;
3337
- if (configuration !== void 0) input.configuration = configuration;
3338
- if (schedule !== void 0) input.schedule = schedule;
3339
- const data = await ctx.gql.workspace.request(CREATE_REPORT, { input });
3340
- return jsonResult(data.createMovethewheelsReport);
3341
- } catch (error) {
3342
- ctx.logger.error("movethewheels reports_create failed", { error: String(error) });
3343
- return errorResult(
3344
- `Failed to create report: ${error instanceof Error ? error.message : String(error)}`
3345
- );
3346
- }
3347
- }
3348
- );
3349
- server.registerTool(
3350
- track(mcpToolName(ctx.productName, "reports_update")),
3351
- {
3352
- title: "Update Report",
3353
- description: "Update a report definition. At least one mutable field must be provided.",
3354
- inputSchema: {
3355
- id: zod.z.string().describe("Report ID"),
3356
- name: zod.z.string().optional().describe("Updated name"),
3357
- type: zod.z.string().optional().describe("Updated type"),
3358
- status: zod.z.string().optional().describe("Updated status"),
3359
- description: zod.z.string().optional().describe("Updated description"),
3360
- configuration: JsonObject.optional().describe("Updated configuration JSON"),
3361
- schedule: zod.z.string().optional().describe("Updated schedule")
3362
- }
3363
- },
3364
- async ({ id, name, type, status, description, configuration, schedule }) => {
3365
- try {
3366
- const input = {};
3367
- if (name !== void 0) input.name = name;
3368
- if (type !== void 0) input.type = type;
3369
- if (status !== void 0) input.status = status;
3370
- if (description !== void 0) input.description = description;
3371
- if (configuration !== void 0) input.configuration = configuration;
3372
- if (schedule !== void 0) input.schedule = schedule;
3373
- if (Object.keys(input).length === 0) {
3374
- return errorResult("No updates specified \u2014 provide at least one mutable field.");
3375
- }
3376
- const data = await ctx.gql.workspace.request(UPDATE_REPORT, { id, input });
3377
- return jsonResult(data.updateMovethewheelsReport);
3378
- } catch (error) {
3379
- ctx.logger.error("movethewheels reports_update failed", { error: String(error) });
3380
- return errorResult(
3381
- `Failed to update report: ${error instanceof Error ? error.message : String(error)}`
3382
- );
3383
- }
3384
- }
3385
- );
3386
- server.registerTool(
3387
- track(mcpToolName(ctx.productName, "reports_generate")),
3388
- {
3389
- title: "Generate Report",
3390
- description: "Run a report definition and return the generated result payload.",
3391
- inputSchema: {
3392
- reportId: zod.z.string().describe("Report ID to generate"),
3393
- parameters: JsonObject.optional().describe("Runtime parameters JSON")
3394
- }
3395
- },
3396
- async ({ reportId, parameters }) => {
3397
- try {
3398
- const input = { reportId };
3399
- if (parameters !== void 0) input.parameters = parameters;
3400
- const data = await ctx.gql.workspace.request(GENERATE_REPORT, { input });
3401
- return jsonResult(data.generateMovethewheelsReport);
3402
- } catch (error) {
3403
- ctx.logger.error("movethewheels reports_generate failed", { error: String(error) });
3404
- return errorResult(
3405
- `Failed to generate report: ${error instanceof Error ? error.message : String(error)}`
3406
- );
3407
- }
3408
- }
3409
- );
3410
- server.registerTool(
3411
- track(mcpToolName(ctx.productName, "reports_delete")),
3412
- {
3413
- title: "Delete Report",
3414
- description: "Soft-delete a report definition by ID.",
3415
- inputSchema: { id: zod.z.string().describe("Report ID") }
3416
- },
3417
- async ({ id }) => {
3418
- try {
3419
- const data = await ctx.gql.workspace.request(
3420
- DELETE_REPORT,
3421
- { id }
3422
- );
3423
- return jsonResult({ deleted: data.deleteMovethewheelsReport, id });
3424
- } catch (error) {
3425
- ctx.logger.error("movethewheels reports_delete failed", { error: String(error) });
3426
- return errorResult(
3427
- `Failed to delete report: ${error instanceof Error ? error.message : String(error)}`
3428
- );
3429
- }
3430
- }
3431
- );
3432
- server.registerTool(
3433
- track(mcpToolName(ctx.productName, "settings_get")),
3434
- {
3435
- title: "Get Module Settings",
3436
- description: "Fetch the Movethewheels module settings (preferences) for the bound workspace.",
3437
- inputSchema: {}
3438
- },
3439
- async () => {
3440
- try {
3441
- const data = await ctx.gql.workspace.request(GET_MODULE_SETTINGS, {});
3442
- return jsonResult(data.moduleSettings);
3443
- } catch (error) {
3444
- ctx.logger.error("movethewheels settings_get failed", { error: String(error) });
3445
- return errorResult(
3446
- `Failed to get module settings: ${error instanceof Error ? error.message : String(error)}`
3447
- );
3448
- }
3449
- }
3450
- );
3451
- server.registerTool(
3452
- track(mcpToolName(ctx.productName, "settings_update")),
3453
- {
3454
- title: "Update Module Settings",
3455
- description: "Replace the Movethewheels module preferences JSON for the bound workspace.",
3456
- inputSchema: {
3457
- preferences: JsonObject.describe("Module preferences JSON (full replacement)")
3458
- }
3459
- },
3460
- async ({ preferences }) => {
3461
- try {
3462
- const data = await ctx.gql.workspace.request(UPDATE_MODULE_SETTINGS, { input: { preferences } });
3463
- return jsonResult(data.updateModuleSettings);
3464
- } catch (error) {
3465
- ctx.logger.error("movethewheels settings_update failed", { error: String(error) });
3466
- return errorResult(
3467
- `Failed to update module settings: ${error instanceof Error ? error.message : String(error)}`
3468
- );
3469
- }
3470
- }
3471
- );
3472
- server.registerTool(
3473
- track(mcpToolName(ctx.productName, "data_export")),
3474
- {
3475
- title: "Export Data",
3476
- description: 'Export a Movethewheels resource (e.g. "orders", "shipments", "inventory") as a payload. `format` defaults to "json".',
3477
- inputSchema: {
3478
- resource: zod.z.string().min(1).describe('Resource to export, e.g. "orders"'),
3479
- format: zod.z.string().optional().describe('Export format (default "json")')
3480
- }
3481
- },
3482
- async ({ resource, format }) => {
3483
- try {
3484
- const input = { resource };
3485
- if (format !== void 0) input.format = format;
3486
- const data = await ctx.gql.workspace.request(EXPORT_DATA, { input });
3487
- return jsonResult(data.exportData);
3488
- } catch (error) {
3489
- ctx.logger.error("movethewheels data_export failed", { error: String(error) });
3490
- return errorResult(
3491
- `Failed to export data: ${error instanceof Error ? error.message : String(error)}`
3492
- );
3493
- }
3494
- }
3495
- );
3496
- server.registerTool(
3497
- track(mcpToolName(ctx.productName, "data_import")),
3498
- {
3499
- title: "Import Data",
3500
- description: 'Import a payload into a Movethewheels resource (e.g. "orders", "customers"). `resource` and `payload` are required.',
3501
- inputSchema: {
3502
- resource: zod.z.string().min(1).describe('Resource to import into, e.g. "customers"'),
3503
- payload: JsonObject.describe("Payload JSON to import")
3504
- }
3505
- },
3506
- async ({ resource, payload }) => {
3507
- try {
3508
- const data = await ctx.gql.workspace.request(IMPORT_DATA, { input: { resource, payload } });
3509
- return jsonResult(data.importData);
3510
- } catch (error) {
3511
- ctx.logger.error("movethewheels data_import failed", { error: String(error) });
3512
- return errorResult(
3513
- `Failed to import data: ${error instanceof Error ? error.message : String(error)}`
3514
- );
3515
- }
3516
- }
3517
- );
3518
- }
3519
3329
 
3520
3330
  // src/modules/movethewheels/tools/analytics.ts
3521
3331
  function registerAnalyticsTools(server, ctx, track) {
@@ -3523,7 +3333,7 @@ function registerAnalyticsTools(server, ctx, track) {
3523
3333
  track(mcpToolName(ctx.productName, "analytics_series")),
3524
3334
  {
3525
3335
  title: "Analytics Time Series",
3526
- description: "Time-series trends for orders, deliveries, and revenue.",
3336
+ description: "Time-series trends for delivery jobs (orderTrend), deliveries, and revenue.",
3527
3337
  inputSchema: {}
3528
3338
  },
3529
3339
  async () => {
@@ -3542,7 +3352,7 @@ function registerAnalyticsTools(server, ctx, track) {
3542
3352
  track(mcpToolName(ctx.productName, "analytics_dashboard")),
3543
3353
  {
3544
3354
  title: "Dashboard Metrics",
3545
- description: "Headline operations KPIs: total orders, active deliveries, active vehicles, available drivers, low-stock items, total revenue, and recent orders.",
3355
+ description: "Headline operations KPIs: total delivery jobs, active deliveries, active vehicles, available drivers, low-stock items, total revenue, on-time delivery rate, customer satisfaction, and the most recent delivery jobs.",
3546
3356
  inputSchema: {}
3547
3357
  },
3548
3358
  async () => {
@@ -3558,20 +3368,22 @@ function registerAnalyticsTools(server, ctx, track) {
3558
3368
  }
3559
3369
  );
3560
3370
  server.registerTool(
3561
- track(mcpToolName(ctx.productName, "analytics_order_stats")),
3371
+ track(mcpToolName(ctx.productName, "analytics_delivery_job_stats")),
3562
3372
  {
3563
- title: "Order Stats",
3564
- description: "Order counts by lifecycle bucket: total, pending, in-transit, delivered, cancelled, failed.",
3373
+ title: "Delivery Job Stats",
3374
+ description: "Delivery job counts by lifecycle status: total, pending, confirmed, assigned, picked up, in transit, out for delivery, delivered, cancelled, failed, returned.",
3565
3375
  inputSchema: {}
3566
3376
  },
3567
3377
  async () => {
3568
3378
  try {
3569
- const data = await ctx.gql.workspace.request(GET_ORDER_STATS, {});
3570
- return jsonResult(data.orderStats);
3379
+ const data = await ctx.gql.workspace.request(GET_DELIVERY_JOB_STATS, {});
3380
+ return jsonResult(data.deliveryJobStats);
3571
3381
  } catch (error) {
3572
- ctx.logger.error("movethewheels analytics_order_stats failed", { error: String(error) });
3382
+ ctx.logger.error("movethewheels analytics_delivery_job_stats failed", {
3383
+ error: String(error)
3384
+ });
3573
3385
  return errorResult(
3574
- `Failed to get order stats: ${error instanceof Error ? error.message : String(error)}`
3386
+ `Failed to get delivery job stats: ${error instanceof Error ? error.message : String(error)}`
3575
3387
  );
3576
3388
  }
3577
3389
  }
@@ -3640,32 +3452,38 @@ Logistics / fleet / warehouse / last-mile-delivery operations platform.
3640
3452
  - Customer \u2014 shipper/consignee (B2B/B2C)
3641
3453
  - Driver \u2014 fleet driver (status, license, telemetry)
3642
3454
  - Vehicle \u2014 fleet vehicle (type, status, capacity, location)
3643
- - Product \u2014 cargo SKU master (weight, dimensions, hazardous/fragile/temp)
3644
- - MovethewheelsOrder (+OrderStatusHistory) \u2014 delivery order + status timeline
3645
- - Shipment (+TrackingEvent) \u2014 freight shipment + tracking timeline
3455
+ - CargoItem \u2014 cargo SKU master (weight, dimensions, hazardous/fragile/temp).
3456
+ Not a sellable product: storefront SKUs live in global-store-svc.
3457
+ - DeliveryJob (+DeliveryJobStatusHistory) \u2014 the dispatch unit (pickup,
3458
+ delivery, cargo, driver/vehicle/route) + status timeline. Not a checkout
3459
+ order: the order of record is a global-store StoreOrder (storeOrderId).
3460
+ - Shipment (+TrackingEvent) \u2014 freight shipment for a delivery job + tracking
3461
+ timeline; carrierId may point at a marketplace ServiceProvider
3646
3462
  - Route \u2014 planned/optimized delivery route
3647
3463
  - Warehouse (+WarehouseLocation) \u2014 facilities + storage locations
3648
3464
  - InventoryItem (+InventoryTransaction) \u2014 stock at a warehouse + ledger
3649
3465
  - ServiceProvider (+ServiceOffering) \u2014 3PL marketplace providers + offerings
3650
- - MovethewheelsReport \u2014 report definitions
3651
3466
 
3652
3467
  ## Enums
3653
3468
  - DriverStatus: AVAILABLE, INACTIVE, OFF_DUTY, ON_BREAK, ON_DELIVERY
3654
3469
  - VehicleStatus: ACTIVE, DECOMMISSIONED, INACTIVE, IN_TRANSIT, MAINTENANCE
3655
3470
  - VehicleType: BICYCLE, DRONE, FLATBED, MOTORCYCLE, REFRIGERATED, SEMI_TRAILER, TRUCK, VAN
3656
- - OrderType: B2B, B2C, MARKETPLACE, SUBSCRIPTION
3657
- - OrderPriority: CRITICAL, HIGH, LOW, MEDIUM, URGENT
3658
- - OrderStatus: PENDING, CONFIRMED, ASSIGNED, PICKED_UP, IN_TRANSIT, OUT_FOR_DELIVERY, DELIVERED, CANCELLED, FAILED, RETURNED
3471
+ - DeliveryPriority: CRITICAL, HIGH, LOW, MEDIUM, URGENT
3472
+ - DeliveryJobStatus: PENDING, CONFIRMED, ASSIGNED, PICKED_UP, IN_TRANSIT, OUT_FOR_DELIVERY, DELIVERED, CANCELLED, FAILED, RETURNED
3659
3473
  - ShipmentStatus: PLANNED, PICKED_UP, IN_TRANSIT, DELIVERED, FAILED, RETURNED
3660
3474
  - TrackingEventType: CREATED, PICKED_UP, DEPARTED, ARRIVED, IN_TRANSIT, OUT_FOR_DELIVERY, DELIVERED, FAILED, RETURNED
3661
3475
  - RouteStatus: PLANNED, IN_PROGRESS, COMPLETED, CANCELLED
3662
3476
  - WarehouseType: COLD_STORAGE, CROSS_DOCK, DISTRIBUTION, FULFILLMENT, RETAIL
3663
3477
  - InventoryTransactionType: RECEIPT, ISSUE, TRANSFER, ADJUSTMENT, RETURN
3664
3478
 
3479
+ ## Stock rule
3480
+ Inventory counts are non-negative integers and available + allocated + damaged
3481
+ must equal onHand. Move stock between lines with inventory_transfer_stock.
3482
+
3665
3483
  ## Tool groups
3666
- customers, drivers, vehicles, products, orders, shipments, tracking, routes,
3667
- warehouses, inventory, marketplace (service providers + offerings), reports
3668
- (+ settings + import/export), analytics.
3484
+ customers, drivers, vehicles, cargo, delivery_jobs, shipments, tracking,
3485
+ routes, warehouses, inventory, marketplace (service providers + offerings),
3486
+ analytics.
3669
3487
  All run against the WORKSPACE gateway (workspace-scoped). The subgraph has no
3670
3488
  @public health field, so there is no health tool.
3671
3489
  `;
@@ -3679,7 +3497,7 @@ All run against the WORKSPACE gateway (workspace-scoped). The subgraph has no
3679
3497
  dashboardUri,
3680
3498
  {
3681
3499
  title: "Movethewheels Dashboard Metrics",
3682
- description: "Live headline operations KPIs (orders, active deliveries, vehicles, drivers, low-stock, revenue).",
3500
+ description: "Live headline operations KPIs (delivery jobs, active deliveries, vehicles, drivers, low-stock, revenue, on-time rate).",
3683
3501
  mimeType: "application/json"
3684
3502
  },
3685
3503
  async () => {
@@ -3797,28 +3615,28 @@ function registerMovethewheelsPrompts(server, ctx, track) {
3797
3615
  fulfilmentName,
3798
3616
  {
3799
3617
  title: "Delivery Fulfilment",
3800
- description: "Guide for fulfilling a delivery order end to end: create the order, create a shipment, assign a driver/vehicle, and advance it through tracking to delivery.",
3618
+ description: "Guide for fulfilling a delivery job end to end: create the job, assign a driver/vehicle, create a shipment, and advance it through tracking to delivery.",
3801
3619
  argsSchema: {
3802
- customerId: zod.z.string().optional().describe("Customer placing the order"),
3803
- orderId: zod.z.string().optional().describe("Existing order ID to fulfil")
3620
+ customerId: zod.z.string().optional().describe("Customer the delivery is for"),
3621
+ deliveryJobId: zod.z.string().optional().describe("Existing delivery job ID to fulfil")
3804
3622
  }
3805
3623
  },
3806
- ({ customerId, orderId }) => {
3807
- ctx.logger.debug(`Prompt ${fulfilmentName} called`, { customerId, orderId });
3808
- const orderNote = orderId ? `Operate the existing order "${orderId}".` : customerId ? `Create a new order for customer "${customerId}".` : `First pick a customer with ${p}_customers_list (or create one with ${p}_customers_create).`;
3624
+ ({ customerId, deliveryJobId }) => {
3625
+ ctx.logger.debug(`Prompt ${fulfilmentName} called`, { customerId, deliveryJobId });
3626
+ const jobNote = deliveryJobId ? `Operate the existing delivery job "${deliveryJobId}".` : customerId ? `Create a new delivery job for customer "${customerId}".` : `First pick a customer with ${p}_customers_list (or create one with ${p}_customers_create).`;
3809
3627
  return {
3810
3628
  messages: [
3811
3629
  {
3812
3630
  role: "user",
3813
3631
  content: {
3814
3632
  type: "text",
3815
- text: `Help me fulfil a Movethewheels delivery order. ${orderNote}
3633
+ text: `Help me fulfil a Movethewheels delivery job. ${jobNote}
3816
3634
 
3817
- 1. **Order**: If needed, use ${p}_orders_create with a unique orderNumber, pickupAddress, deliveryAddress, and items.
3818
- 2. **Assign Capacity**: Use ${p}_drivers_list (status=AVAILABLE) and ${p}_vehicles_list (status=ACTIVE), then ${p}_drivers_assign_vehicle and ${p}_orders_update to attach driverId/vehicleId.
3819
- 3. **Shipment**: Use ${p}_shipments_create with the orderId, a unique shipmentNumber, origin, and destination.
3820
- 4. **Track**: As the shipment moves, use ${p}_tracking_add_event (PICKED_UP \u2192 IN_TRANSIT \u2192 OUT_FOR_DELIVERY \u2192 DELIVERED) and mirror order state with ${p}_orders_update_status.
3821
- 5. **Verify**: Use ${p}_tracking_order_events to confirm the timeline and ${p}_orders_get for the final state.
3635
+ 1. **Delivery job**: If needed, use ${p}_delivery_jobs_create with a unique deliveryJobNumber, pickupAddress, deliveryAddress, and cargoItems.
3636
+ 2. **Assign Capacity**: Use ${p}_drivers_list (status=AVAILABLE) and ${p}_vehicles_list (status=ACTIVE), then ${p}_drivers_assign_vehicle and ${p}_delivery_jobs_update to attach driverId/vehicleId.
3637
+ 3. **Shipment**: Use ${p}_shipments_create with the deliveryJobId, a unique shipmentNumber, origin, and destination.
3638
+ 4. **Track**: As the shipment moves, use ${p}_tracking_add_event (PICKED_UP \u2192 IN_TRANSIT \u2192 OUT_FOR_DELIVERY \u2192 DELIVERED) and mirror the job's state with ${p}_delivery_jobs_update_status.
3639
+ 5. **Verify**: Use ${p}_tracking_delivery_job_events to confirm the timeline and ${p}_delivery_jobs_get for the final state.
3822
3640
 
3823
3641
  Show results at each step and confirm before marking DELIVERED.`
3824
3642
  }
@@ -3831,7 +3649,7 @@ Show results at each step and confirm before marking DELIVERED.`
3831
3649
  fleetName,
3832
3650
  {
3833
3651
  title: "Fleet & Warehouse Operations",
3834
- description: "Daily operations workflow: review KPIs, triage the order queue and tracking alerts, balance fleet status, and watch low inventory.",
3652
+ description: "Daily operations workflow: review KPIs, triage the delivery-job queue and tracking alerts, balance fleet status, and watch low inventory.",
3835
3653
  argsSchema: {}
3836
3654
  },
3837
3655
  () => {
@@ -3844,11 +3662,11 @@ Show results at each step and confirm before marking DELIVERED.`
3844
3662
  type: "text",
3845
3663
  text: `Run daily Movethewheels operations.
3846
3664
 
3847
- 1. **KPIs**: Use ${p}_analytics_dashboard for headline numbers, ${p}_analytics_order_stats and ${p}_analytics_fleet for status breakdowns, and ${p}_analytics_finance for revenue/fuel/invoices.
3848
- 2. **Order Queue**: Use ${p}_orders_list filtered by status=PENDING (and CONFIRMED) to find orders needing assignment; advance them with ${p}_orders_update_status.
3849
- 3. **Tracking Alerts**: Use ${p}_tracking_alerts to find delayed/exception shipments and ${p}_shipments_get to investigate.
3665
+ 1. **KPIs**: Use ${p}_analytics_dashboard for headline numbers, ${p}_analytics_delivery_job_stats and ${p}_analytics_fleet for status breakdowns, and ${p}_analytics_finance for revenue/fuel/invoices.
3666
+ 2. **Job Queue**: Use ${p}_delivery_jobs_list with unassigned=true (or status=PENDING / CONFIRMED) to find jobs needing assignment; advance them with ${p}_delivery_jobs_update_status.
3667
+ 3. **Tracking Alerts**: Use ${p}_tracking_alerts to find DELAYED and AT_RISK shipments and ${p}_shipments_get to investigate.
3850
3668
  4. **Fleet Balance**: Use ${p}_vehicles_list and ${p}_drivers_list to spot MAINTENANCE/OFF_DUTY capacity; update with ${p}_vehicles_update_status / ${p}_drivers_update_status.
3851
- 5. **Inventory**: Use ${p}_inventory_stats and ${p}_inventory_list_items to find low-stock items; record movements with ${p}_inventory_create_transaction.
3669
+ 5. **Inventory**: Use ${p}_inventory_stats and ${p}_inventory_list_items (lowStock=true) to find low-stock items; move stock with ${p}_inventory_transfer_stock and record receipts/issues with ${p}_inventory_create_transaction.
3852
3670
 
3853
3671
  Summarize what needs attention after each step.`
3854
3672
  }
@@ -3885,15 +3703,14 @@ var movethewheelsModule = {
3885
3703
  registerCustomerTools(server, ctx, trackTool);
3886
3704
  registerDriverTools(server, ctx, trackTool);
3887
3705
  registerVehicleTools(server, ctx, trackTool);
3888
- registerProductTools(server, ctx, trackTool);
3889
- registerOrderTools(server, ctx, trackTool);
3706
+ registerCargoTools(server, ctx, trackTool);
3707
+ registerDeliveryJobTools(server, ctx, trackTool);
3890
3708
  registerShipmentTools(server, ctx, trackTool);
3891
3709
  registerTrackingTools(server, ctx, trackTool);
3892
3710
  registerRouteTools(server, ctx, trackTool);
3893
3711
  registerWarehouseTools(server, ctx, trackTool);
3894
3712
  registerInventoryTools(server, ctx, trackTool);
3895
3713
  registerMarketplaceTools(server, ctx, trackTool);
3896
- registerReportTools(server, ctx, trackTool);
3897
3714
  registerAnalyticsTools(server, ctx, trackTool);
3898
3715
  registerMovethewheelsResources(server, ctx, trackResource);
3899
3716
  registerMovethewheelsPrompts(server, ctx, trackPrompt);