UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

32 lines • 1.19 kB
import { randomUUID } from "node:crypto"; import { ExtensionTransportOwner } from "./extension-owner.js"; /** One session handler's captures, retired synchronously before replacement or disposal awaits. */ export class ExtensionOwnerLifetime { constructor(isClassic, source, onRetireBinding) { this.generation = randomUUID(); this.captures = new Set(); this.source = source; this.onRetireBinding = onRetireBinding; this.classic = isClassic && source === undefined ? new ExtensionTransportOwner() : undefined; } capture() { const owner = this.source === undefined ? this.classic?.capture(this.generation) : this.source(); if (owner) this.captures.add(owner); return owner; } retireBinding() { const hadCaptures = this.captures.size > 0; for (const owner of this.captures) owner.retire(); this.captures.clear(); this.generation = randomUUID(); if (hadCaptures) this.onRetireBinding?.(); } dispose() { this.retireBinding(); this.classic?.retire(); } } //# sourceMappingURL=extension-owner-lifetime.js.map