@moxt-ai/mobius 0.0.138 → 0.0.140

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/runtime.js CHANGED
@@ -23949,6 +23949,7 @@ var APPROVAL_TIMEOUT_MILLISECONDS2 = 36e5;
23949
23949
  var CODEX_AGENT_VERSION = "0.154.0";
23950
23950
  var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
23951
23951
  var CODEX_COMMANDS = Object.freeze([{ description: "Compact the conversation context", name: "compact" }]);
23952
+ var COMPACT_COMPLETED_MESSAGE = "Context compacted.";
23952
23953
  var APPROVAL_OPTIONS = Object.freeze([
23953
23954
  { kind: "allow_once", name: "Allow once", optionId: "accept" },
23954
23955
  { kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
@@ -24641,7 +24642,15 @@ var CodexAcpAgent = class {
24641
24642
  this.#turn = turn;
24642
24643
  try {
24643
24644
  await this.#appServer.request("thread/compact/start", { threadId: this.#nativeSessionId }, signal);
24644
- return await completion.promise;
24645
+ const result = await completion.promise;
24646
+ if (result.stopReason !== "cancelled") {
24647
+ await this.#emit({
24648
+ content: { text: COMPACT_COMPLETED_MESSAGE, type: "text" },
24649
+ messageId: turn.turn.id.length > 0 ? turn.turn.id : "compact-completed",
24650
+ sessionUpdate: "agent_message_chunk"
24651
+ });
24652
+ }
24653
+ return result;
24645
24654
  } finally {
24646
24655
  signal.removeEventListener("abort", aborted2);
24647
24656
  if (this.#turn === turn) {
@@ -28158,6 +28167,7 @@ var AcpAgentSettingsSnapshot = class {
28158
28167
  // src/acp/session-history.ts
28159
28168
  var HISTORY_ACTIVITY_FIELD_LIMIT = 1e5;
28160
28169
  var HISTORY_ACTIVITY_LIMIT = 100;
28170
+ var HISTORY_MESSAGE_LIMIT = 50;
28161
28171
  function historyActivity(activity2) {
28162
28172
  return {
28163
28173
  activityId: activity2.activityId.slice(0, 128),
@@ -28200,6 +28210,7 @@ var AcpHistoryReplay = class {
28200
28210
  () => Promise.resolve()
28201
28211
  );
28202
28212
  #lastMessageId = null;
28213
+ #firstMessageIndex = 0;
28203
28214
  #characters = 0;
28204
28215
  #truncated = false;
28205
28216
  record = async (update) => {
@@ -28285,7 +28296,7 @@ var AcpHistoryReplay = class {
28285
28296
  };
28286
28297
  snapshot = async () => {
28287
28298
  await this.#activityTracker.finish();
28288
- const messages = this.#messages.map((message) => {
28299
+ const messages = this.#messages.slice(this.#firstMessageIndex).map((message) => {
28289
28300
  if (message.role === "user") {
28290
28301
  return message;
28291
28302
  }
@@ -28350,13 +28361,18 @@ var AcpHistoryReplay = class {
28350
28361
  this.trimMessages();
28351
28362
  };
28352
28363
  trimMessages = () => {
28353
- while (this.#messages.length > SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT || this.#characters > SESSION_HISTORY_CHARACTER_LIMIT) {
28354
- const removed = this.#messages.shift();
28364
+ while (this.#messages.length - this.#firstMessageIndex > HISTORY_MESSAGE_LIMIT || this.#characters > SESSION_HISTORY_CHARACTER_LIMIT) {
28365
+ const removed = this.#messages[this.#firstMessageIndex];
28355
28366
  if (removed !== void 0) {
28356
28367
  this.#characters -= removed.text.length;
28368
+ this.#firstMessageIndex += 1;
28357
28369
  }
28358
28370
  this.#truncated = true;
28359
28371
  }
28372
+ if (this.#firstMessageIndex >= HISTORY_MESSAGE_LIMIT) {
28373
+ this.#messages.splice(0, this.#firstMessageIndex);
28374
+ this.#firstMessageIndex = 0;
28375
+ }
28360
28376
  };
28361
28377
  };
28362
28378