replicas-engine 0.1.165 → 0.1.166

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.
Files changed (2) hide show
  1. package/dist/src/index.js +116 -1
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -285,7 +285,7 @@ function parseReplicasConfigString(content, filename) {
285
285
  }
286
286
 
287
287
  // ../shared/src/engine/environment.ts
288
- var DAYTONA_SNAPSHOT_ID = "13-05-2026-royal-york-v11";
288
+ var DAYTONA_SNAPSHOT_ID = "13-05-2026-royal-york-v12";
289
289
 
290
290
  // ../shared/src/engine/types.ts
291
291
  var DEFAULT_CHAT_TITLES = {
@@ -2522,6 +2522,35 @@ var MessageQueueService = class {
2522
2522
  this.queue = [];
2523
2523
  return drained;
2524
2524
  }
2525
+ /**
2526
+ * Get all queued messages (does not include the currently processing message)
2527
+ */
2528
+ getQueue() {
2529
+ return [...this.queue];
2530
+ }
2531
+ /**
2532
+ * Remove a message from the queue by its ID
2533
+ * @returns true if the message was found and removed
2534
+ */
2535
+ removeFromQueue(messageId) {
2536
+ const index = this.queue.findIndex((m) => m.id === messageId);
2537
+ if (index === -1) return false;
2538
+ this.queue.splice(index, 1);
2539
+ return true;
2540
+ }
2541
+ /**
2542
+ * Move a message to a new position in the queue
2543
+ * @returns true if the message was found and moved
2544
+ */
2545
+ reorderQueue(messageId, newPosition) {
2546
+ const index = this.queue.findIndex((m) => m.id === messageId);
2547
+ if (index === -1) return false;
2548
+ const clamped = Math.max(0, Math.min(newPosition, this.queue.length - 1));
2549
+ if (index === clamped) return true;
2550
+ const [item] = this.queue.splice(index, 1);
2551
+ this.queue.splice(clamped, 0, item);
2552
+ return true;
2553
+ }
2525
2554
  /**
2526
2555
  * Reset everything including clearing processing state
2527
2556
  */
@@ -2567,6 +2596,22 @@ var CodingAgentManager = class {
2567
2596
  isProcessing() {
2568
2597
  return this.messageQueue.isProcessing();
2569
2598
  }
2599
+ getQueue() {
2600
+ return this.messageQueue.getQueue().map((m) => ({
2601
+ id: m.id,
2602
+ message: m.message,
2603
+ queuedAt: m.queuedAt,
2604
+ ...m.senderUserId ? { senderUserId: m.senderUserId } : {},
2605
+ ...m.senderEmail ? { senderEmail: m.senderEmail } : {},
2606
+ ...m.senderDisplayName ? { senderDisplayName: m.senderDisplayName } : {}
2607
+ }));
2608
+ }
2609
+ removeFromQueue(messageId) {
2610
+ return this.messageQueue.removeFromQueue(messageId);
2611
+ }
2612
+ reorderQueue(messageId, newPosition) {
2613
+ return this.messageQueue.reorderQueue(messageId, newPosition);
2614
+ }
2570
2615
  async enqueueMessage(request) {
2571
2616
  await this.initialized;
2572
2617
  return this.messageQueue.enqueue(request);
@@ -3971,6 +4016,15 @@ var RelayManager = class {
3971
4016
  isProcessing() {
3972
4017
  return this.inner.isProcessing();
3973
4018
  }
4019
+ getQueue() {
4020
+ return this.inner.getQueue();
4021
+ }
4022
+ removeFromQueue(messageId) {
4023
+ return this.inner.removeFromQueue(messageId);
4024
+ }
4025
+ reorderQueue(messageId, newPosition) {
4026
+ return this.inner.reorderQueue(messageId, newPosition);
4027
+ }
3974
4028
  };
3975
4029
 
3976
4030
  // src/services/keep-alive-service.ts
@@ -4221,6 +4275,30 @@ var ChatService = class {
4221
4275
  });
4222
4276
  return result;
4223
4277
  }
4278
+ getChatQueue(chatId) {
4279
+ const chat = this.requireChat(chatId);
4280
+ return {
4281
+ chatId,
4282
+ processing: chat.provider.isProcessing(),
4283
+ queue: chat.provider.getQueue()
4284
+ };
4285
+ }
4286
+ removeFromQueue(chatId, messageId) {
4287
+ const chat = this.requireChat(chatId);
4288
+ const success = chat.provider.removeFromQueue(messageId);
4289
+ return {
4290
+ success,
4291
+ queue: chat.provider.getQueue()
4292
+ };
4293
+ }
4294
+ reorderQueue(chatId, messageId, position) {
4295
+ const chat = this.requireChat(chatId);
4296
+ const success = chat.provider.reorderQueue(messageId, position);
4297
+ return {
4298
+ success,
4299
+ queue: chat.provider.getQueue()
4300
+ };
4301
+ }
4224
4302
  async deleteChat(chatId) {
4225
4303
  const chat = this.requireChat(chatId);
4226
4304
  if (chat.persisted.title === DEFAULT_CHAT_TITLES[chat.persisted.provider]) {
@@ -5112,6 +5190,43 @@ function createV1Routes(deps) {
5112
5190
  return c.json(jsonError("Failed to interrupt chat", error instanceof Error ? error.message : "Unknown error"), 404);
5113
5191
  }
5114
5192
  });
5193
+ app2.get("/chats/:chatId/queue", (c) => {
5194
+ try {
5195
+ const result = deps.chatService.getChatQueue(c.req.param("chatId"));
5196
+ return c.json(result);
5197
+ } catch (error) {
5198
+ if (error instanceof ChatNotFoundError) {
5199
+ return c.json(jsonError("Chat not found", error.message), 404);
5200
+ }
5201
+ return c.json(jsonError("Failed to get queue", error instanceof Error ? error.message : "Unknown error"), 500);
5202
+ }
5203
+ });
5204
+ app2.delete("/chats/:chatId/queue/:messageId", (c) => {
5205
+ try {
5206
+ const result = deps.chatService.removeFromQueue(c.req.param("chatId"), c.req.param("messageId"));
5207
+ return c.json(result);
5208
+ } catch (error) {
5209
+ if (error instanceof ChatNotFoundError) {
5210
+ return c.json(jsonError("Chat not found", error.message), 404);
5211
+ }
5212
+ return c.json(jsonError("Failed to remove from queue", error instanceof Error ? error.message : "Unknown error"), 500);
5213
+ }
5214
+ });
5215
+ app2.patch("/chats/:chatId/queue/reorder", async (c) => {
5216
+ try {
5217
+ const body = await c.req.json();
5218
+ if (!body.messageId || typeof body.position !== "number" || !Number.isFinite(body.position)) {
5219
+ return c.json(jsonError("Invalid request", "messageId and position are required"), 400);
5220
+ }
5221
+ const result = deps.chatService.reorderQueue(c.req.param("chatId"), body.messageId, body.position);
5222
+ return c.json(result);
5223
+ } catch (error) {
5224
+ if (error instanceof ChatNotFoundError) {
5225
+ return c.json(jsonError("Chat not found", error.message), 404);
5226
+ }
5227
+ return c.json(jsonError("Failed to reorder queue", error instanceof Error ? error.message : "Unknown error"), 500);
5228
+ }
5229
+ });
5115
5230
  app2.get("/repos", async (c) => {
5116
5231
  const includeDiffs = c.req.query("includeDiffs") === "true";
5117
5232
  const repos = await gitService.listRepos({ includeDiffs });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.165",
3
+ "version": "0.1.166",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",