UNPKG

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) 1.27 kB
import{readAllowlist as a,writeAllowlist as r}from"./allowlist-store.js";import{log as s}from"../log/index.js";class u{filePath;writeQueue=Promise.resolve();constructor(e){this.filePath=e}async checkAccess(e){if(!e?.trim())return!1;const t=a(this.filePath);return t.includes(e)?!0:t.length===0?this.autoAdd(e):!1}async addOwner(e){e?.trim()&&(this.writeQueue=this.writeQueue.then(async()=>{const t=a(this.filePath);t.includes(e)||(t.push(e),await r(this.filePath,t))}).catch(t=>{s.error("allowlist-gate",`addOwner failed for ${e}: ${t instanceof Error?t.message:t}`)}),await this.writeQueue)}async removeOwner(e){e?.trim()&&(this.writeQueue=this.writeQueue.then(async()=>{const t=a(this.filePath),i=t.filter(l=>l!==e);i.length!==t.length&&await r(this.filePath,i)}).catch(t=>{s.error("allowlist-gate",`removeOwner failed for ${e}: ${t instanceof Error?t.message:t}`)}),await this.writeQueue)}async listOwners(){return a(this.filePath)}autoAdd(e){return new Promise(t=>{this.writeQueue=this.writeQueue.then(async()=>{const i=a(this.filePath);if(i.includes(e)){t(!0);return}if(i.length>0){t(!1);return}await r(this.filePath,[e]),t(!0)}).catch(i=>{s.error("allowlist-gate",`autoAdd failed for ${e}: ${i instanceof Error?i.message:i}`),t(!1)})})}}export{u as AllowlistGate};