@otium-team/negotium 0.23.14 → 0.23.15

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/registry.js CHANGED
@@ -133,7 +133,7 @@ var codexRegistryOperations = {
133
133
  return { sessionId: threadId, rolloutPath };
134
134
  },
135
135
  async forkSession({ parentSessionId }) {
136
- const { forkCodexSession } = await import("./chunk-3v58ejrk.js");
136
+ const { forkCodexSession } = await import("./chunk-3hf8y6bd.js");
137
137
  return await forkCodexSession(parentSessionId);
138
138
  },
139
139
  async cleanupRollouts({ sessionIds }) {
@@ -987,6 +987,29 @@ async function drainOneDurableUserTurn(): Promise<void> {
987
987
  try {
988
988
  const request = claimNextRuntimeUserTurnRequest(RUNTIME_INSTANCE_ID);
989
989
  if (!request) return;
990
+ // The claim only proves the topic's turn lease *looked* stale. When the
991
+ // host sleeps, or this event loop stalls, past TURN_LEASE_STALE_MS, this
992
+ // process's own running turn looks abandoned too, and the worker claims
993
+ // the row that turn is executing. Starting it again would take the
994
+ // same-actor steering path and fold the request into itself, doubling its
995
+ // messages, then re-queue the doubled row for the next tick to double
996
+ // again. A turn this process is running is never someone else's to
997
+ // recover: keep its row marked running, or hand a different row back to
998
+ // be claimed once the local turn releases the room.
999
+ const localTurn = getRoomQuery(request.topicId);
1000
+ if (localTurn) {
1001
+ if (localTurn.durableRequestIds?.includes(request.requestId)) {
1002
+ markRuntimeUserTurnRunning(
1003
+ request.topicId,
1004
+ request.requestId,
1005
+ RUNTIME_INSTANCE_ID,
1006
+ localTurn.queryId,
1007
+ );
1008
+ } else {
1009
+ releaseRuntimeUserTurnClaim(request.topicId, request.requestId, RUNTIME_INSTANCE_ID);
1010
+ }
1011
+ return;
1012
+ }
990
1013
  const topic = getTopic(request.topicId);
991
1014
  if (!topic?.agent) {
992
1015
  completeRuntimeUserTurnRequest(request.topicId, request.requestId, RUNTIME_INSTANCE_ID);
@@ -1275,6 +1298,22 @@ export function startAiTurn(params: StartAiTurnParams): string | null {
1275
1298
  }
1276
1299
  if (decision.action === "abort-replace") {
1277
1300
  const running = decision.running;
1301
+ // A replay of the very request this room is already running carries no
1302
+ // new message. Steering with it would append the running turn's messages
1303
+ // to themselves and replace the turn with a doubled copy of the same
1304
+ // request. Leave the running turn alone; its own settlement completes the
1305
+ // durable row.
1306
+ const runningRequestIds = new Set(running.durableRequestIds ?? []);
1307
+ if (
1308
+ durableRequestIds.length > 0 &&
1309
+ durableRequestIds.every((requestId) => runningRequestIds.has(requestId))
1310
+ ) {
1311
+ logger.warn(
1312
+ { topicId, queryId: running.queryId, durableRequestIds },
1313
+ "ai: ignored a replay of the durable request this room is already running",
1314
+ );
1315
+ return running.queryId;
1316
+ }
1278
1317
  // Another person's running answer is not this message's to interrupt. The
1279
1318
  // message keeps its own durable row (the merge never folds across actors)
1280
1319
  // and the worker claims it once the running turn releases the room. A
@@ -1 +1 @@
1
- export const NEGOTIUM_VERSION = "0.23.14";
1
+ export const NEGOTIUM_VERSION = "0.23.15";
@@ -1 +1 @@
1
- export declare const NEGOTIUM_VERSION = "0.23.14";
1
+ export declare const NEGOTIUM_VERSION = "0.23.15";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otium-team/negotium",
3
- "version": "0.23.14",
3
+ "version": "0.23.15",
4
4
  "type": "module",
5
5
  "description": "Install the Negotium multi-agent runtime and CLI with one package",
6
6
  "license": "Apache-2.0",