@mindstudio-ai/remy 0.1.171 → 0.1.173

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.
@@ -12,6 +12,14 @@
12
12
  * - Every command ends with exactly one `completed` event:
13
13
  * {event:"completed", requestId, success:true|false, error?:string}
14
14
  * - `tool_result` is fire-and-forget (resolves an in-flight promise, no completed event).
15
+ *
16
+ * `get_history` is paginated. Request: {action:"get_history", before?:number,
17
+ * limit?:number, requestId}. `before` is an exclusive upper bound on message
18
+ * index (defaults to end of array — the most recent messages); `limit` caps
19
+ * page size (default 500, hard cap 2000). Response: {event:"history",
20
+ * messages, startIndex, endIndex, totalMessageCount, ...}. Walk backward by
21
+ * passing the previous response's `startIndex` as the next `before`. When
22
+ * `startIndex === 0`, no older messages remain.
15
23
  */
16
24
  interface HeadlessOptions {
17
25
  apiKey?: string;
package/dist/headless.js CHANGED
@@ -6731,6 +6731,8 @@ var USER_FACING_TOOLS = /* @__PURE__ */ new Set([
6731
6731
  "presentPublishPlan"
6732
6732
  ]);
6733
6733
  var FORCED_COMPACTION_THRESHOLD_TOKENS = 85e4;
6734
+ var HISTORY_DEFAULT_LIMIT = 500;
6735
+ var HISTORY_MAX_LIMIT = 2e3;
6734
6736
  var HeadlessSession = class {
6735
6737
  // Configuration
6736
6738
  opts;
@@ -7427,8 +7429,21 @@ var HeadlessSession = class {
7427
7429
  }
7428
7430
  if (action === "get_history") {
7429
7431
  this.applyPendingBlockUpdates();
7432
+ const total = this.state.messages.length;
7433
+ const rawLimit = parsed.limit;
7434
+ const limit = typeof rawLimit === "number" && Number.isFinite(rawLimit) ? Math.min(Math.max(1, rawLimit | 0), HISTORY_MAX_LIMIT) : HISTORY_DEFAULT_LIMIT;
7435
+ const rawBefore = parsed.before;
7436
+ const before = typeof rawBefore === "number" && Number.isFinite(rawBefore) ? Math.max(0, Math.min(rawBefore | 0, total)) : total;
7437
+ let startIndex = Math.max(0, before - limit);
7438
+ while (startIndex > 0 && this.state.messages[startIndex].role === "user" && this.state.messages[startIndex].toolCallId) {
7439
+ startIndex--;
7440
+ }
7441
+ const endIndex = before;
7430
7442
  this.dispatchSimple(requestId, "history", () => ({
7431
- messages: this.state.messages,
7443
+ messages: this.state.messages.slice(startIndex, endIndex),
7444
+ startIndex,
7445
+ endIndex,
7446
+ totalMessageCount: total,
7432
7447
  running: this.running,
7433
7448
  ...this.running && this.currentRequestId ? { currentRequestId: this.currentRequestId } : {},
7434
7449
  ...this.queueFields()
package/dist/index.js CHANGED
@@ -7457,7 +7457,7 @@ var headless_exports = {};
7457
7457
  __export(headless_exports, {
7458
7458
  HeadlessSession: () => HeadlessSession
7459
7459
  });
7460
- var log14, EXTERNAL_TOOL_TIMEOUT_MS, USER_FACING_TOOLS, FORCED_COMPACTION_THRESHOLD_TOKENS, HeadlessSession;
7460
+ var log14, EXTERNAL_TOOL_TIMEOUT_MS, USER_FACING_TOOLS, FORCED_COMPACTION_THRESHOLD_TOKENS, HISTORY_DEFAULT_LIMIT, HISTORY_MAX_LIMIT, HeadlessSession;
7461
7461
  var init_headless = __esm({
7462
7462
  "src/headless/index.ts"() {
7463
7463
  "use strict";
@@ -7485,6 +7485,8 @@ var init_headless = __esm({
7485
7485
  "presentPublishPlan"
7486
7486
  ]);
7487
7487
  FORCED_COMPACTION_THRESHOLD_TOKENS = 85e4;
7488
+ HISTORY_DEFAULT_LIMIT = 500;
7489
+ HISTORY_MAX_LIMIT = 2e3;
7488
7490
  HeadlessSession = class {
7489
7491
  // Configuration
7490
7492
  opts;
@@ -8181,8 +8183,21 @@ var init_headless = __esm({
8181
8183
  }
8182
8184
  if (action === "get_history") {
8183
8185
  this.applyPendingBlockUpdates();
8186
+ const total = this.state.messages.length;
8187
+ const rawLimit = parsed.limit;
8188
+ const limit = typeof rawLimit === "number" && Number.isFinite(rawLimit) ? Math.min(Math.max(1, rawLimit | 0), HISTORY_MAX_LIMIT) : HISTORY_DEFAULT_LIMIT;
8189
+ const rawBefore = parsed.before;
8190
+ const before = typeof rawBefore === "number" && Number.isFinite(rawBefore) ? Math.max(0, Math.min(rawBefore | 0, total)) : total;
8191
+ let startIndex = Math.max(0, before - limit);
8192
+ while (startIndex > 0 && this.state.messages[startIndex].role === "user" && this.state.messages[startIndex].toolCallId) {
8193
+ startIndex--;
8194
+ }
8195
+ const endIndex = before;
8184
8196
  this.dispatchSimple(requestId, "history", () => ({
8185
- messages: this.state.messages,
8197
+ messages: this.state.messages.slice(startIndex, endIndex),
8198
+ startIndex,
8199
+ endIndex,
8200
+ totalMessageCount: total,
8186
8201
  running: this.running,
8187
8202
  ...this.running && this.currentRequestId ? { currentRequestId: this.currentRequestId } : {},
8188
8203
  ...this.queueFields()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/remy",
3
- "version": "0.1.171",
3
+ "version": "0.1.173",
4
4
  "description": "MindStudio coding agent",
5
5
  "repository": {
6
6
  "type": "git",