negotium 0.6.6 → 0.6.7

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.
Files changed (30) hide show
  1. package/dist/agent-helpers.js +168 -152
  2. package/dist/agent-helpers.js.map +11 -11
  3. package/dist/{chunk-pxnv3gh2.js → chunk-f124y9d0.js} +2 -2
  4. package/dist/{chunk-pxnv3gh2.js.map → chunk-f124y9d0.js.map} +2 -2
  5. package/dist/hosted-agent.js +2 -2
  6. package/dist/hosted-agent.js.map +2 -2
  7. package/dist/main.js +40 -16
  8. package/dist/main.js.map +12 -12
  9. package/dist/mcp-factories.js +29 -13
  10. package/dist/mcp-factories.js.map +9 -9
  11. package/dist/registry.js +1 -1
  12. package/dist/runtime/src/agents/archiver.ts +25 -7
  13. package/dist/runtime/src/agents/idle-archiver.ts +1 -0
  14. package/dist/runtime/src/application/topic-service.ts +5 -1
  15. package/dist/runtime/src/runtime/turn-event-stream.ts +2 -1
  16. package/dist/runtime/src/runtime/turn-runner.ts +8 -1
  17. package/dist/runtime/src/runtime-gateway.ts +6 -2
  18. package/dist/runtime/src/topics/lifecycle.ts +4 -1
  19. package/dist/runtime/src/topics/session.ts +15 -9
  20. package/dist/runtime/src/version.ts +1 -1
  21. package/dist/runtime-gateway.js +7 -6
  22. package/dist/runtime-gateway.js.map +3 -3
  23. package/dist/types/packages/core/src/agents/archiver.d.ts +3 -1
  24. package/dist/types/packages/core/src/runtime/turn-event-stream.d.ts +1 -0
  25. package/dist/types/packages/core/src/runtime/turn-runner.d.ts +1 -0
  26. package/dist/types/packages/core/src/runtime-gateway.d.ts +2 -2
  27. package/dist/types/packages/core/src/topics/lifecycle.d.ts +2 -0
  28. package/dist/types/packages/core/src/topics/session.d.ts +2 -0
  29. package/dist/types/packages/core/src/version.d.ts +1 -1
  30. package/package.json +1 -1
@@ -3019,7 +3019,7 @@ var init_codex = __esm(async () => {
3019
3019
  });
3020
3020
 
3021
3021
  // ../../packages/core/src/version.ts
3022
- var NEGOTIUM_VERSION = "0.6.6";
3022
+ var NEGOTIUM_VERSION = "0.6.7";
3023
3023
 
3024
3024
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
3025
3025
  import { spawn as spawn2 } from "child_process";
@@ -10841,6 +10841,7 @@ function createArchiverRuntime(host) {
10841
10841
  const runTurn = (params) => {
10842
10842
  const {
10843
10843
  userId,
10844
+ sourceTopicId,
10844
10845
  topicId,
10845
10846
  topicTitle,
10846
10847
  archivePath,
@@ -10848,6 +10849,7 @@ function createArchiverRuntime(host) {
10848
10849
  messageCount,
10849
10850
  mode = "deleted-topic"
10850
10851
  } = params;
10852
+ const generalTopicId = host.storage.getGeneralTopicId(userId, sourceTopicId);
10851
10853
  let definition;
10852
10854
  try {
10853
10855
  definition = getAgentDefinition();
@@ -11006,7 +11008,7 @@ function createArchiverRuntime(host) {
11006
11008
  }
11007
11009
  }
11008
11010
  const text = finalText.trimEnd();
11009
- finalizeGeneralMemory(host, userId, topicTitle, messageCount, startMs, ok, mode, topicId, ok && text ? { text, agent, model, usage } : undefined);
11011
+ finalizeGeneralMemory(host, userId, topicTitle, messageCount, startMs, ok, mode, topicId, generalTopicId, ok && text ? { text, agent, model, usage } : undefined);
11010
11012
  });
11011
11013
  topicQueues.set(safeTopic, work);
11012
11014
  work.finally(() => {
@@ -11052,14 +11054,14 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
11052
11054
  }
11053
11055
  return best?.path ?? null;
11054
11056
  }
11055
- function finalizeGeneralMemory(host, userId, topicTitle, messageCount, startMs, ok, mode, topicId, generalReply) {
11056
- const generalTopicId = host.storage.getGeneralTopicId(userId);
11057
+ function finalizeGeneralMemory(host, userId, topicTitle, messageCount, startMs, ok, mode, topicId, generalTopicId, generalReply) {
11058
+ const resolvedGeneralTopicId = generalTopicId ?? host.storage.getGeneralTopicId(userId, topicId);
11057
11059
  const date = host.config.now().toISOString().slice(0, 10);
11058
11060
  try {
11059
11061
  const summaryPath = ok ? findSummaryFile(host.storage, topicTitle, date, startMs, topicId) : null;
11060
11062
  const summaryMd = summaryPath ? host.storage.readTextFile(summaryPath) : "";
11061
11063
  const oneLine = summaryMd && distillOneLine(summaryMd) || `Archived ${messageCount} messages`;
11062
- const prev = host.storage.getTopicBrief(generalTopicId);
11064
+ const prev = host.storage.getTopicBrief(resolvedGeneralTopicId);
11063
11065
  const prevEntries = (prev?.briefMd ?? "").split(`
11064
11066
  `).map((l) => l.trim()).filter((l) => l.startsWith("- "));
11065
11067
  const newEntry = `- **${topicTitle}** (${date}): ${oneLine}`;
@@ -11074,7 +11076,7 @@ Recent memory digest distilled from archived topics (deletions and idle/session-
11074
11076
  ## Recent Archives
11075
11077
  ${rolled.join(`
11076
11078
  `)}`;
11077
- host.storage.setTopicBrief(generalTopicId, {
11079
+ host.storage.setTopicBrief(resolvedGeneralTopicId, {
11078
11080
  briefMd,
11079
11081
  ...summaryMd ? { latestSummaryMd: summaryMd, summaryDate: date } : {}
11080
11082
  });
@@ -11093,13 +11095,13 @@ ${rolled.join(`
11093
11095
  } : { authorId: "system" };
11094
11096
  const msg = {
11095
11097
  id: host.config.createId(),
11096
- topicId: generalTopicId,
11098
+ topicId: resolvedGeneralTopicId,
11097
11099
  text,
11098
11100
  ...replyMeta,
11099
11101
  createdAt: host.config.now().toISOString()
11100
11102
  };
11101
11103
  host.messaging.appendMessage(msg);
11102
- host.messaging.broadcastMessage(generalTopicId, msg);
11104
+ host.messaging.broadcastMessage(resolvedGeneralTopicId, msg);
11103
11105
  } catch (err) {
11104
11106
  host.config.warn({ err, topicTitle }, "archiver: failed to post #General notification");
11105
11107
  }
@@ -11118,6 +11120,7 @@ var init_archiver = __esm(async () => {
11118
11120
  init_background_session_policy();
11119
11121
  await init_api_messages();
11120
11122
  await init_api_topic_brief();
11123
+ await init_api_topics();
11121
11124
  await init_wiki();
11122
11125
  init_wiki_summary_names();
11123
11126
  await init_personal_general();
@@ -11129,7 +11132,12 @@ var init_archiver = __esm(async () => {
11129
11132
  readTextFile: (path) => readFileSync18(path, "utf-8"),
11130
11133
  fileSize: (path) => statSync7(path).size,
11131
11134
  fileModifiedAt: (path) => statSync7(path).mtimeMs,
11132
- getGeneralTopicId: (userId) => ensurePersonalGeneral(userId).id,
11135
+ getGeneralTopicId: (userId, sourceTopicId) => {
11136
+ const source = sourceTopicId ? getTopic(sourceTopicId) : null;
11137
+ return source ? ensurePersonalGeneral(userId, source.surface, {
11138
+ surfaceScope: source.surfaceScope ?? null
11139
+ }).id : ensurePersonalGeneral(userId).id;
11140
+ },
11133
11141
  getTopicBrief,
11134
11142
  setTopicBrief: (topicId, fields) => {
11135
11143
  setTopicBrief(topicId, fields);
@@ -11612,6 +11620,7 @@ function archiveActiveTopicForMemory(topicId, userId, options) {
11612
11620
  const memoryTitle = memoryTopic.memoryKey?.trim() || memoryTopic.title;
11613
11621
  const launched = (options.launchArchiver ?? runArchiverTurn)({
11614
11622
  userId,
11623
+ sourceTopicId: topic.id,
11615
11624
  topicId: memoryTopic.id,
11616
11625
  topicTitle: memoryTitle,
11617
11626
  archivePath: job.archivePath,
@@ -13979,7 +13988,8 @@ async function deleteTopicCascadeImpl(topic, userId, options, deletingAncestorId
13979
13988
  const memoryTopic = topic.memoryKey ? topic : getTopicMemoryOrigin(topicId) ?? topic;
13980
13989
  const memoryTitle = memoryTopic.memoryKey?.trim() || memoryTopic.title;
13981
13990
  runArchiverTurn({
13982
- userId,
13991
+ userId: options.memoryUserId ?? userId,
13992
+ sourceTopicId: topicId,
13983
13993
  ...memoryTopic.id !== topicId && !deletingTopicIds.has(memoryTopic.id) ? { topicId: memoryTopic.id } : {},
13984
13994
  topicTitle: memoryTitle,
13985
13995
  archivePath: archived.path,
@@ -15779,7 +15789,7 @@ ${JSON.stringify(event.input ?? {})}`);
15779
15789
  }
15780
15790
  }
15781
15791
  if (!silent) {
15782
- scheduleIdleArchiveForTopic(topicId, userId);
15792
+ scheduleIdleArchiveForTopic(topicId, execution?.actorUserId ?? userId);
15783
15793
  hub.broadcastDone(topicId, queryId, event.usage ? {
15784
15794
  input: event.usage.inputTokens,
15785
15795
  output: event.usage.outputTokens,
@@ -17150,7 +17160,13 @@ function startAiTurn(params) {
17150
17160
  WsHub.get().broadcastTyping(topicId, "ai");
17151
17161
  WsHub.get().broadcastAiActive(topicId, queryId);
17152
17162
  }
17153
- streamAgentEvents(topicId, topic.title, queryId, events, control, agentKind, resolvedModel, resolvedEffort, userId, !sessionRetried, onSessionId, { silent, peerBridge, sourceNode, ...threadRootId ? { threadRootId } : {} }).then(async (streamOutcome) => {
17163
+ streamAgentEvents(topicId, topic.title, queryId, events, control, agentKind, resolvedModel, resolvedEffort, userId, !sessionRetried, onSessionId, {
17164
+ silent,
17165
+ actorUserId: params.actorUserId,
17166
+ peerBridge,
17167
+ sourceNode,
17168
+ ...threadRootId ? { threadRootId } : {}
17169
+ }).then(async (streamOutcome) => {
17154
17170
  let outcome = streamOutcome;
17155
17171
  if (outcome.kind === "session-expired") {
17156
17172
  const retry = resolveSessionRetry({
@@ -21552,4 +21568,4 @@ export {
21552
21568
  createAgentHealthMcpServer
21553
21569
  };
21554
21570
 
21555
- //# debugId=84FF0128D358C07F64756E2164756E21
21571
+ //# debugId=B75B5A4C65EC41E364756E2164756E21