@chrischall/hellofresh-mcp 0.1.0 → 0.2.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +19 -9
- package/dist/bundle.js +1754 -713
- package/dist/client.js +123 -1
- package/dist/cooking.js +123 -0
- package/dist/index.js +5 -4
- package/dist/normalize.js +32 -0
- package/dist/planner.js +71 -16
- package/dist/session.js +47 -3
- package/dist/tools/cooking.js +150 -0
- package/dist/tools/favorites.js +164 -0
- package/dist/tools/index.js +7 -1
- package/dist/tools/planner.js +276 -83
- package/dist/tools/promo.js +108 -0
- package/dist/tools/reads.js +71 -40
- package/dist/tools/shared.js +210 -24
- package/dist/tools/writes/index.js +9 -0
- package/dist/tools/writes/plan.js +177 -0
- package/dist/tools/writes/shared.js +137 -0
- package/dist/tools/{writes.js → writes/week.js} +8 -290
- package/dist/transport.js +13 -1
- package/dist/version.js +1 -1
- package/manifest.json +43 -4
- package/mint.yaml +6 -0
- package/package.json +1 -1
- package/server.json +8 -2
- package/skills/hellofresh/SKILL.md +49 -12
- package/skills/hellofresh-fpx/SKILL.md +13 -5
- package/skills/hellofresh-fpx/references/requests.md +30 -10
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Cooking day: one recipe's detail (hf_get_recipe) and the week's picks in a
|
|
2
|
+
// recommended cook order (hf_cooking_plan). Read-only. Recipe text (names,
|
|
3
|
+
// ingredients, steps) is written by HelloFresh — third-party content — so both
|
|
4
|
+
// answer inside the untrusted-content envelope.
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { McpToolError, UNTRUSTED_CONTENT_RULE, UNTRUSTED_DESCRIPTION_SUFFIX, toolAnnotations, untrustedResult, } from '@chrischall/mcp-utils';
|
|
7
|
+
import { cookOrder, dayFrom, projectRecipe, recipeMinutes } from '../cooking.js';
|
|
8
|
+
import { projectDelivery, projectMenu } from '../normalize.js';
|
|
9
|
+
import { foodMeta } from './hints.js';
|
|
10
|
+
import { attempt, dateOf, loadAccount, readRawMenu, weekParam } from './shared.js';
|
|
11
|
+
const readOnly = (title) => toolAnnotations({ title, readOnly: true, idempotent: true, openWorld: true });
|
|
12
|
+
const RECIPE_NOTE = `Recipe names, headlines, ingredients and steps below are written by HelloFresh (third-party content), not the user. ${UNTRUSTED_CONTENT_RULE}`;
|
|
13
|
+
/** `note` is reserved by the envelope (a payload carrying one is nested under `data`): say `summary` instead. */
|
|
14
|
+
const fenced = (payload) => untrustedResult(payload, { note: RECIPE_NOTE });
|
|
15
|
+
/** How many ingredient names a cooking-plan dish lists. */
|
|
16
|
+
const SHORT_INGREDIENTS = 8;
|
|
17
|
+
/** Where a menu index sits: its raw meal and, for a protein swap, the base course and the swap's title. */
|
|
18
|
+
function locate(raw, menu, index) {
|
|
19
|
+
const meal = (raw.meals ?? []).find((m) => m.index === index);
|
|
20
|
+
for (const base of menu.meals) {
|
|
21
|
+
const variant = base.variants.find((v) => v.index === index);
|
|
22
|
+
if (variant)
|
|
23
|
+
return { meal, base, variant };
|
|
24
|
+
}
|
|
25
|
+
return { meal, base: menu.meals.find((m) => m.index === index), variant: undefined };
|
|
26
|
+
}
|
|
27
|
+
/** A protein swap as hf_get_recipe names it: what it swaps in is the swap's title, else its own recipe name, else unsaid. */
|
|
28
|
+
function swapOf(base, variant) {
|
|
29
|
+
const swapsIn = variant.title?.trim() || variant.name?.trim();
|
|
30
|
+
return {
|
|
31
|
+
baseIndex: base.index,
|
|
32
|
+
baseName: base.name,
|
|
33
|
+
...(variant.title ? { protein: variant.title } : {}),
|
|
34
|
+
note: `Protein swap of #${base.index} ${base.name}${swapsIn ? `: swaps in ${swapsIn}` : ''}.`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function recipeIdOf(meal, index, week) {
|
|
38
|
+
const id = meal?.recipe?.id;
|
|
39
|
+
if (!id)
|
|
40
|
+
throw new McpToolError(`HelloFresh returned no recipe id for menu index ${index} in ${week}, so its recipe cannot be read.`);
|
|
41
|
+
return id;
|
|
42
|
+
}
|
|
43
|
+
export function registerCookingTools(server, deps) {
|
|
44
|
+
const { client } = deps;
|
|
45
|
+
server.registerTool('hf_get_recipe', {
|
|
46
|
+
description: 'Read the full HelloFresh recipe for one meal on a week’s menu (by menu index, a protein swap included): ' +
|
|
47
|
+
'total time, difficulty, allergens, nutrition per serving, ingredients with amounts for the week’s servings ' +
|
|
48
|
+
'(nearest listed yield otherwise, said so), the cooking steps as plain text, utensils, the printable recipe ' +
|
|
49
|
+
`card and web page. Answers "how do I cook this?". ${UNTRUSTED_DESCRIPTION_SUFFIX}`,
|
|
50
|
+
annotations: readOnly('HelloFresh: get recipe'),
|
|
51
|
+
_meta: foodMeta('lookup', { aliases: ['hellofresh recipe', 'recipe card', 'how to cook'] }),
|
|
52
|
+
inputSchema: z.object({
|
|
53
|
+
week: weekParam,
|
|
54
|
+
index: z.number().int().min(0).describe('The meal’s menu index (from hf_get_menu or hf_get_delivery; a protein swap has its own).'),
|
|
55
|
+
}),
|
|
56
|
+
}, async ({ week, index }) => {
|
|
57
|
+
const account = await loadAccount(client);
|
|
58
|
+
const delivery = projectDelivery(await client.getDelivery(account.subscriptionId, week));
|
|
59
|
+
const raw = await readRawMenu(client, account, delivery, week);
|
|
60
|
+
const { meal, base, variant } = locate(raw, projectMenu(raw), index);
|
|
61
|
+
if (!meal) {
|
|
62
|
+
throw new McpToolError(`There is no meal with index ${index} on the ${week} menu.`, {
|
|
63
|
+
hint: 'hf_get_menu lists the week’s menu indexes (protein swaps under each course).',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const detail = await client.getRecipe(recipeIdOf(meal, index, week));
|
|
67
|
+
const servings = delivery.servings;
|
|
68
|
+
const quantity = meal.selection?.quantity ?? 0;
|
|
69
|
+
return fenced({
|
|
70
|
+
week,
|
|
71
|
+
index,
|
|
72
|
+
servings,
|
|
73
|
+
...(quantity > 0 ? { selectedQuantity: quantity } : {}),
|
|
74
|
+
...(quantity > 1
|
|
75
|
+
? { quantityNote: `This meal is picked ${quantity}× this week: multiply the amounts by ${quantity}.` }
|
|
76
|
+
: {}),
|
|
77
|
+
...(variant && base ? { swap: swapOf(base, variant) } : {}),
|
|
78
|
+
recipe: projectRecipe(detail, servings),
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
server.registerTool('hf_cooking_plan', {
|
|
82
|
+
description: 'Plan cooking for a HelloFresh delivery week: the picked meals in a recommended cook order, most perishable ' +
|
|
83
|
+
'first (fish, then shellfish, other seafood, poultry, ground meat, whole cuts of beef/pork/lamb, vegetarian ' +
|
|
84
|
+
'last; ties by shorter total time), each with a suggested day counted from the delivery date, why, total ' +
|
|
85
|
+
`time, a short ingredient list and the recipe card. ${UNTRUSTED_DESCRIPTION_SUFFIX}`,
|
|
86
|
+
annotations: readOnly('HelloFresh: cooking plan'),
|
|
87
|
+
_meta: foodMeta('whats-on', { aliases: ['what to cook', 'cooking order', 'dinner this week'] }),
|
|
88
|
+
inputSchema: z.object({ week: weekParam }),
|
|
89
|
+
}, async ({ week }) => {
|
|
90
|
+
const account = await loadAccount(client);
|
|
91
|
+
const delivery = projectDelivery(await client.getDelivery(account.subscriptionId, week));
|
|
92
|
+
const deliveryDate = dateOf(delivery.deliveryDate);
|
|
93
|
+
const head = { week, ...(deliveryDate ? { deliveryDate } : {}), status: delivery.status };
|
|
94
|
+
if (delivery.status === 'skipped') {
|
|
95
|
+
return fenced({ ...head, dishes: [], summary: `${week} is skipped: nothing is delivered, so there is nothing to cook.` });
|
|
96
|
+
}
|
|
97
|
+
const raw = await readRawMenu(client, account, delivery, week);
|
|
98
|
+
const menu = projectMenu(raw);
|
|
99
|
+
if (menu.selected.length === 0) {
|
|
100
|
+
return fenced({ ...head, dishes: [], summary: `No meals are picked for ${week} yet — pick them with hf_select_meals.` });
|
|
101
|
+
}
|
|
102
|
+
const servings = delivery.servings; // readRawMenu refuses a week without it
|
|
103
|
+
const dishes = await Promise.all(menu.selected.map(async (s) => {
|
|
104
|
+
const { meal, base, variant } = locate(raw, menu, s.index);
|
|
105
|
+
const recipe = meal?.recipe ?? {};
|
|
106
|
+
const read = await attempt(async () => projectRecipe(await client.getRecipe(recipeIdOf(meal, s.index, week)), servings));
|
|
107
|
+
const shipped = read.ok ? read.value.ingredients.filter((i) => !i.notInBox).map((i) => i.name) : [];
|
|
108
|
+
const dish = variant ?? base;
|
|
109
|
+
return {
|
|
110
|
+
index: s.index,
|
|
111
|
+
name: recipe.name,
|
|
112
|
+
quantity: s.quantity,
|
|
113
|
+
...(s.quantity > 1
|
|
114
|
+
? {
|
|
115
|
+
dinners: s.quantity,
|
|
116
|
+
quantityNote: `Picked ${s.quantity}× this week: this covers ${s.quantity} dinners (cook it on ${s.quantity} nights, or once at ${s.quantity}× the amounts).`,
|
|
117
|
+
}
|
|
118
|
+
: {}),
|
|
119
|
+
...(variant ? { swapOf: s.baseIndex } : {}),
|
|
120
|
+
category: dish?.category ?? recipe.category ?? null,
|
|
121
|
+
seafoodKind: dish?.seafoodKind ?? null,
|
|
122
|
+
totalMinutes: recipeMinutes(recipe),
|
|
123
|
+
text: [recipe.name, recipe.headline, ...shipped].join(' '),
|
|
124
|
+
...(read.ok
|
|
125
|
+
? {
|
|
126
|
+
ingredients: shipped.slice(0, SHORT_INGREDIENTS),
|
|
127
|
+
...(shipped.length > SHORT_INGREDIENTS ? { moreIngredients: shipped.length - SHORT_INGREDIENTS } : {}),
|
|
128
|
+
...(read.value.cardLink ? { cardLink: read.value.cardLink } : {}),
|
|
129
|
+
}
|
|
130
|
+
: { ingredientsError: read.reason }),
|
|
131
|
+
};
|
|
132
|
+
}));
|
|
133
|
+
const ordered = cookOrder(dishes);
|
|
134
|
+
return fenced({
|
|
135
|
+
...head,
|
|
136
|
+
dishes: ordered.map(({ text: _text, category: _category, seafoodKind: _kind, rank, why, ...d }, i) => {
|
|
137
|
+
const tied = ordered.filter((o) => o.rank === rank && o.index !== d.index).map((o) => `#${o.index}`);
|
|
138
|
+
return {
|
|
139
|
+
order: i + 1,
|
|
140
|
+
...(deliveryDate ? dayFrom(deliveryDate, i) : {}),
|
|
141
|
+
...d,
|
|
142
|
+
why: tied.length > 0 ? `${why} Same perishability as ${tied.join(', ')}: shorter total time first.` : why,
|
|
143
|
+
};
|
|
144
|
+
}),
|
|
145
|
+
...(deliveryDate
|
|
146
|
+
? { dayNote: 'Days count from the delivery day (the most perishable dish that evening); shift them to fit your week.' }
|
|
147
|
+
: {}),
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Favourites and ratings (docs/HELLOFRESH-API.md "Added 2026-11-12"):
|
|
2
|
+
//
|
|
3
|
+
// hf_list_favorites — read: the user's favourite recipe ids (never the
|
|
4
|
+
// customer uuid each item carries), named from a
|
|
5
|
+
// week's menu when one is given;
|
|
6
|
+
// hf_list_ratings — read: the user's own recipe ratings on the v2 and/or
|
|
7
|
+
// v3 (5-star) scale. The list's item shape is NOT yet
|
|
8
|
+
// observed, so items are parsed defensively and the
|
|
9
|
+
// unparseable ones are skipped and counted;
|
|
10
|
+
// hf_favorite_recipe /
|
|
11
|
+
// hf_unfavorite_recipe — confirm-gated writes (each the other's inverse, so
|
|
12
|
+
// neither is destructive), verified by re-reading the
|
|
13
|
+
// favourites list.
|
|
14
|
+
//
|
|
15
|
+
// There is deliberately NO rating write: the rate call is not verified live
|
|
16
|
+
// (it needs a delivered box), see the API doc.
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { McpToolError, minifiedResult, toolAnnotations } from '@chrischall/mcp-utils';
|
|
19
|
+
import { addFavoriteRequest, removeFavoriteRequest } from '../client.js';
|
|
20
|
+
import { projectDelivery, projectFavorites } from '../normalize.js';
|
|
21
|
+
import { foodMeta } from './hints.js';
|
|
22
|
+
import { RATING_SCALES, attempt, loadAccount, readMenu, readRatings, weekParam } from './shared.js';
|
|
23
|
+
import { CHANGE, registerGated, sendAndVerify, shown } from './writes/shared.js';
|
|
24
|
+
const readOnly = (title) => toolAnnotations({ title, readOnly: true, idempotent: true, openWorld: true });
|
|
25
|
+
/** Every recipe on the menu (base courses and their protein swaps): recipe id → menu index + name. */
|
|
26
|
+
function recipesOf(menu) {
|
|
27
|
+
const recipes = new Map();
|
|
28
|
+
for (const m of menu.meals) {
|
|
29
|
+
if (m.recipeId)
|
|
30
|
+
recipes.set(m.recipeId, { index: m.index, name: m.name });
|
|
31
|
+
for (const v of m.variants)
|
|
32
|
+
if (v.recipeId)
|
|
33
|
+
recipes.set(v.recipeId, { index: v.index, name: v.name ?? v.title });
|
|
34
|
+
}
|
|
35
|
+
return recipes;
|
|
36
|
+
}
|
|
37
|
+
/** The week's menu, best effort: its recipes, or the reason it could not be read. */
|
|
38
|
+
async function weekRecipes(client, week) {
|
|
39
|
+
return attempt(async () => {
|
|
40
|
+
const account = await loadAccount(client);
|
|
41
|
+
const delivery = projectDelivery(await client.getDelivery(account.subscriptionId, week));
|
|
42
|
+
return recipesOf(await readMenu(client, account, delivery, week));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Name each item found on the week's menu (best effort); `menuError` when the menu could not be read. */
|
|
46
|
+
async function nameFromWeek(client, items, week) {
|
|
47
|
+
if (!week)
|
|
48
|
+
return { items, extra: {} };
|
|
49
|
+
const recipes = await weekRecipes(client, week);
|
|
50
|
+
if (!recipes.ok)
|
|
51
|
+
return { items, extra: { menuError: recipes.reason } };
|
|
52
|
+
const named = items.map((item) => {
|
|
53
|
+
const hit = recipes.value.get(item.recipeId);
|
|
54
|
+
return hit ? { ...item, menuWeek: week, index: hit.index, ...(hit.name ? { name: hit.name } : {}) } : item;
|
|
55
|
+
});
|
|
56
|
+
return { items: named, extra: { onMenu: named.filter((i) => 'index' in i).length } };
|
|
57
|
+
}
|
|
58
|
+
const optionalWeek = weekParam
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('A delivery week (ISO, e.g. 2026-W49): items on that week’s menu are named with their menu index.');
|
|
61
|
+
export function registerFavoriteTools(server, deps) {
|
|
62
|
+
const { client } = deps;
|
|
63
|
+
server.registerTool('hf_list_favorites', {
|
|
64
|
+
description: 'List the recipes the user favourited on HelloFresh (recipe ids and when). Give a week to name the ones on ' +
|
|
65
|
+
'that week’s menu with their menu index (hf_favorite_recipe / hf_unfavorite_recipe take that index). ' +
|
|
66
|
+
'hf_suggest_meals and hf_weekly_plan already favour these recipes.',
|
|
67
|
+
annotations: readOnly('HelloFresh: list favourite recipes'),
|
|
68
|
+
_meta: foodMeta('lookup', { aliases: ['hellofresh favorites', 'favourite recipes', 'saved recipes'] }),
|
|
69
|
+
inputSchema: z.object({ week: optionalWeek }),
|
|
70
|
+
}, async ({ week }) => {
|
|
71
|
+
const { total, favorites } = projectFavorites(await client.listFavorites());
|
|
72
|
+
const { items, extra } = await nameFromWeek(client, favorites, week);
|
|
73
|
+
return minifiedResult({ ...(total !== undefined ? { total } : {}), favorites: items, ...extra });
|
|
74
|
+
});
|
|
75
|
+
server.registerTool('hf_list_ratings', {
|
|
76
|
+
description: 'List the user’s own HelloFresh recipe ratings (both rating scales by default: v2, and v3 = 5 stars). Give a ' +
|
|
77
|
+
'week to name the rated recipes on that week’s menu. The planner never suggests a recipe rated 2 or lower. ' +
|
|
78
|
+
'The ratings list’s item shape has not been observed yet, so items without a recipe id and a numeric rating ' +
|
|
79
|
+
'are skipped and counted, not guessed at. Read-only: rating a recipe is not supported.',
|
|
80
|
+
annotations: readOnly('HelloFresh: list recipe ratings'),
|
|
81
|
+
_meta: foodMeta('lookup', { aliases: ['hellofresh ratings', 'rated recipes', 'my recipe ratings'] }),
|
|
82
|
+
inputSchema: z.object({
|
|
83
|
+
week: optionalWeek,
|
|
84
|
+
scale: z.enum(['v2', 'v3']).optional().describe('One rating scale only (v3 = 5 stars). Default: both.'),
|
|
85
|
+
}),
|
|
86
|
+
}, async ({ week, scale }) => {
|
|
87
|
+
const scales = scale ? [scale] : RATING_SCALES;
|
|
88
|
+
const read = await readRatings(client, scales);
|
|
89
|
+
if (read.unreadable.length === scales.length) {
|
|
90
|
+
throw new McpToolError(`Could not read your HelloFresh ratings: ${read.unreadable.map((u) => `${u.source}: ${u.reason}`).join('; ')}`);
|
|
91
|
+
}
|
|
92
|
+
const { items, extra } = await nameFromWeek(client, read.ratings, week);
|
|
93
|
+
return minifiedResult({
|
|
94
|
+
ratings: items,
|
|
95
|
+
...(read.skipped > 0 ? { skipped: read.skipped } : {}),
|
|
96
|
+
...(read.unreadable.length > 0 ? { unreadable: read.unreadable } : {}),
|
|
97
|
+
...extra,
|
|
98
|
+
note: 'The ratings item shape is not yet observed live: an item counts when it has a recipe id (object_id) and ' +
|
|
99
|
+
'a numeric rating; any other item is skipped and counted.',
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const favoriteWrite = (add) => {
|
|
103
|
+
const name = add ? 'hf_favorite_recipe' : 'hf_unfavorite_recipe';
|
|
104
|
+
registerGated(server, {
|
|
105
|
+
name,
|
|
106
|
+
title: add ? 'HelloFresh: favourite a recipe' : 'HelloFresh: un-favourite a recipe',
|
|
107
|
+
description: add
|
|
108
|
+
? 'Add a recipe from a week’s menu to the user’s HelloFresh favourites (the planner then favours it). Give ' +
|
|
109
|
+
'the week and the menu index from hf_get_menu (a protein swap favourites the swap’s own recipe). Undo with ' +
|
|
110
|
+
'hf_unfavorite_recipe. Re-reads the favourites to verify.'
|
|
111
|
+
: 'Remove a recipe on a week’s menu from the user’s HelloFresh favourites. Give the week and the menu index ' +
|
|
112
|
+
'(hf_list_favorites with the week shows which are favourites). Undo with hf_favorite_recipe. Re-reads the ' +
|
|
113
|
+
'favourites to verify.',
|
|
114
|
+
destructive: false,
|
|
115
|
+
meta: CHANGE(add ? ['favorite hellofresh recipe', 'save recipe', 'like this recipe'] : ['unfavorite hellofresh recipe', 'remove favorite']),
|
|
116
|
+
input: {
|
|
117
|
+
week: weekParam,
|
|
118
|
+
index: z.number().int().positive().describe('The recipe’s menu index for that week (from hf_get_menu).'),
|
|
119
|
+
},
|
|
120
|
+
async plan({ week, index }) {
|
|
121
|
+
const account = await loadAccount(client);
|
|
122
|
+
const delivery = projectDelivery(await client.getDelivery(account.subscriptionId, week));
|
|
123
|
+
const menu = await readMenu(client, account, delivery, week);
|
|
124
|
+
const entry = [...recipesOf(menu)].find(([, r]) => r.index === index);
|
|
125
|
+
if (!entry) {
|
|
126
|
+
const listed = menu.meals.some((m) => m.index === index || m.variants.some((v) => v.index === index));
|
|
127
|
+
throw new McpToolError(listed ? `HelloFresh returned no recipe id for meal ${index} on the ${week} menu.` : `Meal ${index} is not on the ${week} menu.`, { hint: `hf_get_menu {week: "${week}"} lists the indexes.` });
|
|
128
|
+
}
|
|
129
|
+
const [recipeId, recipe] = entry;
|
|
130
|
+
const favorites = projectFavorites(await client.listFavorites()).favorites;
|
|
131
|
+
const isFavorite = favorites.some((f) => f.recipeId === recipeId);
|
|
132
|
+
const label = `“${recipe.name ?? recipeId}” (menu #${index}, ${week})`;
|
|
133
|
+
if (add && isFavorite)
|
|
134
|
+
throw new McpToolError(`${label} is already one of your favorites.`);
|
|
135
|
+
if (!add && !isFavorite)
|
|
136
|
+
throw new McpToolError(`${label} is not one of your favorites.`);
|
|
137
|
+
const request = add ? addFavoriteRequest(recipeId, week) : removeFavoriteRequest(recipeId);
|
|
138
|
+
return {
|
|
139
|
+
gate: {
|
|
140
|
+
action: add ? 'hellofresh.recipe.favorite' : 'hellofresh.recipe.unfavorite',
|
|
141
|
+
summary: add ? `Add ${label} to your HelloFresh favorites` : `Remove ${label} from your HelloFresh favorites`,
|
|
142
|
+
account: account.subscriptionId,
|
|
143
|
+
target: recipeId,
|
|
144
|
+
request: shown(request),
|
|
145
|
+
preview: { recipe: { index, name: recipe.name, recipeId }, favoritesNow: favorites.length },
|
|
146
|
+
},
|
|
147
|
+
state: { recipeId, week },
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
execute: (s) => sendAndVerify({
|
|
151
|
+
send: () => (add ? client.addFavorite(s.recipeId, s.week) : client.removeFavorite(s.recipeId)),
|
|
152
|
+
before: { favorite: !add },
|
|
153
|
+
checkWith: `hf_list_favorites {week: "${s.week}"}`,
|
|
154
|
+
mismatch: `HelloFresh accepted the request, but the re-read favourites ${add ? 'do not include' : 'still include'} the recipe.`,
|
|
155
|
+
verify: async () => {
|
|
156
|
+
const favorite = projectFavorites(await client.listFavorites()).favorites.some((f) => f.recipeId === s.recipeId);
|
|
157
|
+
return { ok: favorite === add, after: { favorite } };
|
|
158
|
+
},
|
|
159
|
+
}),
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
favoriteWrite(true);
|
|
163
|
+
favoriteWrite(false);
|
|
164
|
+
}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// The one list of tool registrars. `src/index.ts` registers exactly these, and
|
|
2
2
|
// the manifest-roster and annotation tests drive the same list, so a registrar
|
|
3
3
|
// can never be wired into the server but missed by the tests (or vice versa).
|
|
4
|
+
import { registerCookingTools } from './cooking.js';
|
|
5
|
+
import { registerFavoriteTools } from './favorites.js';
|
|
4
6
|
import { registerHealthcheckTool } from './healthcheck.js';
|
|
5
7
|
import { registerPlannerTools } from './planner.js';
|
|
8
|
+
import { registerPromoTools } from './promo.js';
|
|
6
9
|
import { registerReadTools } from './reads.js';
|
|
7
|
-
import { registerWriteTools } from './writes.js';
|
|
10
|
+
import { registerWriteTools } from './writes/index.js';
|
|
8
11
|
export const TOOL_REGISTRARS = [
|
|
9
12
|
registerHealthcheckTool,
|
|
10
13
|
registerReadTools,
|
|
11
14
|
registerWriteTools,
|
|
12
15
|
registerPlannerTools,
|
|
16
|
+
registerCookingTools,
|
|
17
|
+
registerFavoriteTools,
|
|
18
|
+
registerPromoTools,
|
|
13
19
|
];
|