negotium 0.6.12 → 0.6.13

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/main.js CHANGED
@@ -3708,7 +3708,7 @@ var exports_version = {};
3708
3708
  __export(exports_version, {
3709
3709
  NEGOTIUM_VERSION: () => NEGOTIUM_VERSION
3710
3710
  });
3711
- var NEGOTIUM_VERSION = "0.6.12";
3711
+ var NEGOTIUM_VERSION = "0.6.13";
3712
3712
 
3713
3713
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
3714
3714
  import { spawn as spawn2 } from "child_process";
@@ -7201,8 +7201,8 @@ class SqliteRuntimeBus {
7201
7201
  broadcastTopicUpdated(topicId) {
7202
7202
  this.emit({ type: "topic-updated", topicId, payload: null });
7203
7203
  }
7204
- broadcastTopicDeleted(topicId) {
7205
- this.emit({ type: "topic-deleted", topicId, payload: null });
7204
+ broadcastTopicDeleted(topicId, meta) {
7205
+ this.emit({ type: "topic-deleted", topicId, payload: meta ?? null });
7206
7206
  }
7207
7207
  broadcastAiActive(topicId, queryId) {
7208
7208
  this.broadcastAiStatus(topicId, { kind: "ai_active", queryId });
@@ -17165,7 +17165,10 @@ async function deleteTopicCascadeImpl(topic, userId, options, deletingAncestorId
17165
17165
  return;
17166
17166
  }
17167
17167
  deleted = true;
17168
- WsHub.get().broadcastTopicDeleted(topicId);
17168
+ WsHub.get().broadcastTopicDeleted(topicId, {
17169
+ surface: topic.surface,
17170
+ surfaceScope: topic.surfaceScope
17171
+ });
17169
17172
  for (const childId of reparentedChildIds)
17170
17173
  WsHub.get().broadcastTopicUpdated(childId);
17171
17174
  } finally {
@@ -32659,17 +32662,39 @@ function runtimeEvent(event) {
32659
32662
  createdAt: event.createdAt
32660
32663
  };
32661
32664
  }
32665
+ function isTopicDeletedMeta(payload) {
32666
+ if (!payload || typeof payload !== "object")
32667
+ return false;
32668
+ const { surface, surfaceScope } = payload;
32669
+ return (surface === undefined || surface === "terminal" || surface === "telegram" || surface === "otium") && (surfaceScope === undefined || typeof surfaceScope === "string" || surfaceScope === null);
32670
+ }
32662
32671
  function createRuntimeContractEventStream(req, after, topicId, scope = {}) {
32663
32672
  const scoped = "surfaceScope" in scope;
32664
32673
  const visible = new Map;
32665
- const eventInScope = (eventTopicId) => {
32674
+ const scopeAllows = (topic) => Boolean((topicId || topic.surface === "otium") && (!scoped || topicInRequestScope(req, topic)));
32675
+ const eventInScope = (event) => {
32676
+ const eventTopicId = event.topicId;
32677
+ if (event.type === "topic-created" || event.type === "topic-updated") {
32678
+ visible.delete(eventTopicId);
32679
+ }
32680
+ if (event.type === "topic-deleted")
32681
+ visible.delete(eventTopicId);
32666
32682
  const cached = visible.get(eventTopicId);
32667
32683
  if (cached !== undefined)
32668
32684
  return cached;
32669
32685
  const topic = getTopic(eventTopicId);
32670
- const allowed = Boolean(topic && (topicId || topic.surface === "otium") && (!scoped || topicInRequestScope(req, topic)));
32671
- visible.set(eventTopicId, allowed);
32672
- return allowed;
32686
+ if (topic) {
32687
+ const allowed = scopeAllows(topic);
32688
+ visible.set(eventTopicId, allowed);
32689
+ return allowed;
32690
+ }
32691
+ if (event.type === "topic-deleted") {
32692
+ if (isTopicDeletedMeta(event.payload) && (event.payload.surface !== undefined || event.payload.surfaceScope !== undefined)) {
32693
+ return scopeAllows(event.payload);
32694
+ }
32695
+ }
32696
+ visible.set(eventTopicId, false);
32697
+ return false;
32673
32698
  };
32674
32699
  let cursor = Math.max(0, after);
32675
32700
  let reportedCursor = cursor;
@@ -32690,7 +32715,7 @@ function createRuntimeContractEventStream(req, after, topicId, scope = {}) {
32690
32715
  break;
32691
32716
  }
32692
32717
  for (const event of events) {
32693
- if ((!topicId || event.topicId === topicId) && eventInScope(event.topicId)) {
32718
+ if ((!topicId || event.topicId === topicId) && eventInScope(event)) {
32694
32719
  if (!send("runtime", runtimeEvent(event), event.seq))
32695
32720
  return;
32696
32721
  }
@@ -48959,4 +48984,4 @@ switch (command) {
48959
48984
  }
48960
48985
  }
48961
48986
 
48962
- //# debugId=8E59E4A84CF4D0A164756E2164756E21
48987
+ //# debugId=6567233F28C2818664756E2164756E21