grix-connector
Version:
Connect local AI coding agents (Claude, Codex, Gemini, Qwen, DeepSeek, Cursor, OpenCode, Pi, OpenHuman, Reasonix) to the Grix scheduling platform. Also serves as an OpenClaw plugin for Grix channel transport.
2 lines (1 loc) • 681 B
JavaScript
import{readJSONFile as r,writeJSONFileAtomic as a}from"../util/json-file.js";import{log as o}from"../log/index.js";import{unlink as n}from"node:fs/promises";class v{filePath;constructor(t){this.filePath=t}async save(t){if(t.length===0){await this.remove();return}const i=t.map(e=>({eventId:e,savedAt:Date.now()}));await a(this.filePath,i),o.info("active-event-store",`Saved ${i.length} active event(s)`)}async drain(){const t=r(this.filePath);if(await this.remove(),!Array.isArray(t))return[];const i=[];for(const e of t)e&&typeof e=="object"&&typeof e.eventId=="string"&&i.push(e.eventId);return i}async remove(){try{await n(this.filePath)}catch{}}}export{v as ActiveEventStore};