@supanadit/morse-web 0.9.4 → 0.9.5
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/server.mjs
CHANGED
|
@@ -2383,6 +2383,11 @@ var SessionTranscriptStore = class {
|
|
|
2383
2383
|
projectors = /* @__PURE__ */ new Map();
|
|
2384
2384
|
cursors = /* @__PURE__ */ new Map();
|
|
2385
2385
|
listeners = /* @__PURE__ */ new Set();
|
|
2386
|
+
/**
|
|
2387
|
+
* Agent events already projected, by instance (see `apply`). A weak set, so
|
|
2388
|
+
* a projected record never keeps itself alive after it has been fanned out.
|
|
2389
|
+
*/
|
|
2390
|
+
applied = /* @__PURE__ */ new WeakSet();
|
|
2386
2391
|
subscribe(listener) {
|
|
2387
2392
|
this.listeners.add(listener);
|
|
2388
2393
|
return () => {
|
|
@@ -2402,7 +2407,25 @@ var SessionTranscriptStore = class {
|
|
|
2402
2407
|
setHistoryCursor(sessionKey, cursor) {
|
|
2403
2408
|
this.cursors.set(sessionKey, cursor);
|
|
2404
2409
|
}
|
|
2410
|
+
/**
|
|
2411
|
+
* Feeds one agent event in. Idempotent per event *instance*: the registry
|
|
2412
|
+
* fans a single tagged event out to every subscribed controller, and each of
|
|
2413
|
+
* them writes it here, so a host with more than one connected client would
|
|
2414
|
+
* otherwise project the same stream once per connection. The symptoms are
|
|
2415
|
+
* unmistakable — a delta doubled into "therethere", a second `message_end`
|
|
2416
|
+
* creating a duplicate prose row, and a second `tool-start` re-binding the
|
|
2417
|
+
* call id so the first tool item never receives its `tool-end` and stays
|
|
2418
|
+
* `running` forever ("Working for …" never settling).
|
|
2419
|
+
*
|
|
2420
|
+
* Identity is the right key because `SessionRegistry.emit` passes the same
|
|
2421
|
+
* event object to every listener: the first writer projects it, the rest are
|
|
2422
|
+
* no-ops, whatever the connection count.
|
|
2423
|
+
*/
|
|
2405
2424
|
apply(sessionKey, event) {
|
|
2425
|
+
if (this.applied.has(event)) {
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
this.applied.add(event);
|
|
2406
2429
|
this.projectorFor(sessionKey).apply(event);
|
|
2407
2430
|
}
|
|
2408
2431
|
/** Replays a resumed session's history into an empty transcript. */
|
|
@@ -3253,7 +3276,7 @@ var HostSessionController = class {
|
|
|
3253
3276
|
this.agentReady = false;
|
|
3254
3277
|
this.agentError = event.message;
|
|
3255
3278
|
this.agentFailure = hintOnly(this.options.agentHint);
|
|
3256
|
-
this.options.transcripts.
|
|
3279
|
+
this.options.transcripts.apply(sessionKey, event);
|
|
3257
3280
|
this.emitState();
|
|
3258
3281
|
return;
|
|
3259
3282
|
default:
|