Files
iAs/resources/skills/list_scheduled_tasks/scripts/list.sh
T
wunianxiao 81c736f873 refactor: skill 脚本输出改为结构化 JSON
- query_weather: {location, now: {temp,text}, forecast: [{date,day,night,tempMin,tempMax}]}
- search_web: {query, answer, results: [{title,url,content}]}
- get_current_datetime: {datetime}
- list_scheduled_tasks: {tasks: [{name,description,enabled,command,...}]}
- manage_scheduled_task: {ok, action, name} / {error}

LLM 直接看到结构化数据,不再依赖脚本拼接的中文自然语言
2026-06-02 10:32:27 +08:00

27 lines
778 B
Bash
Executable File

#!/bin/bash
# 列出定时任务 → JSON 输出
DB_URL="${DATABASE_URL}"
[ -z "$DB_URL" ] && echo '{"tasks":[],"error":"数据库未配置"}' && exit 0
psql "$DB_URL" -t -A -F '|' -c "
SELECT jsonb_build_object(
'name', name,
'description', description,
'enabled', enabled,
'command', command,
'interval_seconds', interval_seconds,
'next_run_at', next_run_at
)
FROM scheduled_tasks ORDER BY name
" 2>/dev/null | python3 -c "
import sys, json
tasks = []
for line in sys.stdin:
line = line.strip()
if line:
try: tasks.append(json.loads(line))
except: pass
print(json.dumps({'tasks': tasks}, ensure_ascii=False))
"
[ -z "$(psql "$DB_URL" -t -A -c "SELECT count(*) FROM scheduled_tasks" 2>/dev/null)" ] && echo '{"tasks":[]}'