feat(v2.6.0): implement GlobalEnvelope, T1-T9 hardening, 12 tools, and CI acceptance test suite

This commit is contained in:
Amirul Islam Redwan71
2026-11-10 08:22:06 +06:00
parent c47d78f3a7
commit b3fec955cc
55 changed files with 5316 additions and 2157 deletions
+18 -26
View File
@@ -1,4 +1,5 @@
import axios from "axios";
import { McpToolError, withGetRetry } from "../envelope.js";
export class RedxAdapter {
courierName = "redx";
client;
@@ -89,10 +90,14 @@ export class RedxAdapter {
}
async trackParcel(trackingCode) {
if (!this.enabled) {
throw new Error("RedX credentials are not configured.");
throw new McpToolError({
code: "COURIER_NOT_CONFIGURED",
message: "RedX credentials are not configured.",
courier: "redx",
});
}
try {
const response = await this.client.get(`/parcel/track/${encodeURIComponent(trackingCode)}`);
const response = await withGetRetry(() => this.client.get(`/parcel/track/${encodeURIComponent(trackingCode)}`));
const data = response.data;
const events = data?.tracking || [];
const latest = events[events.length - 1];
@@ -108,41 +113,28 @@ export class RedxAdapter {
}
catch (err) {
if (err?.response?.status === 404 || err?.response?.status === 400) {
return {
success: false,
throw new McpToolError({
code: "CONSIGNMENT_NOT_FOUND",
message: `Consignment '${trackingCode}' was not found in RedX.`,
retryable: false,
courier: "redx",
tracking_code: trackingCode,
status: "not_found_in_redx",
updated_at: new Date().toISOString(),
raw_response: err.response?.data || { message: "No parcel data found in RedX for this tracking ID." },
};
});
}
throw err;
}
}
/**
* 100% Live RedX Merchant Account & Pickup Store Verification + Settlement Status
* Queries GET /pickup/stores on RedX OpenAPI v1.0.0-beta
* RedX does not expose a live wallet balance API endpoint (T3).
*/
async getBalance() {
if (!this.enabled) {
throw new Error("RedX credentials are not configured.");
}
const response = await this.client.get("/pickup/stores");
const stores = response.data?.pickup_stores || [];
const primaryStore = stores[0] || null;
return {
success: true,
courier: "redx",
current_balance: 0,
raw_response: {
live_api_status: "RedX OpenAPI v1.0.0-beta Authenticated & Active",
currency: "BDT",
settlement_cycle: "Direct Bank / bKash Automatic Daily Settlement",
connected_stores_count: stores.length,
active_pickup_store: primaryStore,
pickup_stores: stores,
},
amount_bdt: null,
pending_bdt: null,
current_balance: null,
status: "UNSUPPORTED_BY_PROVIDER",
hint: "Use RedX merchant portal",
};
}
}