@moxt-ai/mobius 0.0.138 → 0.0.139

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
@@ -28158,6 +28158,7 @@ var AcpAgentSettingsSnapshot = class {
28158
28158
  // src/acp/session-history.ts
28159
28159
  var HISTORY_ACTIVITY_FIELD_LIMIT = 1e5;
28160
28160
  var HISTORY_ACTIVITY_LIMIT = 100;
28161
+ var HISTORY_MESSAGE_LIMIT = 50;
28161
28162
  function historyActivity(activity2) {
28162
28163
  return {
28163
28164
  activityId: activity2.activityId.slice(0, 128),
@@ -28200,6 +28201,7 @@ var AcpHistoryReplay = class {
28200
28201
  () => Promise.resolve()
28201
28202
  );
28202
28203
  #lastMessageId = null;
28204
+ #firstMessageIndex = 0;
28203
28205
  #characters = 0;
28204
28206
  #truncated = false;
28205
28207
  record = async (update) => {
@@ -28285,7 +28287,7 @@ var AcpHistoryReplay = class {
28285
28287
  };
28286
28288
  snapshot = async () => {
28287
28289
  await this.#activityTracker.finish();
28288
- const messages = this.#messages.map((message) => {
28290
+ const messages = this.#messages.slice(this.#firstMessageIndex).map((message) => {
28289
28291
  if (message.role === "user") {
28290
28292
  return message;
28291
28293
  }
@@ -28350,13 +28352,18 @@ var AcpHistoryReplay = class {
28350
28352
  this.trimMessages();
28351
28353
  };
28352
28354
  trimMessages = () => {
28353
- while (this.#messages.length > SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT || this.#characters > SESSION_HISTORY_CHARACTER_LIMIT) {
28354
- const removed = this.#messages.shift();
28355
+ while (this.#messages.length - this.#firstMessageIndex > HISTORY_MESSAGE_LIMIT || this.#characters > SESSION_HISTORY_CHARACTER_LIMIT) {
28356
+ const removed = this.#messages[this.#firstMessageIndex];
28355
28357
  if (removed !== void 0) {
28356
28358
  this.#characters -= removed.text.length;
28359
+ this.#firstMessageIndex += 1;
28357
28360
  }
28358
28361
  this.#truncated = true;
28359
28362
  }
28363
+ if (this.#firstMessageIndex >= HISTORY_MESSAGE_LIMIT) {
28364
+ this.#messages.splice(0, this.#firstMessageIndex);
28365
+ this.#firstMessageIndex = 0;
28366
+ }
28360
28367
  };
28361
28368
  };
28362
28369