feat: schedule cache, workflow-aligned prompts, dispatchInbound wakeup
1. ScheduleCache: local cache of today's schedule, synced every 5 min
from HF backend via new getDaySchedule() API
2. Wakeup prompts updated to reference daily-routine skill workflows
(task-handson, plan-schedule, slot-complete)
3. Agent wakeup via dispatchInboundMessageWithDispatcher (in-process)
- Same mechanism as Discord plugin
- Creates unique session per slot: agent:{agentId}:hf-calendar:slot-{slotId}
- No WebSocket, CLI, or cron dependency
- Verified working on test environment
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -169,6 +169,74 @@ export class CalendarBridgeClient {
|
||||
return this.sendBoolean('POST', url, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the full day schedule for this agent.
|
||||
*
|
||||
* Unlike heartbeat() which only returns pending (NOT_STARTED/DEFERRED) slots,
|
||||
* this returns ALL slots for the given date, enabling the plugin to maintain
|
||||
* a complete local view of today's schedule.
|
||||
*
|
||||
* @param date Date string in YYYY-MM-DD format
|
||||
* @returns Array of all slots for the day, or null if unreachable
|
||||
*/
|
||||
async getDaySchedule(date: string): Promise<CalendarSlotResponse[] | null> {
|
||||
const url = `${this.baseUrl}/calendar/day?date=${encodeURIComponent(date)}`;
|
||||
try {
|
||||
const response = await this.fetchJson<{ slots: CalendarSlotResponse[] }>(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-Agent-ID': this.config.agentId,
|
||||
'X-Claw-Identifier': this.config.clawIdentifier,
|
||||
},
|
||||
});
|
||||
return response?.slots ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync today's schedules for all agents on this claw instance.
|
||||
*
|
||||
* Returns { agentId → slots[] } for all agents with matching claw_identifier.
|
||||
* This is the primary data source for the multi-agent schedule cache.
|
||||
*/
|
||||
async syncSchedules(): Promise<{ schedules: Record<string, any[]>; date: string } | null> {
|
||||
const url = `${this.baseUrl}/calendar/sync`;
|
||||
try {
|
||||
const response = await this.fetchJson<{ schedules: Record<string, any[]>; date: string }>(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-Claw-Identifier': this.config.clawIdentifier,
|
||||
},
|
||||
});
|
||||
return response;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific agent's status.
|
||||
*
|
||||
* @param agentId The agent ID to query
|
||||
*/
|
||||
async getAgentStatus(agentId: string): Promise<string | null> {
|
||||
const url = `${this.baseUrl}/calendar/agent/status?agent_id=${encodeURIComponent(agentId)}`;
|
||||
try {
|
||||
const response = await this.fetchJson<{ status: string }>(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-Agent-ID': agentId,
|
||||
'X-Claw-Identifier': this.config.clawIdentifier,
|
||||
},
|
||||
});
|
||||
return response?.status ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Internal helpers
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user