Files
HarborForge.OpenclawPlugin/plugin/calendar/index.ts
operator 4a66a7cc90 feat: add local schedule cache + periodic sync to CalendarScheduler
- New ScheduleCache class: maintains today's full schedule locally
- CalendarBridgeClient.getDaySchedule(): fetch all slots for a date
- Scheduler now runs two intervals:
  - Heartbeat (60s): existing slot execution flow (unchanged)
  - Sync (5min): pulls full day schedule into local cache
- Exposes getScheduleCache() for tools and status reporting

This enables the plugin to detect slots assigned by other agents
between heartbeats and provides a complete local view of the schedule.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-19 03:26:56 +00:00

35 lines
1.2 KiB
TypeScript

/**
* HarborForge Calendar — Plugin Module
*
* PLG-CAL-001: Calendar heartbeat request/response format definition.
* PLG-CAL-002: Plugin-side slot execution scheduler and agent wakeup.
*
* Exports:
* • Types for heartbeat request/response and slot update
* • CalendarBridgeClient — HTTP client for backend communication
* • createCalendarBridgeClient — factory from plugin API context
* • CalendarScheduler — manages periodic heartbeat and slot execution
* • createCalendarScheduler — factory for scheduler
* • AgentWakeContext — context passed to agent when waking
*
* Usage in plugin/index.ts:
* import { createCalendarBridgeClient, createCalendarScheduler } from './calendar';
*
* const agentId = process.env.AGENT_ID || 'unknown';
* const calendar = createCalendarBridgeClient(api, 'https://monitor.hangman-lab.top', agentId);
*
* const scheduler = createCalendarScheduler({
* bridge: calendar,
* getAgentStatus: async () => { ... },
* wakeAgent: async (context) => { ... },
* logger: api.logger,
* });
*
* scheduler.start();
*/
export * from './types';
export * from './calendar-bridge';
export * from './scheduler';
export * from './schedule-cache';