UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

34 lines • 1.21 kB
export class InMemoryOpenCodeSessionStore { refs = new Map(); async get(threadId) { return this.refs.get(threadId) ?? null; } async set(threadId, ref) { this.refs.set(threadId, ref); } } /** * Sessions kept in a shared key-value store (Redis…), so every process of a deployment finds the * session a thread already has — what running more than one process needs, alongside a * cross-process sink (`tokenSinks.redis()` / `tokenSinks.lucid()`). Keys are `<prefix><threadId>`. */ export function keyValueOpenCodeSessionStore(kv, prefix = 'agora:opencode:session:') { return { async get(threadId) { const raw = await kv.get(`${prefix}${threadId}`); if (raw === null || raw === undefined) return null; try { const ref = JSON.parse(raw); return typeof ref.sessionId === 'string' && typeof ref.serverKey === 'string' ? ref : null; } catch { return null; } }, async set(threadId, ref) { await kv.set(`${prefix}${threadId}`, JSON.stringify(ref)); }, }; } //# sourceMappingURL=host.js.map