@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
23 lines • 1.05 kB
JavaScript
export class HandoffAnnouncement {
/** Builds the record once the successor is known; undefined (logged) when the endpoint could not be checked. */
begin(superseded, identity, publicSocket, log) {
this.record = superseded.then((replaced) => ({
type: "host_superseded",
...identity,
successor: replaced ? { socket: publicSocket } : null,
}), (cause) => {
log(`handoff announcement failed: ${String(cause)}`);
return undefined;
});
return this.record;
}
/** Takes a connection that finished authenticating during the drain; false when it must be refused instead. */
deliverLate(stream, arrivedBeforeDrain) {
const record = this.record;
if (!arrivedBeforeDrain || record === undefined)
return false;
void record.then((announced) => announced === undefined ? stream.destroy() : stream.end(`${JSON.stringify(announced)}\n`));
return true;
}
}
//# sourceMappingURL=host-handoff-announcement.js.map