feat: wake agent via cron service instead of WebSocket/spawn

Use the same mechanism as dreaming/memory-core: acquire cron
service from gateway_start event, create one-shot cron job
with wakeMode: "now" and deleteAfterRun: true.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
operator
2026-04-19 07:35:48 +00:00
parent fb53af642d
commit ae2d035a83
2 changed files with 41 additions and 82 deletions

View File

@@ -7,10 +7,20 @@ export function registerGatewayStartHook(api: any, deps: {
pushMetaToMonitor: () => Promise<void>;
startCalendarScheduler: () => void;
setMetaPushInterval: (handle: ReturnType<typeof setInterval>) => void;
onCronServiceAvailable?: (cron: any) => void;
}) {
const { logger, pushMetaToMonitor, startCalendarScheduler, setMetaPushInterval } = deps;
api.on('gateway_start', () => {
api.on('gateway_start', (event?: any) => {
// Extract cron service from gateway startup event (same as memory-core dreaming)
if (event && deps.onCronServiceAvailable) {
const context = event?.context;
const cron = context?.cron ?? context?.deps?.cron;
if (cron && typeof cron.add === 'function') {
deps.onCronServiceAvailable(cron);
logger.info('HarborForge: cron service acquired from gateway_start');
}
}
logger.info('HarborForge plugin active');
const live = getPluginConfig(api);