replicas-engine 0.1.1350 → 0.1.1352

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.
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-XR55TOMZ.js";
7
- import "./chunk-PESCC5AC.js";
8
- import "./chunk-7XURQLGZ.js";
6
+ } from "./chunk-6CNCQ5GN.js";
7
+ import "./chunk-2KXHN7RZ.js";
8
+ import "./chunk-5366QBIH.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-HCSEZ4G6.js";
12
+ import "./chunk-KQXHQH5H.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -14,12 +14,12 @@ import {
14
14
  recoverCompletedTurn,
15
15
  spawnMuseMsp,
16
16
  startMuseSession
17
- } from "./chunk-QOC2TFRB.js";
17
+ } from "./chunk-E5CHPARE.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-Q4GKLQ3B.js";
22
- import "./chunk-7XURQLGZ.js";
21
+ } from "./chunk-AUWC35GL.js";
22
+ import "./chunk-5366QBIH.js";
23
23
  import {
24
24
  AGENT,
25
25
  OPENCODE_GO_PROVIDER,
@@ -29,7 +29,7 @@ import {
29
29
  headlessAgentUsagePath,
30
30
  isRecord,
31
31
  withTimeout
32
- } from "./chunk-HCSEZ4G6.js";
32
+ } from "./chunk-KQXHQH5H.js";
33
33
  import "./chunk-VEQXQN22.js";
34
34
 
35
35
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
29
  reportCommandProtectionBlock
30
- } from "./chunk-XR55TOMZ.js";
30
+ } from "./chunk-6CNCQ5GN.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -65,10 +65,10 @@ import {
65
65
  spawnMuseMsp,
66
66
  startMuseSession,
67
67
  uuidV7
68
- } from "./chunk-QOC2TFRB.js";
68
+ } from "./chunk-E5CHPARE.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
- } from "./chunk-DCEJYFAU.js";
71
+ } from "./chunk-IK3CUAXD.js";
72
72
  import {
73
73
  ACCOUNT_RATE_LIMITS_READ_METHOD,
74
74
  AsyncLock,
@@ -143,7 +143,7 @@ import {
143
143
  timestampFromSeconds,
144
144
  upsertCredentialFileLines,
145
145
  writeSecureCredentialFile
146
- } from "./chunk-UOBO75SD.js";
146
+ } from "./chunk-CFYYW3KY.js";
147
147
  import {
148
148
  ENGINE_ENV,
149
149
  monolithRequest,
@@ -153,15 +153,15 @@ import {
153
153
  resolveDiffBase,
154
154
  setAgentCredentialSnapshot,
155
155
  setLinearSessionId
156
- } from "./chunk-PESCC5AC.js";
156
+ } from "./chunk-2KXHN7RZ.js";
157
157
  import {
158
158
  getCodexModelProvider
159
- } from "./chunk-Q4GKLQ3B.js";
159
+ } from "./chunk-AUWC35GL.js";
160
160
  import {
161
161
  SUBPROCESS_MAX_BUFFER,
162
162
  execAsync,
163
163
  execFileAsync
164
- } from "./chunk-7XURQLGZ.js";
164
+ } from "./chunk-5366QBIH.js";
165
165
  import {
166
166
  isRecord as isRecord2
167
167
  } from "./chunk-UZSNFLDQ.js";
@@ -293,6 +293,7 @@ import {
293
293
  createProviderSlashCommand,
294
294
  createSuccessResult,
295
295
  createUuidFromHex,
296
+ currentStepLabel,
296
297
  defaultForkChatTitle,
297
298
  describeCredential,
298
299
  describeQuotaLimit,
@@ -354,6 +355,7 @@ import {
354
355
  isSkillRegistryManifest,
355
356
  isTokenUsageCounts,
356
357
  isTokenUsageUploadRecord,
358
+ isToolInputQuestion,
357
359
  isTransientErrorText,
358
360
  isValidAgentProvider,
359
361
  isValidEngineLogSessionId,
@@ -395,6 +397,7 @@ import {
395
397
  readOpenAICompatibleAuthEnv,
396
398
  readReplicasRuntimeEnv,
397
399
  resolveWarmHookConfig,
400
+ respondToolInputRequestSchema,
398
401
  safeJsonParse,
399
402
  sanitizeCanvasFilename,
400
403
  searchRepoFileIndex,
@@ -419,7 +422,7 @@ import {
419
422
  workspaceTokenRequestSchema,
420
423
  workspaceTokenResponseSchema,
421
424
  wrapInTag
422
- } from "./chunk-HCSEZ4G6.js";
425
+ } from "./chunk-KQXHQH5H.js";
423
426
  import {
424
427
  cloneMcpConfig,
425
428
  ensureCompatibilityImports,
@@ -10640,6 +10643,7 @@ function devicesInstruction() {
10640
10643
  import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir18, readFile as readFile17, rename as rename3, rm as rm5, stat as stat6 } from "fs/promises";
10641
10644
  import { join as join29 } from "path";
10642
10645
  import { randomUUID as randomUUID9 } from "crypto";
10646
+ import { z as z3 } from "zod";
10643
10647
 
10644
10648
  // ../shared/src/workspace-chat.ts
10645
10649
  var WORKSPACE_CHATS_QUERY_SCHEMA_VERSION = 17;
@@ -13458,7 +13462,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13458
13462
  toolUseId,
13459
13463
  toolName,
13460
13464
  ...requestOptions ? { options: requestOptions } : {},
13461
- ...requestQuestions ? { questions: requestQuestions } : {}
13465
+ ...requestQuestions ? { questions: requestQuestions } : {},
13466
+ ...typeof input.plan === "string" ? { plan: input.plan } : {}
13462
13467
  }).catch((err) => {
13463
13468
  console.error("[ClaudeManager] Failed to emit tool-input request event:", err);
13464
13469
  });
@@ -14612,6 +14617,12 @@ var ItemUpdateCoalescer = class {
14612
14617
  }
14613
14618
  this.timers.set(key, setTimeout(() => this.flushNow(key), this.intervalMs - elapsed));
14614
14619
  }
14620
+ /** Drops a pending flush but keeps when the key last flushed, so the next schedule still waits out the interval. */
14621
+ cancel(key) {
14622
+ const timer = this.timers.get(key);
14623
+ if (timer) clearTimeout(timer);
14624
+ this.timers.delete(key);
14625
+ }
14615
14626
  flushPending() {
14616
14627
  for (const key of [...this.timers.keys()]) this.flushNow(key);
14617
14628
  }
@@ -60231,7 +60242,16 @@ function terminalErrorsFromEvent(event, provider) {
60231
60242
  }
60232
60243
  var LAST_MESSAGE_PREVIEW_MAX = 200;
60233
60244
  var FINAL_MESSAGE_MAX = 6e3;
60245
+ var PROGRESS_INTERVAL_MS = 2e4;
60246
+ var PROGRESS_STEP_MAX = 120;
60234
60247
  var TURN_REQUEST_MAX = 8e3;
60248
+ var toolInputRequestSchema = z3.object({
60249
+ requestId: z3.string().optional(),
60250
+ toolName: z3.string().optional(),
60251
+ questions: z3.array(z3.custom(isToolInputQuestion)).optional(),
60252
+ plan: z3.string().optional()
60253
+ });
60254
+ var toolInputResolvedSchema = z3.object({ requestId: z3.string() });
60235
60255
  var MAX_ACCEPTED_SEND_RESPONSES = 50;
60236
60256
  var MAX_REMOVED_MESSAGE_IDS = 6e3;
60237
60257
  var SUBAGENT_POLL_INTERVAL_MS = 2e3;
@@ -61639,6 +61659,8 @@ ${note}`;
61639
61659
  idleReleaseTimer: null,
61640
61660
  unpublishedHistoryStarts: [],
61641
61661
  live: false,
61662
+ progressStep: null,
61663
+ progressSentStep: null,
61642
61664
  release: null,
61643
61665
  switching: null,
61644
61666
  errorNotificationTargets: /* @__PURE__ */ new Map(),
@@ -61754,6 +61776,10 @@ ${note}`;
61754
61776
  const parentToolUseId = typeof event.payload.parent_tool_use_id === "string" ? event.payload.parent_tool_use_id : null;
61755
61777
  const messages = parseDisplayMessages([event], chat.persisted.provider, { filter: false, parentToolUseId });
61756
61778
  if (chat.hasActiveTurn) this.agentChatActivityTrackerService.noteSkillMcpCalls(chatId, messages);
61779
+ if (!parentToolUseId && !chat.persisted.parentChatId && event.type !== CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE) {
61780
+ const step = currentStepLabel(messages);
61781
+ if (step) this.reportProgress(chat, step.slice(0, PROGRESS_STEP_MAX));
61782
+ }
61757
61783
  if (!parentToolUseId && event.type !== CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE && event.type !== CODEX_ITEM_PARTIAL_EVENT_TYPE) {
61758
61784
  for (const message of messages) {
61759
61785
  if (message.type === "agent") {
@@ -61814,8 +61840,39 @@ ${note}`;
61814
61840
  }
61815
61841
  if (event.type === "replicas-tool-input-request") {
61816
61842
  this.persistTurnArtifacts(chat);
61843
+ if (!chat.persisted.parentChatId) {
61844
+ const request = toolInputRequestSchema.safeParse(event.payload).data;
61845
+ void monolithService.sendEvent({
61846
+ type: "agent_input_requested",
61847
+ payload: {
61848
+ chatId: chat.persisted.id,
61849
+ requestId: request?.requestId,
61850
+ toolName: request?.toolName,
61851
+ question: request?.questions?.[0]?.prompt,
61852
+ questions: request?.questions?.map(({ id, multiSelect, options }) => ({ id, multiSelect, options: options.map(({ id: id2, label }) => ({ id: id2, label })) })),
61853
+ plan: request?.plan,
61854
+ at: (/* @__PURE__ */ new Date()).toISOString()
61855
+ }
61856
+ });
61857
+ }
61858
+ }
61859
+ if (event.type === "replicas-tool-input-resolved" && !chat.persisted.parentChatId) {
61860
+ const resolved = toolInputResolvedSchema.safeParse(event.payload).data;
61861
+ if (resolved) void monolithService.sendEvent({ type: "agent_input_resolved", payload: { chatId: chat.persisted.id, requestId: resolved.requestId } });
61817
61862
  }
61818
61863
  }
61864
+ progressCoalescer = new ItemUpdateCoalescer((chatId) => {
61865
+ const chat = this.getRuntimeChat(chatId);
61866
+ const latest = chat?.progressStep;
61867
+ if (!chat || !latest || latest === chat.progressSentStep || !hasActiveChatTurn(chat)) return;
61868
+ chat.progressSentStep = latest;
61869
+ void monolithService.sendEvent({ type: "agent_progress", payload: { chatId, step: latest } });
61870
+ }, PROGRESS_INTERVAL_MS);
61871
+ reportProgress(chat, step) {
61872
+ chat.progressStep = step;
61873
+ if (step === chat.progressSentStep) this.progressCoalescer.cancel(chat.persisted.id);
61874
+ else this.progressCoalescer.schedule(chat.persisted.id);
61875
+ }
61819
61876
  handleProcessingStopped(chatId) {
61820
61877
  const chat = this.getRuntimeChat(chatId);
61821
61878
  if (!chat) return;
@@ -61859,6 +61916,9 @@ ${note}`;
61859
61916
  this.agentTokenUsageTracker.endTurn(chat.persisted.id);
61860
61917
  this.agentChatActivityTrackerService.noteTurnEnded(chat.persisted.id);
61861
61918
  delete chat.persisted.turnStartedAt;
61919
+ this.progressCoalescer.cancel(chat.persisted.id);
61920
+ chat.progressStep = null;
61921
+ chat.progressSentStep = null;
61862
61922
  this.touch(chat);
61863
61923
  }
61864
61924
  async handleTurnFinished(chatId) {
@@ -62565,7 +62625,7 @@ var RepoFileService = class {
62565
62625
 
62566
62626
  // src/v1-routes.ts
62567
62627
  import { Hono } from "hono";
62568
- import { z as z4 } from "zod";
62628
+ import { z as z5 } from "zod";
62569
62629
  import { readdir as readdir10, stat as stat7, readFile as readFile21 } from "fs/promises";
62570
62630
  import { join as join34, resolve as resolve5 } from "path";
62571
62631
 
@@ -62912,17 +62972,17 @@ ${combinedScript}` : combinedScript;
62912
62972
  import { randomUUID as randomUUID10 } from "crypto";
62913
62973
  import { existsSync as existsSync17 } from "fs";
62914
62974
  import { spawn as spawn6 } from "node-pty";
62915
- import { z as z3 } from "zod";
62975
+ import { z as z4 } from "zod";
62916
62976
  var MAX_REPLAY_CHARS2 = 1024 * 1024;
62917
62977
  var MAX_TERMINAL_SESSIONS = 8;
62918
62978
  var MAX_PENDING_INPUT = 64;
62919
- var terminalSizeSchema = z3.object({
62920
- cols: z3.number().int().min(2).max(500),
62921
- rows: z3.number().int().min(1).max(200)
62979
+ var terminalSizeSchema = z4.object({
62980
+ cols: z4.number().int().min(2).max(500),
62981
+ rows: z4.number().int().min(1).max(200)
62922
62982
  });
62923
- var terminalCommandSchema = z3.discriminatedUnion("type", [
62924
- z3.object({ type: z3.literal("input"), data: z3.string() }),
62925
- terminalSizeSchema.extend({ type: z3.literal("resize") })
62983
+ var terminalCommandSchema = z4.discriminatedUnion("type", [
62984
+ z4.object({ type: z4.literal("input"), data: z4.string() }),
62985
+ terminalSizeSchema.extend({ type: z4.literal("resize") })
62926
62986
  ]);
62927
62987
  var TerminalService = class {
62928
62988
  sessions = /* @__PURE__ */ new Map();
@@ -63043,28 +63103,24 @@ var TerminalService = class {
63043
63103
  var terminalService = new TerminalService();
63044
63104
 
63045
63105
  // src/v1-routes.ts
63046
- var createPreviewSchema = z4.object({
63047
- port: z4.number().int().min(1).max(65535),
63048
- publicUrl: z4.string().min(1)
63106
+ var createPreviewSchema = z5.object({
63107
+ port: z5.number().int().min(1).max(65535),
63108
+ publicUrl: z5.string().min(1)
63049
63109
  });
63050
- var writeTerminalSessionSchema = z4.object({
63051
- data: z4.string().max(64 * 1024),
63052
- generation: z4.number().int().nonnegative(),
63053
- sequence: z4.number().int().nonnegative()
63110
+ var writeTerminalSessionSchema = z5.object({
63111
+ data: z5.string().max(64 * 1024),
63112
+ generation: z5.number().int().nonnegative(),
63113
+ sequence: z5.number().int().nonnegative()
63054
63114
  });
63055
- var respondToolInputSchema = z4.object({
63056
- requestId: z4.string().min(1),
63057
- selectionId: z4.string().min(1)
63058
- });
63059
- var updateGoalSchema = z4.object({
63060
- objective: z4.string().trim().min(1).max(MAX_CODEX_GOAL_OBJECTIVE_CHARS).optional(),
63061
- status: z4.enum(["active", "paused"]).optional()
63115
+ var updateGoalSchema = z5.object({
63116
+ objective: z5.string().trim().min(1).max(MAX_CODEX_GOAL_OBJECTIVE_CHARS).optional(),
63117
+ status: z5.enum(["active", "paused"]).optional()
63062
63118
  }).refine((body) => body.objective !== void 0 || body.status !== void 0, {
63063
63119
  message: "Goal objective or status required"
63064
63120
  });
63065
- var updateTextFileSchema = (maxLength) => z4.object({
63066
- content: z4.string().max(maxLength),
63067
- expectedRevision: z4.string().regex(/^[a-f0-9]{64}$/)
63121
+ var updateTextFileSchema = (maxLength) => z5.object({
63122
+ content: z5.string().max(maxLength),
63123
+ expectedRevision: z5.string().regex(/^[a-f0-9]{64}$/)
63068
63124
  });
63069
63125
  function jsonError(message, details) {
63070
63126
  return { error: message, details };
@@ -63114,11 +63170,11 @@ function createV1Routes(deps) {
63114
63170
  const app2 = new Hono();
63115
63171
  app2.post("/pull-requests/check", async (c) => {
63116
63172
  if (c.req.header("content-type")?.includes("application/json")) {
63117
- const result = z4.object({
63118
- toolName: z4.string(),
63119
- toolInput: z4.unknown(),
63120
- output: z4.unknown(),
63121
- success: z4.boolean()
63173
+ const result = z5.object({
63174
+ toolName: z5.string(),
63175
+ toolInput: z5.unknown(),
63176
+ output: z5.unknown(),
63177
+ success: z5.boolean()
63122
63178
  }).safeParse(await c.req.json().catch(() => null));
63123
63179
  if (!result.success) return c.json({ error: "Invalid PR tool result" }, 400);
63124
63180
  await pullRequestCheckService.onToolResult(result.data);
@@ -63338,7 +63394,7 @@ function createV1Routes(deps) {
63338
63394
  const chat = await deps.chatService.updateDisplayName(c.req.param("chatId"), body.displayName);
63339
63395
  return c.json({ chat });
63340
63396
  } catch (error) {
63341
- if (error instanceof z4.ZodError) {
63397
+ if (error instanceof z5.ZodError) {
63342
63398
  return c.json(jsonError(error.issues[0]?.message || "Invalid tab name"), 400);
63343
63399
  }
63344
63400
  if (error instanceof ChatNotFoundError) {
@@ -63458,7 +63514,7 @@ function createV1Routes(deps) {
63458
63514
  const result = await deps.chatService.updateGoal(c.req.param("chatId"), body);
63459
63515
  return c.json(result);
63460
63516
  } catch (error) {
63461
- if (error instanceof z4.ZodError) {
63517
+ if (error instanceof z5.ZodError) {
63462
63518
  return c.json(jsonError(error.issues[0]?.message || "Invalid goal update"), 400);
63463
63519
  }
63464
63520
  if (error instanceof ChatNotFoundError) {
@@ -63583,7 +63639,7 @@ function createV1Routes(deps) {
63583
63639
  }
63584
63640
  app2.post("/chats/:chatId/tool-input", async (c) => {
63585
63641
  try {
63586
- const body = respondToolInputSchema.parse(await c.req.json());
63642
+ const body = respondToolInputRequestSchema.parse(await c.req.json());
63587
63643
  const resolved = await deps.chatService.respondToToolInput(
63588
63644
  c.req.param("chatId"),
63589
63645
  body.requestId,
@@ -63993,7 +64049,7 @@ data: ${JSON.stringify("Terminal session not found")}
63993
64049
  return c.json({ success: true, repos: [] });
63994
64050
  });
63995
64051
  app2.put("/linear-session", async (c) => {
63996
- const body = z4.object({ linearSessionId: z4.string().min(1) }).safeParse(await c.req.json().catch(() => null));
64052
+ const body = z5.object({ linearSessionId: z5.string().min(1) }).safeParse(await c.req.json().catch(() => null));
63997
64053
  if (!body.success) return c.json(jsonError("linearSessionId is required"), 400);
63998
64054
  setLinearSessionId(body.data.linearSessionId);
63999
64055
  return c.json({ success: true });
@@ -64103,17 +64159,17 @@ data: ${JSON.stringify("Terminal session not found")}
64103
64159
  }
64104
64160
 
64105
64161
  // src/services/terminal-socket.ts
64106
- import { z as z5 } from "zod";
64162
+ import { z as z6 } from "zod";
64107
64163
  var ndcModule;
64108
64164
  var loadNdc = () => ndcModule ??= import("node-datachannel").then((module) => module.default, () => null);
64109
64165
  var CHANNEL_CHUNK_CHARS = 16384;
64110
64166
  var MAX_QUEUED_CANDIDATES = 32;
64111
64167
  var MAX_BUFFERED_BYTES = 8 * 1024 * 1024;
64112
- var socketMessageSchema = z5.union([
64168
+ var socketMessageSchema = z6.union([
64113
64169
  terminalCommandSchema,
64114
- z5.object({ type: z5.literal("rtc-offer"), sdp: z5.string().max(64 * 1024) }),
64115
- z5.object({ type: z5.literal("rtc-candidate"), candidate: z5.string().max(1024), mid: z5.string().max(64) }),
64116
- z5.object({ type: z5.literal("rtc-switch") })
64170
+ z6.object({ type: z6.literal("rtc-offer"), sdp: z6.string().max(64 * 1024) }),
64171
+ z6.object({ type: z6.literal("rtc-candidate"), candidate: z6.string().max(1024), mid: z6.string().max(64) }),
64172
+ z6.object({ type: z6.literal("rtc-switch") })
64117
64173
  ]);
64118
64174
  function parse(schema, raw) {
64119
64175
  try {
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-DCEJYFAU.js";
6
+ } from "./chunk-IK3CUAXD.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-HCSEZ4G6.js";
12
+ } from "./chunk-KQXHQH5H.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -11,7 +11,7 @@ import {
11
11
  spawnSubagentRequestSchema,
12
12
  subagentResponseSchema,
13
13
  waitSubagentRequestSchema
14
- } from "./chunk-HCSEZ4G6.js";
14
+ } from "./chunk-KQXHQH5H.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1350",
3
+ "version": "0.1.1352",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",