replicas-engine 0.1.1685 → 0.1.1687

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.
package/dist/src/index.js CHANGED
@@ -87,11 +87,15 @@ import {
87
87
  truncateToWidth,
88
88
  visibleWidth
89
89
  } from "./chunk-244SUBHF.js";
90
+ import {
91
+ getManagedPiMcpServers,
92
+ managedMcpServerProcess
93
+ } from "./chunk-BXZA2HFS.js";
90
94
  import {
91
95
  evaluateCommandProtection,
92
96
  extractToolCommand,
93
97
  reportCommandProtectionBlock
94
- } from "./chunk-MTCBDF6Q.js";
98
+ } from "./chunk-4WUIIT6Z.js";
95
99
  import {
96
100
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
101
  AGENT_MESSAGE_DELTA_METHOD,
@@ -100,10 +104,6 @@ import {
100
104
  ITEM_COMPLETED_METHOD,
101
105
  ITEM_STARTED_METHOD,
102
106
  MODEL_REROUTED_METHOD,
103
- MUSE_AUTH_PATH,
104
- OPENCODE_AUTH_PATH,
105
- PI_AUTH_PATH,
106
- PI_MCP_CONFIG_PATH,
107
107
  REASONING_SUMMARY_PART_ADDED_METHOD,
108
108
  REASONING_SUMMARY_TEXT_DELTA_METHOD,
109
109
  REASONING_TEXT_DELTA_METHOD,
@@ -129,10 +129,15 @@ import {
129
129
  spawnMuseMsp,
130
130
  startMuseSession,
131
131
  uuidV7
132
- } from "./chunk-TS5VL625.js";
132
+ } from "./chunk-XL3IOGIZ.js";
133
+ import {
134
+ MUSE_AUTH_PATH,
135
+ OPENCODE_AUTH_PATH,
136
+ PI_AUTH_PATH
137
+ } from "./chunk-7ZDAVYTV.js";
133
138
  import {
134
139
  publishedPullRequestUrls
135
- } from "./chunk-HFLANP5M.js";
140
+ } from "./chunk-KNEA2XCI.js";
136
141
  import {
137
142
  ACCOUNT_RATE_LIMITS_READ_METHOD,
138
143
  AsyncLock,
@@ -151,7 +156,6 @@ import {
151
156
  OPENCODE_HISTORY_DIR,
152
157
  PI_HISTORY_DIR,
153
158
  SKILLS_LIST_METHOD,
154
- SUBAGENT_MCP_TOOL_TIMEOUT_MS,
155
159
  THREAD_BACKGROUND_TERMINALS_CLEAN_METHOD,
156
160
  THREAD_COMPACT_START_METHOD,
157
161
  THREAD_FORK_METHOD,
@@ -177,7 +181,6 @@ import {
177
181
  clearCredentialFallbacks,
178
182
  codexTokenManager,
179
183
  configureManagedGitCredentialHelper,
180
- engineScriptProcess,
181
184
  extractRateLimitsSnapshot,
182
185
  forgetExhaustedCredentials,
183
186
  formatTurnFailure,
@@ -205,14 +208,18 @@ import {
205
208
  routineRefreshRequest,
206
209
  saveRepoState,
207
210
  scrubSecrets,
208
- subagentMcpProcessConfig,
209
211
  threadToAspTranscript,
210
212
  timestampFromMilliseconds,
211
213
  timestampFromSeconds,
212
214
  transcriptSecrets,
213
215
  upsertCredentialFileLines,
214
216
  writeSecureCredentialFile
215
- } from "./chunk-PD4L7TVG.js";
217
+ } from "./chunk-NR6MTHUJ.js";
218
+ import {
219
+ SUBAGENT_MCP_TOOL_TIMEOUT_MS,
220
+ engineScriptProcess,
221
+ subagentMcpProcessConfig
222
+ } from "./chunk-NYAS7KNX.js";
216
223
  import {
217
224
  ENGINE_ENV,
218
225
  UNQUOTED_PATHS_CONFIG,
@@ -223,19 +230,19 @@ import {
223
230
  resolveDiffBase,
224
231
  setAgentCredentialSnapshot,
225
232
  setLinearSessionId
226
- } from "./chunk-3JU53Q52.js";
233
+ } from "./chunk-67ZXXRJ5.js";
227
234
  import {
228
235
  AspRequestTimeoutError,
229
236
  buildCodexAgentEnv,
230
237
  getCodexModelProvider
231
- } from "./chunk-BB6K3H62.js";
238
+ } from "./chunk-JNVXGKRR.js";
232
239
  import {
233
240
  SUBPROCESS_MAX_BUFFER,
234
241
  execAsync,
235
242
  execFileAsync
236
- } from "./chunk-OBCGNFJD.js";
243
+ } from "./chunk-IL6OBS3T.js";
237
244
  import {
238
- isRecord as isRecord2
245
+ isRecord
239
246
  } from "./chunk-UZSNFLDQ.js";
240
247
  import {
241
248
  ACCEPTED_USER_MESSAGE_SOURCE,
@@ -267,6 +274,7 @@ import {
267
274
  CODEX_ITEM_PARTIAL_EVENT_TYPE,
268
275
  CODEX_QUOTA_STATUS_EVENT_TYPE,
269
276
  CODEX_TURN_RETRY_EVENT_TYPE,
277
+ CODE_MODE_MCP_SERVER,
270
278
  CONTEXT_USAGE_EVENT_TYPE,
271
279
  CREDENTIAL_METHOD,
272
280
  CREDENTIAL_SCOPE,
@@ -456,7 +464,7 @@ import {
456
464
  isLatestChatHistoryPage,
457
465
  isNonEmptyString,
458
466
  isPullRequestFeedbackChat,
459
- isRecord,
467
+ isRecord as isRecord2,
460
468
  isSameCredential,
461
469
  isSkillRegistryManifest,
462
470
  isTokenUsageCounts,
@@ -533,7 +541,7 @@ import {
533
541
  workspaceTokenRequestSchema,
534
542
  workspaceTokenResponseSchema,
535
543
  wrapInTag
536
- } from "./chunk-N2E6OIK5.js";
544
+ } from "./chunk-25TILJOA.js";
537
545
  import {
538
546
  __commonJS,
539
547
  __export,
@@ -9365,7 +9373,7 @@ var ClaudeTokenManager = class extends BaseRefreshManager {
9365
9373
  async resyncIfWiped() {
9366
9374
  const content = await fs.readFile(credentialsPath(), "utf8").catch(() => "");
9367
9375
  const file = safeJsonParse(content, null);
9368
- if (!isRecord(file) || !isRecord(file.claudeAiOauth) || file.claudeAiOauth.refreshToken !== "") return;
9376
+ if (!isRecord2(file) || !isRecord2(file.claudeAiOauth) || file.claudeAiOauth.refreshToken !== "") return;
9369
9377
  console.warn("[ClaudeTokenManager] Claude Code cleared its OAuth login; fetching fresh credentials");
9370
9378
  await this.refreshOnce();
9371
9379
  }
@@ -9514,7 +9522,7 @@ var WorkspaceIdentityTokens = class {
9514
9522
  return createErrorResult({ message: `Workspace identity request failed: ${response.status} ${await response.text()}`, code: response.status === 400 ? 400 : 503 });
9515
9523
  }
9516
9524
  const data = await response.json().catch(() => null);
9517
- if (isRecord(data) && data.configured === false) {
9525
+ if (isRecord2(data) && data.configured === false) {
9518
9526
  return createErrorResult({ message: "Workspace identity is not enabled for this workspace", code: 503 });
9519
9527
  }
9520
9528
  const parsed = workspaceTokenResponseSchema.safeParse(data);
@@ -9525,7 +9533,7 @@ var WorkspaceIdentityTokens = class {
9525
9533
  }
9526
9534
  if (awsSourceIdentity) {
9527
9535
  const payload = JSON.parse(Buffer.from(token.token.split(".")[1] ?? "", "base64url").toString() || "null");
9528
- if (!isRecord(payload) || typeof payload[AWS_SOURCE_IDENTITY_CLAIM] !== "string") {
9536
+ if (!isRecord2(payload) || typeof payload[AWS_SOURCE_IDENTITY_CLAIM] !== "string") {
9529
9537
  return createErrorResult({ message: "AWS source identity is unavailable from this Replicas version", code: 503 });
9530
9538
  }
9531
9539
  }
@@ -9707,7 +9715,7 @@ var McpOAuthTokens = class {
9707
9715
  const data = await response.json().catch(() => null);
9708
9716
  const parsed = engineMcpOAuthTokenResponseSchema.safeParse(data);
9709
9717
  if (!response.ok || !parsed.success) {
9710
- const message = isRecord(data) && typeof data.error === "string" ? data.error : `MCP OAuth token request failed: ${response.status}`;
9718
+ const message = isRecord2(data) && typeof data.error === "string" ? data.error : `MCP OAuth token request failed: ${response.status}`;
9711
9719
  return createErrorResult({ message, code: response.ok ? 502 : response.status });
9712
9720
  }
9713
9721
  rememberSecret(`mcp:${environmentMcpId}`, parsed.data.access_token);
@@ -9982,10 +9990,10 @@ async function getPiProviderCredentials() {
9982
9990
  } catch {
9983
9991
  return createErrorResult({ message: "Pi credentials are unavailable." });
9984
9992
  }
9985
- if (isRecord2(credentials)) {
9993
+ if (isRecord(credentials)) {
9986
9994
  for (const { method: provider } of AGENT_CREDENTIAL_METHODS_IN_ORDER.pi) {
9987
9995
  const credential = credentials[provider];
9988
- if (isRecord2(credential) && credential.type === "api_key" && typeof credential.key === "string") {
9996
+ if (isRecord(credential) && credential.type === "api_key" && typeof credential.key === "string") {
9989
9997
  return createSuccessResult({ provider, apiKey: credential.key });
9990
9998
  }
9991
9999
  }
@@ -11119,14 +11127,14 @@ function localControlComputers() {
11119
11127
  }
11120
11128
 
11121
11129
  // src/services/chat/chat-service.ts
11122
- import { appendFile as appendFile4, copyFile as copyFile2, mkdir as mkdir15, readFile as readFile18, rename as rename3, rm as rm7 } from "fs/promises";
11130
+ import { appendFile as appendFile4, copyFile as copyFile2, mkdir as mkdir15, readFile as readFile17, rename as rename3, rm as rm7 } from "fs/promises";
11123
11131
  import { join as join30 } from "path";
11124
11132
  import { randomUUID as randomUUID9 } from "crypto";
11125
11133
  import { z as z4 } from "zod";
11126
11134
 
11127
11135
  // ../shared/src/persisted-query-hashes.ts
11128
11136
  var PERSISTED_QUERY_HASHES = {
11129
- workspaceChats: "74224a72"
11137
+ workspaceChats: "5800ba0e"
11130
11138
  };
11131
11139
 
11132
11140
  // ../shared/src/workspace-chat.ts
@@ -11160,9 +11168,9 @@ var eventSignalsCache = /* @__PURE__ */ new WeakMap();
11160
11168
  function claudeToolResultId(event) {
11161
11169
  if (event.type !== "claude-user") return null;
11162
11170
  const { message } = event.payload;
11163
- const content = isRecord(message) ? message.content : void 0;
11164
- const result = Array.isArray(content) ? content.find((block) => isRecord(block) && block.type === "tool_result") : void 0;
11165
- return isRecord(result) && typeof result.tool_use_id === "string" ? `tool_result:${result.tool_use_id}` : null;
11171
+ const content = isRecord2(message) ? message.content : void 0;
11172
+ const result = Array.isArray(content) ? content.find((block) => isRecord2(block) && block.type === "tool_result") : void 0;
11173
+ return isRecord2(result) && typeof result.tool_use_id === "string" ? `tool_result:${result.tool_use_id}` : null;
11166
11174
  }
11167
11175
  function workspaceChatEventSignals(event) {
11168
11176
  let signals = eventSignalsCache.get(event);
@@ -12454,7 +12462,7 @@ function linearThoughtToResponse(thought) {
12454
12462
  function summarizeInput(input) {
12455
12463
  if (!input) return "";
12456
12464
  if (typeof input === "string") return input;
12457
- if (isRecord(input)) {
12465
+ if (isRecord2(input)) {
12458
12466
  if (input.file_path) return String(input.file_path);
12459
12467
  if (input.command) return String(input.command);
12460
12468
  if (input.pattern) return `pattern: ${String(input.pattern)}`;
@@ -12471,7 +12479,7 @@ function summarizeInput(input) {
12471
12479
  function summarizeResult(result) {
12472
12480
  if (!result) return "";
12473
12481
  if (typeof result === "string") return result;
12474
- if (isRecord(result)) {
12482
+ if (isRecord2(result)) {
12475
12483
  if (typeof result.message === "string") return result.message;
12476
12484
  if (typeof result.error === "string") return result.error;
12477
12485
  if (typeof result.stdout === "string") return result.stdout;
@@ -12640,7 +12648,7 @@ function convertCursorEvent(event, linearSessionId) {
12640
12648
  return null;
12641
12649
  }
12642
12650
  function isOpencodePartEnded(part) {
12643
- return "time" in part && isRecord(part.time) && "end" in part.time && part.time.end !== void 0;
12651
+ return "time" in part && isRecord2(part.time) && "end" in part.time && part.time.end !== void 0;
12644
12652
  }
12645
12653
  function convertOpencodePart(part, linearSessionId) {
12646
12654
  if ((part.type === "text" || part.type === "reasoning") && isOpencodePartEnded(part)) {
@@ -13550,8 +13558,8 @@ function appendUserContent(earlier, later) {
13550
13558
  var TOOL_TARGET = /^\s*\{\s*"(\w+)"\s*:\s*(?:"((?:[^"\\]|\\.)*)(")?)?/;
13551
13559
  var JSON_FIRST_LINE = /^(?:[^\\]|\\[^n])*?(?=\\n)/;
13552
13560
  function isPromptMessage(message) {
13553
- const content = isRecord(message) ? message.content : void 0;
13554
- return typeof content === "string" || Array.isArray(content) && content.some((block) => !isRecord(block) || block.type !== "tool_result");
13561
+ const content = isRecord2(message) ? message.content : void 0;
13562
+ return typeof content === "string" || Array.isArray(content) && content.some((block) => !isRecord2(block) || block.type !== "tool_result");
13555
13563
  }
13556
13564
  function toSlashCommands(command) {
13557
13565
  const names = [command.name, ...command.aliases ?? []];
@@ -13765,9 +13773,9 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13765
13773
  if (this.activeQuery !== query2 || !this.sessionId) return;
13766
13774
  const entry = (await getSessionMessages(this.sessionId, { dir: this.workingDirectory })).findLast((message) => message.uuid === uuid);
13767
13775
  if (!entry) continue;
13768
- const origin = "origin" in entry && isRecord(entry.origin) ? entry.origin : null;
13776
+ const origin = "origin" in entry && isRecord2(entry.origin) ? entry.origin : null;
13769
13777
  if (origin?.kind !== "peer" || origin.senderTaskId) return;
13770
- const text = extractToolResultText(isRecord(entry.message) ? entry.message.content : void 0);
13778
+ const text = extractToolResultText(isRecord2(entry.message) ? entry.message.content : void 0);
13771
13779
  const envelopes = [...text.matchAll(/<cross-session-message\b([^>]*)>\n?([\s\S]*?)\n?<\/cross-session-message>/g)].map(([, attributes, body]) => ({
13772
13780
  name: /\bfrom-name="([^"]*)"/.exec(attributes)?.[1],
13773
13781
  from: /\bfrom="([^"]*)"/.exec(attributes)?.[1],
@@ -14578,14 +14586,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14578
14586
  matcher: "Bash",
14579
14587
  hooks: [async (input) => {
14580
14588
  const response2 = input.hook_event_name === "PostToolUse" ? input.tool_response : void 0;
14581
- return isRecord(response2) && response2.backgroundedByUser === true ? { hookSpecificOutput: { hookEventName: "PostToolUse", updatedToolOutput: { ...response2, backgroundedByUser: false, backgroundedToDeliverMessage: true } } } : {};
14589
+ return isRecord2(response2) && response2.backgroundedByUser === true ? { hookSpecificOutput: { hookEventName: "PostToolUse", updatedToolOutput: { ...response2, backgroundedByUser: false, backgroundedToDeliverMessage: true } } } : {};
14582
14590
  }],
14583
14591
  timeout: 30
14584
14592
  }, {
14585
14593
  matcher: "Workflow",
14586
14594
  hooks: [async (input) => {
14587
14595
  const response2 = input.hook_event_name === "PostToolUse" ? input.tool_response : void 0;
14588
- if (isRecord(response2) && typeof response2.taskId === "string" && typeof response2.transcriptDir === "string") {
14596
+ if (isRecord2(response2) && typeof response2.taskId === "string" && typeof response2.transcriptDir === "string") {
14589
14597
  this.workflowTranscripts.set(response2.taskId, { dir: response2.transcriptDir, offsets: /* @__PURE__ */ new Map() });
14590
14598
  }
14591
14599
  return {};
@@ -14694,7 +14702,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14694
14702
  const wasProcessing = this.isProcessing();
14695
14703
  this.setAuthRetrying(false);
14696
14704
  const lifecycle2 = msg;
14697
- if (isRecord(lifecycle2) && lifecycle2.type === "command_lifecycle" && lifecycle2.state === "started" && typeof lifecycle2.command_uuid === "string") {
14705
+ if (isRecord2(lifecycle2) && lifecycle2.type === "command_lifecycle" && lifecycle2.state === "started" && typeof lifecycle2.command_uuid === "string") {
14698
14706
  if (this.pendingTurn?.userMessageUuids.has(lifecycle2.command_uuid)) {
14699
14707
  this.turnPromptRecorded = true;
14700
14708
  if (lifecycle2.command_uuid === this.sentPrompt?.uuid) {
@@ -17131,20 +17139,20 @@ async function ensureCursorCommandProtectionHook() {
17131
17139
  try {
17132
17140
  const content = await readFile8(path8, "utf8");
17133
17141
  const parsed = content.trim() ? JSON.parse(content) : {};
17134
- if (!isRecord2(parsed)) throw new Error("Invalid Cursor hooks configuration.");
17142
+ if (!isRecord(parsed)) throw new Error("Invalid Cursor hooks configuration.");
17135
17143
  config = parsed;
17136
17144
  } catch (error) {
17137
17145
  if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
17138
17146
  }
17139
- const hooks = isRecord2(config.hooks) ? config.hooks : {};
17147
+ const hooks = isRecord(config.hooks) ? config.hooks : {};
17140
17148
  const existing = Array.isArray(hooks.preToolUse) ? hooks.preToolUse : [];
17141
17149
  hooks.preToolUse = [
17142
- ...existing.filter((entry) => !isRecord2(entry) || typeof entry.command !== "string" || !entry.command.includes("command-protection-hook")),
17150
+ ...existing.filter((entry) => !isRecord(entry) || typeof entry.command !== "string" || !entry.command.includes("command-protection-hook")),
17143
17151
  { command: shellCommand(hookPath, "cursor") }
17144
17152
  ];
17145
17153
  const existingPost = Array.isArray(hooks.postToolUse) ? hooks.postToolUse : [];
17146
17154
  hooks.postToolUse = [
17147
- ...existingPost.filter((entry) => !isRecord2(entry) || typeof entry.command !== "string" || !entry.command.includes("post-tool-pr-hook")),
17155
+ ...existingPost.filter((entry) => !isRecord(entry) || typeof entry.command !== "string" || !entry.command.includes("post-tool-pr-hook")),
17148
17156
  { command: shellCommand(postToolHookPath) }
17149
17157
  ];
17150
17158
  await mkdir9(dirname4(path8), { recursive: true });
@@ -17224,7 +17232,7 @@ async function listCursorCommandsInDirectory(directory) {
17224
17232
  try {
17225
17233
  entries = await readdir5(directory, { withFileTypes: true });
17226
17234
  } catch (error) {
17227
- if (isRecord2(error) && error.code === "ENOENT") return [];
17235
+ if (isRecord(error) && error.code === "ENOENT") return [];
17228
17236
  console.warn("[CursorManager] Failed to read slash command directory:", error);
17229
17237
  return [];
17230
17238
  }
@@ -17642,7 +17650,7 @@ var MuseQuotaError = class extends Error {
17642
17650
  };
17643
17651
  var MUSE_INTERRUPT_TIMEOUT_MS = 5e3;
17644
17652
  function isPendingQuestion(value) {
17645
- return isRecord(value) && typeof value.id === "string";
17653
+ return isRecord2(value) && typeof value.id === "string";
17646
17654
  }
17647
17655
  var MuseManager = class extends CodingAgentManager {
17648
17656
  process = null;
@@ -17670,7 +17678,7 @@ var MuseManager = class extends CodingAgentManager {
17670
17678
  client.on("notification", (notification) => this.handleNotification(notification));
17671
17679
  client.on("serverRequest", (request) => {
17672
17680
  const frame = request;
17673
- if (isRecord(frame) && frame.method === "approval/request") {
17681
+ if (isRecord2(frame) && frame.method === "approval/request") {
17674
17682
  this.handleNotification({ method: "approval/requested", params: frame.params });
17675
17683
  client.respond(request.id, {});
17676
17684
  } else {
@@ -17711,9 +17719,9 @@ var MuseManager = class extends CodingAgentManager {
17711
17719
  if (!this.sessionId) return;
17712
17720
  const previous = new Map(this.pendingApprovals);
17713
17721
  const result = await this.request("approval/listPending", { sessionId: this.sessionId }).catch(() => null);
17714
- if (!isRecord(result) || !Array.isArray(result.approvals)) return;
17722
+ if (!isRecord2(result) || !Array.isArray(result.approvals)) return;
17715
17723
  for (const [approvalId, pending] of previous) {
17716
- if (this.pendingApprovals.get(approvalId) === pending && !result.approvals.some((approval) => isRecord(approval) && approval.approvalId === approvalId)) {
17724
+ if (this.pendingApprovals.get(approvalId) === pending && !result.approvals.some((approval) => isRecord2(approval) && approval.approvalId === approvalId)) {
17717
17725
  this.resolveApproval(approvalId, "resolved");
17718
17726
  }
17719
17727
  }
@@ -17741,8 +17749,8 @@ var MuseManager = class extends CodingAgentManager {
17741
17749
  const previous = this.pendingApprovals.get(params.approvalId);
17742
17750
  const value = { ...previous, ...params };
17743
17751
  const requirement = value.currentRequirementId;
17744
- if (!isRecord(requirement) || requirement.approvalId !== params.approvalId || typeof requirement.sourceIndex !== "number" || !Number.isSafeInteger(requirement.sourceIndex) || requirement.sourceIndex < 0 || typeof value.itemId !== "string" || typeof value.toolName !== "string" || typeof value.rawArgs !== "string" || !isRecord(value.subject) || !Array.isArray(value.availableChoices)) return;
17745
- const choices = value.availableChoices.filter((choice) => isRecord(choice) && typeof choice.choiceId === "string" && typeof choice.label === "string" && typeof choice.decision === "string" && (choice.rulePreview === void 0 || typeof choice.rulePreview === "string"));
17752
+ if (!isRecord2(requirement) || requirement.approvalId !== params.approvalId || typeof requirement.sourceIndex !== "number" || !Number.isSafeInteger(requirement.sourceIndex) || requirement.sourceIndex < 0 || typeof value.itemId !== "string" || typeof value.toolName !== "string" || typeof value.rawArgs !== "string" || !isRecord2(value.subject) || !Array.isArray(value.availableChoices)) return;
17753
+ const choices = value.availableChoices.filter((choice) => isRecord2(choice) && typeof choice.choiceId === "string" && typeof choice.label === "string" && typeof choice.decision === "string" && (choice.rulePreview === void 0 || typeof choice.rulePreview === "string"));
17746
17754
  if (choices.length === 0 || choices.length !== value.availableChoices.length) return;
17747
17755
  if (previous && (requirement.sourceIndex < previous.currentRequirementId.sourceIndex || typeof params.viewCursor === "string" && params.viewCursor === previous.viewCursor)) return;
17748
17756
  const requestId = previous?.currentRequirementId.sourceIndex === requirement.sourceIndex ? previous.requestId : `muse-approval:${params.approvalId}:${requirement.sourceIndex}:${uuidV7()}`;
@@ -17764,8 +17772,8 @@ var MuseManager = class extends CodingAgentManager {
17764
17772
  }
17765
17773
  this.pendingApprovals.set(pending.approvalId, pending);
17766
17774
  const stages = Array.isArray(pending.subject.stages) ? pending.subject.stages : [];
17767
- const stage = stages.find((stage2) => isRecord(stage2) && isRecord(stage2.requirementId) && stage2.requirementId.sourceIndex === requirement.sourceIndex);
17768
- const stageLabel = isRecord(stage) ? ` (stage ${stage.position} of ${stage.totalStages})` : "";
17775
+ const stage = stages.find((stage2) => isRecord2(stage2) && isRecord2(stage2.requirementId) && stage2.requirementId.sourceIndex === requirement.sourceIndex);
17776
+ const stageLabel = isRecord2(stage) ? ` (stage ${stage.position} of ${stage.totalStages})` : "";
17769
17777
  this.recordHistoryEvent("replicas-tool-input-request", {
17770
17778
  requestId,
17771
17779
  toolUseId: pending.itemId,
@@ -17824,7 +17832,7 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
17824
17832
  return input;
17825
17833
  }
17826
17834
  handleNotification(frame) {
17827
- if (!isRecord(frame) || typeof frame.method !== "string" || !isRecord(frame.params)) return;
17835
+ if (!isRecord2(frame) || typeof frame.method !== "string" || !isRecord2(frame.params)) return;
17828
17836
  if (typeof frame.params.sessionId === "string" && this.sessionId && frame.params.sessionId !== this.sessionId) return;
17829
17837
  this.recordHistoryEvent(`muse-${frame.method.replaceAll("/", "-")}`, frame.params);
17830
17838
  if (frame.method === "approval/requested" || frame.method === "approval/updated") {
@@ -17836,11 +17844,11 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
17836
17844
  this.resolveApproval(frame.params.approvalId, choice?.choiceId ?? decision);
17837
17845
  } else if (frame.method === "turn/completed") {
17838
17846
  for (const approvalId of this.pendingApprovals.keys()) this.resolveApproval(approvalId, "aborted");
17839
- this.turnError = isRecord(frame.params.error) && typeof frame.params.error.message === "string" ? frame.params.error.message : null;
17847
+ this.turnError = isRecord2(frame.params.error) && typeof frame.params.error.message === "string" ? frame.params.error.message : null;
17840
17848
  this.activeTurnId = null;
17841
17849
  this.turnComplete?.resolve();
17842
17850
  this.turnComplete = null;
17843
- } else if (frame.method === "item/completed" && isRecord(frame.params.item) && frame.params.item.kind === "compaction") {
17851
+ } else if (frame.method === "item/completed" && isRecord2(frame.params.item) && frame.params.item.kind === "compaction") {
17844
17852
  this.compactionComplete?.resolve();
17845
17853
  this.compactionComplete = null;
17846
17854
  } else if (frame.method === "session/tokenUsage") {
@@ -17919,7 +17927,7 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
17919
17927
  commandId: uuidV7(),
17920
17928
  sessionId: this.sessionId
17921
17929
  });
17922
- if (isRecord(result2) && result2.status === "accepted") {
17930
+ if (isRecord2(result2) && result2.status === "accepted") {
17923
17931
  await completed2;
17924
17932
  } else {
17925
17933
  this.compactionComplete = null;
@@ -17953,7 +17961,7 @@ ${pending}
17953
17961
  ...museTurnStartParams(this.sessionId, this.createTurnInput(text, request.images), request.thinkingLevel),
17954
17962
  displayText: request.message
17955
17963
  });
17956
- if (!isRecord(result) || typeof result.turnId !== "string") throw new Error("Muse did not start a turn.");
17964
+ if (!isRecord2(result) || typeof result.turnId !== "string") throw new Error("Muse did not start a turn.");
17957
17965
  this.activeTurnId = result.turnId;
17958
17966
  if (pending) this.deliveredInstructions = pending;
17959
17967
  await completed;
@@ -18021,7 +18029,7 @@ ${pending}
18021
18029
  selections = JSON.parse(selectionId);
18022
18030
  } catch {
18023
18031
  }
18024
- const answer = isRecord(selections) && isRecord(selections.approval) ? selections.approval : null;
18032
+ const answer = isRecord2(selections) && isRecord2(selections.approval) ? selections.approval : null;
18025
18033
  const choiceId = selectionId === "declined" ? approval.availableChoices.find((choice2) => choice2.decision === "abort" || choice2.decision === "denied")?.choiceId : answer && !answer.custom && Array.isArray(answer.options) && answer.options.length === 1 ? answer.options[0] : selectionId;
18026
18034
  const choice = approval.availableChoices.find((candidate) => candidate.choiceId === choiceId);
18027
18035
  if (!choice) return false;
@@ -18096,8 +18104,8 @@ ${pending}
18096
18104
  "--json"
18097
18105
  ], { maxBuffer: SUBPROCESS_MAX_BUFFER });
18098
18106
  const parsed = JSON.parse(stdout);
18099
- this.slashCommands = isRecord(parsed) && Array.isArray(parsed.skills) ? parsed.skills.flatMap((skill) => {
18100
- if (!isRecord(skill) || typeof skill.name !== "string") return [];
18107
+ this.slashCommands = isRecord2(parsed) && Array.isArray(parsed.skills) ? parsed.skills.flatMap((skill) => {
18108
+ if (!isRecord2(skill) || typeof skill.name !== "string") return [];
18101
18109
  const command = createProviderSlashCommand(
18102
18110
  "muse",
18103
18111
  skill.name,
@@ -18193,19 +18201,19 @@ function isOpencodePart(value) {
18193
18201
  return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
18194
18202
  }
18195
18203
  function isOpencodeQuestionRequest(value) {
18196
- return isRecord2(value) && typeof value.id === "string" && typeof value.sessionID === "string" && (value.tool === void 0 || isRecord2(value.tool) && typeof value.tool.messageID === "string" && typeof value.tool.callID === "string") && Array.isArray(value.questions) && value.questions.every((question) => isRecord2(question) && typeof question.question === "string" && typeof question.header === "string" && (question.multiple === void 0 || typeof question.multiple === "boolean") && (question.custom === void 0 || typeof question.custom === "boolean") && Array.isArray(question.options) && question.options.every((option) => isRecord2(option) && typeof option.label === "string" && typeof option.description === "string"));
18204
+ return isRecord(value) && typeof value.id === "string" && typeof value.sessionID === "string" && (value.tool === void 0 || isRecord(value.tool) && typeof value.tool.messageID === "string" && typeof value.tool.callID === "string") && Array.isArray(value.questions) && value.questions.every((question) => isRecord(question) && typeof question.question === "string" && typeof question.header === "string" && (question.multiple === void 0 || typeof question.multiple === "boolean") && (question.custom === void 0 || typeof question.custom === "boolean") && Array.isArray(question.options) && question.options.every((option) => isRecord(option) && typeof option.label === "string" && typeof option.description === "string"));
18197
18205
  }
18198
18206
  function opencodeQuestionToolUseId(request) {
18199
18207
  return request.tool?.callID ?? request.id;
18200
18208
  }
18201
18209
  function isStringRecord(value) {
18202
- return isRecord2(value) && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
18210
+ return isRecord(value) && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
18203
18211
  }
18204
18212
  function isStringArray(value) {
18205
18213
  return Array.isArray(value) && value.every((item) => typeof item === "string");
18206
18214
  }
18207
18215
  function isOpencodeMcpEntry(value) {
18208
- if (!isRecord2(value) || Array.isArray(value)) return false;
18216
+ if (!isRecord(value) || Array.isArray(value)) return false;
18209
18217
  if (typeof value.enabled === "boolean" && typeof value.type !== "string") return true;
18210
18218
  if (value.type === "local") {
18211
18219
  return isStringArray(value.command) && (value.environment === void 0 || isStringRecord(value.environment));
@@ -18220,13 +18228,13 @@ async function readProvisionedOpencodeMcpConfig() {
18220
18228
  try {
18221
18229
  raw = await readFile10(OPENCODE_CONFIG_PATH, "utf8");
18222
18230
  } catch (error) {
18223
- if (isRecord2(error) && error.code === "ENOENT") return void 0;
18231
+ if (isRecord(error) && error.code === "ENOENT") return void 0;
18224
18232
  console.error("[OpencodeManager] Failed to read Opencode config:", error);
18225
18233
  return void 0;
18226
18234
  }
18227
18235
  try {
18228
18236
  const parsed = JSON.parse(raw);
18229
- if (!isRecord2(parsed) || !isRecord2(parsed.mcp) || Array.isArray(parsed.mcp)) return void 0;
18237
+ if (!isRecord(parsed) || !isRecord(parsed.mcp) || Array.isArray(parsed.mcp)) return void 0;
18230
18238
  const mcp = {};
18231
18239
  for (const [name, entry] of Object.entries(parsed.mcp)) {
18232
18240
  if (isOpencodeMcpEntry(entry)) mcp[name] = entry;
@@ -18246,17 +18254,17 @@ function timestampMs(value) {
18246
18254
  return Date.now();
18247
18255
  }
18248
18256
  function isOpencodeRuntimeEvent(value) {
18249
- return isRecord2(value) && typeof value.type === "string";
18257
+ return isRecord(value) && typeof value.type === "string";
18250
18258
  }
18251
18259
  function opencodeEventPayload(event) {
18252
- if ("properties" in event && isRecord2(event.properties)) return event.properties;
18253
- if ("data" in event && isRecord2(event.data)) return event.data;
18260
+ if ("properties" in event && isRecord(event.properties)) return event.properties;
18261
+ if ("data" in event && isRecord(event.data)) return event.data;
18254
18262
  return null;
18255
18263
  }
18256
18264
  function opencodeErrorMessage(error) {
18257
18265
  if (error instanceof Error) return error.message;
18258
18266
  if (typeof error === "string") return error;
18259
- if (!isRecord2(error)) return void 0;
18267
+ if (!isRecord(error)) return void 0;
18260
18268
  if (typeof error.message === "string") return error.message;
18261
18269
  if (typeof error.name === "string") return error.name;
18262
18270
  if ("error" in error) return opencodeErrorMessage(error.error);
@@ -18267,7 +18275,7 @@ function opencodeErrorMessage(error) {
18267
18275
  function opencodeErrorPayload(error) {
18268
18276
  const message = opencodeErrorMessage(error) ?? String(error);
18269
18277
  const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : void 0;
18270
- const cause = error instanceof Error && isRecord2(error.cause) ? error.cause : null;
18278
+ const cause = error instanceof Error && isRecord(error.cause) ? error.cause : null;
18271
18279
  const status = typeof cause?.status === "number" ? cause.status : void 0;
18272
18280
  return {
18273
18281
  message: code === "ENOENT" ? `Failed to start Opencode server binary (${message}).` : message,
@@ -18342,8 +18350,8 @@ var OpencodeManager = class extends CodingAgentManager {
18342
18350
  // An abort of this engine ends every message the session has made by the time OpenCode answers it.
18343
18351
  reportsOwnStop(event) {
18344
18352
  const { info } = event.payload;
18345
- if (event.type !== "opencode-message.updated" || !isRecord2(info) || !isRecord2(info.error) || info.error.name !== "MessageAbortedError") return false;
18346
- return this.stopsInFlight > 0 || isRecord2(info.time) && typeof info.time.created === "number" && info.time.created <= this.stoppedBefore;
18353
+ if (event.type !== "opencode-message.updated" || !isRecord(info) || !isRecord(info.error) || info.error.name !== "MessageAbortedError") return false;
18354
+ return this.stopsInFlight > 0 || isRecord(info.time) && typeof info.time.created === "number" && info.time.created <= this.stoppedBefore;
18347
18355
  }
18348
18356
  async getHistory(page2 = {}) {
18349
18357
  await this.historyFile.flush();
@@ -18672,7 +18680,7 @@ var OpencodeManager = class extends CodingAgentManager {
18672
18680
  const sessionID = typeof payload.sessionID === "string" ? payload.sessionID : void 0;
18673
18681
  const part = payload.part;
18674
18682
  if (typeof sessionID === "string" && this.sessionId && sessionID !== this.sessionId) return;
18675
- const partSessionID = isRecord2(part) ? part.sessionID : void 0;
18683
+ const partSessionID = isRecord(part) ? part.sessionID : void 0;
18676
18684
  if (typeof partSessionID === "string" && this.sessionId && partSessionID !== this.sessionId) return;
18677
18685
  if (event.type === "message.part.updated" && isOpencodePart(part)) {
18678
18686
  if (this.shouldRecordOpencodePart(part)) this.recordOpencodePart(part);
@@ -18731,8 +18739,8 @@ var OpencodeManager = class extends CodingAgentManager {
18731
18739
  return this.pendingQuestions.size > 0;
18732
18740
  }
18733
18741
  async handleAccountRateLimit(payload) {
18734
- const status = isRecord2(payload.status) ? payload.status : null;
18735
- const action = isRecord2(status?.action) ? status.action : null;
18742
+ const status = isRecord(payload.status) ? payload.status : null;
18743
+ const action = isRecord(status?.action) ? status.action : null;
18736
18744
  if (status?.type !== "retry" || action?.reason !== "account_rate_limit" || this.handledAccountRateLimit) return;
18737
18745
  this.handledAccountRateLimit = true;
18738
18746
  const message = typeof status.message === "string" ? status.message : typeof action.message === "string" ? action.message : "OpenCode Go usage limit reached.";
@@ -18754,7 +18762,7 @@ var OpencodeManager = class extends CodingAgentManager {
18754
18762
  await this.abortActiveTurn();
18755
18763
  }
18756
18764
  recordOpencodeMessageRole(payload) {
18757
- const info = isRecord2(payload.info) ? payload.info : null;
18765
+ const info = isRecord(payload.info) ? payload.info : null;
18758
18766
  const id = typeof info?.id === "string" ? info.id : void 0;
18759
18767
  const role = typeof info?.role === "string" ? info.role : void 0;
18760
18768
  if (!id || !role) return;
@@ -18861,20 +18869,6 @@ import {
18861
18869
  DefaultResourceLoader
18862
18870
  } from "@earendil-works/pi-coding-agent";
18863
18871
 
18864
- // src/managers/managed-mcp-servers.ts
18865
- import { readFile as readFile11 } from "fs/promises";
18866
- async function getManagedPiMcpServers() {
18867
- try {
18868
- const parsed = JSON.parse(await readFile11(PI_MCP_CONFIG_PATH, "utf8"));
18869
- if (!isRecord2(parsed) || !isRecord2(parsed.mcpServers)) return {};
18870
- return Object.fromEntries(Object.entries(parsed.mcpServers).filter(
18871
- (entry) => isRecord2(entry[1]) && (typeof entry[1].command === "string" || typeof entry[1].url === "string")
18872
- ));
18873
- } catch {
18874
- return {};
18875
- }
18876
- }
18877
-
18878
18872
  // ../node_modules/.bun/typebox@1.3.7/node_modules/typebox/build/system/memory/memory.mjs
18879
18873
  var memory_exports = {};
18880
18874
  __export(memory_exports, {
@@ -59689,7 +59683,7 @@ function registerPiProvider(modelRegistry, {
59689
59683
  });
59690
59684
  }
59691
59685
  function eventPayload(event) {
59692
- return isRecord2(event) ? { ...event } : { value: event };
59686
+ return isRecord(event) ? { ...event } : { value: event };
59693
59687
  }
59694
59688
  function explicitSkillName(session, message) {
59695
59689
  const match = message.match(/^\/skill:([^\s]+)(?:\s|$)/);
@@ -59971,7 +59965,7 @@ var PiManager = class extends CodingAgentManager {
59971
59965
  };
59972
59966
 
59973
59967
  // src/services/chat/chat-commands.ts
59974
- import { mkdir as mkdir12, readFile as readFile12, rm as rm6 } from "fs/promises";
59968
+ import { mkdir as mkdir12, readFile as readFile11, rm as rm6 } from "fs/promises";
59975
59969
  import { join as join23 } from "path";
59976
59970
  import { z as z3 } from "zod";
59977
59971
  var CHAT_COMMANDS_DIR = join23(ENGINE_DIR, "chat-commands");
@@ -60003,14 +59997,14 @@ var ChatCommands = class _ChatCommands {
60003
59997
  state;
60004
59998
  writing = Promise.resolve();
60005
59999
  static async load(chatId) {
60006
- const content = await readFile12(join23(CHAT_COMMANDS_DIR, `${chatId}.json`), "utf-8").catch((error) => {
60000
+ const content = await readFile11(join23(CHAT_COMMANDS_DIR, `${chatId}.json`), "utf-8").catch((error) => {
60007
60001
  if (error.code === "ENOENT") return null;
60008
60002
  throw error;
60009
60003
  });
60010
60004
  if (content === null) return null;
60011
60005
  try {
60012
60006
  const saved = JSON.parse(content);
60013
- if (isRecord(saved) && Array.isArray(saved.queue)) {
60007
+ if (isRecord2(saved) && Array.isArray(saved.queue)) {
60014
60008
  saved.queue = saved.queue.filter((entry) => {
60015
60009
  const { success, error } = queuedMessageSchema.safeParse(entry);
60016
60010
  if (!success) console.error("[ChatCommands] Dropped an unreadable queued message:", { chatId, error });
@@ -60059,7 +60053,7 @@ async function uploadAnalytics(endpoint, body) {
60059
60053
  import {
60060
60054
  appendFile as appendFile3,
60061
60055
  mkdir as mkdir13,
60062
- readFile as readFile13,
60056
+ readFile as readFile12,
60063
60057
  readdir as readdir6,
60064
60058
  rename as rename2,
60065
60059
  unlink
@@ -60197,7 +60191,7 @@ var AnalyticsRecordBuffer = class {
60197
60191
  return { flushed, failed };
60198
60192
  }
60199
60193
  async uploadSegment(filePath) {
60200
- const records = this.parseRecords(await readFile13(filePath, "utf-8"));
60194
+ const records = this.parseRecords(await readFile12(filePath, "utf-8"));
60201
60195
  if (records.length > 0) await this.options.upload(records);
60202
60196
  await rename2(filePath, `${filePath}${UPLOADED_SUFFIX}`).catch(() => {
60203
60197
  });
@@ -60244,7 +60238,7 @@ function extractSkillMcpCalls(messages) {
60244
60238
  return skillCallsFromCommand(message.id, message.skillNames ?? [], message.timestamp);
60245
60239
  }
60246
60240
  if (message.type !== "tool_call") return [];
60247
- const command = SHELL_TOOL_NAMES.test(message.tool) && isRecord(message.input) ? message.input.command ?? message.input.cmd : void 0;
60241
+ const command = SHELL_TOOL_NAMES.test(message.tool) && isRecord2(message.input) ? message.input.command ?? message.input.cmd : void 0;
60248
60242
  if (typeof command === "string") return skillCallsFromCommand(message.id, skillNamesFromCommand(command), message.timestamp);
60249
60243
  const mcpName = mcpNameFromToolCall(message);
60250
60244
  return mcpName ? [{ kind: "mcp", id: message.id, mcpName, occurredAt: message.timestamp }] : [];
@@ -60458,12 +60452,12 @@ function recordParsedTokenUsage(event, harness, parse3) {
60458
60452
 
60459
60453
  // src/analytics/token-usage/claude/parse.ts
60460
60454
  function isClaudeModelUsage(value) {
60461
- if (!isRecord(value) || !isTokenUsageCounts(value)) return false;
60455
+ if (!isRecord2(value) || !isTokenUsageCounts(value)) return false;
60462
60456
  return (value.costUsd === void 0 || typeof value.costUsd === "number" && Number.isFinite(value.costUsd) && value.costUsd >= 0) && (value.pricingProvider === void 0 || isNonEmptyString(value.pricingProvider));
60463
60457
  }
60464
60458
  var withoutDate = (model) => model.replace(/-\d{8}$/, "");
60465
60459
  function parseClaudeRequestStart(payload) {
60466
- if (!isRecord(payload) || payload.type !== "message" || !isNonEmptyString(payload.model) || !isRecord(payload.usage)) return null;
60460
+ if (!isRecord2(payload) || payload.type !== "message" || !isNonEmptyString(payload.model) || !isRecord2(payload.usage)) return null;
60467
60461
  const usage = {
60468
60462
  inputTokens: payload.usage.input_tokens,
60469
60463
  outputTokens: payload.usage.output_tokens,
@@ -60473,11 +60467,11 @@ function parseClaudeRequestStart(payload) {
60473
60467
  return isTokenUsageCounts(usage) ? { model: withoutDate(payload.model), usage } : null;
60474
60468
  }
60475
60469
  function parseClaudeResult(payload) {
60476
- if (!isRecord(payload) || payload.type !== "result") return null;
60477
- if (!isNonEmptyString(payload.session_id) || !isRecord(payload.modelUsage)) return null;
60470
+ if (!isRecord2(payload) || payload.type !== "result") return null;
60471
+ if (!isNonEmptyString(payload.session_id) || !isRecord2(payload.modelUsage)) return null;
60478
60472
  const snapshot = {};
60479
60473
  for (const [rawModel, rawUsage] of Object.entries(payload.modelUsage)) {
60480
- if (!isNonEmptyString(rawModel) || !isRecord(rawUsage)) continue;
60474
+ if (!isNonEmptyString(rawModel) || !isRecord2(rawUsage)) continue;
60481
60475
  const usage = {
60482
60476
  inputTokens: rawUsage.inputTokens,
60483
60477
  outputTokens: rawUsage.outputTokens,
@@ -60507,7 +60501,7 @@ function parseClaudeResult(payload) {
60507
60501
 
60508
60502
  // src/analytics/token-usage/claude/index.ts
60509
60503
  function isClaudeTokenUsageCheckpoint(value) {
60510
- return isRecord(value) && isNonEmptyString(value.chatId) && isNonEmptyString(value.sessionId) && isRecord(value.snapshot) && Object.values(value.snapshot).every(isClaudeModelUsage);
60504
+ return isRecord2(value) && isNonEmptyString(value.chatId) && isNonEmptyString(value.sessionId) && isRecord2(value.snapshot) && Object.values(value.snapshot).every(isClaudeModelUsage);
60511
60505
  }
60512
60506
  function normalizeClaudeTokenUsage(result, previous, context, occurredAt) {
60513
60507
  return Object.entries(result.snapshot).flatMap(([model, currentMetrics]) => {
@@ -60568,11 +60562,11 @@ function isTokenCount(value) {
60568
60562
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
60569
60563
  }
60570
60564
  function parseCodexTurn(value) {
60571
- if (!isRecord(value) || !isNonEmptyString(value.threadId) || !isNonEmptyString(value.turnId)) return void 0;
60565
+ if (!isRecord2(value) || !isNonEmptyString(value.threadId) || !isNonEmptyString(value.turnId)) return void 0;
60572
60566
  return { threadId: value.threadId, turnId: value.turnId };
60573
60567
  }
60574
60568
  function parseCodexUsage(value) {
60575
- if (!isRecord(value) || !isTokenCount(value.inputTokens) || !isTokenCount(value.cachedInputTokens) || !isTokenCount(value.outputTokens)) {
60569
+ if (!isRecord2(value) || !isTokenCount(value.inputTokens) || !isTokenCount(value.cachedInputTokens) || !isTokenCount(value.outputTokens)) {
60576
60570
  return void 0;
60577
60571
  }
60578
60572
  const cacheWriteInputTokens = value.cacheWriteInputTokens;
@@ -60585,15 +60579,15 @@ function parseCodexUsage(value) {
60585
60579
  };
60586
60580
  }
60587
60581
  function parseCodexUsageUpdate(value) {
60588
- if (!isRecord(value)) return void 0;
60582
+ if (!isRecord2(value)) return void 0;
60589
60583
  const turn = parseCodexTurn(value);
60590
- if (!turn || !isRecord(value.tokenUsage)) return void 0;
60584
+ if (!turn || !isRecord2(value.tokenUsage)) return void 0;
60591
60585
  const total = parseCodexUsage(value.tokenUsage.total);
60592
60586
  const last = parseCodexUsage(value.tokenUsage.last);
60593
60587
  return total && last ? { ...turn, total, last } : void 0;
60594
60588
  }
60595
60589
  function parseCodexModelReroute(value) {
60596
- if (!isRecord(value) || !isNonEmptyString(value.toModel)) return void 0;
60590
+ if (!isRecord2(value) || !isNonEmptyString(value.toModel)) return void 0;
60597
60591
  const turn = parseCodexTurn(value);
60598
60592
  return turn ? { ...turn, model: value.toModel } : void 0;
60599
60593
  }
@@ -60737,7 +60731,7 @@ var CodexTokenUsageService = class {
60737
60731
 
60738
60732
  // src/analytics/token-usage/cursor/index.ts
60739
60733
  function parseCursorTokenUsage(payload) {
60740
- if (!isRecord(payload) || payload.type !== "turn-ended" || !isRecord(payload.usage)) return void 0;
60734
+ if (!isRecord2(payload) || payload.type !== "turn-ended" || !isRecord2(payload.usage)) return void 0;
60741
60735
  const usage = {
60742
60736
  inputTokens: payload.usage.inputTokens,
60743
60737
  outputTokens: payload.usage.outputTokens,
@@ -60779,7 +60773,7 @@ var CursorTokenUsageService = class {
60779
60773
  // src/analytics/token-usage/muse/index.ts
60780
60774
  var MuseTokenUsageService = class {
60781
60775
  record(event) {
60782
- if (event.type !== "usage-updated" || !isRecord(event.payload) || !isRecord(event.payload.usage)) return void 0;
60776
+ if (event.type !== "usage-updated" || !isRecord2(event.payload) || !isRecord2(event.payload.usage)) return void 0;
60783
60777
  const usage = {
60784
60778
  inputTokens: event.payload.promptTokens,
60785
60779
  outputTokens: event.payload.usage.outputTokens,
@@ -60800,7 +60794,7 @@ var MuseTokenUsageService = class {
60800
60794
 
60801
60795
  // src/analytics/token-usage/opencode/index.ts
60802
60796
  function parseOpencodeTokenUsage(payload) {
60803
- if (!isRecord(payload) || payload.type !== "step-finish" || !isRecord(payload.tokens) || !isRecord(payload.tokens.cache)) return void 0;
60797
+ if (!isRecord2(payload) || payload.type !== "step-finish" || !isRecord2(payload.tokens) || !isRecord2(payload.tokens.cache)) return void 0;
60804
60798
  const usage = {
60805
60799
  inputTokens: payload.tokens.input,
60806
60800
  outputTokens: payload.tokens.output,
@@ -60817,7 +60811,7 @@ var OpencodeTokenUsageService = class {
60817
60811
 
60818
60812
  // src/analytics/token-usage/pi/index.ts
60819
60813
  function parsePiTokenUsage(payload) {
60820
- if (!isRecord(payload) || payload.type !== "message_end" || !isRecord(payload.message) || payload.message.role !== "assistant" || !isRecord(payload.message.usage)) return void 0;
60814
+ if (!isRecord2(payload) || payload.type !== "message_end" || !isRecord2(payload.message) || payload.message.role !== "assistant" || !isRecord2(payload.message.usage)) return void 0;
60821
60815
  const usage = {
60822
60816
  inputTokens: payload.message.usage.input,
60823
60817
  outputTokens: payload.message.usage.output,
@@ -60872,7 +60866,7 @@ var AgentTokenUsageTracker = class {
60872
60866
  constructor(uploadAnalytics2) {
60873
60867
  this.buffer = new AnalyticsRecordBuffer({
60874
60868
  storageName: "chat-token-usage",
60875
- validate: (value) => isRecord(value) && isNonEmptyString(value.harness) && Array.isArray(value.records) && value.records.every(isTokenUsageUploadRecord),
60869
+ validate: (value) => isRecord2(value) && isNonEmptyString(value.harness) && Array.isArray(value.records) && value.records.every(isTokenUsageUploadRecord),
60876
60870
  upload: (batches) => uploadAnalytics2(TOKEN_USAGE_PATH, {
60877
60871
  records: batches.flatMap(({ records }) => records)
60878
60872
  }),
@@ -61018,7 +61012,7 @@ var KeepAliveService = class _KeepAliveService {
61018
61012
  var keepAliveService = new KeepAliveService();
61019
61013
 
61020
61014
  // src/services/canvas-service.ts
61021
- import { readdir as readdir7, readFile as readFile15, stat as stat3 } from "fs/promises";
61015
+ import { readdir as readdir7, readFile as readFile14, stat as stat3 } from "fs/promises";
61022
61016
  import { homedir as homedir7 } from "os";
61023
61017
  import { join as join25 } from "path";
61024
61018
 
@@ -61046,9 +61040,9 @@ function fileRevision(content) {
61046
61040
  }
61047
61041
 
61048
61042
  // src/utils/revisioned-text-file.ts
61049
- import { readFile as readFile14 } from "fs/promises";
61043
+ import { readFile as readFile13 } from "fs/promises";
61050
61044
  async function writeRevisionedTextFile(filePath, content, expectedRevision) {
61051
- const current = await readFile14(filePath, "utf8");
61045
+ const current = await readFile13(filePath, "utf8");
61052
61046
  const revision = fileRevision(current);
61053
61047
  if (revision !== expectedRevision) {
61054
61048
  return {
@@ -61138,7 +61132,7 @@ var CanvasService = class {
61138
61132
  if (!item) return null;
61139
61133
  const { path: path8, ...file } = item;
61140
61134
  if (file.sizeBytes > maxBytes) return { ...file, tooLarge: true };
61141
- const bytes = await readFile15(path8).catch(() => null);
61135
+ const bytes = await readFile14(path8).catch(() => null);
61142
61136
  return bytes ? { ...file, bytes } : null;
61143
61137
  }
61144
61138
  async getItem(filename) {
@@ -61278,7 +61272,7 @@ async function reconcileCanvasItems(filenames) {
61278
61272
 
61279
61273
  // src/services/upload-chat-transcripts.ts
61280
61274
  import { createHash as createHash8 } from "crypto";
61281
- import { readFile as readFile16, readdir as readdir8 } from "fs/promises";
61275
+ import { readFile as readFile15, readdir as readdir8 } from "fs/promises";
61282
61276
  import { Readable } from "stream";
61283
61277
  import { basename as basename3, join as join27 } from "path";
61284
61278
 
@@ -61345,7 +61339,7 @@ function currentTranscriptAuth(provider) {
61345
61339
  return method === "none" ? {} : { credentialSource: "environment", environmentAuthMethod: method };
61346
61340
  }
61347
61341
  function normalizeTranscriptAuth(value) {
61348
- if (!isRecord(value)) return void 0;
61342
+ if (!isRecord2(value)) return void 0;
61349
61343
  const { credential, credentialSource, environmentAuthMethod } = normalizeChatTranscriptMetadata(value);
61350
61344
  return { credential, credentialSource, environmentAuthMethod };
61351
61345
  }
@@ -61441,7 +61435,7 @@ async function uploadOpenedTranscript(chatId, opened, historyVersion, chat, capt
61441
61435
  } : {};
61442
61436
  try {
61443
61437
  metadata.senders = parseChatMessageSendersJsonl(
61444
- await readFile16(chatMessageSendersFilePath(chatId), "utf-8")
61438
+ await readFile15(chatMessageSendersFilePath(chatId), "utf-8")
61445
61439
  );
61446
61440
  } catch (error) {
61447
61441
  if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
@@ -61475,7 +61469,7 @@ async function uploadOpenedTranscript(chatId, opened, historyVersion, chat, capt
61475
61469
  throw new Error(`prepare failed: ${prepareResponse.status} ${await prepareResponse.text()}`);
61476
61470
  }
61477
61471
  const prepareBody = await prepareResponse.json();
61478
- if (!isRecord(prepareBody) || typeof prepareBody.uploadUrl !== "string" && prepareBody.uploadUrl !== null) {
61472
+ if (!isRecord2(prepareBody) || typeof prepareBody.uploadUrl !== "string" && prepareBody.uploadUrl !== null) {
61479
61473
  throw new Error("prepare failed: invalid response");
61480
61474
  }
61481
61475
  if (prepareBody.uploadUrl === null) return null;
@@ -61487,7 +61481,7 @@ async function uploadOpenedTranscript(chatId, opened, historyVersion, chat, capt
61487
61481
  throw new Error(`finalize failed: ${finalizeResponse.status} ${await finalizeResponse.text()}`);
61488
61482
  }
61489
61483
  const finalizeBody = await finalizeResponse.json();
61490
- if (!isRecord(finalizeBody)) throw new Error("finalize failed: invalid response");
61484
+ if (!isRecord2(finalizeBody)) throw new Error("finalize failed: invalid response");
61491
61485
  if (finalizeBody.artifact === null) return null;
61492
61486
  const artifact = parseChatTranscriptArtifact(finalizeBody.artifact);
61493
61487
  if (!artifact) throw new Error("finalize failed: invalid artifact");
@@ -61657,7 +61651,7 @@ async function uploadEngineLog(input, timeoutMs) {
61657
61651
 
61658
61652
  // src/services/chat/fork-handoff.ts
61659
61653
  import { createHash as createHash9 } from "crypto";
61660
- import { mkdir as mkdir14, readFile as readFile17, writeFile as writeFile8 } from "fs/promises";
61654
+ import { mkdir as mkdir14, readFile as readFile16, writeFile as writeFile8 } from "fs/promises";
61661
61655
  import { homedir as homedir8 } from "os";
61662
61656
  import { join as join29 } from "path";
61663
61657
  var EXCERPT_MAX_CHARS = 24e3;
@@ -61757,7 +61751,7 @@ async function buildForkHandoff(input) {
61757
61751
  };
61758
61752
  }
61759
61753
  async function readPullRequestDecisions(notesPath) {
61760
- const notes = await readFile17(notesPath.replace(/^~(?=\/)/, homedir8()), "utf-8").catch(() => "");
61754
+ const notes = await readFile16(notesPath.replace(/^~(?=\/)/, homedir8()), "utf-8").catch(() => "");
61761
61755
  const decisions = /^## Decisions[^\n]*\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(notes)?.[1].trim();
61762
61756
  if (!decisions) return null;
61763
61757
  const body = decisions.length > PULL_REQUEST_DECISIONS_MAX_CHARS ? `${decisions.slice(0, PULL_REQUEST_DECISIONS_MAX_CHARS)}
@@ -61865,7 +61859,7 @@ function hasActiveChatTurn(chat) {
61865
61859
  return chat.hasActiveTurn || chat.pendingMessageIds.length > 0 || isForkPreparing(chat) || chat.provider.isProcessing();
61866
61860
  }
61867
61861
  function isPersistedChat(value) {
61868
- if (!isRecord2(value)) {
61862
+ if (!isRecord(value)) {
61869
61863
  return false;
61870
61864
  }
61871
61865
  const candidate = value;
@@ -61896,9 +61890,9 @@ function normalizePersistedChat(chat) {
61896
61890
  ...typeof chat.lastSenderKey === "string" ? { lastSenderKey: chat.lastSenderKey } : {},
61897
61891
  ...typeof chat.turnStartedAt === "string" ? { turnStartedAt: chat.turnStartedAt } : {},
61898
61892
  ...chat.turnErrorNotificationTargets ? { turnErrorNotificationTargets: z4.array(integrationErrorNotificationTargetSchema).safeParse(chat.turnErrorNotificationTargets).data } : {},
61899
- ...isRecord2(chat.uploadedHistory) && typeof chat.uploadedHistory.version === "string" && typeof chat.uploadedHistory.size === "number" ? { uploadedHistory: { version: chat.uploadedHistory.version, size: chat.uploadedHistory.size } } : {},
61893
+ ...isRecord(chat.uploadedHistory) && typeof chat.uploadedHistory.version === "string" && typeof chat.uploadedHistory.size === "number" ? { uploadedHistory: { version: chat.uploadedHistory.version, size: chat.uploadedHistory.size } } : {},
61900
61894
  ...Array.isArray(chat.removedMessageIds) ? { removedMessageIds: chat.removedMessageIds.filter((id) => typeof id === "string") } : {},
61901
- ...isRecord2(chat.acceptedSendResponses) ? {
61895
+ ...isRecord(chat.acceptedSendResponses) ? {
61902
61896
  acceptedSendResponses: Object.fromEntries(Object.entries(chat.acceptedSendResponses).flatMap(([key, value]) => {
61903
61897
  const response = sendChatMessageResponseSchema.safeParse(value);
61904
61898
  return response.success ? [[key, response.data]] : [];
@@ -62075,7 +62069,7 @@ var ChatService = class {
62075
62069
  const [discovered, learnedSkills] = await Promise.all([
62076
62070
  chat.provider.listSlashCommands?.() ?? [],
62077
62071
  // Learned skills work in the background, so they stay out of the slash menu.
62078
- readFile18(LEARNED_SKILLS_MANIFEST_PATH, "utf-8").then((content) => new Set(learnedSkillsManifestSchema.parse(JSON.parse(content)).skills.flatMap(({ name }) => [`/${name}`, `/${LEARNED_SKILL_DIR_PREFIX}${name}`]))).catch(() => /* @__PURE__ */ new Set())
62072
+ readFile17(LEARNED_SKILLS_MANIFEST_PATH, "utf-8").then((content) => new Set(learnedSkillsManifestSchema.parse(JSON.parse(content)).skills.flatMap(({ name }) => [`/${name}`, `/${LEARNED_SKILL_DIR_PREFIX}${name}`]))).catch(() => /* @__PURE__ */ new Set())
62079
62073
  ]);
62080
62074
  const providerCommands = discovered.filter(({ command }) => !learnedSkills.has(command)).map((command) => ({
62081
62075
  ...command,
@@ -62553,7 +62547,7 @@ ${decisions}` };
62553
62547
  }
62554
62548
  }
62555
62549
  async readSenders(chatId) {
62556
- return readFile18(chatMessageSendersFilePath(chatId), "utf-8").then(parseChatMessageSendersJsonl).catch((error) => {
62550
+ return readFile17(chatMessageSendersFilePath(chatId), "utf-8").then(parseChatMessageSendersJsonl).catch((error) => {
62557
62551
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return [];
62558
62552
  console.error("[ChatService] Failed to read sender records:", error);
62559
62553
  return [];
@@ -63874,7 +63868,7 @@ ${note}`;
63874
63868
  }
63875
63869
  async loadChats() {
63876
63870
  try {
63877
- const content = await readFile18(CHATS_FILE, "utf-8");
63871
+ const content = await readFile17(CHATS_FILE, "utf-8");
63878
63872
  return parsePersistedChatsContent(content);
63879
63873
  } catch (error) {
63880
63874
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
@@ -63889,7 +63883,7 @@ ${note}`;
63889
63883
  console.error("[ChatService] Failed to quarantine corrupt chats file:", renameError);
63890
63884
  }
63891
63885
  try {
63892
- const backupContent = await readFile18(CHATS_BACKUP_FILE, "utf-8");
63886
+ const backupContent = await readFile17(CHATS_BACKUP_FILE, "utf-8");
63893
63887
  return parsePersistedChatsContent(backupContent);
63894
63888
  } catch (backupError) {
63895
63889
  if (backupError && typeof backupError === "object" && "code" in backupError && backupError.code === "ENOENT") {
@@ -64038,7 +64032,7 @@ ${note}`;
64038
64032
  // src/services/repo-file-service.ts
64039
64033
  import { execFile as execFile7 } from "child_process";
64040
64034
  import { createReadStream as createReadStream2 } from "fs";
64041
- import { readFile as readFile19, realpath as realpath2, stat as stat5 } from "fs/promises";
64035
+ import { readFile as readFile18, realpath as realpath2, stat as stat5 } from "fs/promises";
64042
64036
  import { homedir as homedir9 } from "os";
64043
64037
  import { extname as extname3, isAbsolute as isAbsolute3, join as join32, resolve as resolve5 } from "path";
64044
64038
 
@@ -64420,7 +64414,7 @@ var RepoFileService = class {
64420
64414
  async inspectSymbol(repoName, filePath, line, character, action) {
64421
64415
  const resolved = await this.resolveFile(repoName, filePath);
64422
64416
  if (!resolved || line < 1 || character < 0 || isBinaryExtension(filePath)) return null;
64423
- const content = await readFile19(resolved.fullPath, "utf8");
64417
+ const content = await readFile18(resolved.fullPath, "utf8");
64424
64418
  const sourceLine = content.split("\n")[line - 1];
64425
64419
  if (sourceLine === void 0) return null;
64426
64420
  const symbolMatch = Array.from(sourceLine.matchAll(/[\p{L}_$][\p{L}\p{N}_$]*/gu)).find((match) => character >= match.index && character <= match.index + match[0].length);
@@ -64533,18 +64527,18 @@ var RepoFileService = class {
64533
64527
  // src/v1-routes.ts
64534
64528
  import { Hono } from "hono";
64535
64529
  import { z as z6 } from "zod";
64536
- import { readdir as readdir11, stat as stat6, readFile as readFile22 } from "fs/promises";
64530
+ import { readdir as readdir11, stat as stat6, readFile as readFile21 } from "fs/promises";
64537
64531
  import { openAsBlob } from "fs";
64538
64532
  import { join as join35, resolve as resolve6 } from "path";
64539
64533
 
64540
64534
  // src/services/warm-hooks-service.ts
64541
64535
  import { spawn as spawn5 } from "child_process";
64542
- import { readFile as readFile21 } from "fs/promises";
64536
+ import { readFile as readFile20 } from "fs/promises";
64543
64537
  import { existsSync as existsSync16 } from "fs";
64544
64538
  import { join as join34 } from "path";
64545
64539
 
64546
64540
  // src/services/warm-hook-logs-service.ts
64547
- import { mkdir as mkdir16, readFile as readFile20, writeFile as writeFile9, readdir as readdir10, appendFile as appendFile5, unlink as unlink2 } from "fs/promises";
64541
+ import { mkdir as mkdir16, readFile as readFile19, writeFile as writeFile9, readdir as readdir10, appendFile as appendFile5, unlink as unlink2 } from "fs/promises";
64548
64542
  import { homedir as homedir10 } from "os";
64549
64543
  import { join as join33 } from "path";
64550
64544
  var LOGS_DIR2 = join33(homedir10(), ".replicas", "warm-hook-logs");
@@ -64593,7 +64587,7 @@ var WarmHookLogsService = class {
64593
64587
  continue;
64594
64588
  }
64595
64589
  try {
64596
- const raw = await readFile20(join33(LOGS_DIR2, file), "utf-8");
64590
+ const raw = await readFile19(join33(LOGS_DIR2, file), "utf-8");
64597
64591
  const stored = JSON.parse(raw);
64598
64592
  if (stored.hookType !== "environment" && stored.hookType !== "repository") continue;
64599
64593
  logs.push(withPreview2(stored));
@@ -64620,7 +64614,7 @@ var WarmHookLogsService = class {
64620
64614
  }
64621
64615
  async getCurrentRunLog() {
64622
64616
  try {
64623
- return await readFile20(CURRENT_RUN_LOG, "utf-8");
64617
+ return await readFile19(CURRENT_RUN_LOG, "utf-8");
64624
64618
  } catch (err) {
64625
64619
  if (err.code === "ENOENT") return null;
64626
64620
  throw err;
@@ -64629,7 +64623,7 @@ var WarmHookLogsService = class {
64629
64623
  async getFullOutput(hookType, hookName) {
64630
64624
  const filename = hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
64631
64625
  try {
64632
- const raw = await readFile20(join33(LOGS_DIR2, filename), "utf-8");
64626
+ const raw = await readFile19(join33(LOGS_DIR2, filename), "utf-8");
64633
64627
  const stored = JSON.parse(raw);
64634
64628
  if (stored.hookType !== hookType || stored.hookName !== hookName) {
64635
64629
  return null;
@@ -64653,7 +64647,7 @@ async function readRepoWarmHook(repoPath) {
64653
64647
  continue;
64654
64648
  }
64655
64649
  try {
64656
- const raw = await readFile21(configPath, "utf-8");
64650
+ const raw = await readFile20(configPath, "utf-8");
64657
64651
  const config = parseReplicasConfigString(raw, filename);
64658
64652
  if (!config.warmHook) {
64659
64653
  return null;
@@ -66058,7 +66052,7 @@ data: ${JSON.stringify("Terminal session not found")}
66058
66052
  }
66059
66053
  let content;
66060
66054
  try {
66061
- content = await readFile22(filePath, "utf-8");
66055
+ content = await readFile21(filePath, "utf-8");
66062
66056
  } catch {
66063
66057
  return c.json(jsonError("Log session not found"), 404);
66064
66058
  }
@@ -66282,11 +66276,14 @@ function resolvePath(target) {
66282
66276
  return resolve7(ENGINE_ENV.WORKSPACE_ROOT, target);
66283
66277
  }
66284
66278
  async function mcpServerProcess(name) {
66279
+ if (name === CODE_MODE_MCP_SERVER) {
66280
+ const gateway = engineScriptProcess("codemode-mcp", []);
66281
+ return { file: gateway.command, args: gateway.args, env: void 0 };
66282
+ }
66285
66283
  const entry = (await getManagedPiMcpServers())[name];
66286
66284
  if (!entry) throw new ExecError("ENOENT", `No MCP server named ${name}`);
66287
- if (entry.command) return { file: entry.command, args: entry.args ?? [], env: entry.env };
66288
- const bridge = engineScriptProcess("mcp-http-bridge", []);
66289
- return { file: bridge.command, args: bridge.args, env: { REPLICAS_MCP_URL: entry.url ?? "", REPLICAS_MCP_HEADERS: JSON.stringify(entry.headers ?? {}) } };
66285
+ const { command, args, env } = managedMcpServerProcess(entry);
66286
+ return { file: command, args, env };
66290
66287
  }
66291
66288
  function toErrorBody(error) {
66292
66289
  if (error instanceof ExecError) return { code: error.code, message: error.message, path: error.path };
@@ -66551,13 +66548,13 @@ function attachTerminalSocket(id, socket) {
66551
66548
  }
66552
66549
 
66553
66550
  // src/services/resource-monitor.ts
66554
- import { readFile as readFile23 } from "fs/promises";
66551
+ import { readFile as readFile22 } from "fs/promises";
66555
66552
  var SAMPLE_INTERVAL_MS = 5e3;
66556
66553
  var READ_TIMEOUT_MS = 2e3;
66557
66554
  var pendingReads = new InFlightMap();
66558
66555
  var boundedReads = /* @__PURE__ */ new WeakMap();
66559
66556
  function readWithin(path8) {
66560
- const read = pendingReads.run(path8, () => readFile23(path8, "utf8"));
66557
+ const read = pendingReads.run(path8, () => readFile22(path8, "utf8"));
66561
66558
  const bounded = boundedReads.get(read) ?? withTimeout(read, READ_TIMEOUT_MS, `Timed out reading ${path8}`);
66562
66559
  boundedReads.set(read, bounded);
66563
66560
  return bounded;
@@ -66773,8 +66770,8 @@ var HeartbeatService = class _HeartbeatService {
66773
66770
  });
66774
66771
  if (response.ok) {
66775
66772
  const reply = await response.json().catch(() => null);
66776
- if (isRecord(reply) && reply.resourcesRecorded === true) resourceMonitor.acknowledge(resources);
66777
- if (isRecord(reply)) this.autoSize = reply.autoSize === true;
66773
+ if (isRecord2(reply) && reply.resourcesRecorded === true) resourceMonitor.acknowledge(resources);
66774
+ if (isRecord2(reply)) this.autoSize = reply.autoSize === true;
66778
66775
  } else {
66779
66776
  console.warn(`[EngineHeartbeat] Ping returned ${response.status}`);
66780
66777
  }
@@ -66844,7 +66841,7 @@ async function listen() {
66844
66841
  } catch {
66845
66842
  continue;
66846
66843
  }
66847
- if (!isRecord2(event)) continue;
66844
+ if (!isRecord(event)) continue;
66848
66845
  if (event.event === "def_repo" && typeof event.worktree === "string") worktree = event.worktree;
66849
66846
  if ((event.event === "exit" || event.event === "atexit") && typeof event.code === "number") exitCode = event.code;
66850
66847
  if (event.event === "cmd_name") {
@@ -66975,7 +66972,7 @@ app.use("*", authMiddleware);
66975
66972
  var lifecycleResponse = (c, result) => result.ok ? c.json(result.data) : c.json({ error: result.error.message }, result.error.code);
66976
66973
  app.post(ENGINE_ACTIVATE_PATH, async (c) => {
66977
66974
  const body = await c.req.json().catch(() => null);
66978
- const workspaceId = isRecord(body) && typeof body.workspaceId === "string" ? body.workspaceId : void 0;
66975
+ const workspaceId = isRecord2(body) && typeof body.workspaceId === "string" ? body.workspaceId : void 0;
66979
66976
  return lifecycleResponse(c, await lifecycle.transition(() => activate(workspaceId === void 0 ? void 0 : { workspaceId })));
66980
66977
  });
66981
66978
  app.post(ENGINE_SLEEP_PATH, async (c) => lifecycleResponse(c, await lifecycle.transition(sleep4)));