@moxt-ai/mobius 0.0.465 → 0.0.466

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.
@@ -5,7 +5,7 @@ import {
5
5
  __toESM,
6
6
  __using,
7
7
  package_default
8
- } from "./chunk-RQXSP55N.js";
8
+ } from "./chunk-CP7CJWBV.js";
9
9
 
10
10
  // ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
11
11
  var require_ignore = __commonJS({
@@ -105158,6 +105158,7 @@ var MAX_SESSION_EVENT_RESENDS = 5;
105158
105158
  var RuntimeSessionEventPublisher = class {
105159
105159
  #retained = [];
105160
105160
  #sessions = /* @__PURE__ */ new Map();
105161
+ /** Sessions whose latest prompt has started and has not yet produced its first answer text. */
105161
105162
  #awaitingFirstAnswer = /* @__PURE__ */ new Map();
105162
105163
  #retainedBytes = 0;
105163
105164
  #unsentCount = 0;
@@ -105291,7 +105292,8 @@ var RuntimeSessionEventPublisher = class {
105291
105292
  return;
105292
105293
  }
105293
105294
  const awaiting = this.#awaitingFirstAnswer.get(event.sessionId);
105294
- const firstAnswer = this.#consumeFirstAnswer(event);
105295
+ const decision = this.#decideHandoff(event);
105296
+ const firstAnswer = decision.firstAnswer;
105295
105297
  this.#retained.push({
105296
105298
  event,
105297
105299
  position: Number(event.position),
@@ -105313,7 +105315,7 @@ var RuntimeSessionEventPublisher = class {
105313
105315
  return;
105314
105316
  }
105315
105317
  const socket = connection.socket;
105316
- if (firstAnswer || this.#unsentCount >= SESSION_EVENT_BATCH_MAX_SIZE || EMPTY_ENVELOPE_BYTES + this.#unsentBytes >= MAX_EVENT_BATCH_BYTES) {
105318
+ if (decision.immediate || this.#unsentCount >= SESSION_EVENT_BATCH_MAX_SIZE || EMPTY_ENVELOPE_BYTES + this.#unsentBytes >= MAX_EVENT_BATCH_BYTES) {
105317
105319
  this.flushEvents(socket);
105318
105320
  return;
105319
105321
  }
@@ -105402,24 +105404,48 @@ var RuntimeSessionEventPublisher = class {
105402
105404
  delivery.resends = 0;
105403
105405
  }
105404
105406
  };
105405
- #consumeFirstAnswer = (event) => {
105407
+ /**
105408
+ * Decides whether `event` leaves without waiting for the batching window: the first thought or message after a
105409
+ * `prompt.started`, and the first answer text. Only the send time differs; batches keep the published order, so
105410
+ * whatever was waiting, the start included, leaves with them.
105411
+ *
105412
+ * The start itself and tool calls stay batched, because a client may act on either the moment it sees it. A
105413
+ * prompt is recorded as started just before it is handed to the Agent, and a cancellation that arrives in
105414
+ * between reaches an Agent that has nothing to cancel yet. An Agent such as Antigravity refuses steering for an
105415
+ * instant after announcing a command. The first thought or message cannot come before the Agent has the prompt.
105416
+ */
105417
+ #decideHandoff = (event) => {
105418
+ const batched = { firstAnswer: false, immediate: false };
105406
105419
  if (event.type === "lifecycle-metadata") {
105407
105420
  const payload = event.payload;
105408
105421
  if (payload.kind === "prompt.started") {
105409
105422
  this.#awaitingFirstAnswer.set(event.sessionId, {
105410
105423
  commandId: payload.commandId,
105411
- generationId: event.sessionGenerationId
105424
+ generationId: event.sessionGenerationId,
105425
+ output: "awaiting-first-output"
105412
105426
  });
105413
- } else if (isPromptTerminal(payload) && this.#awaitingFirstAnswer.get(event.sessionId)?.commandId === payload.commandId && this.#awaitingFirstAnswer.get(event.sessionId)?.generationId === event.sessionGenerationId) {
105427
+ return batched;
105428
+ }
105429
+ if (isPromptTerminal(payload) && this.#awaitingFirstAnswer.get(event.sessionId)?.commandId === payload.commandId && this.#awaitingFirstAnswer.get(event.sessionId)?.generationId === event.sessionGenerationId) {
105414
105430
  this.#awaitingFirstAnswer.delete(event.sessionId);
105415
105431
  }
105416
- return false;
105432
+ return batched;
105417
105433
  }
105418
- if (event.type !== "acp" || event.payload.sessionUpdate !== "agent_message_chunk" || event.payload.content.type !== "text" || event.payload.content.text.length === 0 || this.#awaitingFirstAnswer.get(event.sessionId)?.generationId !== event.sessionGenerationId) {
105419
- return false;
105434
+ const awaiting = this.#awaitingFirstAnswer.get(event.sessionId);
105435
+ if (event.type !== "acp" || awaiting?.generationId !== event.sessionGenerationId) {
105436
+ return batched;
105420
105437
  }
105421
- this.#awaitingFirstAnswer.delete(event.sessionId);
105422
- return true;
105438
+ const update = event.payload;
105439
+ if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text" && update.content.text.length > 0) {
105440
+ this.#awaitingFirstAnswer.delete(event.sessionId);
105441
+ return { firstAnswer: true, immediate: true };
105442
+ }
105443
+ const isOutput = update.sessionUpdate === "agent_message_chunk" || update.sessionUpdate === "agent_thought_chunk";
105444
+ if (isOutput && awaiting.output === "awaiting-first-output") {
105445
+ this.#awaitingFirstAnswer.set(event.sessionId, { ...awaiting, output: "first-output-handed-off" });
105446
+ return { firstAnswer: false, immediate: true };
105447
+ }
105448
+ return batched;
105423
105449
  };
105424
105450
  cancelFlush = () => {
105425
105451
  this.#pendingTask?.cancel();
@@ -106070,4 +106096,4 @@ export {
106070
106096
  * MIT Licensed
106071
106097
  *)
106072
106098
  */
106073
- //# sourceMappingURL=chunk-CPVZCCBS.js.map
106099
+ //# sourceMappingURL=chunk-7P2QHD5S.js.map