replicas-engine 0.1.471 → 0.1.473

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 +151 -77
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -582,7 +582,7 @@ var WORKSPACE_SIZES = ["small", "large"];
582
582
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
583
583
 
584
584
  // ../shared/src/e2b.ts
585
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-21-v1";
585
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-21-v3";
586
586
 
587
587
  // ../shared/src/runtime-env.ts
588
588
  function shellQuotePosix(value) {
@@ -2809,6 +2809,44 @@ var createChatRequestSchema = z2.object({
2809
2809
  parentChatId: z2.string().uuid().optional(),
2810
2810
  clientRequestId: z2.string().min(1).max(128).optional()
2811
2811
  });
2812
+ var sendChatMessageRequestSchema = z2.object({
2813
+ messageId: z2.string().optional(),
2814
+ submittedAt: z2.string().optional(),
2815
+ message: z2.string(),
2816
+ model: z2.string().optional(),
2817
+ customInstructions: z2.string().optional(),
2818
+ planMode: z2.boolean().optional(),
2819
+ images: z2.array(z2.object({
2820
+ type: z2.literal("image"),
2821
+ source: z2.discriminatedUnion("type", [
2822
+ z2.object({ type: z2.literal("base64"), media_type: z2.enum(IMAGE_MEDIA_TYPES), data: z2.string() }),
2823
+ z2.object({ type: z2.literal("url"), url: z2.string() })
2824
+ ])
2825
+ })).optional(),
2826
+ thinkingLevel: z2.enum(VALID_THINKING_LEVELS).optional(),
2827
+ goalMode: z2.boolean().optional(),
2828
+ fastMode: z2.boolean().optional(),
2829
+ enableInteractiveTools: z2.boolean().optional(),
2830
+ type: z2.string().optional(),
2831
+ merge: z2.boolean().optional(),
2832
+ idempotencyKey: z2.string().optional(),
2833
+ senderUserId: z2.string().optional(),
2834
+ senderEmail: z2.string().optional(),
2835
+ senderDisplayName: z2.string().optional(),
2836
+ senderAvatarUrl: z2.string().optional(),
2837
+ errorNotificationTarget: z2.discriminatedUnion("type", [
2838
+ z2.object({ type: z2.literal("slack") }),
2839
+ z2.object({ type: z2.literal("linear"), sessionId: z2.string() }),
2840
+ z2.object({
2841
+ type: z2.literal("code_host"),
2842
+ provider: z2.enum(["github", "gitlab"]),
2843
+ resource: z2.enum(["issue", "pull_request"]),
2844
+ repositoryId: z2.string(),
2845
+ resourceNumber: z2.number()
2846
+ }),
2847
+ z2.object({ type: z2.literal("automation"), executionId: z2.string() })
2848
+ ]).optional()
2849
+ }).passthrough();
2812
2850
  function normalizeCodexAspTranscriptStatus(status, failed = false) {
2813
2851
  if (failed || status === "failed" || status === "declined") return "failed";
2814
2852
  if (status === "completed") return "completed";
@@ -3137,6 +3175,18 @@ var DEFAULT_WORKSPACE_FILTERS = {
3137
3175
  };
3138
3176
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
3139
3177
 
3178
+ // ../shared/src/routes/workspace-events.ts
3179
+ import { z as z3 } from "zod";
3180
+ var workspaceChangedEventSchema = z3.discriminatedUnion("type", [
3181
+ z3.object({ type: z3.literal("workspace.changed"), workspaceId: z3.string(), ts: z3.string() }),
3182
+ z3.object({
3183
+ type: z3.literal("workspace.chat.changed"),
3184
+ workspaceId: z3.string(),
3185
+ chatId: z3.string(),
3186
+ ts: z3.string()
3187
+ })
3188
+ ]);
3189
+
3140
3190
  // ../shared/src/audit-log.ts
3141
3191
  var AUDIT_LOG_ACTION = {
3142
3192
  CREATE: "create",
@@ -4318,6 +4368,19 @@ function parseClaudeEvents(events, parentToolUseId) {
4318
4368
  isChatBased: true,
4319
4369
  timestamp: event.timestamp
4320
4370
  });
4371
+ } else if (toolName === "mcp__relay-subagent-tools__message_agent") {
4372
+ const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
4373
+ messages.push({
4374
+ id: `subagent-followup-${event.timestamp}-${messages.length}`,
4375
+ type: "subagent_followup",
4376
+ toolUseId,
4377
+ chatId: typeof inputObj.chatId === "string" ? inputObj.chatId : "",
4378
+ message: typeof inputObj.message === "string" ? inputObj.message : "",
4379
+ model: typeof inputObj.model === "string" ? inputObj.model : void 0,
4380
+ thinkingLevel: isValidThinkingLevel(inputObj.thinking_level) ? inputObj.thinking_level : void 0,
4381
+ status: "in_progress",
4382
+ timestamp: event.timestamp
4383
+ });
4321
4384
  } else if (toolName === "mcp__relay-subagent-tools__delete_agent") {
4322
4385
  const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
4323
4386
  const mcp = parseMcpToolName(toolName);
@@ -4461,10 +4524,21 @@ function parseClaudeEvents(events, parentToolUseId) {
4461
4524
  message.chatId = parsed.chatId;
4462
4525
  }
4463
4526
  }
4527
+ } else if (message.type === "subagent_followup") {
4528
+ message.output = resultContent;
4529
+ message.status = status;
4464
4530
  }
4465
4531
  }
4466
4532
  }
4467
4533
  });
4534
+ for (const message of messages) {
4535
+ if (message.type !== "subagent_followup") continue;
4536
+ const target = messages.find((candidate) => candidate.type === "subagent" && candidate.chatId === message.chatId);
4537
+ if (target?.type === "subagent") {
4538
+ message.targetTitle = target.description;
4539
+ message.targetProvider = target.subagentType;
4540
+ }
4541
+ }
4468
4542
  const staleIndexes = /* @__PURE__ */ new Set();
4469
4543
  for (const streamId of [...completedStreamIds, ...supersededStreamIds]) {
4470
4544
  const refs = partialIndexes.get(streamId);
@@ -9832,7 +9906,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
9832
9906
  var MIN_CODEX_CLI_VERSION = "0.144.6";
9833
9907
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
9834
9908
  var codexCliVersionEnsured = null;
9835
- var ENGINE_PACKAGE_VERSION = "0.1.471";
9909
+ var ENGINE_PACKAGE_VERSION = "0.1.473";
9836
9910
  var INITIALIZE_METHOD = "initialize";
9837
9911
  var INITIALIZED_NOTIFICATION = "initialized";
9838
9912
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -12371,7 +12445,7 @@ import { delimiter, dirname as dirname6, join as join18 } from "path";
12371
12445
  import { randomBytes as randomBytes2 } from "crypto";
12372
12446
  import { fileURLToPath } from "url";
12373
12447
  import { Agent } from "undici";
12374
- import { z as z3 } from "zod";
12448
+ import { z as z4 } from "zod";
12375
12449
  import {
12376
12450
  createOpencodeClient,
12377
12451
  createOpencodeServer
@@ -12408,9 +12482,9 @@ var OPENCODE_VARIANT_CANDIDATES_BY_THINKING_LEVEL = {
12408
12482
  ultra: ["max", "xhigh", "high"],
12409
12483
  ultracode: ["max", "xhigh", "high"]
12410
12484
  };
12411
- var opencodeAuthSchema = z3.record(z3.string(), z3.object({
12412
- type: z3.string().optional(),
12413
- key: z3.string().optional()
12485
+ var opencodeAuthSchema = z4.record(z4.string(), z4.object({
12486
+ type: z4.string().optional(),
12487
+ key: z4.string().optional()
12414
12488
  }));
12415
12489
  async function hasOpenCodeGoCredentials() {
12416
12490
  if (!existsSync7(OPENCODE_AUTH_PATH2)) return false;
@@ -13255,7 +13329,7 @@ var PiManager = class extends CodingAgentManager {
13255
13329
 
13256
13330
  // src/managers/relay-tools.ts
13257
13331
  import { createSdkMcpServer, tool } from "@anthropic-ai/claude-agent-sdk";
13258
- import { z as z4 } from "zod";
13332
+ import { z as z5 } from "zod";
13259
13333
 
13260
13334
  // src/managers/relay-providers.ts
13261
13335
  function isRelaySubagentProviderAllowed(provider, allowedProviders) {
@@ -13370,7 +13444,7 @@ function buildSpawnAgentTool(parentChatId, availability = {}, getAllowedProvider
13370
13444
  const cursorAvailable = availability.cursorAvailable ?? false;
13371
13445
  const opencodeAvailable = availability.opencodeAvailable ?? false;
13372
13446
  const availableProviders = getAvailableRelayProviders(availability);
13373
- const providerEnum = z4.enum(availableProviders);
13447
+ const providerEnum = z5.enum(availableProviders);
13374
13448
  const codeProviders = getAvailableCodeProviders(availability);
13375
13449
  const providerDesc = codeProviders.length > 0 ? `Which agent to use. Prefer ${codeProviders.join(" or ")} for code writing, claude for exploration/analysis, relay for complex multi-step orchestration.` : "Which agent to use. Use claude for code writing, exploration, and analysis. Use relay for complex multi-step orchestration.";
13376
13450
  const useCases = codeProviders.length > 0 ? `- Complex code writing tasks (use provider '${codeProviders.join("' or '")}' with a capable model)
@@ -13389,18 +13463,18 @@ The tool blocks until the subagent completes and returns its final response.
13389
13463
  You will also receive the chatId so you can send follow-up messages or clean up the chat.`,
13390
13464
  {
13391
13465
  provider: providerEnum.describe(providerDesc),
13392
- prompt: z4.string().describe("The full prompt/instructions for the subagent. Be detailed - it has no context from your conversation."),
13393
- model: z4.string().optional().describe([
13466
+ prompt: z5.string().describe("The full prompt/instructions for the subagent. Be detailed - it has no context from your conversation."),
13467
+ model: z5.string().optional().describe([
13394
13468
  `Model override. Claude: ${AGENT_MODELS.claude.join(", ")} (opus is the default; sonnet is faster).`,
13395
13469
  codexAvailable ? `Codex: ${AGENT_MODELS.codex.join(", ")}.` : null,
13396
13470
  cursorAvailable ? `Cursor: ${AGENT_MODELS.cursor.join(", ")}.` : null,
13397
13471
  opencodeAvailable ? `Opencode: ${AGENT_MODELS.opencode.join(", ")}.` : null
13398
13472
  ].filter(Boolean).join(" ")),
13399
- thinking_level: z4.enum(VALID_THINKING_LEVELS).optional().describe(
13473
+ thinking_level: z5.enum(VALID_THINKING_LEVELS).optional().describe(
13400
13474
  "Controls how much thinking/reasoning the subagent applies. low = light thinking, medium = moderate, high = deep reasoning, xhigh = extended effort, max = maximum effort, ultra = Codex ultra, ultracode = Claude Code dynamic workflows. Defaults: Claude = high, Codex = medium, Cursor = medium, Opencode = medium."
13401
13475
  ),
13402
- title: z4.string().optional().describe("Optional title for the subagent chat (for identification)."),
13403
- timeout_minutes: z4.number().positive().optional().describe("Timeout in minutes for the subagent to complete (default: 10). Set higher for large tasks to avoid losing work.")
13476
+ title: z5.string().optional().describe("Optional title for the subagent chat (for identification)."),
13477
+ timeout_minutes: z5.number().positive().optional().describe("Timeout in minutes for the subagent to complete (default: 10). Set higher for large tasks to avoid losing work.")
13404
13478
  },
13405
13479
  async (args) => {
13406
13480
  try {
@@ -13475,13 +13549,13 @@ var messageAgentTool = tool(
13475
13549
 
13476
13550
  The tool blocks until the subagent completes and returns its response.`,
13477
13551
  {
13478
- chatId: z4.string().describe("The chat ID of the subagent (returned by spawn_agent)."),
13479
- message: z4.string().describe("The follow-up message to send."),
13480
- model: z4.string().optional().describe("Optional model override for this message."),
13481
- thinking_level: z4.enum(VALID_THINKING_LEVELS).optional().describe(
13552
+ chatId: z5.string().describe("The chat ID of the subagent (returned by spawn_agent)."),
13553
+ message: z5.string().describe("The follow-up message to send."),
13554
+ model: z5.string().optional().describe("Optional model override for this message."),
13555
+ thinking_level: z5.enum(VALID_THINKING_LEVELS).optional().describe(
13482
13556
  "Controls how much thinking/reasoning the subagent applies. low = light thinking, medium = moderate, high = deep reasoning, xhigh = extended effort, max = maximum effort, ultra = Codex ultra, ultracode = Claude Code dynamic workflows. Defaults: Claude = high, Codex = medium, Cursor = medium, Opencode = medium."
13483
13557
  ),
13484
- timeout_minutes: z4.number().positive().optional().describe("Timeout in minutes for the subagent to complete (default: 10). Set higher for large tasks to avoid losing work.")
13558
+ timeout_minutes: z5.number().positive().optional().describe("Timeout in minutes for the subagent to complete (default: 10). Set higher for large tasks to avoid losing work.")
13485
13559
  },
13486
13560
  async (args) => {
13487
13561
  try {
@@ -13519,7 +13593,7 @@ var deleteAgentTool = tool(
13519
13593
  "delete_agent",
13520
13594
  `Delete a subagent chat to free resources. Use this after a subagent has completed its work and you no longer need to send it follow-up messages.`,
13521
13595
  {
13522
- chatId: z4.string().describe("The chat ID of the subagent to delete.")
13596
+ chatId: z5.string().describe("The chat ID of the subagent to delete.")
13523
13597
  },
13524
13598
  async (args) => {
13525
13599
  try {
@@ -15345,7 +15419,7 @@ var RepoFileService = class {
15345
15419
 
15346
15420
  // src/v1-routes.ts
15347
15421
  import { Hono } from "hono";
15348
- import { z as z5 } from "zod";
15422
+ import { z as z6 } from "zod";
15349
15423
  import { readdir as readdir9, stat as stat5, readFile as readFile18 } from "fs/promises";
15350
15424
  import { join as join26, resolve as resolve3 } from "path";
15351
15425
 
@@ -15853,75 +15927,75 @@ var TerminalService = class {
15853
15927
  var terminalService = new TerminalService();
15854
15928
 
15855
15929
  // src/v1-routes.ts
15856
- var setWorkspaceNameSchema = z5.object({
15857
- name: z5.string().min(1).max(48)
15930
+ var setWorkspaceNameSchema = z6.object({
15931
+ name: z6.string().min(1).max(48)
15858
15932
  });
15859
- var imageMediaTypeSchema = z5.enum(IMAGE_MEDIA_TYPES);
15860
- var createPreviewSchema = z5.object({
15861
- port: z5.number().int().min(1).max(65535),
15862
- publicUrl: z5.string().min(1)
15933
+ var imageMediaTypeSchema = z6.enum(IMAGE_MEDIA_TYPES);
15934
+ var createPreviewSchema = z6.object({
15935
+ port: z6.number().int().min(1).max(65535),
15936
+ publicUrl: z6.string().min(1)
15863
15937
  });
15864
- var terminalSizeSchema = z5.object({
15865
- cols: z5.number().int().min(2).max(500),
15866
- rows: z5.number().int().min(1).max(200)
15938
+ var terminalSizeSchema = z6.object({
15939
+ cols: z6.number().int().min(2).max(500),
15940
+ rows: z6.number().int().min(1).max(200)
15867
15941
  });
15868
- var writeTerminalSessionSchema = z5.object({
15869
- data: z5.string().max(64 * 1024),
15870
- generation: z5.number().int().nonnegative(),
15871
- sequence: z5.number().int().nonnegative()
15942
+ var writeTerminalSessionSchema = z6.object({
15943
+ data: z6.string().max(64 * 1024),
15944
+ generation: z6.number().int().nonnegative(),
15945
+ sequence: z6.number().int().nonnegative()
15872
15946
  });
15873
- var sendMessageSchema = z5.object({
15874
- messageId: z5.string().min(1).optional(),
15875
- submittedAt: z5.string().datetime().optional(),
15876
- message: z5.string().min(1),
15877
- model: z5.string().optional(),
15878
- customInstructions: z5.string().optional(),
15879
- planMode: z5.boolean().optional(),
15880
- images: z5.array(z5.object({
15881
- type: z5.literal("image"),
15882
- source: z5.union([
15883
- z5.object({
15884
- type: z5.literal("base64"),
15947
+ var sendMessageSchema = z6.object({
15948
+ messageId: z6.string().min(1).optional(),
15949
+ submittedAt: z6.string().datetime().optional(),
15950
+ message: z6.string().min(1),
15951
+ model: z6.string().optional(),
15952
+ customInstructions: z6.string().optional(),
15953
+ planMode: z6.boolean().optional(),
15954
+ images: z6.array(z6.object({
15955
+ type: z6.literal("image"),
15956
+ source: z6.union([
15957
+ z6.object({
15958
+ type: z6.literal("base64"),
15885
15959
  media_type: imageMediaTypeSchema,
15886
- data: z5.string().min(1)
15960
+ data: z6.string().min(1)
15887
15961
  }),
15888
- z5.object({
15889
- type: z5.literal("url"),
15890
- url: z5.string().url()
15962
+ z6.object({
15963
+ type: z6.literal("url"),
15964
+ url: z6.string().url()
15891
15965
  })
15892
15966
  ])
15893
15967
  })).optional(),
15894
- thinkingLevel: z5.enum(VALID_THINKING_LEVELS).optional(),
15895
- goalMode: z5.boolean().optional(),
15896
- fastMode: z5.boolean().optional(),
15897
- enableInteractiveTools: z5.boolean().optional(),
15898
- type: z5.string().min(1).optional(),
15899
- merge: z5.boolean().optional(),
15900
- idempotencyKey: z5.string().min(1).max(128).optional(),
15901
- senderUserId: z5.string().optional(),
15902
- senderEmail: z5.string().optional(),
15903
- senderDisplayName: z5.string().optional(),
15904
- senderAvatarUrl: z5.string().optional(),
15905
- errorNotificationTarget: z5.discriminatedUnion("type", [
15906
- z5.object({ type: z5.literal("slack") }),
15907
- z5.object({ type: z5.literal("linear"), sessionId: z5.string().min(1) }),
15908
- z5.object({
15909
- type: z5.literal("code_host"),
15910
- provider: z5.enum(["github", "gitlab"]),
15911
- resource: z5.enum(["issue", "pull_request"]),
15912
- repositoryId: z5.string().min(1),
15913
- resourceNumber: z5.number().int().positive()
15968
+ thinkingLevel: z6.enum(VALID_THINKING_LEVELS).optional(),
15969
+ goalMode: z6.boolean().optional(),
15970
+ fastMode: z6.boolean().optional(),
15971
+ enableInteractiveTools: z6.boolean().optional(),
15972
+ type: z6.string().min(1).optional(),
15973
+ merge: z6.boolean().optional(),
15974
+ idempotencyKey: z6.string().min(1).max(128).optional(),
15975
+ senderUserId: z6.string().optional(),
15976
+ senderEmail: z6.string().optional(),
15977
+ senderDisplayName: z6.string().optional(),
15978
+ senderAvatarUrl: z6.string().optional(),
15979
+ errorNotificationTarget: z6.discriminatedUnion("type", [
15980
+ z6.object({ type: z6.literal("slack") }),
15981
+ z6.object({ type: z6.literal("linear"), sessionId: z6.string().min(1) }),
15982
+ z6.object({
15983
+ type: z6.literal("code_host"),
15984
+ provider: z6.enum(["github", "gitlab"]),
15985
+ resource: z6.enum(["issue", "pull_request"]),
15986
+ repositoryId: z6.string().min(1),
15987
+ resourceNumber: z6.number().int().positive()
15914
15988
  }),
15915
- z5.object({ type: z5.literal("automation"), executionId: z5.string().min(1) })
15989
+ z6.object({ type: z6.literal("automation"), executionId: z6.string().min(1) })
15916
15990
  ]).optional()
15917
15991
  });
15918
- var respondToolInputSchema = z5.object({
15919
- requestId: z5.string().min(1),
15920
- selectionId: z5.string().min(1)
15992
+ var respondToolInputSchema = z6.object({
15993
+ requestId: z6.string().min(1),
15994
+ selectionId: z6.string().min(1)
15921
15995
  });
15922
- var updateGoalSchema = z5.object({
15923
- objective: z5.string().trim().min(1).max(MAX_CODEX_GOAL_OBJECTIVE_CHARS).optional(),
15924
- status: z5.enum(["active", "paused"]).optional()
15996
+ var updateGoalSchema = z6.object({
15997
+ objective: z6.string().trim().min(1).max(MAX_CODEX_GOAL_OBJECTIVE_CHARS).optional(),
15998
+ status: z6.enum(["active", "paused"]).optional()
15925
15999
  }).refine((body) => body.objective !== void 0 || body.status !== void 0, {
15926
16000
  message: "Goal objective or status required"
15927
16001
  });
@@ -16112,7 +16186,7 @@ function createV1Routes(deps) {
16112
16186
  const result = await deps.chatService.updateGoal(c.req.param("chatId"), body);
16113
16187
  return c.json(result);
16114
16188
  } catch (error) {
16115
- if (error instanceof z5.ZodError) {
16189
+ if (error instanceof z6.ZodError) {
16116
16190
  return c.json(jsonError(error.issues[0]?.message || "Invalid goal update"), 400);
16117
16191
  }
16118
16192
  if (error instanceof ChatNotFoundError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.471",
3
+ "version": "0.1.473",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",