@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/index.js CHANGED
@@ -24032,6 +24032,7 @@ function sessionFailureMeta(failure2) {
24032
24032
  // src/acp/session-history.ts
24033
24033
  var HISTORY_ACTIVITY_FIELD_LIMIT = 1e5;
24034
24034
  var HISTORY_ACTIVITY_LIMIT = 100;
24035
+ var HISTORY_MESSAGE_LIMIT = 50;
24035
24036
  function historyActivity(activity2) {
24036
24037
  return {
24037
24038
  activityId: activity2.activityId.slice(0, 128),
@@ -24074,6 +24075,7 @@ var AcpHistoryReplay = class {
24074
24075
  () => Promise.resolve()
24075
24076
  );
24076
24077
  #lastMessageId = null;
24078
+ #firstMessageIndex = 0;
24077
24079
  #characters = 0;
24078
24080
  #truncated = false;
24079
24081
  record = async (update) => {
@@ -24159,7 +24161,7 @@ var AcpHistoryReplay = class {
24159
24161
  };
24160
24162
  snapshot = async () => {
24161
24163
  await this.#activityTracker.finish();
24162
- const messages = this.#messages.map((message) => {
24164
+ const messages = this.#messages.slice(this.#firstMessageIndex).map((message) => {
24163
24165
  if (message.role === "user") {
24164
24166
  return message;
24165
24167
  }
@@ -24224,13 +24226,18 @@ var AcpHistoryReplay = class {
24224
24226
  this.trimMessages();
24225
24227
  };
24226
24228
  trimMessages = () => {
24227
- while (this.#messages.length > SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT || this.#characters > SESSION_HISTORY_CHARACTER_LIMIT) {
24228
- const removed = this.#messages.shift();
24229
+ while (this.#messages.length - this.#firstMessageIndex > HISTORY_MESSAGE_LIMIT || this.#characters > SESSION_HISTORY_CHARACTER_LIMIT) {
24230
+ const removed = this.#messages[this.#firstMessageIndex];
24229
24231
  if (removed !== void 0) {
24230
24232
  this.#characters -= removed.text.length;
24233
+ this.#firstMessageIndex += 1;
24231
24234
  }
24232
24235
  this.#truncated = true;
24233
24236
  }
24237
+ if (this.#firstMessageIndex >= HISTORY_MESSAGE_LIMIT) {
24238
+ this.#messages.splice(0, this.#firstMessageIndex);
24239
+ this.#firstMessageIndex = 0;
24240
+ }
24234
24241
  };
24235
24242
  };
24236
24243