统计
@@ -384,6 +416,41 @@ async function loadAgentInfo() {
} catch (e) { console.error('Agent info error:', e) }
}
+async function updateHeartbeat() {
+ if (!agentId.value || !agentInfo.value.heartbeat) return
+ try {
+ await fetch(`/api/agent/${agentId.value}/heartbeat`, {
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(agentInfo.value.heartbeat)
+ })
+ } catch (e) { console.error('Heartbeat update error:', e) }
+}
+
+async function updateCron() {
+ if (!agentId.value || !agentInfo.value.cron) return
+ try {
+ await fetch(`/api/agent/${agentId.value}/cron`, {
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ cron: agentInfo.value.cron })
+ })
+ } catch (e) { console.error('Cron update error:', e) }
+}
+
+function addCron() {
+ if (!agentInfo.value.cron) agentInfo.value.cron = []
+ agentInfo.value.cron.push({ "schedule": "0 8 * * *", "task": "新提醒任务", "enabled": true })
+ updateCron()
+}
+
+function removeCron(index) {
+ if (confirm('确认删除该定时任务?')) {
+ agentInfo.value.cron.splice(index, 1)
+ updateCron()
+ }
+}
+
async function loadConversations() {
if (!agentId.value) return
try {