@agimon-ai/po-core 0.0.0-alpha.184 → 0.0.0-alpha.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/headlessServer.cjs
CHANGED
|
@@ -539,11 +539,13 @@ async function serveHeadlessServer(options) {
|
|
|
539
539
|
}
|
|
540
540
|
});
|
|
541
541
|
};
|
|
542
|
+
/** Sessions a Remove is tearing down: never listed as dormant, so nothing can revive them mid-removal. */
|
|
543
|
+
const removing = /* @__PURE__ */ new Set();
|
|
542
544
|
/**
|
|
543
545
|
* A recorded session is dormant exactly while the hub has no session for its
|
|
544
546
|
* id, so reviving one needs no bookkeeping beyond the hub itself.
|
|
545
547
|
*/
|
|
546
|
-
const dormant = () => (options.dormantSessions?.() ?? []).filter((record) => options.headlessHub.session(record.sessionId) === void 0);
|
|
548
|
+
const dormant = () => (options.dormantSessions?.() ?? []).filter((record) => options.headlessHub.session(record.sessionId) === void 0 && !removing.has(record.sessionId));
|
|
547
549
|
const protocol = require_headlessProtocol.createHeadlessProtocol({
|
|
548
550
|
hub: options.headlessHub,
|
|
549
551
|
telemetry: options.telemetry,
|
|
@@ -557,12 +559,19 @@ async function serveHeadlessServer(options) {
|
|
|
557
559
|
isSessionPersisted: options.isSessionPersisted
|
|
558
560
|
});
|
|
559
561
|
const removeSession = async (sessionId, cleanup) => {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
await
|
|
564
|
-
options.headlessHub.
|
|
565
|
-
|
|
562
|
+
if (cleanup) removing.add(sessionId);
|
|
563
|
+
let removed = false;
|
|
564
|
+
try {
|
|
565
|
+
await sessionMcp?.closeSessionBinding(sessionId);
|
|
566
|
+
await options.headlessHub.closeSession(sessionId, cleanup ? { keepDormant: true } : void 0);
|
|
567
|
+
if (cleanup) {
|
|
568
|
+
await cleanup();
|
|
569
|
+
removed = true;
|
|
570
|
+
options.headlessHub.notifySessionRemoved(sessionId);
|
|
571
|
+
options.headlessHub.notifySessionDeleted(sessionId);
|
|
572
|
+
}
|
|
573
|
+
} finally {
|
|
574
|
+
if (cleanup && removing.delete(sessionId) && !removed) options.headlessHub.notifyDormantChanged(sessionId);
|
|
566
575
|
}
|
|
567
576
|
};
|
|
568
577
|
/** Lifecycle changes keyed by session id, settled once the change succeeds or fails. */
|