negotium 0.6.11 → 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.11";
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 {
@@ -24225,6 +24228,7 @@ __export(exports_node_host, {
24225
24228
  nodeRequestHandlerNames: () => nodeRequestHandlerNames,
24226
24229
  logger: () => logger,
24227
24230
  listVaultEntries: () => listVaultEntries,
24231
+ listThreadMessages: () => listThreadMessages,
24228
24232
  listRuntimeEventsAfter: () => listRuntimeEventsAfter,
24229
24233
  listRunningTopicQueries: () => listRunningTopicQueries,
24230
24234
  listRecentRuntimeEventsForTopic: () => listRecentRuntimeEventsForTopic,
@@ -32658,17 +32662,39 @@ function runtimeEvent(event) {
32658
32662
  createdAt: event.createdAt
32659
32663
  };
32660
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
+ }
32661
32671
  function createRuntimeContractEventStream(req, after, topicId, scope = {}) {
32662
32672
  const scoped = "surfaceScope" in scope;
32663
32673
  const visible = new Map;
32664
- 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);
32665
32682
  const cached = visible.get(eventTopicId);
32666
32683
  if (cached !== undefined)
32667
32684
  return cached;
32668
32685
  const topic = getTopic(eventTopicId);
32669
- const allowed = Boolean(topic && (topicId || topic.surface === "otium") && (!scoped || topicInRequestScope(req, topic)));
32670
- visible.set(eventTopicId, allowed);
32671
- 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;
32672
32698
  };
32673
32699
  let cursor = Math.max(0, after);
32674
32700
  let reportedCursor = cursor;
@@ -32689,7 +32715,7 @@ function createRuntimeContractEventStream(req, after, topicId, scope = {}) {
32689
32715
  break;
32690
32716
  }
32691
32717
  for (const event of events) {
32692
- if ((!topicId || event.topicId === topicId) && eventInScope(event.topicId)) {
32718
+ if ((!topicId || event.topicId === topicId) && eventInScope(event)) {
32693
32719
  if (!send("runtime", runtimeEvent(event), event.seq))
32694
32720
  return;
32695
32721
  }
@@ -33057,6 +33083,21 @@ function createNodeControlHandler(options) {
33057
33083
  });
33058
33084
  return Response.json({ ok: true, v: NODE_RUNTIME_CONTRACT_VERSION, ...result });
33059
33085
  }
33086
+ const runtimeThreadMatch = runtimePath.match(/^\/topics\/([^/]+)\/messages\/([^/]+)\/thread$/);
33087
+ if (runtimeThreadMatch && req.method === "GET") {
33088
+ const topicId = decodeURIComponent(runtimeThreadMatch[1]);
33089
+ const messageId = decodeURIComponent(runtimeThreadMatch[2]);
33090
+ const messagesTopic = getTopic(topicId);
33091
+ if (!messagesTopic || !topicInRequestScope(req, messagesTopic)) {
33092
+ return jsonError(404, "Topic not found");
33093
+ }
33094
+ const target = getApiMessage(topicId, messageId);
33095
+ if (!target || target.deleted)
33096
+ return jsonError(404, "Message not found");
33097
+ const rootId = target.threadRootId ?? target.id;
33098
+ const result = listThreadMessages(topicId, rootId);
33099
+ return Response.json({ ok: true, v: NODE_RUNTIME_CONTRACT_VERSION, ...result });
33100
+ }
33060
33101
  const runtimeMessageMatch = runtimePath.match(/^\/topics\/([^/]+)\/messages\/([^/]+)$/);
33061
33102
  if (runtimeMessageMatch && req.method === "DELETE") {
33062
33103
  const body = await bodyRecord(req);
@@ -48943,4 +48984,4 @@ switch (command) {
48943
48984
  }
48944
48985
  }
48945
48986
 
48946
- //# debugId=7C84B431CFF260BD64756E2164756E21
48987
+ //# debugId=6567233F28C2818664756E2164756E21