latest changes

This commit is contained in:
Joren de Graaf
2026-10-17 11:38:57 +02:00
parent 86e3afaca7
commit 76c76bc281
31 changed files with 4562 additions and 41 deletions
+27
View File
@@ -117,6 +117,12 @@ class InventoryUpdate(BaseModel):
best_before: str | None = None
class InventoryBulkUpdateEntry(BaseModel):
item_id: str
changes: InventoryUpdate
expected_updated_at: str | None = None
class HydrationSettingsUpdate(BaseModel):
daily_water_goal_ml: int | None = None
auto_count_food_drinks: bool | None = None
@@ -457,6 +463,27 @@ def create_server() -> MCPServer:
return {'success': False, 'error': item['error']}
return {'success': True, 'item': _inventory(item)}
@server.tool(structured_output=True, description='Preview or update up to 20 owned inventory rows. Uses inventory_update field rules. Partial success is default; atomic=true rolls back all updates if any item fails. Actual execution requires a unique idempotency_key; reuse the same key and payload on retry. Optionally supply expected_updated_at per item to reject concurrent edits.')
async def inventory_bulk_update(items: list[InventoryBulkUpdateEntry], idempotency_key: str | None = None,
dry_run: bool = True, atomic: bool = False) -> dict[str, Any]:
if not dry_run and not idempotency_key:
raise ToolError('idempotency_key_required: provide an idempotency key for updates')
data = await api_request('POST', 'kitchen/bulk-update/', payload={
'items': [{'item_id': row.item_id, 'changes': row.changes.model_dump(mode='json', exclude_unset=True),
**({'expected_updated_at': row.expected_updated_at} if row.expected_updated_at else {})}
for row in items], 'dry_run': dry_run, 'atomic': atomic}, idempotency_key=idempotency_key)
return {**data, 'idempotency_key': idempotency_key}
@server.tool(structured_output=True, description='Preview or archive up to 20 explicit owned inventory rows, without deleting products or consumption history. Dry run is default. Actual deletion requires confirm=true, a unique idempotency_key, and clear user intent. Partial success is default; atomic=true rolls back all deletions if any item fails.')
async def inventory_bulk_delete(item_ids: list[str], idempotency_key: str | None = None,
dry_run: bool = True, confirm: bool = False, atomic: bool = False) -> dict[str, Any]:
if not dry_run and (not confirm or not idempotency_key):
raise ToolError('confirmation_required: confirm=true and idempotency_key are required for deletion')
data = await api_request('POST', 'kitchen/bulk-delete/', payload={
'item_ids': item_ids, 'dry_run': dry_run, 'confirm': confirm, 'atomic': atomic},
idempotency_key=idempotency_key)
return {**data, 'idempotency_key': idempotency_key}
@server.tool(structured_output=True, description='Permanently remove one kitchen inventory item belonging to the authenticated user. This is destructive; require the user’s clear intent.')
async def inventory_remove(item_id: str) -> dict[str, Any]:
await api_request('DELETE', f'kitchen/items/{item_id}/')