replicas-engine 0.1.902 → 0.1.904

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.
@@ -5,11 +5,11 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-O6UHVK4J.js";
9
- import "./chunk-OBD4D4AW.js";
10
- import "./chunk-KA7C3C4U.js";
8
+ } from "./chunk-WC7COMCW.js";
9
+ import "./chunk-2VZVUDQM.js";
10
+ import "./chunk-5R4AAJD5.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-2ROQAUB6.js";
12
+ import "./chunk-TPOJS4TI.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-2ROQAUB6.js";
18
+ } from "./chunk-TPOJS4TI.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-2ROQAUB6.js";
8
+ } from "./chunk-TPOJS4TI.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES,
6
6
  isVersionBelow
7
- } from "./chunk-2ROQAUB6.js";
7
+ } from "./chunk-TPOJS4TI.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
245
245
  if (method === "foundry") return "azure";
246
246
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
247
247
  }
248
- var ENGINE_PACKAGE_VERSION = "0.1.902";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.904";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-GFIDOFFP.js";
6
+ } from "./chunk-4M3ZD5FV.js";
7
7
  import {
8
8
  shouldRefreshPullRequests
9
- } from "./chunk-2ROQAUB6.js";
9
+ } from "./chunk-TPOJS4TI.js";
10
10
 
11
11
  // src/services/post-tool-pr-notifier.ts
12
12
  async function notifyPostToolUse(toolName, toolInput, result) {
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-OBD4D4AW.js";
6
+ } from "./chunk-2VZVUDQM.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-2ROQAUB6.js";
11
+ } from "./chunk-TPOJS4TI.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -6963,6 +6963,12 @@ var SLASH_COMMANDS = [
6963
6963
  argumentHint: "<objective | pause | resume | clear>",
6964
6964
  providers: ["codex"]
6965
6965
  },
6966
+ {
6967
+ command: "/goal",
6968
+ description: "Set or clear a completion condition to keep working toward.",
6969
+ argumentHint: "<condition | clear>",
6970
+ providers: ["claude"]
6971
+ },
6966
6972
  {
6967
6973
  command: "/compact",
6968
6974
  description: "Compact the conversation context.",
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-OBD4D4AW.js";
8
+ } from "./chunk-2VZVUDQM.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-KA7C3C4U.js";
14
+ } from "./chunk-5R4AAJD5.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./chunk-UZSNFLDQ.js";
@@ -25,7 +25,7 @@ import {
25
25
  listOpenAICompatibleModels,
26
26
  readOllamaAuthEnv,
27
27
  resolveOpenAICompatibleModelsUrl
28
- } from "./chunk-2ROQAUB6.js";
28
+ } from "./chunk-TPOJS4TI.js";
29
29
 
30
30
  // src/managers/codex-token-manager.ts
31
31
  import { promises as fs } from "fs";
@@ -255,7 +255,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
255
255
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
256
256
  await this.applyCredentialsResponse(data);
257
257
  if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
258
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-JCJHOGRT.js");
258
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-75MC3P3L.js");
259
259
  await restartCodexAspHostIfRunning2();
260
260
  });
261
261
  await this.start(true);
@@ -275,7 +275,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
275
275
  await this.applyCredentialUpdate(generation, async () => {
276
276
  await this.applyCredentialsResponse(data);
277
277
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
278
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-JCJHOGRT.js");
278
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-75MC3P3L.js");
279
279
  await restartCodexAspHostIfRunning2();
280
280
  }
281
281
  if (data.scope) {
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-D4UQZM5D.js";
7
- import "./chunk-OBD4D4AW.js";
6
+ } from "./chunk-7W5IP2MX.js";
7
+ import "./chunk-2VZVUDQM.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-2ROQAUB6.js";
11
+ import "./chunk-TPOJS4TI.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/command-protection-hook.ts
@@ -3,14 +3,14 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-D4UQZM5D.js";
6
+ } from "./chunk-7W5IP2MX.js";
7
7
  import {
8
8
  notifyPostToolUse
9
- } from "./chunk-YICM7VI4.js";
10
- import "./chunk-GFIDOFFP.js";
11
- import "./chunk-OBD4D4AW.js";
9
+ } from "./chunk-7TNL7LE7.js";
10
+ import "./chunk-4M3ZD5FV.js";
11
+ import "./chunk-2VZVUDQM.js";
12
12
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-2ROQAUB6.js";
13
+ import "./chunk-TPOJS4TI.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
 
16
16
  // src/deepseek-command-protection-plugin.ts
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-KA7C3C4U.js";
11
+ } from "./chunk-5R4AAJD5.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-2ROQAUB6.js";
16
+ } from "./chunk-TPOJS4TI.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
 
19
19
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  evaluateCommandProtection,
92
92
  extractToolCommand,
93
93
  reportCommandProtectionBlock
94
- } from "./chunk-D4UQZM5D.js";
94
+ } from "./chunk-7W5IP2MX.js";
95
95
  import {
96
96
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
97
  AGENT_MESSAGE_DELTA_METHOD,
@@ -116,7 +116,7 @@ import {
116
116
  } from "./chunk-FLDA7BX3.js";
117
117
  import {
118
118
  publishedPullRequestUrls
119
- } from "./chunk-GFIDOFFP.js";
119
+ } from "./chunk-4M3ZD5FV.js";
120
120
  import {
121
121
  RELAY_MCP_TOOLS,
122
122
  RELAY_MCP_TOOL_NAMES,
@@ -137,21 +137,21 @@ import {
137
137
  refreshDelayMs,
138
138
  restartCodexAspHost,
139
139
  routineRefreshExclusions
140
- } from "./chunk-O6UHVK4J.js";
140
+ } from "./chunk-WC7COMCW.js";
141
141
  import {
142
142
  ENGINE_ENV,
143
143
  IS_WARMING_MODE,
144
144
  monolithRequest,
145
145
  monolithService,
146
146
  setAgentCredentialSnapshot
147
- } from "./chunk-OBD4D4AW.js";
147
+ } from "./chunk-2VZVUDQM.js";
148
148
  import {
149
149
  AspClient,
150
150
  SUBPROCESS_MAX_BUFFER,
151
151
  execAsync,
152
152
  execFileAsync,
153
153
  getCodexModelProvider
154
- } from "./chunk-KA7C3C4U.js";
154
+ } from "./chunk-5R4AAJD5.js";
155
155
  import {
156
156
  isRecord as isRecord2
157
157
  } from "./chunk-UZSNFLDQ.js";
@@ -378,7 +378,7 @@ import {
378
378
  workspaceCredentialProviderSchema,
379
379
  workspaceTokenRequestSchema,
380
380
  workspaceTokenResponseSchema
381
- } from "./chunk-2ROQAUB6.js";
381
+ } from "./chunk-TPOJS4TI.js";
382
382
  import {
383
383
  __commonJS,
384
384
  __export,
@@ -10140,6 +10140,7 @@ var EnvironmentDetailsService = class {
10140
10140
  details.engineVersion = ENGINE_ENV.REPLICAS_SANDBOX_IMAGE_VERSION;
10141
10141
  details.supportsMidTurnSteering = true;
10142
10142
  details.supportsClaudeMidTurnSteering = true;
10143
+ details.supportsClaudeGoals = true;
10143
10144
  details.supportsGoalUpdates = true;
10144
10145
  details.supportsQueuedMessageEditing = true;
10145
10146
  details.supportsChatForking = true;
@@ -12741,6 +12742,7 @@ var CodexHistoryFile = class {
12741
12742
  let found = null;
12742
12743
  try {
12743
12744
  for await (const line of createInterface({ input: createReadStream(this.filePath), crlfDelay: Infinity })) {
12745
+ if (!line.includes(type)) continue;
12744
12746
  const event = parseAgentEventJsonlLine(line);
12745
12747
  if (event?.type === type) found = event;
12746
12748
  }
@@ -13165,6 +13167,9 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13165
13167
  slashCommandsDiscoveredAt = 0;
13166
13168
  slashCommandsDiscovery = null;
13167
13169
  authRetrying = false;
13170
+ currentGoal = null;
13171
+ goalClear = null;
13172
+ lastRequest = null;
13168
13173
  constructor(options) {
13169
13174
  super({ ...options, provider: AGENT.CLAUDE });
13170
13175
  this.historyFilePath = options.historyFilePath ?? join16(homedir11(), ".replicas", "claude", "history.jsonl");
@@ -13179,12 +13184,21 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13179
13184
  await this.abortAllPendingToolInputs();
13180
13185
  await this.tearDownSession(true);
13181
13186
  }
13182
- keepSteeredMessageQueued() {
13183
- return true;
13184
- }
13185
- async steerRequest() {
13186
- if (!this.messageQueue.isProcessing()) return false;
13187
- await this.interruptActiveTurn();
13187
+ // Claude Code folds a `next`-priority prompt into the running turn at its next tool boundary.
13188
+ async steerRequest(request) {
13189
+ const pendingTurn = this.pendingTurn;
13190
+ const promptStream = this.activePromptStream;
13191
+ if (!pendingTurn || !promptStream) return false;
13192
+ if (getGoalCommand(request.message, request.goalMode)) {
13193
+ this.messageQueue.restoreToQueue(request, 0);
13194
+ await this.interruptActiveTurn();
13195
+ return true;
13196
+ }
13197
+ const userMessage = await this.buildUserMessage(request);
13198
+ if (this.pendingTurn !== pendingTurn || this.activePromptStream !== promptStream) return false;
13199
+ pendingTurn.userMessageUuids.add(userMessage.uuid);
13200
+ await this.recordEvent(userMessage, request.messageId);
13201
+ promptStream.push({ ...userMessage, priority: "next" });
13188
13202
  return true;
13189
13203
  }
13190
13204
  async abortAllPendingToolInputs() {
@@ -13209,6 +13223,35 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13209
13223
  isProcessing() {
13210
13224
  return super.isProcessing() || isClaudeSessionActive(this.sessionActivity) || this.hasActiveBackgroundTasks();
13211
13225
  }
13226
+ getGoal() {
13227
+ return this.currentGoal;
13228
+ }
13229
+ async clearGoal(model) {
13230
+ await this.initialized;
13231
+ const previousGoal = this.currentGoal;
13232
+ if (!previousGoal) return null;
13233
+ this.recordGoalChange(null);
13234
+ if (this.sessionId) {
13235
+ this.goalClear = this.executeQuery(
13236
+ { model, ...this.lastRequest, message: "/goal clear", images: void 0, goalMode: false },
13237
+ { skipUserMessageRecord: true }
13238
+ ).finally(() => {
13239
+ this.goalClear = null;
13240
+ });
13241
+ try {
13242
+ await this.goalClear;
13243
+ } catch (error) {
13244
+ this.recordGoalChange(previousGoal);
13245
+ throw error;
13246
+ }
13247
+ }
13248
+ return null;
13249
+ }
13250
+ recordGoalChange(goal) {
13251
+ if (!goal && !this.currentGoal) return;
13252
+ this.currentGoal = goal;
13253
+ this.recordHistoryEvent(CHAT_GOAL_EVENT_TYPE, { goal }, this.historyFile);
13254
+ }
13212
13255
  hasActiveBackgroundTasks() {
13213
13256
  return this.backgroundTasks.active.size > 0 || this.pendingBackgroundCompletion && (isClaudeSessionActive(this.sessionActivity) || this.backgroundContinuationTimer !== null) && !this.messageQueue.isProcessing();
13214
13257
  }
@@ -13422,6 +13465,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13422
13465
  let transientRetries = 0;
13423
13466
  let midTurnContinues = 0;
13424
13467
  let currentRequest = request;
13468
+ await this.goalClear?.catch(() => {
13469
+ });
13425
13470
  try {
13426
13471
  while (true) {
13427
13472
  const attemptedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude;
@@ -13479,7 +13524,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13479
13524
  );
13480
13525
  await this.tearDownSession();
13481
13526
  await new Promise((resolve8) => setTimeout(resolve8, delayMs));
13482
- currentRequest = { ...request, message: CLAUDE_MIDTURN_CONTINUE_PROMPT, images: [] };
13527
+ currentRequest = { ...request, message: CLAUDE_MIDTURN_CONTINUE_PROMPT, images: [], goalMode: false };
13483
13528
  attempt++;
13484
13529
  continue;
13485
13530
  }
@@ -13574,7 +13619,6 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13574
13619
  message,
13575
13620
  model,
13576
13621
  customInstructions,
13577
- images,
13578
13622
  planMode,
13579
13623
  thinkingLevel,
13580
13624
  enableInteractiveTools,
@@ -13584,40 +13628,27 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13584
13628
  throw new Error("Message cannot be empty");
13585
13629
  }
13586
13630
  await this.initialized;
13631
+ this.lastRequest = request;
13587
13632
  this.pendingInterrupt = false;
13588
- const content = [
13589
- {
13590
- type: "text",
13591
- text: message
13592
- }
13593
- ];
13594
- if (images && images.length > 0) {
13595
- const normalizedImages = await normalizeImages(images);
13596
- for (const image of normalizedImages) {
13597
- content.push({
13598
- type: "image",
13599
- source: {
13600
- type: "base64",
13601
- media_type: image.source.media_type,
13602
- data: image.source.data
13603
- }
13604
- });
13605
- }
13606
- }
13607
- const userMessageUuid = randomUUID5();
13608
- const userMessage = {
13609
- type: "user",
13610
- uuid: userMessageUuid,
13611
- message: {
13612
- role: "user",
13613
- content
13614
- },
13615
- parent_tool_use_id: null,
13616
- session_id: this.sessionId ?? ""
13617
- };
13633
+ const userMessage = await this.buildUserMessage(request);
13618
13634
  if (!options.skipUserMessageRecord) {
13619
13635
  await this.recordEvent(userMessage, request.messageId);
13620
13636
  }
13637
+ const goalCommand = getGoalCommand(message, request.goalMode);
13638
+ const goalObjective = goalCommand?.type === "set" ? goalCommand.objective : goalCommand?.type === "resume" ? this.currentGoal?.objective : void 0;
13639
+ if (goalCommand && !options.skipUserMessageRecord) {
13640
+ const now = (/* @__PURE__ */ new Date()).toISOString();
13641
+ this.recordGoalChange(goalObjective ? {
13642
+ threadId: this.sessionId ?? "",
13643
+ objective: goalObjective,
13644
+ status: "active",
13645
+ tokenBudget: null,
13646
+ tokensUsed: 0,
13647
+ timeUsedSeconds: 0,
13648
+ createdAt: now,
13649
+ updatedAt: now
13650
+ } : null);
13651
+ }
13621
13652
  const combinedInstructions = [
13622
13653
  this.buildCombinedInstructions(customInstructions, true),
13623
13654
  "Background tasks must have a concrete completion condition. Use foreground commands for sequential work and managed workspace services for servers. Reserve persistent Monitor tasks for ongoing watches the user requested. You may end a turn while actual background work continues, but do not promise a later update unless a task was successfully launched. Report completion or failure when its notification arrives; do not restart timed-out work automatically."
@@ -13653,10 +13684,41 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13653
13684
  return;
13654
13685
  }
13655
13686
  await new Promise((resolve8, reject) => {
13656
- this.pendingTurn = { resolve: resolve8, reject, sawActivity: false, userMessageUuid };
13657
- promptStream.push(userMessage);
13687
+ this.pendingTurn = { resolve: resolve8, reject, sawActivity: false, userMessageUuids: /* @__PURE__ */ new Set([userMessage.uuid]) };
13688
+ promptStream.push(goalCommand ? { ...userMessage, message: { role: "user", content: `/goal ${goalObjective ?? "clear"}` } } : userMessage);
13658
13689
  });
13659
13690
  }
13691
+ async buildUserMessage({ message, images }) {
13692
+ const content = [
13693
+ {
13694
+ type: "text",
13695
+ text: message
13696
+ }
13697
+ ];
13698
+ if (images && images.length > 0) {
13699
+ const normalizedImages = await normalizeImages(images);
13700
+ for (const image of normalizedImages) {
13701
+ content.push({
13702
+ type: "image",
13703
+ source: {
13704
+ type: "base64",
13705
+ media_type: image.source.media_type,
13706
+ data: image.source.data
13707
+ }
13708
+ });
13709
+ }
13710
+ }
13711
+ return {
13712
+ type: "user",
13713
+ uuid: randomUUID5(),
13714
+ message: {
13715
+ role: "user",
13716
+ content
13717
+ },
13718
+ parent_tool_use_id: null,
13719
+ session_id: this.sessionId ?? ""
13720
+ };
13721
+ }
13660
13722
  async ensureSession(args) {
13661
13723
  const {
13662
13724
  signature,
@@ -13888,7 +13950,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13888
13950
  await this.recordContextUsage(response);
13889
13951
  if (this.activeQuery !== response) break;
13890
13952
  this.sessionLinearForwarder?.flushThoughtAsResponse();
13891
- if (msg.user_message_uuid ? msg.user_message_uuid === this.pendingTurn?.userMessageUuid : !msg.origin || msg.origin.kind === "human") {
13953
+ const pendingUuids = this.pendingTurn?.userMessageUuids;
13954
+ if (msg.user_message_uuid) {
13955
+ for (const uuid of msg.user_message_uuids ?? [msg.user_message_uuid]) pendingUuids?.delete(uuid);
13956
+ if (pendingUuids?.size === 0) this.resolvePendingTurn();
13957
+ } else if (!msg.origin || msg.origin.kind === "human") {
13892
13958
  this.resolvePendingTurn();
13893
13959
  }
13894
13960
  }
@@ -14318,6 +14384,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14318
14384
  }
14319
14385
  async initialize() {
14320
14386
  await mkdir10(dirname4(this.historyFilePath), { recursive: true });
14387
+ const goalEvent = await this.historyFile.findLastEventOfType(CHAT_GOAL_EVENT_TYPE);
14388
+ if (goalEvent) this.currentGoal = coerceChatGoalPayload(goalEvent.payload);
14321
14389
  if (this.initialSessionId) {
14322
14390
  this.sessionId = this.initialSessionId;
14323
14391
  console.log(`[ClaudeManager] Restored session ID from persisted state: ${this.sessionId}`);
@@ -14351,6 +14419,27 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14351
14419
  await this.forwardWorkflowAgentTranscripts(message.task_id);
14352
14420
  }
14353
14421
  await this.recordEvent(message);
14422
+ this.trackGoalProgress(message);
14423
+ }
14424
+ // The SDK doesn't stream goal state, so it is inferred from the evaluator's "not met" feedback and the run's final result.
14425
+ trackGoalProgress(message) {
14426
+ const goal = this.currentGoal;
14427
+ if (!goal) return;
14428
+ if (message.type === "user" && message.isSynthetic) {
14429
+ const content = message.message.content;
14430
+ const text = typeof content === "string" ? content : content[0]?.type === "text" ? content[0].text : "";
14431
+ if (!text.startsWith("Stop hook feedback:")) return;
14432
+ const now = /* @__PURE__ */ new Date();
14433
+ this.recordGoalChange({
14434
+ ...goal,
14435
+ timeUsedSeconds: Math.round((now.getTime() - Date.parse(goal.createdAt)) / 1e3),
14436
+ updatedAt: now.toISOString()
14437
+ });
14438
+ return;
14439
+ }
14440
+ if (message.type === "result" && message.subtype === "success" && message.num_turns > 0 && this.backgroundTasks.active.size === 0) {
14441
+ this.recordGoalChange(null);
14442
+ }
14354
14443
  }
14355
14444
  // Claude Code intercepts /compact and auto-compaction inside the SDK process; we just observe the status messages to mirror state to the UI.
14356
14445
  trackNativeCompaction(message) {
@@ -62001,7 +62090,7 @@ var ChatService = class {
62001
62090
  chat.activeMessageId = null;
62002
62091
  chat.pendingMessageIds = [];
62003
62092
  chat.acceptedUserEvents.clear();
62004
- const goal = await chat.provider.clearGoal();
62093
+ const goal = await chat.provider.clearGoal(chat.persisted.model);
62005
62094
  this.touch(chat);
62006
62095
  await this.publish({
62007
62096
  type: "chat.interrupted",
@@ -62137,31 +62226,10 @@ var ChatService = class {
62137
62226
  }
62138
62227
  async steerFromQueue(chatId, messageId) {
62139
62228
  const chat = this.requireChat(chatId);
62140
- const queuedMessageIds = new Set(chat.provider.getQueue().map((message) => message.id));
62141
- const interruptedMessageId = chat.activeMessageId ?? chat.pendingMessageIds.find((pendingMessageId) => !queuedMessageIds.has(pendingMessageId)) ?? null;
62142
62229
  const result = await chat.provider.steerFromQueue(messageId);
62143
- if (!result.success) {
62144
- return result;
62145
- }
62146
- if (getChatExecutionProvider(chat.persisted) !== "claude") {
62230
+ if (result.success) {
62147
62231
  chat.pendingMessageIds = chat.pendingMessageIds.filter((pendingMessageId) => pendingMessageId !== messageId);
62148
- return result;
62149
- }
62150
- chat.pendingMessageIds = [
62151
- messageId,
62152
- ...chat.pendingMessageIds.filter((pendingMessageId) => pendingMessageId !== messageId && pendingMessageId !== interruptedMessageId)
62153
- ];
62154
- this.endTrackedTurn(chatId);
62155
- chat.hasActiveTurn = false;
62156
- chat.activeMessageId = null;
62157
- if (interruptedMessageId) {
62158
- chat.acceptedUserEvents.delete(interruptedMessageId);
62159
62232
  }
62160
- this.touch(chat);
62161
- await this.publish({
62162
- type: "chat.interrupted",
62163
- payload: { chatId, interrupted: true, queue: [] }
62164
- });
62165
62233
  return result;
62166
62234
  }
62167
62235
  async respondToToolInput(chatId, requestId, selectionId) {
@@ -64325,7 +64393,7 @@ function createV1Routes(deps) {
64325
64393
  if (error instanceof ChatNotFoundError) {
64326
64394
  return c.json(jsonError("Failed to clear goal", error.message), 404);
64327
64395
  }
64328
- return c.json(jsonError("Failed to clear goal", error instanceof Error ? error.message : "Unknown error"), 404);
64396
+ return c.json(jsonError("Failed to clear goal", error instanceof Error ? error.message : "Unknown error"), 500);
64329
64397
  }
64330
64398
  });
64331
64399
  app2.post("/chat-transcripts/flush-all", async (c) => {
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  notifyPostToolUse
6
- } from "./chunk-YICM7VI4.js";
7
- import "./chunk-GFIDOFFP.js";
6
+ } from "./chunk-7TNL7LE7.js";
7
+ import "./chunk-4M3ZD5FV.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-2ROQAUB6.js";
11
+ import "./chunk-TPOJS4TI.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/post-tool-pr-hook.ts
@@ -11,7 +11,7 @@ import {
11
11
  relaySubagentResponseSchema,
12
12
  spawnRelaySubagentRequestSchema,
13
13
  waitRelaySubagentRequestSchema
14
- } from "./chunk-2ROQAUB6.js";
14
+ } from "./chunk-TPOJS4TI.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.902",
3
+ "version": "0.1.904",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",