@tomaspavlin/rohlik-mcp 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -3
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/rohlik-api.d.ts +4 -0
- package/dist/rohlik-api.d.ts.map +1 -1
- package/dist/rohlik-api.js +75 -10
- package/dist/rohlik-api.js.map +1 -1
- package/dist/tools/frequent-items.d.ts +34 -0
- package/dist/tools/frequent-items.d.ts.map +1 -0
- package/dist/tools/frequent-items.js +184 -0
- package/dist/tools/frequent-items.js.map +1 -0
- package/dist/tools/meal-suggestions.d.ts +36 -0
- package/dist/tools/meal-suggestions.d.ts.map +1 -0
- package/dist/tools/meal-suggestions.js +243 -0
- package/dist/tools/meal-suggestions.js.map +1 -0
- package/dist/tools/order-detail.d.ts +28 -0
- package/dist/tools/order-detail.d.ts.map +1 -0
- package/dist/tools/order-detail.js +78 -0
- package/dist/tools/order-detail.js.map +1 -0
- package/dist/tools/shopping-scenarios.d.ts +15 -0
- package/dist/tools/shopping-scenarios.d.ts.map +1 -0
- package/dist/tools/shopping-scenarios.js +143 -0
- package/dist/tools/shopping-scenarios.js.map +1 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function createFrequentItemsTool(createRohlikAPI) {
|
|
3
|
+
return {
|
|
4
|
+
name: "get_frequent_items",
|
|
5
|
+
definition: {
|
|
6
|
+
title: "Get Frequent Items",
|
|
7
|
+
description: "Analyze your order history to find the most frequently purchased items",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
orders_to_analyze: z.number().min(1).max(20).default(5).describe("Number of recent orders to analyze (1-20, default: 5)"),
|
|
10
|
+
top_items: z.number().min(3).max(30).default(10).describe("Number of top items to return overall (3-30, default: 10)"),
|
|
11
|
+
top_per_category: z.number().min(1).max(20).default(10).describe("Number of top items to show per category (1-20, default: 10)"),
|
|
12
|
+
show_categories: z.boolean().default(true).describe("Whether to show per-category breakdown (default: true)")
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
handler: async (args) => {
|
|
16
|
+
const { orders_to_analyze = 5, top_items = 10, top_per_category = 10, show_categories = true } = args;
|
|
17
|
+
try {
|
|
18
|
+
const api = createRohlikAPI();
|
|
19
|
+
// Step 1: Get order history
|
|
20
|
+
const orderHistory = await api.getOrderHistory(orders_to_analyze);
|
|
21
|
+
if (!orderHistory || (Array.isArray(orderHistory) && orderHistory.length === 0)) {
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: "No order history found. You need to have past orders to analyze frequent items."
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const orders = Array.isArray(orderHistory) ? orderHistory : [orderHistory];
|
|
32
|
+
// Step 2: Get detailed information for each order
|
|
33
|
+
const productMap = new Map();
|
|
34
|
+
let processedOrders = 0;
|
|
35
|
+
let totalProducts = 0;
|
|
36
|
+
for (const order of orders) {
|
|
37
|
+
try {
|
|
38
|
+
const orderId = order.id || order.orderNumber;
|
|
39
|
+
if (!orderId)
|
|
40
|
+
continue;
|
|
41
|
+
const orderDetail = await api.getOrderDetail(String(orderId));
|
|
42
|
+
if (!orderDetail)
|
|
43
|
+
continue;
|
|
44
|
+
processedOrders++;
|
|
45
|
+
const products = orderDetail.products || orderDetail.items || [];
|
|
46
|
+
const orderDate = orderDetail.deliveredAt || orderDetail.createdAt;
|
|
47
|
+
for (const product of products) {
|
|
48
|
+
const productId = product.productId || product.id;
|
|
49
|
+
const productName = product.productName || product.name;
|
|
50
|
+
if (!productId || !productName)
|
|
51
|
+
continue;
|
|
52
|
+
totalProducts++;
|
|
53
|
+
const key = `${productId}`;
|
|
54
|
+
// Extract category (use level 1 - mid-level category for grouping)
|
|
55
|
+
const categories = product.categories || [];
|
|
56
|
+
const mainCategory = categories.find((cat) => cat.level === 1) || categories[0];
|
|
57
|
+
const categoryName = mainCategory?.name || 'Uncategorized';
|
|
58
|
+
const categoryId = mainCategory?.id || 0;
|
|
59
|
+
if (productMap.has(key)) {
|
|
60
|
+
const existing = productMap.get(key);
|
|
61
|
+
existing.frequency++;
|
|
62
|
+
existing.totalQuantity += (product.quantity || 1);
|
|
63
|
+
// Update average price
|
|
64
|
+
if (product.price) {
|
|
65
|
+
const currentAvg = existing.averagePrice || 0;
|
|
66
|
+
existing.averagePrice = (currentAvg * (existing.frequency - 1) + product.price) / existing.frequency;
|
|
67
|
+
}
|
|
68
|
+
// Update last order date if newer
|
|
69
|
+
if (orderDate && (!existing.lastOrderDate || orderDate > existing.lastOrderDate)) {
|
|
70
|
+
existing.lastOrderDate = orderDate;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
productMap.set(key, {
|
|
75
|
+
productId: String(productId),
|
|
76
|
+
productName,
|
|
77
|
+
brand: product.brand || '',
|
|
78
|
+
frequency: 1,
|
|
79
|
+
totalQuantity: product.quantity || 1,
|
|
80
|
+
lastOrderDate: orderDate,
|
|
81
|
+
averagePrice: product.price || 0,
|
|
82
|
+
category: categoryName,
|
|
83
|
+
categoryId: categoryId
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
// Skip orders that fail to load
|
|
90
|
+
console.error(`Failed to process order: ${error}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Step 3: Sort by frequency and get top items
|
|
94
|
+
const sortedProducts = Array.from(productMap.values())
|
|
95
|
+
.sort((a, b) => b.frequency - a.frequency)
|
|
96
|
+
.slice(0, top_items);
|
|
97
|
+
if (sortedProducts.length === 0) {
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: "text",
|
|
102
|
+
text: `Analyzed ${processedOrders} orders but found no products. This might be due to API changes or data format issues.`
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Step 4: Group by category
|
|
108
|
+
const categoryMap = new Map();
|
|
109
|
+
for (const product of Array.from(productMap.values())) {
|
|
110
|
+
const catId = product.categoryId || 0;
|
|
111
|
+
const catName = product.category || 'Uncategorized';
|
|
112
|
+
if (!categoryMap.has(catId)) {
|
|
113
|
+
categoryMap.set(catId, {
|
|
114
|
+
categoryId: catId,
|
|
115
|
+
categoryName: catName,
|
|
116
|
+
products: []
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
categoryMap.get(catId).products.push(product);
|
|
120
|
+
}
|
|
121
|
+
// Sort products within each category
|
|
122
|
+
for (const category of categoryMap.values()) {
|
|
123
|
+
category.products.sort((a, b) => b.frequency - a.frequency);
|
|
124
|
+
}
|
|
125
|
+
// Step 5: Format output
|
|
126
|
+
const formatItem = (item, index, showCategory = false) => {
|
|
127
|
+
const brand = item.brand ? ` (${item.brand})` : '';
|
|
128
|
+
const avgPrice = item.averagePrice ? `${item.averagePrice.toFixed(2)} Kč` : 'N/A';
|
|
129
|
+
const lastOrder = item.lastOrderDate ? new Date(item.lastOrderDate).toLocaleDateString() : 'N/A';
|
|
130
|
+
const category = showCategory && item.category ? ` • ${item.category}` : '';
|
|
131
|
+
return `${index + 1}. ${item.productName}${brand}${category}
|
|
132
|
+
📊 ${item.frequency}× orders • ${item.totalQuantity} units • 💰 Avg: ${avgPrice} • 📅 Last: ${lastOrder}
|
|
133
|
+
🆔 ${item.productId}`;
|
|
134
|
+
};
|
|
135
|
+
// Build overall top items section
|
|
136
|
+
let output = `🛒 MOST FREQUENTLY PURCHASED ITEMS
|
|
137
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
138
|
+
📈 Analysis: ${processedOrders} orders • ${totalProducts} total items
|
|
139
|
+
|
|
140
|
+
🏆 TOP ${sortedProducts.length} OVERALL:
|
|
141
|
+
|
|
142
|
+
${sortedProducts.map((item, idx) => formatItem(item, idx, true)).join('\n\n')}`;
|
|
143
|
+
// Add category breakdown if requested
|
|
144
|
+
if (show_categories) {
|
|
145
|
+
// Sort categories by total frequency
|
|
146
|
+
const sortedCategories = Array.from(categoryMap.values())
|
|
147
|
+
.sort((a, b) => {
|
|
148
|
+
const aTotal = a.products.reduce((sum, p) => sum + p.frequency, 0);
|
|
149
|
+
const bTotal = b.products.reduce((sum, p) => sum + p.frequency, 0);
|
|
150
|
+
return bTotal - aTotal;
|
|
151
|
+
});
|
|
152
|
+
output += '\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n📂 TOP ITEMS BY CATEGORY:\n';
|
|
153
|
+
for (const category of sortedCategories) {
|
|
154
|
+
const topCategoryProducts = category.products.slice(0, top_per_category);
|
|
155
|
+
const totalCategoryFrequency = category.products.reduce((sum, p) => sum + p.frequency, 0);
|
|
156
|
+
output += `\n\n📦 ${category.categoryName.toUpperCase()} (${totalCategoryFrequency} total orders)\n${'─'.repeat(40)}\n`;
|
|
157
|
+
output += topCategoryProducts.map((item, idx) => formatItem(item, idx, false)).join('\n\n');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
output += '\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n💡 Tip: Use product IDs with add_to_cart to quickly reorder your favorites!';
|
|
161
|
+
return {
|
|
162
|
+
content: [
|
|
163
|
+
{
|
|
164
|
+
type: "text",
|
|
165
|
+
text: output
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
return {
|
|
172
|
+
content: [
|
|
173
|
+
{
|
|
174
|
+
type: "text",
|
|
175
|
+
text: error instanceof Error ? error.message : String(error)
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
isError: true
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=frequent-items.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frequent-items.js","sourceRoot":"","sources":["../../src/tools/frequent-items.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,MAAM,UAAU,uBAAuB,CAAC,eAAgC;IACtE,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,UAAU,EAAE;YACV,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,wEAAwE;YACrF,WAAW,EAAE;gBACX,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uDAAuD,CAAC;gBACzH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,2DAA2D,CAAC;gBACtH,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,8DAA8D,CAAC;gBAChI,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,wDAAwD,CAAC;aAC9G;SACF;QACD,OAAO,EAAE,KAAK,EAAE,IAA8G,EAAE,EAAE;YAChI,MAAM,EAAE,iBAAiB,GAAG,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAE,eAAe,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;YAEtG,I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import { RohlikAPI } from "../rohlik-api.js";
|
|
3
|
+
declare const MEAL_CATEGORY_MAPPINGS: Record<string, string[]>;
|
|
4
|
+
export declare function createMealSuggestionsTool(createRohlikAPI: () => RohlikAPI): {
|
|
5
|
+
name: string;
|
|
6
|
+
definition: {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
meal_type: z.ZodEnum<["breakfast", "lunch", "dinner", "snack", "baking", "drinks", "healthy"]>;
|
|
11
|
+
items_count: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
orders_to_analyze: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
prefer_frequent: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
handler: (args: {
|
|
17
|
+
meal_type: keyof typeof MEAL_CATEGORY_MAPPINGS;
|
|
18
|
+
items_count?: number;
|
|
19
|
+
orders_to_analyze?: number;
|
|
20
|
+
prefer_frequent?: boolean;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
content: {
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
}[];
|
|
26
|
+
isError: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
content: {
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
}[];
|
|
32
|
+
isError?: undefined;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=meal-suggestions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meal-suggestions.d.ts","sourceRoot":"","sources":["../../src/tools/meal-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAa7C,QAAA,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAsEpD,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,MAAM,SAAS;;;;;;;;;;;;oBAiBhD;QACpB,SAAS,EAAE,MAAM,OAAO,sBAAsB,CAAC;QAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;;;;;;;;;;;;;EAgLJ"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Category mappings for different meal types
|
|
3
|
+
const MEAL_CATEGORY_MAPPINGS = {
|
|
4
|
+
breakfast: [
|
|
5
|
+
"Pekárna",
|
|
6
|
+
"Mléko a mléčné nápoje",
|
|
7
|
+
"Müsli a cereálie",
|
|
8
|
+
"Džemy a pomazánky",
|
|
9
|
+
"Ovoce",
|
|
10
|
+
"Med",
|
|
11
|
+
"Máslo a tuky",
|
|
12
|
+
"Vejce"
|
|
13
|
+
],
|
|
14
|
+
lunch: [
|
|
15
|
+
"Maso a drůbež",
|
|
16
|
+
"Zelenina",
|
|
17
|
+
"Přílohy",
|
|
18
|
+
"Těstoviny",
|
|
19
|
+
"Rýže",
|
|
20
|
+
"Omáčky a dresinky",
|
|
21
|
+
"Polévky",
|
|
22
|
+
"Luštěniny"
|
|
23
|
+
],
|
|
24
|
+
dinner: [
|
|
25
|
+
"Maso a drůbež",
|
|
26
|
+
"Ryby a mořské plody",
|
|
27
|
+
"Zelenina",
|
|
28
|
+
"Přílohy",
|
|
29
|
+
"Těstoviny",
|
|
30
|
+
"Rýže",
|
|
31
|
+
"Brambory",
|
|
32
|
+
"Omáčky a dresinky"
|
|
33
|
+
],
|
|
34
|
+
snack: [
|
|
35
|
+
"Sladkosti",
|
|
36
|
+
"Ovoce",
|
|
37
|
+
"Ořechy a semínka",
|
|
38
|
+
"Jogurty",
|
|
39
|
+
"Sýry",
|
|
40
|
+
"Chipsy a krekry",
|
|
41
|
+
"Tyčinky"
|
|
42
|
+
],
|
|
43
|
+
baking: [
|
|
44
|
+
"Mouka a směsi",
|
|
45
|
+
"Cukr a sladidla",
|
|
46
|
+
"Pečení a vaření",
|
|
47
|
+
"Čokoláda a kakao",
|
|
48
|
+
"Ořechy a semínka",
|
|
49
|
+
"Vejce",
|
|
50
|
+
"Máslo a tuky",
|
|
51
|
+
"Droždí a kypřidla"
|
|
52
|
+
],
|
|
53
|
+
drinks: [
|
|
54
|
+
"Nápoje",
|
|
55
|
+
"Káva",
|
|
56
|
+
"Čaj",
|
|
57
|
+
"Mléko a mléčné nápoje",
|
|
58
|
+
"Džusy a smoothies",
|
|
59
|
+
"Minerální vody",
|
|
60
|
+
"Pivo",
|
|
61
|
+
"Víno"
|
|
62
|
+
],
|
|
63
|
+
healthy: [
|
|
64
|
+
"Bio produkty",
|
|
65
|
+
"Zdravá výživa",
|
|
66
|
+
"Bezlepkové",
|
|
67
|
+
"Veganské",
|
|
68
|
+
"Ovoce",
|
|
69
|
+
"Zelenina",
|
|
70
|
+
"Ořechy a semínka",
|
|
71
|
+
"Luštěniny"
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
export function createMealSuggestionsTool(createRohlikAPI) {
|
|
75
|
+
return {
|
|
76
|
+
name: "get_meal_suggestions",
|
|
77
|
+
definition: {
|
|
78
|
+
title: "Get Meal Suggestions",
|
|
79
|
+
description: "Get smart shopping suggestions for specific meal types (breakfast, lunch, dinner, etc.) based on your purchase history",
|
|
80
|
+
inputSchema: {
|
|
81
|
+
meal_type: z.enum(["breakfast", "lunch", "dinner", "snack", "baking", "drinks", "healthy"])
|
|
82
|
+
.describe("Type of meal or occasion (enum): breakfast, lunch, dinner, snack, baking, drinks, or healthy"),
|
|
83
|
+
items_count: z.number().min(3).max(30).default(10)
|
|
84
|
+
.describe("Number of items to suggest (3-30, default: 10)"),
|
|
85
|
+
orders_to_analyze: z.number().min(1).max(20).default(5)
|
|
86
|
+
.describe("Number of recent orders to analyze (1-20, default: 5)"),
|
|
87
|
+
prefer_frequent: z.boolean().default(true)
|
|
88
|
+
.describe("Prefer items you order frequently (default: true)")
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
handler: async (args) => {
|
|
92
|
+
const { meal_type, items_count = 10, orders_to_analyze = 5, prefer_frequent = true } = args;
|
|
93
|
+
try {
|
|
94
|
+
const api = createRohlikAPI();
|
|
95
|
+
// Get relevant categories for this meal type
|
|
96
|
+
const relevantCategories = MEAL_CATEGORY_MAPPINGS[meal_type];
|
|
97
|
+
if (!relevantCategories || relevantCategories.length === 0) {
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: "text",
|
|
102
|
+
text: `Unknown meal type: ${meal_type}. Available types: breakfast, lunch, dinner, snack, baking, drinks, healthy`
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
isError: true
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Fetch order history
|
|
109
|
+
const orderHistory = await api.getOrderHistory(orders_to_analyze);
|
|
110
|
+
if (!orderHistory || (Array.isArray(orderHistory) && orderHistory.length === 0)) {
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
type: "text",
|
|
115
|
+
text: "No order history found. I need your past orders to make personalized suggestions."
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const orders = Array.isArray(orderHistory) ? orderHistory : [orderHistory];
|
|
121
|
+
// Analyze products from relevant categories
|
|
122
|
+
const productMap = new Map();
|
|
123
|
+
let processedOrders = 0;
|
|
124
|
+
for (const order of orders) {
|
|
125
|
+
try {
|
|
126
|
+
const orderId = order.id || order.orderNumber;
|
|
127
|
+
if (!orderId)
|
|
128
|
+
continue;
|
|
129
|
+
const orderDetail = await api.getOrderDetail(String(orderId));
|
|
130
|
+
if (!orderDetail)
|
|
131
|
+
continue;
|
|
132
|
+
processedOrders++;
|
|
133
|
+
const products = orderDetail.products || orderDetail.items || [];
|
|
134
|
+
for (const product of products) {
|
|
135
|
+
const productId = product.productId || product.id;
|
|
136
|
+
const productName = product.productName || product.name;
|
|
137
|
+
if (!productId || !productName)
|
|
138
|
+
continue;
|
|
139
|
+
// Extract category
|
|
140
|
+
const categories = product.categories || [];
|
|
141
|
+
const mainCategory = categories.find((cat) => cat.level === 1) || categories[0];
|
|
142
|
+
const categoryName = mainCategory?.name || '';
|
|
143
|
+
// Check if this product belongs to relevant categories
|
|
144
|
+
const isRelevant = relevantCategories.some(cat => categoryName.toLowerCase().includes(cat.toLowerCase()) ||
|
|
145
|
+
cat.toLowerCase().includes(categoryName.toLowerCase()));
|
|
146
|
+
if (!isRelevant)
|
|
147
|
+
continue;
|
|
148
|
+
const key = `${productId}`;
|
|
149
|
+
if (productMap.has(key)) {
|
|
150
|
+
const existing = productMap.get(key);
|
|
151
|
+
existing.frequency++;
|
|
152
|
+
existing.totalQuantity += (product.quantity || 1);
|
|
153
|
+
if (product.price) {
|
|
154
|
+
const currentAvg = existing.averagePrice || 0;
|
|
155
|
+
existing.averagePrice = (currentAvg * (existing.frequency - 1) + product.price) / existing.frequency;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
productMap.set(key, {
|
|
160
|
+
productId: String(productId),
|
|
161
|
+
productName,
|
|
162
|
+
brand: product.brand || '',
|
|
163
|
+
frequency: 1,
|
|
164
|
+
totalQuantity: product.quantity || 1,
|
|
165
|
+
averagePrice: product.price || 0,
|
|
166
|
+
category: categoryName
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
console.error(`Failed to process order: ${error}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (productMap.size === 0) {
|
|
176
|
+
return {
|
|
177
|
+
content: [
|
|
178
|
+
{
|
|
179
|
+
type: "text",
|
|
180
|
+
text: `No items found for ${meal_type} in your order history. Try a different meal type or check if you have enough order history.`
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
// Sort by frequency if preferred, otherwise by recency
|
|
186
|
+
const sortedProducts = Array.from(productMap.values())
|
|
187
|
+
.sort((a, b) => {
|
|
188
|
+
if (prefer_frequent) {
|
|
189
|
+
return b.frequency - a.frequency;
|
|
190
|
+
}
|
|
191
|
+
return b.totalQuantity - a.totalQuantity;
|
|
192
|
+
})
|
|
193
|
+
.slice(0, items_count);
|
|
194
|
+
// Format output
|
|
195
|
+
const mealEmojis = {
|
|
196
|
+
breakfast: "🍳",
|
|
197
|
+
lunch: "🍽️",
|
|
198
|
+
dinner: "🍴",
|
|
199
|
+
snack: "🍿",
|
|
200
|
+
baking: "🧁",
|
|
201
|
+
drinks: "🥤",
|
|
202
|
+
healthy: "🥗"
|
|
203
|
+
};
|
|
204
|
+
const emoji = mealEmojis[meal_type] || "🛒";
|
|
205
|
+
const formatItem = (item, index) => {
|
|
206
|
+
const brand = item.brand ? ` (${item.brand})` : '';
|
|
207
|
+
const avgPrice = item.averagePrice ? `${item.averagePrice.toFixed(2)} Kč` : 'N/A';
|
|
208
|
+
const category = item.category ? ` • ${item.category}` : '';
|
|
209
|
+
return `${index + 1}. ${item.productName}${brand}${category}
|
|
210
|
+
📊 Ordered ${item.frequency}× • 💰 ${avgPrice} • 🆔 ${item.productId}`;
|
|
211
|
+
};
|
|
212
|
+
const output = `${emoji} ${meal_type.toUpperCase()} SUGGESTIONS
|
|
213
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
214
|
+
📈 Analyzed ${processedOrders} orders • Found ${productMap.size} relevant items
|
|
215
|
+
🎯 Relevant categories: ${relevantCategories.slice(0, 5).join(", ")}${relevantCategories.length > 5 ? '...' : ''}
|
|
216
|
+
|
|
217
|
+
${prefer_frequent ? '🏆 TOP ITEMS YOU FREQUENTLY ORDER:' : '📦 SUGGESTED ITEMS:'}
|
|
218
|
+
|
|
219
|
+
${sortedProducts.map(formatItem).join('\n\n')}`;
|
|
220
|
+
return {
|
|
221
|
+
content: [
|
|
222
|
+
{
|
|
223
|
+
type: "text",
|
|
224
|
+
text: output
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
return {
|
|
231
|
+
content: [
|
|
232
|
+
{
|
|
233
|
+
type: "text",
|
|
234
|
+
text: error instanceof Error ? error.message : String(error)
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
isError: true
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=meal-suggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meal-suggestions.js","sourceRoot":"","sources":["../../src/tools/meal-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,6CAA6C;AAC7C,MAAM,sBAAsB,GAA6B;IACvD,SAAS,EAAE;QACT,SAAS;QACT,uBAAuB;QACvB,kBAAkB;QAClB,mBAAmB;QACnB,OAAO;QACP,KAAK;QACL,cAAc;QACd,OAAO;KACR;IACD,KAAK,EAAE;QACL,eAAe;QACf,UAAU;QACV,SAAS;QACT,WAAW;QACX,MAAM;QACN,mBAAmB;QACnB,SAAS;QACT,WAAW;KACZ;IACD,MAAM,EAAE;QACN,eAAe;QACf,qBAAqB;QACrB,UAAU;QACV,SAAS;QACT,WAAW;QACX,MAAM;QACN,UAAU;QACV,mBAAmB;KACpB;IACD,KAAK,EAAE;QACL,WAAW;QACX,OAAO;QACP,kBAAkB;QAClB,SAAS;QACT,MAAM;QACN,iBAAiB;QACjB,SAAS;KACV;IACD,MAAM,EAAE;QACN,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,OAAO;QACP,cAAc;QACd,mBA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AAU,CAAC,IAAI;0BACrC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;;EAE9G,eAAe,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,qBAAqB;;EAE9E,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAExC,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,MAAM;yBACb;qBACF;iBACF,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;yBAC7D;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { RohlikAPI } from "../rohlik-api.js";
|
|
3
|
+
export declare function createOrderDetailTool(createRohlikAPI: () => RohlikAPI): {
|
|
4
|
+
name: string;
|
|
5
|
+
definition: {
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: {
|
|
9
|
+
orderId: z.ZodString;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
handler: (args: {
|
|
13
|
+
orderId: string;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
content: {
|
|
16
|
+
type: "text";
|
|
17
|
+
text: string;
|
|
18
|
+
}[];
|
|
19
|
+
isError?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
content: {
|
|
22
|
+
type: "text";
|
|
23
|
+
text: string;
|
|
24
|
+
}[];
|
|
25
|
+
isError: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=order-detail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-detail.d.ts","sourceRoot":"","sources":["../../src/tools/order-detail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,SAAS;;;;;;;;;oBAU5C;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;EAuE5C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function createOrderDetailTool(createRohlikAPI) {
|
|
3
|
+
return {
|
|
4
|
+
name: "get_order_detail",
|
|
5
|
+
definition: {
|
|
6
|
+
title: "Get Order Detail",
|
|
7
|
+
description: "Get detailed information about a specific order by its ID, including all products",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
orderId: z.string().describe("The order ID to fetch details for")
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
handler: async (args) => {
|
|
13
|
+
const { orderId } = args;
|
|
14
|
+
try {
|
|
15
|
+
const api = createRohlikAPI();
|
|
16
|
+
const orderDetail = await api.getOrderDetail(orderId);
|
|
17
|
+
if (!orderDetail) {
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: "text",
|
|
22
|
+
text: `Order with ID ${orderId} not found.`
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const formatProduct = (product, index) => {
|
|
28
|
+
const name = product.productName || product.name || 'Unknown product';
|
|
29
|
+
const quantity = product.quantity || 1;
|
|
30
|
+
const price = product.price || product.totalPrice || 0;
|
|
31
|
+
const brand = product.brand || '';
|
|
32
|
+
return ` ${index + 1}. ${name}${brand ? ` (${brand})` : ''}
|
|
33
|
+
Quantity: ${quantity}
|
|
34
|
+
Price: ${price} CZK`;
|
|
35
|
+
};
|
|
36
|
+
const order = orderDetail;
|
|
37
|
+
const orderNumber = order.orderNumber || order.id || orderId;
|
|
38
|
+
const orderDate = order.deliveredAt || order.createdAt || 'Unknown date';
|
|
39
|
+
const totalPrice = order.totalPrice || order.price || 'Unknown price';
|
|
40
|
+
const status = order.status || 'Unknown status';
|
|
41
|
+
const deliveryDate = order.deliveryDate || order.deliveredAt || 'Unknown delivery date';
|
|
42
|
+
const products = order.products || order.items || [];
|
|
43
|
+
const output = `📦 ORDER DETAILS - ${orderNumber}
|
|
44
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
45
|
+
Order Date: ${orderDate}
|
|
46
|
+
Delivery Date: ${deliveryDate}
|
|
47
|
+
Status: ${status}
|
|
48
|
+
Total Price: ${totalPrice} CZK
|
|
49
|
+
|
|
50
|
+
📋 PRODUCTS (${products.length} items):
|
|
51
|
+
${products.map(formatProduct).join('\n\n')}
|
|
52
|
+
|
|
53
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
54
|
+
Total: ${totalPrice} CZK`;
|
|
55
|
+
return {
|
|
56
|
+
content: [
|
|
57
|
+
{
|
|
58
|
+
type: "text",
|
|
59
|
+
text: output
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: "text",
|
|
69
|
+
text: error instanceof Error ? error.message : String(error)
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
isError: true
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=order-detail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-detail.js","sourceRoot":"","sources":["../../src/tools/order-detail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,qBAAqB,CAAC,eAAgC;IACpE,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE;YACV,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,mFAAmF;YAChG,WAAW,EAAE;gBACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;aAClE;SACF;QACD,OAAO,EAAE,KAAK,EAAE,IAAyB,EAAE,EAAE;YAC3C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YAEzB,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;gBAC9B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;gBAEtD,IAAI,CAAC,WAAW,EAAE,CAAC;oBACjB,OAAO;wBACL,OAAO,EAAE;4BACP;gCACE,IAAI,EAAE,MAAe;gCACrB,IAAI,EAAE,iBAAiB,OAAO,aAAa;6BAC5C;yBACF;qBACF,CAAC;gBACJ,CAAC;gBAED,MAAM,aAAa,GAAG,CAAC,OAAY,EAAE,KAAa,EAAU,EAAE;oBAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,IAAI,iBAAiB,CAAC;oBACtE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;oBACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;oBACvD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;oBAElC,OAAO,KAAK,KAAK,GA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yBAC7D;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function createShoppingScenariosTool(): {
|
|
2
|
+
name: string;
|
|
3
|
+
definition: {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {};
|
|
7
|
+
};
|
|
8
|
+
handler: () => Promise<{
|
|
9
|
+
content: {
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
}[];
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=shopping-scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopping-scenarios.d.ts","sourceRoot":"","sources":["../../src/tools/shopping-scenarios.ts"],"names":[],"mappings":"AAEA,wBAAgB,2BAA2B;;;;;;;;;;;;;EA8I1C"}
|