feat(tools): cancel_timer + adjust_timer
Two new Claude tools for voice control over existing timers.
Both accept a {label} (fuzzy match on tablet side, case-insensitive
substring) so the LLM doesn'\''t need to know internal timer ids.
- cancel_timer(label) → POST /api/voice/timer {action:cancel}
- adjust_timer(label, delta_seconds) → POST {action:adjust}
Use cases:
'\''Отмени таймер чайник'\'' → cancel_timer(label="чайник")
'\''Добавь ещё 5 минут к пасте'\'' → adjust_timer(label="паста", delta_seconds=300)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -131,6 +131,45 @@ TOOL_SCHEMAS: list[dict] = [
|
||||
"required": ["seconds", "label"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "cancel_timer",
|
||||
"description": (
|
||||
"Отменить активный таймер по его названию. "
|
||||
"Для 'отмени таймер чайник', 'убери таймер пасты', 'останови отсчёт'."
|
||||
),
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string",
|
||||
"description": "Название таймера (примерное совпадение — можно частично).",
|
||||
},
|
||||
},
|
||||
"required": ["label"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "adjust_timer",
|
||||
"description": (
|
||||
"Изменить оставшееся время таймера. "
|
||||
"Для 'добавь ещё 5 минут', 'убавь на минуту', 'накинь времени чайнику'. "
|
||||
"Положительный delta_seconds = добавить, отрицательный = уменьшить."
|
||||
),
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string",
|
||||
"description": "Название таймера для которого меняем время.",
|
||||
},
|
||||
"delta_seconds": {
|
||||
"type": "integer",
|
||||
"description": "Секунды (+ добавить, - уменьшить). Например 300 = +5 минут, -60 = -1 минута.",
|
||||
},
|
||||
},
|
||||
"required": ["label", "delta_seconds"],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -172,12 +211,34 @@ def _exec_set_timer(params: dict, agent_id: str) -> Any:
|
||||
)
|
||||
|
||||
|
||||
def _exec_cancel_timer(params: dict, agent_id: str) -> Any:
|
||||
label = params.get("label", "").strip()
|
||||
if not label:
|
||||
return {"error": "label required"}
|
||||
return _tablet_post("/api/voice/timer", {"action": "cancel", "label": label})
|
||||
|
||||
|
||||
def _exec_adjust_timer(params: dict, agent_id: str) -> Any:
|
||||
label = params.get("label", "").strip()
|
||||
delta = int(params.get("delta_seconds", 0))
|
||||
if not label:
|
||||
return {"error": "label required"}
|
||||
if delta == 0:
|
||||
return {"error": "delta_seconds must be non-zero"}
|
||||
return _tablet_post(
|
||||
"/api/voice/timer",
|
||||
{"action": "adjust", "label": label, "delta_seconds": delta},
|
||||
)
|
||||
|
||||
|
||||
EXECUTORS = {
|
||||
"get_weather": _exec_get_weather,
|
||||
"get_transport": _exec_get_transport,
|
||||
"get_today_events": _exec_get_today_events,
|
||||
"get_notes": _exec_get_notes,
|
||||
"set_timer": _exec_set_timer,
|
||||
"cancel_timer": _exec_cancel_timer,
|
||||
"adjust_timer": _exec_adjust_timer,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user