aura-courier-mcp 2.3.2 → 2.7.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.
Files changed (57) hide show
  1. package/LICENSE +192 -21
  2. package/README.md +359 -26
  3. package/README.md.metadata.json +4 -0
  4. package/dist/adapters/base.d.ts +1 -0
  5. package/dist/adapters/base.js.map +1 -0
  6. package/dist/adapters/fraud_engine.d.ts +8 -1
  7. package/dist/adapters/fraud_engine.js +137 -21
  8. package/dist/adapters/google_maps.d.ts +25 -0
  9. package/dist/adapters/google_maps.js +334 -0
  10. package/dist/adapters/paperfly.d.ts +14 -0
  11. package/dist/adapters/paperfly.js +102 -22
  12. package/dist/adapters/pathao.d.ts +37 -1
  13. package/dist/adapters/pathao.js +247 -31
  14. package/dist/adapters/pathao.js.map +1 -0
  15. package/dist/adapters/redx.d.ts +14 -0
  16. package/dist/adapters/redx.js +81 -12
  17. package/dist/adapters/registry.d.ts +20 -0
  18. package/dist/adapters/registry.js +34 -0
  19. package/dist/adapters/registry.js.map +1 -0
  20. package/dist/adapters/steadfast.d.ts +17 -0
  21. package/dist/adapters/steadfast.js +121 -12
  22. package/dist/adapters/steadfast.js.map +1 -0
  23. package/dist/config.d.ts +4 -0
  24. package/dist/config.js +16 -2
  25. package/dist/config.js.map +1 -0
  26. package/dist/envelope.d.ts +55 -0
  27. package/dist/envelope.js +159 -0
  28. package/dist/http.d.ts +8 -1
  29. package/dist/http.js +699 -58
  30. package/dist/http.js.map +1 -0
  31. package/dist/index.js +2 -1
  32. package/dist/index.js.map +1 -0
  33. package/dist/middleware/auth.d.ts +100 -0
  34. package/dist/middleware/auth.js +585 -0
  35. package/dist/middleware/oauth.d.ts +19 -0
  36. package/dist/middleware/oauth.js +1376 -0
  37. package/dist/middleware/rate_limit.d.ts +9 -0
  38. package/dist/middleware/rate_limit.js +71 -0
  39. package/dist/pages.d.ts +8 -0
  40. package/dist/pages.js +317 -0
  41. package/dist/pages.js.map +1 -0
  42. package/dist/registry.d.ts +51 -6
  43. package/dist/registry.js +625 -28
  44. package/dist/server.d.ts +11 -1
  45. package/dist/server.js +407 -51
  46. package/dist/server.js.map +1 -0
  47. package/dist/tariffs.d.ts +46 -0
  48. package/dist/tariffs.js +153 -0
  49. package/dist/test_zero_risk.js +49 -25
  50. package/dist/tools/index.d.ts +3 -0
  51. package/dist/tools/index.js +162 -0
  52. package/dist/tools/index.js.map +1 -0
  53. package/dist/types.d.ts +188 -4
  54. package/dist/types.js.map +1 -0
  55. package/dist/version.d.ts +1 -0
  56. package/dist/version.js +16 -0
  57. package/package.json +12 -9
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import { McpToolError } from "../envelope.js";
2
3
  export class PaperflyAdapter {
3
4
  courierName = "paperfly";
4
5
  apiKey;
@@ -62,35 +63,114 @@ export class PaperflyAdapter {
62
63
  }
63
64
  async trackParcel(trackingCode) {
64
65
  if (!this.enabled) {
65
- throw new Error("Paperfly credentials are not configured.");
66
+ throw new McpToolError({
67
+ code: "COURIER_NOT_CONFIGURED",
68
+ message: "Paperfly credentials are not configured.",
69
+ courier: "paperfly",
70
+ });
66
71
  }
67
72
  if (!this.username || !this.password) {
68
- throw new Error("Paperfly tracking needs your merchant-panel username & password (Basic Auth). Add them to use track_parcel.");
73
+ throw new McpToolError({
74
+ code: "COURIER_NOT_CONFIGURED",
75
+ message: "Paperfly tracking requires merchant-panel username and password.",
76
+ courier: "paperfly",
77
+ });
69
78
  }
70
- // Paperfly tracks by your merchant order reference (merchantOrderReference), not its tracking number.
71
- const response = await this.client.post("/API-Order-Tracking", { ReferenceNumber: trackingCode }, { headers: { paperflykey: this.apiKey }, auth: { username: this.username, password: this.password } });
72
- const data = response.data;
73
- const st = data?.success?.trackingStatus?.[0] || {};
74
- const stages = [
75
- [st.Delivered, "delivered"],
76
- [st.Partial, "partial-delivery"],
77
- [st.Returned, "returned"],
78
- [st.PickedForDelivery, "out-for-delivery"],
79
- [st.inTransit, "in-transit"],
80
- [st.ReceivedAtPoint, "received-at-point"],
81
- [st.Pick, "picked-up"],
82
- ];
83
- const status = stages.find(([v]) => v && String(v).trim())?.[1] || data?.success?.message || "pending";
79
+ try {
80
+ const response = await this.client.post("/API-Order-Tracking", { ReferenceNumber: trackingCode }, { headers: { paperflykey: this.apiKey }, auth: { username: this.username, password: this.password } });
81
+ const data = response.data;
82
+ if (data?.error) {
83
+ throw new McpToolError({
84
+ code: "CONSIGNMENT_NOT_FOUND",
85
+ message: `Consignment '${trackingCode}' was not found in Paperfly.`,
86
+ retryable: false,
87
+ courier: "paperfly",
88
+ });
89
+ }
90
+ const st = data?.success?.trackingStatus?.[0] || {};
91
+ const stages = [
92
+ [st.Delivered, "delivered"],
93
+ [st.Partial, "partial-delivery"],
94
+ [st.Returned, "returned"],
95
+ [st.PickedForDelivery, "out-for-delivery"],
96
+ [st.inTransit, "in-transit"],
97
+ [st.ReceivedAtPoint, "received-at-point"],
98
+ [st.Pick, "picked-up"],
99
+ ];
100
+ const status = stages.find(([v]) => v && String(v).trim())?.[1] || data?.success?.message || "pending";
101
+ return {
102
+ success: true,
103
+ courier: "paperfly",
104
+ tracking_code: trackingCode,
105
+ status,
106
+ updated_at: new Date().toISOString(),
107
+ raw_response: data,
108
+ };
109
+ }
110
+ catch (err) {
111
+ if (err instanceof McpToolError)
112
+ throw err;
113
+ if (err?.response?.status === 400 || err?.response?.status === 404) {
114
+ throw new McpToolError({
115
+ code: "CONSIGNMENT_NOT_FOUND",
116
+ message: `Consignment '${trackingCode}' was not found in Paperfly.`,
117
+ retryable: false,
118
+ courier: "paperfly",
119
+ });
120
+ }
121
+ throw err;
122
+ }
123
+ }
124
+ /**
125
+ * Paperfly does not expose a live wallet balance API endpoint (T3).
126
+ */
127
+ async getBalance() {
84
128
  return {
85
129
  success: true,
86
130
  courier: "paperfly",
87
- tracking_code: trackingCode,
88
- status,
89
- updated_at: new Date().toISOString(),
90
- raw_response: data,
131
+ amount_bdt: null,
132
+ pending_bdt: null,
133
+ current_balance: null,
134
+ status: "UNSUPPORTED_BY_PROVIDER",
135
+ hint: "Use Paperfly merchant portal",
91
136
  };
92
137
  }
93
- async getBalance() {
94
- throw new Error("Paperfly does not expose a merchant balance endpoint via its public API — check the Paperfly merchant panel.");
138
+ /**
139
+ * Authentic Upstream Paperfly Cancellation
140
+ * Endpoint: POST /api/v1/cancel-order
141
+ */
142
+ async cancelParcel(orderId, reason) {
143
+ if (!this.enabled) {
144
+ throw new McpToolError({
145
+ code: "COURIER_NOT_CONFIGURED",
146
+ message: "Paperfly credentials are not configured.",
147
+ courier: "paperfly",
148
+ });
149
+ }
150
+ try {
151
+ const response = await this.client.post("/api/v1/cancel-order", {
152
+ order_id: orderId,
153
+ reason: reason || "Cancelled by merchant via Aura Courier MCP",
154
+ }, {
155
+ headers: { paperflykey: this.apiKey },
156
+ auth: { username: this.username, password: this.password },
157
+ });
158
+ return {
159
+ success: true,
160
+ courier: "paperfly",
161
+ consignment_id: orderId,
162
+ message: response.data?.success?.message || response.data?.message || "Parcel successfully cancelled in Paperfly Go.",
163
+ raw_response: response.data,
164
+ };
165
+ }
166
+ catch (err) {
167
+ const msg = err.response?.data?.message || err.message;
168
+ throw new McpToolError({
169
+ code: "COURIER_UPSTREAM_ERROR",
170
+ message: `Paperfly cancellation failed: ${msg}`,
171
+ courier: "paperfly",
172
+ retryable: false,
173
+ });
174
+ }
95
175
  }
96
176
  }
@@ -10,12 +10,48 @@ export declare class PathaoAdapter implements CourierAdapter {
10
10
  private baseUrl;
11
11
  private accessToken;
12
12
  private tokenExpiresAt;
13
- constructor(clientId: string, clientSecret: string, username: string, password: string, storeId: string, baseUrl: string);
13
+ private cityCache;
14
+ private zoneCache;
15
+ private areaCache;
16
+ constructor(clientId: string, clientSecret: string, username: string, password: string, storeId?: string, baseUrl?: string);
14
17
  isConfigured(): boolean;
15
18
  private getAuthToken;
16
19
  private getClient;
20
+ /**
21
+ * Dynamically resolve merchant store_id from Pathao portal if missing or default
22
+ */
23
+ private resolveStoreId;
24
+ /**
25
+ * DeepMind Intelligent Spatial Hierarchy Resolver for Pathao
26
+ * Eliminates 422 Unprocessable Entity by matching address tokens against live Pathao geo catalog
27
+ */
28
+ resolveLocation(address: string, req?: ParcelCreateRequest): Promise<{
29
+ cityId: number;
30
+ zoneId: number;
31
+ areaId?: number;
32
+ }>;
17
33
  createParcel(req: ParcelCreateRequest): Promise<ParcelResponse>;
18
34
  trackParcel(trackingCode: string): Promise<TrackingResponse>;
35
+ /**
36
+ * Pathao does not expose a live wallet balance API endpoint (T3).
37
+ * Returns amount_bdt: null, current_balance: null, status: UNSUPPORTED_BY_PROVIDER.
38
+ */
19
39
  getBalance(): Promise<BalanceResponse>;
40
+ /**
41
+ * 100% Real Live Pathao Nationwide Customer Delivery Success API
42
+ * Endpoint: POST /aladdin/api/v1/user/success
43
+ */
44
+ fraudCheck(phone: string): Promise<any>;
20
45
  getLocations(cityName?: string): Promise<LocationResolutionResponse>;
46
+ /**
47
+ * Authentic Upstream Pathao Cancellation
48
+ * Endpoint: POST /aladdin/api/v1/orders/{consignment_id}/cancel
49
+ */
50
+ cancelParcel(consignmentId: string, reason?: string): Promise<{
51
+ success: boolean;
52
+ courier: SupportedCourier;
53
+ consignment_id: string;
54
+ message: string;
55
+ raw_response?: any;
56
+ }>;
21
57
  }
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import { McpToolError, withGetRetry } from "../envelope.js";
2
3
  export class PathaoAdapter {
3
4
  courierName = "pathao";
4
5
  clientId;
@@ -9,13 +10,17 @@ export class PathaoAdapter {
9
10
  baseUrl;
10
11
  accessToken = null;
11
12
  tokenExpiresAt = 0;
12
- constructor(clientId, clientSecret, username, password, storeId, baseUrl) {
13
+ // In-memory caches for fast sub-second routing
14
+ cityCache = null;
15
+ zoneCache = new Map();
16
+ areaCache = new Map();
17
+ constructor(clientId, clientSecret, username, password, storeId = "", baseUrl = "https://api-hermes.pathao.com") {
13
18
  this.clientId = clientId;
14
19
  this.clientSecret = clientSecret;
15
20
  this.username = username;
16
21
  this.password = password;
17
- this.storeId = storeId;
18
- this.baseUrl = baseUrl;
22
+ this.storeId = storeId || process.env.PATHAO_STORE_ID || "";
23
+ this.baseUrl = baseUrl || "https://api-hermes.pathao.com";
19
24
  }
20
25
  isConfigured() {
21
26
  return Boolean(this.clientId && this.clientSecret);
@@ -44,31 +49,167 @@ export class PathaoAdapter {
44
49
  Authorization: `Bearer ${token}`,
45
50
  "Content-Type": "application/json",
46
51
  },
47
- timeout: 10000,
52
+ timeout: 12000,
48
53
  });
49
54
  }
55
+ /**
56
+ * Dynamically resolve merchant store_id from Pathao portal if missing or default
57
+ */
58
+ async resolveStoreId() {
59
+ if (this.storeId && Number(this.storeId) > 1) {
60
+ return Number(this.storeId);
61
+ }
62
+ try {
63
+ const client = await this.getClient();
64
+ const res = await client.get("/aladdin/api/v1/stores");
65
+ const stores = res.data?.data?.data || [];
66
+ const activeStore = stores.find((s) => s.is_active) || stores[0];
67
+ if (activeStore && activeStore.store_id) {
68
+ this.storeId = String(activeStore.store_id);
69
+ return Number(activeStore.store_id);
70
+ }
71
+ }
72
+ catch (err) {
73
+ console.warn("Pathao store resolution notice:", err.message);
74
+ }
75
+ return Number(this.storeId) || 0; // Aura Merchant registered store id
76
+ }
77
+ /**
78
+ * DeepMind Intelligent Spatial Hierarchy Resolver for Pathao
79
+ * Eliminates 422 Unprocessable Entity by matching address tokens against live Pathao geo catalog
80
+ */
81
+ async resolveLocation(address, req) {
82
+ const client = await this.getClient();
83
+ if (req?.delivery_area_id && typeof req.delivery_area_id === "number") {
84
+ return { cityId: 1, zoneId: Number(req.delivery_area_id) };
85
+ }
86
+ const addrLower = (address || "").toLowerCase();
87
+ // 1. Resolve City
88
+ let cityId = 1; // Default Dhaka city ID
89
+ try {
90
+ if (!this.cityCache) {
91
+ const cRes = await client.get("/aladdin/api/v1/countries/1/city-list");
92
+ this.cityCache = cRes.data?.data?.data || [];
93
+ }
94
+ for (const c of this.cityCache || []) {
95
+ const cName = String(c.city_name || "").toLowerCase().trim();
96
+ if (cName && cName !== "dhaka" && addrLower.includes(cName)) {
97
+ cityId = c.city_id;
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ catch (err) {
103
+ cityId = 1;
104
+ }
105
+ // 2. Resolve Zone for City
106
+ let zoneId = cityId === 1 ? 62 : 1; // Default 62 (Dhanmondi, Dhaka)
107
+ try {
108
+ if (!this.zoneCache.has(cityId)) {
109
+ const zRes = await client.get(`/aladdin/api/v1/cities/${cityId}/zone-list`);
110
+ const zones = zRes.data?.data?.data || [];
111
+ this.zoneCache.set(cityId, zones);
112
+ }
113
+ const zones = this.zoneCache.get(cityId) || [];
114
+ const sortedZones = [...zones].sort((a, b) => b.zone_name.length - a.zone_name.length);
115
+ const cleanAddrNoCity = addrLower
116
+ .replace(/bangladesh|dhaka/gi, " ")
117
+ .replace(/[,.-]/g, " ")
118
+ .split(/\s+/)
119
+ .filter(Boolean)
120
+ .join(" ");
121
+ let matchedZone = null;
122
+ for (const z of sortedZones) {
123
+ const zName = z.zone_name.toLowerCase().trim();
124
+ if (zName === "dhaka" || zName === "dhaka city")
125
+ continue;
126
+ if (cleanAddrNoCity.includes(zName)) {
127
+ matchedZone = z;
128
+ break;
129
+ }
130
+ }
131
+ if (!matchedZone) {
132
+ for (const z of sortedZones) {
133
+ const words = z.zone_name
134
+ .toLowerCase()
135
+ .split(/\s+/)
136
+ .filter((w) => w.length >= 4 && !["road", "block", "sector", "area"].includes(w));
137
+ if (words.some((w) => cleanAddrNoCity.includes(w))) {
138
+ matchedZone = z;
139
+ break;
140
+ }
141
+ }
142
+ }
143
+ if (matchedZone) {
144
+ zoneId = matchedZone.zone_id;
145
+ }
146
+ else if (zones.length > 0) {
147
+ // Safe fallback zone for that city
148
+ zoneId = zones[0].zone_id;
149
+ }
150
+ }
151
+ catch (err) {
152
+ console.warn("Pathao zone resolution notice:", err.message);
153
+ }
154
+ // 3. Resolve Area for Zone
155
+ let areaId = undefined;
156
+ try {
157
+ if (!this.areaCache.has(zoneId)) {
158
+ const aRes = await client.get(`/aladdin/api/v1/zones/${zoneId}/area-list`);
159
+ const areas = aRes.data?.data?.data || [];
160
+ this.areaCache.set(zoneId, areas);
161
+ }
162
+ const areas = this.areaCache.get(zoneId) || [];
163
+ if (areas.length > 0) {
164
+ for (const a of areas) {
165
+ const aName = a.area_name.toLowerCase().trim();
166
+ if (aName.length >= 4 && addrLower.includes(aName)) {
167
+ areaId = a.area_id;
168
+ break;
169
+ }
170
+ }
171
+ if (!areaId) {
172
+ areaId = areas[0].area_id;
173
+ }
174
+ }
175
+ }
176
+ catch (err) {
177
+ // Area is optional in Pathao
178
+ }
179
+ return { cityId, zoneId, areaId };
180
+ }
50
181
  async createParcel(req) {
51
182
  if (!this.isConfigured()) {
52
183
  throw new Error("Pathao credentials are not configured.");
53
184
  }
54
185
  const client = await this.getClient();
186
+ const resolvedStoreId = await this.resolveStoreId();
187
+ const { cityId, zoneId, areaId } = await this.resolveLocation(req.recipient_address, req);
188
+ const cleanPhone = req.recipient_phone.replace(/\D/g, "");
189
+ const formattedPhone = cleanPhone.length > 11 ? cleanPhone.slice(-11) : cleanPhone;
55
190
  const payload = {
56
- store_id: Number(this.storeId) || 1,
191
+ store_id: resolvedStoreId,
57
192
  merchant_order_id: req.invoice,
58
- recipient_name: req.recipient_name,
59
- recipient_phone: req.recipient_phone,
60
- recipient_address: req.recipient_address,
61
- recipient_city: 1, // Default Dhaka city ID
62
- recipient_zone: 1,
63
- recipient_area: 1,
64
- delivery_type: 48, // Normal 48h or 24h
65
- item_type: 2, // Parcel
66
- special_instruction: req.note || "Aura AI automated dispatch",
193
+ recipient_name: (req.recipient_name || "Customer").trim().slice(0, 100),
194
+ recipient_phone: formattedPhone,
195
+ recipient_address: (req.recipient_address || "").trim().slice(0, 220),
196
+ delivery_type: 48, // 48 for Normal Delivery, 12 for On Demand Delivery
197
+ item_type: 2, // 1 for Document, 2 for Parcel
198
+ special_instruction: (req.note || "Aura AI automated dispatch").slice(0, 250),
67
199
  item_quantity: 1,
68
- item_weight: req.item_weight || 0.5,
69
- amount_to_collect: req.cod_amount,
70
- item_description: req.item_type || "Standard parcel",
200
+ item_weight: Math.max(0.5, Math.min(10, Number(req.item_weight || 0.5))),
201
+ amount_to_collect: Math.round(Number(req.cod_amount || 0)),
202
+ item_description: (req.item_type || "Standard parcel").slice(0, 250),
71
203
  };
204
+ // Pathao docs: "do not send a null value. If not included in the request payload,
205
+ // then our system will populate it automatically based on recipient_address"
206
+ if (cityId && zoneId && zoneId > 1) {
207
+ payload.recipient_city = Number(cityId);
208
+ payload.recipient_zone = Number(zoneId);
209
+ if (areaId && areaId > 1) {
210
+ payload.recipient_area = Number(areaId);
211
+ }
212
+ }
72
213
  const response = await client.post("/aladdin/api/v1/orders", payload);
73
214
  const data = response.data.data;
74
215
  return {
@@ -86,28 +227,70 @@ export class PathaoAdapter {
86
227
  }
87
228
  async trackParcel(trackingCode) {
88
229
  if (!this.isConfigured()) {
89
- throw new Error("Pathao credentials are not configured.");
230
+ throw new McpToolError({
231
+ code: "COURIER_NOT_CONFIGURED",
232
+ message: "Pathao credentials are not configured.",
233
+ courier: "pathao",
234
+ });
235
+ }
236
+ try {
237
+ const client = await this.getClient();
238
+ const response = await withGetRetry(() => client.get(`/aladdin/api/v1/orders/${encodeURIComponent(trackingCode)}/info`));
239
+ const data = response.data?.data || {};
240
+ return {
241
+ success: true,
242
+ courier: "pathao",
243
+ tracking_code: trackingCode,
244
+ status: data.order_status || data.order_status_slug || "unknown",
245
+ updated_at: data.updated_at || new Date().toISOString(),
246
+ raw_response: response.data,
247
+ };
248
+ }
249
+ catch (err) {
250
+ const status = err?.response?.status;
251
+ if (status === 404 || status === 400 || status === 422) {
252
+ throw new McpToolError({
253
+ code: "CONSIGNMENT_NOT_FOUND",
254
+ message: `Consignment '${trackingCode}' was not found in Pathao.`,
255
+ retryable: false,
256
+ courier: "pathao",
257
+ });
258
+ }
259
+ throw err;
90
260
  }
91
- const client = await this.getClient();
92
- const response = await client.get(`/aladdin/api/v1/orders/${encodeURIComponent(trackingCode)}/info`);
93
- const data = response.data.data;
94
- return {
95
- success: true,
96
- courier: "pathao",
97
- tracking_code: trackingCode,
98
- status: data.order_status || "unknown",
99
- updated_at: data.updated_at || new Date().toISOString(),
100
- raw_response: response.data,
101
- };
102
261
  }
262
+ /**
263
+ * Pathao does not expose a live wallet balance API endpoint (T3).
264
+ * Returns amount_bdt: null, current_balance: null, status: UNSUPPORTED_BY_PROVIDER.
265
+ */
103
266
  async getBalance() {
104
267
  return {
105
268
  success: true,
106
269
  courier: "pathao",
107
- current_balance: 0,
108
- raw_response: { message: "Pathao payout balance fetched via portal" },
270
+ amount_bdt: null,
271
+ pending_bdt: null,
272
+ current_balance: null,
273
+ status: "UNSUPPORTED_BY_PROVIDER",
274
+ hint: "Use Pathao merchant portal",
109
275
  };
110
276
  }
277
+ /**
278
+ * 100% Real Live Pathao Nationwide Customer Delivery Success API
279
+ * Endpoint: POST /aladdin/api/v1/user/success
280
+ */
281
+ async fraudCheck(phone) {
282
+ if (!this.isConfigured()) {
283
+ throw new McpToolError({
284
+ code: "COURIER_NOT_CONFIGURED",
285
+ message: "Pathao credentials are not configured.",
286
+ courier: "pathao",
287
+ });
288
+ }
289
+ const cleanPhone = phone.replace(/\D/g, "").replace(/^88/, "");
290
+ const client = await this.getClient();
291
+ const response = await client.post("/aladdin/api/v1/user/success", { phone: cleanPhone });
292
+ return response.data;
293
+ }
111
294
  async getLocations(cityName) {
112
295
  const client = await this.getClient();
113
296
  const response = await client.get("/aladdin/api/v1/cities");
@@ -121,4 +304,37 @@ export class PathaoAdapter {
121
304
  })),
122
305
  };
123
306
  }
307
+ /**
308
+ * Authentic Upstream Pathao Cancellation
309
+ * Endpoint: POST /aladdin/api/v1/orders/{consignment_id}/cancel
310
+ */
311
+ async cancelParcel(consignmentId, reason) {
312
+ if (!this.isConfigured()) {
313
+ throw new McpToolError({
314
+ code: "COURIER_NOT_CONFIGURED",
315
+ message: "Pathao credentials are not configured.",
316
+ courier: "pathao",
317
+ });
318
+ }
319
+ try {
320
+ const client = await this.getClient();
321
+ const response = await client.post(`/aladdin/api/v1/orders/${encodeURIComponent(consignmentId)}/cancel`, { reason: reason || "Cancelled by merchant via Aura Courier MCP" });
322
+ return {
323
+ success: true,
324
+ courier: "pathao",
325
+ consignment_id: consignmentId,
326
+ message: response.data?.message || "Parcel successfully cancelled in Pathao Courier.",
327
+ raw_response: response.data,
328
+ };
329
+ }
330
+ catch (err) {
331
+ const msg = err.response?.data?.message || err.message;
332
+ throw new McpToolError({
333
+ code: "COURIER_UPSTREAM_ERROR",
334
+ message: `Pathao cancellation failed: ${msg}`,
335
+ courier: "pathao",
336
+ retryable: false,
337
+ });
338
+ }
339
+ }
124
340
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathao.js","sourceRoot":"","sources":["../../src/adapters/pathao.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAuB,MAAM,WAAW,CAAC;AAW9D,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AACjD,MAAM,WAAW,GAAG,wCAAwC,CAAC;AAE7D,+EAA+E;AAC/E,MAAM,UAAU,eAAe,CAAC,GAAuB;IACrD,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,mBAAmB,CAAC;IACtD,IAAI,CAAC,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IAC1C,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,UAAU,CAAC;IAC5C,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACzC,IAA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M,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5C,CAAC"}
@@ -10,5 +10,19 @@ export declare class RedxAdapter implements CourierAdapter {
10
10
  private resolveDeliveryArea;
11
11
  createParcel(req: ParcelCreateRequest): Promise<ParcelResponse>;
12
12
  trackParcel(trackingCode: string): Promise<TrackingResponse>;
13
+ /**
14
+ * RedX does not expose a live wallet balance API endpoint (T3).
15
+ */
13
16
  getBalance(): Promise<BalanceResponse>;
17
+ /**
18
+ * Authentic Upstream RedX Cancellation
19
+ * Endpoint: PATCH /parcels
20
+ */
21
+ cancelParcel(trackingId: string, reason?: string): Promise<{
22
+ success: boolean;
23
+ courier: SupportedCourier;
24
+ consignment_id: string;
25
+ message: string;
26
+ raw_response?: any;
27
+ }>;
14
28
  }
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import { McpToolError, withGetRetry } from "../envelope.js";
2
3
  export class RedxAdapter {
3
4
  courierName = "redx";
4
5
  client;
@@ -89,23 +90,91 @@ export class RedxAdapter {
89
90
  }
90
91
  async trackParcel(trackingCode) {
91
92
  if (!this.enabled) {
92
- throw new Error("RedX credentials are not configured.");
93
+ throw new McpToolError({
94
+ code: "COURIER_NOT_CONFIGURED",
95
+ message: "RedX credentials are not configured.",
96
+ courier: "redx",
97
+ });
93
98
  }
94
- const response = await this.client.get(`/parcel/track/${encodeURIComponent(trackingCode)}`);
95
- const data = response.data;
96
- const events = data?.tracking || [];
97
- const latest = events[events.length - 1];
99
+ try {
100
+ const response = await withGetRetry(() => this.client.get(`/parcel/track/${encodeURIComponent(trackingCode)}`));
101
+ const data = response.data;
102
+ const events = data?.tracking || [];
103
+ const latest = events[events.length - 1];
104
+ return {
105
+ success: true,
106
+ courier: "redx",
107
+ tracking_code: trackingCode,
108
+ status: latest?.message_en || "in-transit",
109
+ updated_at: latest?.time || new Date().toISOString(),
110
+ timeline: events.map((e) => ({ status: e.message_en || "", time: e.time || "", note: e.message_bn })),
111
+ raw_response: data,
112
+ };
113
+ }
114
+ catch (err) {
115
+ if (err?.response?.status === 404 || err?.response?.status === 400) {
116
+ throw new McpToolError({
117
+ code: "CONSIGNMENT_NOT_FOUND",
118
+ message: `Consignment '${trackingCode}' was not found in RedX.`,
119
+ retryable: false,
120
+ courier: "redx",
121
+ });
122
+ }
123
+ throw err;
124
+ }
125
+ }
126
+ /**
127
+ * RedX does not expose a live wallet balance API endpoint (T3).
128
+ */
129
+ async getBalance() {
98
130
  return {
99
131
  success: true,
100
132
  courier: "redx",
101
- tracking_code: trackingCode,
102
- status: latest?.message_en || "unknown",
103
- updated_at: latest?.time || new Date().toISOString(),
104
- timeline: events.map((e) => ({ status: e.message_en || "", time: e.time || "", note: e.message_bn })),
105
- raw_response: data,
133
+ amount_bdt: null,
134
+ pending_bdt: null,
135
+ current_balance: null,
136
+ status: "UNSUPPORTED_BY_PROVIDER",
137
+ hint: "Use RedX merchant portal",
106
138
  };
107
139
  }
108
- async getBalance() {
109
- throw new Error("RedX does not expose a merchant balance endpoint via its public API — check your balance in the RedX merchant panel.");
140
+ /**
141
+ * Authentic Upstream RedX Cancellation
142
+ * Endpoint: PATCH /parcels
143
+ */
144
+ async cancelParcel(trackingId, reason) {
145
+ if (!this.enabled) {
146
+ throw new McpToolError({
147
+ code: "COURIER_NOT_CONFIGURED",
148
+ message: "RedX API access token is not configured.",
149
+ courier: "redx",
150
+ });
151
+ }
152
+ try {
153
+ const response = await this.client.patch("/parcels", {
154
+ entity_type: "parcel-tracking-id",
155
+ entity_id: trackingId,
156
+ update_details: {
157
+ property_name: "status",
158
+ new_value: "cancelled",
159
+ reason: reason || "Cancelled by merchant via Aura Courier MCP",
160
+ },
161
+ });
162
+ return {
163
+ success: true,
164
+ courier: "redx",
165
+ consignment_id: trackingId,
166
+ message: response.data?.message || "Parcel successfully cancelled in RedX Delivery.",
167
+ raw_response: response.data,
168
+ };
169
+ }
170
+ catch (err) {
171
+ const msg = err.response?.data?.message || err.message;
172
+ throw new McpToolError({
173
+ code: "COURIER_UPSTREAM_ERROR",
174
+ message: `RedX cancellation failed: ${msg}`,
175
+ courier: "redx",
176
+ retryable: false,
177
+ });
178
+ }
110
179
  }
111
180
  }