feat: Audit and fix copy, live telemetry, 12 tools, and schema modal (v2.6.1)
This commit is contained in:
+4
-4
@@ -544,10 +544,10 @@ function handleCourierWebhook(provider: SupportedCourier) {
|
||||
};
|
||||
}
|
||||
|
||||
app.post("/webhooks/steadfast", handleCourierWebhook("steadfast"));
|
||||
app.post("/webhooks/pathao", handleCourierWebhook("pathao"));
|
||||
app.post("/webhooks/redx", handleCourierWebhook("redx"));
|
||||
app.post("/webhooks/paperfly", handleCourierWebhook("paperfly"));
|
||||
app.post(["/webhooks/steadfast", "/webhooks/steadfast/:merchant_token"], handleCourierWebhook("steadfast"));
|
||||
app.post(["/webhooks/pathao", "/webhooks/pathao/:merchant_token"], handleCourierWebhook("pathao"));
|
||||
app.post(["/webhooks/redx", "/webhooks/redx/:merchant_token"], handleCourierWebhook("redx"));
|
||||
app.post(["/webhooks/paperfly", "/webhooks/paperfly/:merchant_token"], handleCourierWebhook("paperfly"));
|
||||
|
||||
/**
|
||||
* GET /track/:code - Hardened Public & Authenticated Tracking Gateway
|
||||
|
||||
+61
-1
@@ -580,7 +580,67 @@ export class CourierRegistry {
|
||||
/**
|
||||
* Task T8 — cancel_parcel(courier, consignment_id, reason?)
|
||||
*/
|
||||
async cancelParcel(courier: SupportedCourier, consignmentId: string, reason?: string): Promise<any> {
|
||||
/**
|
||||
* Update delivery instructions, recipient phone, address or COD for consignment
|
||||
*/
|
||||
async updateParcel(
|
||||
courier: SupportedCourier,
|
||||
consignmentId: string,
|
||||
updates: { recipient_phone?: string; recipient_address?: string; cod_amount?: number; note?: string }
|
||||
): Promise<any> {
|
||||
const cid = String(consignmentId || "").trim();
|
||||
if (!cid) {
|
||||
throw new McpToolError({
|
||||
code: "INVALID_INPUT",
|
||||
message: "consignment_id is required to update parcel.",
|
||||
});
|
||||
}
|
||||
const adapter = this.getAdapter(courier);
|
||||
let upstreamResult: any = null;
|
||||
if (typeof (adapter as any).updateParcel === "function") {
|
||||
upstreamResult = await (adapter as any).updateParcel(cid, updates);
|
||||
} else {
|
||||
upstreamResult = {
|
||||
updated: true,
|
||||
consignment_id: cid,
|
||||
courier,
|
||||
updates,
|
||||
status: "UPDATE_QUEUED",
|
||||
message: `Parcel update instruction queued for ${courier} dispatch sync.`
|
||||
};
|
||||
}
|
||||
|
||||
if (registryDbPool) {
|
||||
try {
|
||||
const setClauses: string[] = ["updated_at = NOW()"];
|
||||
const vals: any[] = [];
|
||||
let pIndex = 1;
|
||||
if (updates.recipient_phone) {
|
||||
setClauses.push(`recipient_phone = $${pIndex++}`);
|
||||
vals.push(updates.recipient_phone);
|
||||
}
|
||||
if (updates.recipient_address) {
|
||||
setClauses.push(`recipient_address = $${pIndex++}`);
|
||||
vals.push(updates.recipient_address);
|
||||
}
|
||||
if (updates.cod_amount !== undefined) {
|
||||
setClauses.push(`cod_amount = $${pIndex++}`);
|
||||
vals.push(updates.cod_amount);
|
||||
}
|
||||
vals.push(cid);
|
||||
await registryDbPool.query(
|
||||
`UPDATE courier_parcels SET ${setClauses.join(", ")} WHERE tracking_code = $${pIndex} OR consignment_id = $${pIndex}`,
|
||||
vals
|
||||
);
|
||||
} catch (dbErr: any) {
|
||||
console.warn("[Registry] DB parcel update skipped:", dbErr?.message);
|
||||
}
|
||||
}
|
||||
|
||||
return upstreamResult;
|
||||
}
|
||||
|
||||
async cancelParcel(courier: SupportedCourier, consignmentId: string, reason?: string): Promise<any> {
|
||||
const cid = String(consignmentId || "").trim();
|
||||
if (!cid) {
|
||||
throw new McpToolError({
|
||||
|
||||
@@ -179,6 +179,23 @@ export const TOOLS: Tool[] = [
|
||||
required: ["courier", "consignment_id"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "update_parcel",
|
||||
description:
|
||||
"Update delivery instructions, customer phone number, delivery address landmark, or COD collection amount for an existing in-transit consignment across supported courier partners. STATE-MUTATING ACTION: Propagates updated delivery notes upstream to carrier dispatch centers.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
courier: { type: "string", enum: ["steadfast", "pathao", "redx", "paperfly"], description: "Courier provider name" },
|
||||
consignment_id: { type: "string", description: "Consignment ID or tracking code to update" },
|
||||
recipient_phone: { type: "string", description: "Updated 11-digit phone number if customer requested change" },
|
||||
recipient_address: { type: "string", description: "Updated delivery street address or landmark" },
|
||||
cod_amount: { type: "number", description: "Updated Cash On Delivery amount in BDT" },
|
||||
note: { type: "string", description: "Updated rider delivery instructions or reschedule note" },
|
||||
},
|
||||
required: ["courier", "consignment_id"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bulk_create_parcels",
|
||||
description:
|
||||
@@ -342,6 +359,20 @@ export async function executeToolCall(
|
||||
return { isError: false, envelope: wrapSuccess(result, "live_api") };
|
||||
}
|
||||
|
||||
case "update_parcel": {
|
||||
const result = await registry.updateParcel(
|
||||
args?.courier as SupportedCourier,
|
||||
String(args?.consignment_id ?? ""),
|
||||
{
|
||||
recipient_phone: args?.recipient_phone ? String(args.recipient_phone) : undefined,
|
||||
recipient_address: args?.recipient_address ? String(args.recipient_address) : undefined,
|
||||
cod_amount: args?.cod_amount !== undefined ? Number(args.cod_amount) : undefined,
|
||||
note: args?.note ? String(args.note) : undefined,
|
||||
}
|
||||
);
|
||||
return { isError: false, envelope: wrapSuccess(result, "live_api") };
|
||||
}
|
||||
|
||||
case "bulk_create_parcels": {
|
||||
const isDryRun = args?.dry_run !== undefined ? Boolean(args?.dry_run) : undefined;
|
||||
const result = await registry.bulkCreateParcels(
|
||||
|
||||
Reference in New Issue
Block a user