From 2538c91876455fe96febf441fc8dde20f2606023 Mon Sep 17 00:00:00 2001 From: Agando Date: Thu, 9 Jul 2026 06:00:32 +0200 Subject: auto: 2026-07-09_06:00 changes --- modules/core/module-leases.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'modules/core/module-leases.js') diff --git a/modules/core/module-leases.js b/modules/core/module-leases.js index 7489c92..60e8d98 100644 --- a/modules/core/module-leases.js +++ b/modules/core/module-leases.js @@ -38,10 +38,15 @@ class LeaseModule { this.terminal.print('πŸ“œ Lease system loaded', 'info'); } createLease(args) { + // Parse --write flag + const writeIdx = args.indexOf('--write'); + const writeAccess = writeIdx !== -1; + if (writeIdx !== -1) args.splice(writeIdx, 1); + const workerId = args[1]; const duration = parseInt(args[2]) || 30; const task = args.slice(3).join(' ') || 'generic task'; - if (!workerId) return this.terminal.print('Usage: lease-create [duration_sec] [task]', 'error'); + if (!workerId) return this.terminal.print('Usage: lease-create [duration_sec] [task] [--write]', 'error'); const lease = { id: `lease-${Date.now()}`, @@ -51,7 +56,8 @@ class LeaseModule { createdAt: new Date().toISOString(), expiresAt: new Date(Date.now() + duration * 1000).toISOString(), status: 'active', - duration + duration, + write_access: writeAccess }; this._leases[lease.id] = lease; this.terminal.fs.writeFile(`leases/${lease.id}.json`, JSON.stringify(lease)); @@ -79,9 +85,14 @@ class LeaseModule { this.terminal.print(`πŸ“œ Leases: ${active.length} active, ${expired.length} expired, ${revoked.length} revoked`, 'header'); active.forEach(l => { const remaining = Math.max(0, Math.round((new Date(l.expiresAt) - Date.now()) / 1000)); - this.terminal.print(` ${l.id} β†’ ${l.workerId} (${remaining}s remain) β€” ${l.task.substring(0, 40)}`, 'info'); + const writeTag = l.write_access ? ' ✏️write' : ' πŸ”read'; + this.terminal.print(` ${l.id} β†’ ${l.workerId} (${remaining}s remain)${writeTag} β€” ${l.task.substring(0, 40)}`, 'info'); }); } + hasWriteAccess(agentId) { + // Check if any active lease grants write access for this agent + return Object.values(this._leases).some(l => l.workerId === agentId && l.status === 'active' && l.write_access === true); + } revokeLease(id) { if (!this._leases[id]) return this.terminal.print(`❌ Lease ${id} not found`, 'error'); this._leases[id].status = 'revoked'; -- cgit v1.2.3