@muggleai/works 5.22.0-staging.150 → 5.22.0-staging.152

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.
@@ -1,6 +1,6 @@
1
1
  import * as fs4 from 'fs';
2
2
  import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
3
- import * as path13 from 'path';
3
+ import * as path14 from 'path';
4
4
  import { join, dirname } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import * as crypto from 'crypto';
@@ -10,7 +10,7 @@ import { platform } from 'os';
10
10
  import winston from 'winston';
11
11
  import { exec, spawn } from 'child_process';
12
12
  import axios, { AxiosError } from 'axios';
13
- import * as fs12 from 'fs/promises';
13
+ import * as fs13 from 'fs/promises';
14
14
  import AppInsights from 'applicationinsights';
15
15
  import { z } from 'zod';
16
16
 
@@ -160,26 +160,26 @@ var ElectronAppReleaseStream = /* @__PURE__ */ ((ElectronAppReleaseStream3) => {
160
160
  var DEFAULT_AUTH0_SCOPE = "openid profile email offline_access";
161
161
  var DEFAULT_WEB_SERVICE_URL = "http://localhost:3001";
162
162
  var RUNTIME_TARGET_ENV_VAR = "MUGGLE_MCP_PROMPT_SERVICE_TARGET";
163
- var RUNTIME_TARGETS_FILE = path13.join("config", "runtime-targets.json");
163
+ var RUNTIME_TARGETS_FILE = path14.join("config", "runtime-targets.json");
164
164
  function getPackageRoot() {
165
- const currentDir = path13.dirname(fileURLToPath(import.meta.url));
166
- if (currentDir.includes(path13.join("dist", "shared"))) {
167
- return path13.resolve(currentDir, "..", "..");
165
+ const currentDir = path14.dirname(fileURLToPath(import.meta.url));
166
+ if (currentDir.includes(path14.join("dist", "shared"))) {
167
+ return path14.resolve(currentDir, "..", "..");
168
168
  }
169
169
  if (currentDir.endsWith("dist")) {
170
- return path13.resolve(currentDir, "..");
170
+ return path14.resolve(currentDir, "..");
171
171
  }
172
- if (currentDir.includes(path13.join("src", "shared"))) {
173
- return path13.resolve(currentDir, "..", "..", "..", "..");
172
+ if (currentDir.includes(path14.join("src", "shared"))) {
173
+ return path14.resolve(currentDir, "..", "..", "..", "..");
174
174
  }
175
- return path13.dirname(currentDir);
175
+ return path14.dirname(currentDir);
176
176
  }
177
177
  var runtimeTargetDataCache = null;
178
178
  function getRuntimeTargetData() {
179
179
  if (runtimeTargetDataCache) {
180
180
  return runtimeTargetDataCache;
181
181
  }
182
- const profilesPath = path13.join(getPackageRoot(), RUNTIME_TARGETS_FILE);
182
+ const profilesPath = path14.join(getPackageRoot(), RUNTIME_TARGETS_FILE);
183
183
  let parsedData;
184
184
  try {
185
185
  parsedData = JSON.parse(fs4.readFileSync(profilesPath, "utf-8"));
@@ -258,7 +258,7 @@ function assertDeviceCodeClientProvisioned(target) {
258
258
  }
259
259
  var DATA_DIR_NAME = ".muggle-ai";
260
260
  function getDataDir() {
261
- return path13.join(os4.homedir(), DATA_DIR_NAME);
261
+ return path14.join(os4.homedir(), DATA_DIR_NAME);
262
262
  }
263
263
  var DEV_MANIFEST = {
264
264
  release: "dev",
@@ -312,24 +312,24 @@ var configInstance = null;
312
312
  var muggleConfigCache = null;
313
313
  function getPackageRoot2() {
314
314
  const currentFilePath = fileURLToPath(import.meta.url);
315
- const currentDir = path13.dirname(currentFilePath);
316
- if (currentDir.includes(path13.join("dist", "shared"))) {
317
- return path13.resolve(currentDir, "..", "..");
315
+ const currentDir = path14.dirname(currentFilePath);
316
+ if (currentDir.includes(path14.join("dist", "shared"))) {
317
+ return path14.resolve(currentDir, "..", "..");
318
318
  }
319
319
  if (currentDir.endsWith("dist")) {
320
- return path13.resolve(currentDir, "..");
320
+ return path14.resolve(currentDir, "..");
321
321
  }
322
- if (currentDir.includes(path13.join("src", "shared"))) {
323
- return path13.resolve(currentDir, "..", "..", "..", "..");
322
+ if (currentDir.includes(path14.join("src", "shared"))) {
323
+ return path14.resolve(currentDir, "..", "..", "..", "..");
324
324
  }
325
- return path13.dirname(currentDir);
325
+ return path14.dirname(currentDir);
326
326
  }
327
327
  function getMuggleConfig() {
328
328
  if (muggleConfigCache) {
329
329
  return muggleConfigCache;
330
330
  }
331
331
  const packageRoot = getPackageRoot2();
332
- const packageJsonPath = path13.join(packageRoot, "package.json");
332
+ const packageJsonPath = path14.join(packageRoot, "package.json");
333
333
  let packageJson;
334
334
  try {
335
335
  const content = fs4.readFileSync(packageJsonPath, "utf-8");
@@ -405,7 +405,7 @@ function buildOAuthSessionFileName(params) {
405
405
  function getDownloadedElectronAppPath() {
406
406
  const platformName = os4.platform();
407
407
  const version = getElectronAppVersion();
408
- const baseDir = path13.join(
408
+ const baseDir = path14.join(
409
409
  getDataDir2(),
410
410
  ELECTRON_APP_DIR,
411
411
  buildElectronAppDirName({
@@ -416,13 +416,13 @@ function getDownloadedElectronAppPath() {
416
416
  let binaryPath;
417
417
  switch (platformName) {
418
418
  case "darwin":
419
- binaryPath = path13.join(baseDir, "MuggleAI.app", "Contents", "MacOS", "MuggleAI");
419
+ binaryPath = path14.join(baseDir, "MuggleAI.app", "Contents", "MacOS", "MuggleAI");
420
420
  break;
421
421
  case "win32":
422
- binaryPath = path13.join(baseDir, "MuggleAI.exe");
422
+ binaryPath = path14.join(baseDir, "MuggleAI.exe");
423
423
  break;
424
424
  case "linux":
425
- binaryPath = path13.join(baseDir, "MuggleAI");
425
+ binaryPath = path14.join(baseDir, "MuggleAI");
426
426
  break;
427
427
  default:
428
428
  return null;
@@ -438,13 +438,13 @@ function getSystemElectronAppPath() {
438
438
  let binaryPath;
439
439
  switch (platformName) {
440
440
  case "darwin":
441
- binaryPath = path13.join(homeDir, "Applications", "MuggleAI.app", "Contents", "MacOS", "MuggleAI");
441
+ binaryPath = path14.join(homeDir, "Applications", "MuggleAI.app", "Contents", "MacOS", "MuggleAI");
442
442
  break;
443
443
  case "win32":
444
- binaryPath = path13.join(homeDir, "AppData", "Local", "Programs", "MuggleAI", "MuggleAI.exe");
444
+ binaryPath = path14.join(homeDir, "AppData", "Local", "Programs", "MuggleAI", "MuggleAI.exe");
445
445
  break;
446
446
  case "linux":
447
- binaryPath = path13.join(homeDir, ".local", "share", "muggle-ai", "MuggleAI");
447
+ binaryPath = path14.join(homeDir, ".local", "share", "muggle-ai", "MuggleAI");
448
448
  break;
449
449
  default:
450
450
  return null;
@@ -475,7 +475,7 @@ function resolveWebServicePath() {
475
475
  return customPath;
476
476
  }
477
477
  const packageRoot = getPackageRoot2();
478
- const siblingPath = path13.resolve(packageRoot, "..", "web-service", "dist", "src", "index.js");
478
+ const siblingPath = path14.resolve(packageRoot, "..", "web-service", "dist", "src", "index.js");
479
479
  if (fs4.existsSync(siblingPath)) {
480
480
  return siblingPath;
481
481
  }
@@ -518,16 +518,16 @@ function buildLocalQaConfig() {
518
518
  webServiceUrl: process.env.WEB_SERVICE_URL ?? DEFAULT_WEB_SERVICE_URL,
519
519
  promptServiceUrl: process.env.PROMPT_SERVICE_BASE_URL ?? activeProfile.promptServiceBaseUrl,
520
520
  dataDir,
521
- sessionsDir: path13.join(dataDir, "sessions"),
522
- projectsDir: path13.join(dataDir, "projects"),
523
- tempDir: path13.join(dataDir, "temp"),
524
- apiKeyFilePath: path13.join(dataDir, API_KEY_FILE),
525
- oauthSessionFilePath: path13.join(
521
+ sessionsDir: path14.join(dataDir, "sessions"),
522
+ projectsDir: path14.join(dataDir, "projects"),
523
+ tempDir: path14.join(dataDir, "temp"),
524
+ apiKeyFilePath: path14.join(dataDir, API_KEY_FILE),
525
+ oauthSessionFilePath: path14.join(
526
526
  dataDir,
527
527
  buildOAuthSessionFileName({ runtimeTarget: getActiveRuntimeTarget() })
528
528
  ),
529
529
  webServicePath: resolveWebServicePath(),
530
- webServicePidFile: path13.join(dataDir, "web-service.pid"),
530
+ webServicePidFile: path14.join(dataDir, "web-service.pid"),
531
531
  auth0: {
532
532
  domain: process.env.AUTH0_DOMAIN ?? activeProfile.auth0Domain,
533
533
  clientId: process.env.AUTH0_CLIENT_ID ?? activeProfile.auth0ClientId,
@@ -562,7 +562,7 @@ function getElectronAppVersion() {
562
562
  if (envVersion && /^\d+\.\d+\.\d+$/.test(envVersion)) {
563
563
  return envVersion;
564
564
  }
565
- const overridePath = path13.join(getDataDir2(), VERSION_OVERRIDE_FILE);
565
+ const overridePath = path14.join(getDataDir2(), VERSION_OVERRIDE_FILE);
566
566
  if (fs4.existsSync(overridePath)) {
567
567
  try {
568
568
  const content = JSON.parse(fs4.readFileSync(overridePath, "utf-8"));
@@ -579,7 +579,7 @@ function getElectronAppVersionSource() {
579
579
  if (envVersion && /^\d+\.\d+\.\d+$/.test(envVersion)) {
580
580
  return "env";
581
581
  }
582
- const overridePath = path13.join(getDataDir2(), VERSION_OVERRIDE_FILE);
582
+ const overridePath = path14.join(getDataDir2(), VERSION_OVERRIDE_FILE);
583
583
  if (fs4.existsSync(overridePath)) {
584
584
  try {
585
585
  const content = JSON.parse(fs4.readFileSync(overridePath, "utf-8"));
@@ -626,7 +626,7 @@ function isElectronAppInstalled() {
626
626
  }
627
627
  function getElectronAppDir(version) {
628
628
  const resolvedVersion = version ?? getElectronAppVersion();
629
- return path13.join(
629
+ return path14.join(
630
630
  getDataDir2(),
631
631
  ELECTRON_APP_DIR,
632
632
  buildElectronAppDirName({
@@ -666,8 +666,8 @@ function getLogger() {
666
666
  return loggerInstance;
667
667
  }
668
668
  function createChildLogger(correlationId) {
669
- const logger6 = getLogger();
670
- return logger6.child({ correlationId });
669
+ const logger7 = getLogger();
670
+ return logger7.child({ correlationId });
671
671
  }
672
672
  function resetLogger() {
673
673
  loggerInstance = null;
@@ -707,7 +707,7 @@ async function calculateFileChecksum(filePath) {
707
707
  async function verifyFileChecksum(filePath, expectedChecksum) {
708
708
  if (!expectedChecksum || expectedChecksum.trim() === "") {
709
709
  logger.warn("Checksum verification skipped - no checksum provided", {
710
- file: path13.basename(filePath)
710
+ file: path14.basename(filePath)
711
711
  });
712
712
  return {
713
713
  valid: true,
@@ -723,13 +723,13 @@ async function verifyFileChecksum(filePath, expectedChecksum) {
723
723
  const valid = normalizedExpected === normalizedActual;
724
724
  if (!valid) {
725
725
  logger.error("Checksum verification failed", {
726
- file: path13.basename(filePath),
726
+ file: path14.basename(filePath),
727
727
  expected: normalizedExpected,
728
728
  actual: normalizedActual
729
729
  });
730
730
  } else {
731
731
  logger.info("Checksum verified successfully", {
732
- file: path13.basename(filePath),
732
+ file: path14.basename(filePath),
733
733
  checksum: normalizedActual
734
734
  });
735
735
  }
@@ -742,7 +742,7 @@ async function verifyFileChecksum(filePath, expectedChecksum) {
742
742
  } catch (error) {
743
743
  const errorMessage = error instanceof Error ? error.message : String(error);
744
744
  logger.error("Checksum calculation failed", {
745
- file: path13.basename(filePath),
745
+ file: path14.basename(filePath),
746
746
  error: errorMessage
747
747
  });
748
748
  return {
@@ -917,14 +917,14 @@ var StorageService = class {
917
917
  * Ensure the base directories exist.
918
918
  */
919
919
  ensureDirectories() {
920
- const logger6 = getLogger();
920
+ const logger7 = getLogger();
921
921
  if (!fs4.existsSync(this.dataDir)) {
922
922
  fs4.mkdirSync(this.dataDir, { recursive: true });
923
- logger6.info("Created data directory", { path: this.dataDir });
923
+ logger7.info("Created data directory", { path: this.dataDir });
924
924
  }
925
925
  if (!fs4.existsSync(this.sessionsDir)) {
926
926
  fs4.mkdirSync(this.sessionsDir, { recursive: true });
927
- logger6.info("Created sessions directory", { path: this.sessionsDir });
927
+ logger7.info("Created sessions directory", { path: this.sessionsDir });
928
928
  }
929
929
  }
930
930
  /**
@@ -933,14 +933,14 @@ var StorageService = class {
933
933
  * @returns Path to the session directory.
934
934
  */
935
935
  createSessionDirectory(sessionId) {
936
- const logger6 = getLogger();
936
+ const logger7 = getLogger();
937
937
  this.ensureDirectories();
938
- const sessionDir = path13.join(this.sessionsDir, sessionId);
938
+ const sessionDir = path14.join(this.sessionsDir, sessionId);
939
939
  if (!fs4.existsSync(sessionDir)) {
940
940
  fs4.mkdirSync(sessionDir, { recursive: true });
941
- fs4.mkdirSync(path13.join(sessionDir, "screenshots"), { recursive: true });
942
- fs4.mkdirSync(path13.join(sessionDir, "logs"), { recursive: true });
943
- logger6.info("Created session directory", { sessionId, path: sessionDir });
941
+ fs4.mkdirSync(path14.join(sessionDir, "screenshots"), { recursive: true });
942
+ fs4.mkdirSync(path14.join(sessionDir, "logs"), { recursive: true });
943
+ logger7.info("Created session directory", { sessionId, path: sessionDir });
944
944
  }
945
945
  return sessionDir;
946
946
  }
@@ -949,11 +949,11 @@ var StorageService = class {
949
949
  * @param metadata - Session metadata to save.
950
950
  */
951
951
  saveSessionMetadata(metadata) {
952
- const logger6 = getLogger();
952
+ const logger7 = getLogger();
953
953
  const sessionDir = this.createSessionDirectory(metadata.sessionId);
954
- const metadataPath = path13.join(sessionDir, "metadata.json");
954
+ const metadataPath = path14.join(sessionDir, "metadata.json");
955
955
  fs4.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2), "utf-8");
956
- logger6.debug("Saved session metadata", { sessionId: metadata.sessionId });
956
+ logger7.debug("Saved session metadata", { sessionId: metadata.sessionId });
957
957
  }
958
958
  /**
959
959
  * Load session metadata.
@@ -961,8 +961,8 @@ var StorageService = class {
961
961
  * @returns Session metadata, or null if not found.
962
962
  */
963
963
  loadSessionMetadata(sessionId) {
964
- const logger6 = getLogger();
965
- const metadataPath = path13.join(this.sessionsDir, sessionId, "metadata.json");
964
+ const logger7 = getLogger();
965
+ const metadataPath = path14.join(this.sessionsDir, sessionId, "metadata.json");
966
966
  if (!fs4.existsSync(metadataPath)) {
967
967
  return null;
968
968
  }
@@ -970,7 +970,7 @@ var StorageService = class {
970
970
  const content = fs4.readFileSync(metadataPath, "utf-8");
971
971
  return JSON.parse(content);
972
972
  } catch (error) {
973
- logger6.error("Failed to load session metadata", {
973
+ logger7.error("Failed to load session metadata", {
974
974
  sessionId,
975
975
  error: error instanceof Error ? error.message : String(error)
976
976
  });
@@ -986,7 +986,7 @@ var StorageService = class {
986
986
  return [];
987
987
  }
988
988
  return fs4.readdirSync(this.sessionsDir).filter((entry) => {
989
- const entryPath = path13.join(this.sessionsDir, entry);
989
+ const entryPath = path14.join(this.sessionsDir, entry);
990
990
  return fs4.statSync(entryPath).isDirectory();
991
991
  });
992
992
  }
@@ -995,13 +995,13 @@ var StorageService = class {
995
995
  * @returns Current session ID, or null.
996
996
  */
997
997
  getCurrentSessionId() {
998
- const currentPath = path13.join(this.sessionsDir, "current");
998
+ const currentPath = path14.join(this.sessionsDir, "current");
999
999
  if (!fs4.existsSync(currentPath)) {
1000
1000
  return null;
1001
1001
  }
1002
1002
  try {
1003
1003
  const target = fs4.readlinkSync(currentPath);
1004
- return path13.basename(target);
1004
+ return path14.basename(target);
1005
1005
  } catch {
1006
1006
  return null;
1007
1007
  }
@@ -1011,14 +1011,14 @@ var StorageService = class {
1011
1011
  * @param sessionId - Session ID to set as current.
1012
1012
  */
1013
1013
  setCurrentSession(sessionId) {
1014
- const logger6 = getLogger();
1015
- const currentPath = path13.join(this.sessionsDir, "current");
1016
- const targetPath = path13.join(this.sessionsDir, sessionId);
1014
+ const logger7 = getLogger();
1015
+ const currentPath = path14.join(this.sessionsDir, "current");
1016
+ const targetPath = path14.join(this.sessionsDir, sessionId);
1017
1017
  if (fs4.existsSync(currentPath)) {
1018
1018
  fs4.unlinkSync(currentPath);
1019
1019
  }
1020
1020
  fs4.symlinkSync(targetPath, currentPath);
1021
- logger6.info("Set current session", { sessionId });
1021
+ logger7.info("Set current session", { sessionId });
1022
1022
  }
1023
1023
  /**
1024
1024
  * Save a screenshot to the session directory.
@@ -1026,11 +1026,11 @@ var StorageService = class {
1026
1026
  */
1027
1027
  saveScreenshot(params) {
1028
1028
  const { sessionId, filename, data } = params;
1029
- const logger6 = getLogger();
1029
+ const logger7 = getLogger();
1030
1030
  const sessionDir = this.createSessionDirectory(sessionId);
1031
- const screenshotPath = path13.join(sessionDir, "screenshots", filename);
1031
+ const screenshotPath = path14.join(sessionDir, "screenshots", filename);
1032
1032
  fs4.writeFileSync(screenshotPath, data);
1033
- logger6.debug("Saved screenshot", { sessionId, filename });
1033
+ logger7.debug("Saved screenshot", { sessionId, filename });
1034
1034
  return screenshotPath;
1035
1035
  }
1036
1036
  /**
@@ -1039,11 +1039,11 @@ var StorageService = class {
1039
1039
  */
1040
1040
  appendToResults(params) {
1041
1041
  const { sessionId, content } = params;
1042
- const logger6 = getLogger();
1042
+ const logger7 = getLogger();
1043
1043
  const sessionDir = this.createSessionDirectory(sessionId);
1044
- const resultsPath = path13.join(sessionDir, "results.md");
1044
+ const resultsPath = path14.join(sessionDir, "results.md");
1045
1045
  fs4.appendFileSync(resultsPath, content + "\n", "utf-8");
1046
- logger6.debug("Appended to results", { sessionId });
1046
+ logger7.debug("Appended to results", { sessionId });
1047
1047
  }
1048
1048
  /**
1049
1049
  * Get the results markdown content.
@@ -1051,7 +1051,7 @@ var StorageService = class {
1051
1051
  * @returns Results content, or null if not found.
1052
1052
  */
1053
1053
  getResults(sessionId) {
1054
- const resultsPath = path13.join(this.sessionsDir, sessionId, "results.md");
1054
+ const resultsPath = path14.join(this.sessionsDir, sessionId, "results.md");
1055
1055
  if (!fs4.existsSync(resultsPath)) {
1056
1056
  return null;
1057
1057
  }
@@ -1078,7 +1078,7 @@ var StorageService = class {
1078
1078
  */
1079
1079
  createSession(params) {
1080
1080
  const { sessionId, targetUrl, testInstructions } = params;
1081
- const logger6 = getLogger();
1081
+ const logger7 = getLogger();
1082
1082
  const sessionDir = this.createSessionDirectory(sessionId);
1083
1083
  const metadata = {
1084
1084
  sessionId,
@@ -1090,7 +1090,7 @@ var StorageService = class {
1090
1090
  };
1091
1091
  this.saveSessionMetadata(metadata);
1092
1092
  this.setCurrentSession(sessionId);
1093
- logger6.info("Created session", { sessionId, targetUrl });
1093
+ logger7.info("Created session", { sessionId, targetUrl });
1094
1094
  return sessionDir;
1095
1095
  }
1096
1096
  /**
@@ -1099,10 +1099,10 @@ var StorageService = class {
1099
1099
  */
1100
1100
  updateSessionStatus(params) {
1101
1101
  const { sessionId, status } = params;
1102
- const logger6 = getLogger();
1102
+ const logger7 = getLogger();
1103
1103
  const metadata = this.loadSessionMetadata(sessionId);
1104
1104
  if (!metadata) {
1105
- logger6.warn("Session not found for status update", { sessionId });
1105
+ logger7.warn("Session not found for status update", { sessionId });
1106
1106
  return;
1107
1107
  }
1108
1108
  metadata.status = status;
@@ -1110,7 +1110,7 @@ var StorageService = class {
1110
1110
  metadata.endTime = (/* @__PURE__ */ new Date()).toISOString();
1111
1111
  }
1112
1112
  this.saveSessionMetadata(metadata);
1113
- logger6.debug("Updated session status", { sessionId, status });
1113
+ logger7.debug("Updated session status", { sessionId, status });
1114
1114
  }
1115
1115
  /**
1116
1116
  * Initialize the results.md file with a header.
@@ -1118,9 +1118,9 @@ var StorageService = class {
1118
1118
  */
1119
1119
  initializeResults(params) {
1120
1120
  const { sessionId, targetUrl, testInstructions } = params;
1121
- const logger6 = getLogger();
1121
+ const logger7 = getLogger();
1122
1122
  const sessionDir = this.createSessionDirectory(sessionId);
1123
- const resultsPath = path13.join(sessionDir, "results.md");
1123
+ const resultsPath = path14.join(sessionDir, "results.md");
1124
1124
  const header = [
1125
1125
  `# Test Results: ${sessionId}`,
1126
1126
  "",
@@ -1134,7 +1134,7 @@ var StorageService = class {
1134
1134
  ""
1135
1135
  ].join("\n");
1136
1136
  fs4.writeFileSync(resultsPath, header, "utf-8");
1137
- logger6.debug("Initialized results.md", { sessionId });
1137
+ logger7.debug("Initialized results.md", { sessionId });
1138
1138
  }
1139
1139
  /**
1140
1140
  * Append a test step to the results.md file.
@@ -1142,9 +1142,9 @@ var StorageService = class {
1142
1142
  */
1143
1143
  appendStepToResults(params) {
1144
1144
  const { sessionId, step } = params;
1145
- const logger6 = getLogger();
1145
+ const logger7 = getLogger();
1146
1146
  const sessionDir = this.createSessionDirectory(sessionId);
1147
- const resultsPath = path13.join(sessionDir, "results.md");
1147
+ const resultsPath = path14.join(sessionDir, "results.md");
1148
1148
  const statusIcon = step.success ? "\u2713" : "\u2717";
1149
1149
  const stepContent = [
1150
1150
  `### Step ${step.stepNumber}: ${step.action}`,
@@ -1155,7 +1155,7 @@ var StorageService = class {
1155
1155
  ""
1156
1156
  ].filter(Boolean).join("\n");
1157
1157
  fs4.appendFileSync(resultsPath, stepContent + "\n", "utf-8");
1158
- logger6.debug("Appended step to results", { sessionId, stepNumber: step.stepNumber });
1158
+ logger7.debug("Appended step to results", { sessionId, stepNumber: step.stepNumber });
1159
1159
  const metadata = this.loadSessionMetadata(sessionId);
1160
1160
  if (metadata) {
1161
1161
  metadata.stepsCount = (metadata.stepsCount ?? 0) + 1;
@@ -1168,11 +1168,11 @@ var StorageService = class {
1168
1168
  */
1169
1169
  finalizeResults(params) {
1170
1170
  const { sessionId, status, summary } = params;
1171
- const logger6 = getLogger();
1172
- const sessionDir = path13.join(this.sessionsDir, sessionId);
1173
- const resultsPath = path13.join(sessionDir, "results.md");
1171
+ const logger7 = getLogger();
1172
+ const sessionDir = path14.join(this.sessionsDir, sessionId);
1173
+ const resultsPath = path14.join(sessionDir, "results.md");
1174
1174
  if (!fs4.existsSync(resultsPath)) {
1175
- logger6.warn("Results file not found for finalization", { sessionId });
1175
+ logger7.warn("Results file not found for finalization", { sessionId });
1176
1176
  return;
1177
1177
  }
1178
1178
  const metadata = this.loadSessionMetadata(sessionId);
@@ -1195,7 +1195,7 @@ var StorageService = class {
1195
1195
  summary ? summary : ""
1196
1196
  ].join("\n");
1197
1197
  fs4.appendFileSync(resultsPath, footer, "utf-8");
1198
- logger6.debug("Finalized results.md", { sessionId, status });
1198
+ logger7.debug("Finalized results.md", { sessionId, status });
1199
1199
  if (metadata) {
1200
1200
  metadata.durationMs = durationMs;
1201
1201
  metadata.endTime = endTime.toISOString();
@@ -1237,7 +1237,7 @@ var StorageService = class {
1237
1237
  */
1238
1238
  cleanupOldSessions(params) {
1239
1239
  const maxAgeDays = params?.maxAgeDays ?? DEFAULT_SESSION_MAX_AGE_DAYS;
1240
- const logger6 = getLogger();
1240
+ const logger7 = getLogger();
1241
1241
  const cutoffDate = /* @__PURE__ */ new Date();
1242
1242
  cutoffDate.setDate(cutoffDate.getDate() - maxAgeDays);
1243
1243
  const sessionIds = this.listSessions();
@@ -1252,16 +1252,16 @@ var StorageService = class {
1252
1252
  }
1253
1253
  const sessionDate = new Date(metadata.startTime);
1254
1254
  if (sessionDate < cutoffDate) {
1255
- const sessionDir = path13.join(this.sessionsDir, sessionId);
1255
+ const sessionDir = path14.join(this.sessionsDir, sessionId);
1256
1256
  try {
1257
1257
  fs4.rmSync(sessionDir, { recursive: true, force: true });
1258
1258
  deletedCount++;
1259
- logger6.info("Deleted old session", {
1259
+ logger7.info("Deleted old session", {
1260
1260
  sessionId,
1261
1261
  age: Math.floor((Date.now() - sessionDate.getTime()) / (1e3 * 60 * 60 * 24))
1262
1262
  });
1263
1263
  } catch (error) {
1264
- logger6.error("Failed to delete session", {
1264
+ logger7.error("Failed to delete session", {
1265
1265
  sessionId,
1266
1266
  error: error instanceof Error ? error.message : String(error)
1267
1267
  });
@@ -1269,7 +1269,7 @@ var StorageService = class {
1269
1269
  }
1270
1270
  }
1271
1271
  if (deletedCount > 0) {
1272
- logger6.info("Session cleanup completed", {
1272
+ logger7.info("Session cleanup completed", {
1273
1273
  deletedCount,
1274
1274
  maxAgeDays
1275
1275
  });
@@ -1282,7 +1282,7 @@ var StorageService = class {
1282
1282
  * @returns Session directory path.
1283
1283
  */
1284
1284
  getSessionPath(sessionId) {
1285
- return path13.join(this.sessionsDir, sessionId);
1285
+ return path14.join(this.sessionsDir, sessionId);
1286
1286
  }
1287
1287
  /**
1288
1288
  * Delete a specific session.
@@ -1290,25 +1290,25 @@ var StorageService = class {
1290
1290
  * @returns Whether deletion succeeded.
1291
1291
  */
1292
1292
  deleteSession(sessionId) {
1293
- const logger6 = getLogger();
1294
- const sessionDir = path13.join(this.sessionsDir, sessionId);
1293
+ const logger7 = getLogger();
1294
+ const sessionDir = path14.join(this.sessionsDir, sessionId);
1295
1295
  if (!fs4.existsSync(sessionDir)) {
1296
- logger6.warn("Session not found for deletion", { sessionId });
1296
+ logger7.warn("Session not found for deletion", { sessionId });
1297
1297
  return false;
1298
1298
  }
1299
1299
  try {
1300
1300
  const currentId = this.getCurrentSessionId();
1301
1301
  if (currentId === sessionId) {
1302
- const currentPath = path13.join(this.sessionsDir, "current");
1302
+ const currentPath = path14.join(this.sessionsDir, "current");
1303
1303
  if (fs4.existsSync(currentPath)) {
1304
1304
  fs4.unlinkSync(currentPath);
1305
1305
  }
1306
1306
  }
1307
1307
  fs4.rmSync(sessionDir, { recursive: true, force: true });
1308
- logger6.info("Deleted session", { sessionId });
1308
+ logger7.info("Deleted session", { sessionId });
1309
1309
  return true;
1310
1310
  } catch (error) {
1311
- logger6.error("Failed to delete session", {
1311
+ logger7.error("Failed to delete session", {
1312
1312
  sessionId,
1313
1313
  error: error instanceof Error ? error.message : String(error)
1314
1314
  });
@@ -1335,8 +1335,8 @@ var RunResultStorageService = class {
1335
1335
  constructor() {
1336
1336
  const storageService = getStorageService();
1337
1337
  const dataDir = storageService.getDataDir();
1338
- this.runResultsDir = path13.join(dataDir, "run-results");
1339
- this.testScriptsDir = path13.join(dataDir, "test-scripts");
1338
+ this.runResultsDir = path14.join(dataDir, "run-results");
1339
+ this.testScriptsDir = path14.join(dataDir, "test-scripts");
1340
1340
  this.ensureDirectories();
1341
1341
  }
1342
1342
  /**
@@ -1362,7 +1362,7 @@ var RunResultStorageService = class {
1362
1362
  const results = [];
1363
1363
  for (const file of files) {
1364
1364
  try {
1365
- const content = fs4.readFileSync(path13.join(this.runResultsDir, file), "utf-8");
1365
+ const content = fs4.readFileSync(path14.join(this.runResultsDir, file), "utf-8");
1366
1366
  results.push(JSON.parse(content));
1367
1367
  } catch {
1368
1368
  logger3.warn("Failed to read run result file", { file });
@@ -1377,7 +1377,7 @@ var RunResultStorageService = class {
1377
1377
  * Get a run result by ID.
1378
1378
  */
1379
1379
  getRunResult(runId) {
1380
- const filePath = path13.join(this.runResultsDir, `${runId}.json`);
1380
+ const filePath = path14.join(this.runResultsDir, `${runId}.json`);
1381
1381
  if (!fs4.existsSync(filePath)) {
1382
1382
  return void 0;
1383
1383
  }
@@ -1392,7 +1392,7 @@ var RunResultStorageService = class {
1392
1392
  * Save a run result.
1393
1393
  */
1394
1394
  saveRunResult(result) {
1395
- const filePath = path13.join(this.runResultsDir, `${result.id}.json`);
1395
+ const filePath = path14.join(this.runResultsDir, `${result.id}.json`);
1396
1396
  fs4.writeFileSync(filePath, JSON.stringify(result, null, 2));
1397
1397
  }
1398
1398
  /**
@@ -1445,7 +1445,7 @@ var RunResultStorageService = class {
1445
1445
  const scripts = [];
1446
1446
  for (const file of files) {
1447
1447
  try {
1448
- const content = fs4.readFileSync(path13.join(this.testScriptsDir, file), "utf-8");
1448
+ const content = fs4.readFileSync(path14.join(this.testScriptsDir, file), "utf-8");
1449
1449
  scripts.push(JSON.parse(content));
1450
1450
  } catch {
1451
1451
  logger3.warn("Failed to read test script file", { file });
@@ -1460,7 +1460,7 @@ var RunResultStorageService = class {
1460
1460
  * Get a test script by ID.
1461
1461
  */
1462
1462
  getTestScript(testScriptId) {
1463
- const filePath = path13.join(this.testScriptsDir, `${testScriptId}.json`);
1463
+ const filePath = path14.join(this.testScriptsDir, `${testScriptId}.json`);
1464
1464
  if (!fs4.existsSync(filePath)) {
1465
1465
  return void 0;
1466
1466
  }
@@ -1475,7 +1475,7 @@ var RunResultStorageService = class {
1475
1475
  * Save a test script.
1476
1476
  */
1477
1477
  saveTestScript(script) {
1478
- const filePath = path13.join(this.testScriptsDir, `${script.id}.json`);
1478
+ const filePath = path14.join(this.testScriptsDir, `${script.id}.json`);
1479
1479
  fs4.writeFileSync(filePath, JSON.stringify(script, null, 2));
1480
1480
  }
1481
1481
  /**
@@ -1527,7 +1527,7 @@ function resetRunResultStorageService() {
1527
1527
 
1528
1528
  // packages/mcps/src/mcp/local/services/run-view/read-run-view.ts
1529
1529
  function getRunSessionsDir() {
1530
- return path13.join(getDataDir(), RUN_SESSIONS_DIR_NAME);
1530
+ return path14.join(getDataDir(), RUN_SESSIONS_DIR_NAME);
1531
1531
  }
1532
1532
  var RunViewError = class extends Error {
1533
1533
  };
@@ -1544,16 +1544,16 @@ function resolveRunSessionPath(runId) {
1544
1544
  throw new RunViewError(`No runs found under ${sessionsDir}`);
1545
1545
  }
1546
1546
  if (!runId) {
1547
- const newest = names.map((name) => ({ name, modifiedAtMs: fs4.statSync(path13.join(sessionsDir, name)).mtimeMs })).sort((left, right) => right.modifiedAtMs - left.modifiedAtMs)[0];
1548
- return path13.join(sessionsDir, newest.name);
1547
+ const newest = names.map((name) => ({ name, modifiedAtMs: fs4.statSync(path14.join(sessionsDir, name)).mtimeMs })).sort((left, right) => right.modifiedAtMs - left.modifiedAtMs)[0];
1548
+ return path14.join(sessionsDir, newest.name);
1549
1549
  }
1550
1550
  const exact = names.find((name) => name === runId);
1551
1551
  if (exact) {
1552
- return path13.join(sessionsDir, exact);
1552
+ return path14.join(sessionsDir, exact);
1553
1553
  }
1554
1554
  const prefixed = names.filter((name) => name.startsWith(runId));
1555
1555
  if (prefixed.length === 1) {
1556
- return path13.join(sessionsDir, prefixed[0]);
1556
+ return path14.join(sessionsDir, prefixed[0]);
1557
1557
  }
1558
1558
  if (prefixed.length > 1) {
1559
1559
  throw new RunViewError(
@@ -1563,7 +1563,7 @@ function resolveRunSessionPath(runId) {
1563
1563
  throw new RunViewError(`No run matching "${runId}" under ${sessionsDir}`);
1564
1564
  }
1565
1565
  var listScreenshotFileNames = (sessionPath) => {
1566
- const screenshotDir = path13.join(sessionPath, ...SCREENSHOT_DIR_RELATIVE_PATH.split("/"));
1566
+ const screenshotDir = path14.join(sessionPath, ...SCREENSHOT_DIR_RELATIVE_PATH.split("/"));
1567
1567
  if (!fs4.existsSync(screenshotDir)) {
1568
1568
  return [];
1569
1569
  }
@@ -1578,14 +1578,14 @@ var resolveScreenshotPath = (sessionPath, screenshotFileNames, recordedPath) =>
1578
1578
  return null;
1579
1579
  }
1580
1580
  const match = screenshotFileNames.find((name) => name === recordedName) ?? screenshotFileNames.find((name) => name.endsWith(recordedName));
1581
- return match ? path13.join(sessionPath, ...SCREENSHOT_DIR_RELATIVE_PATH.split("/"), match) : null;
1581
+ return match ? path14.join(sessionPath, ...SCREENSHOT_DIR_RELATIVE_PATH.split("/"), match) : null;
1582
1582
  };
1583
1583
  function readRunView(runId) {
1584
1584
  const sessionPath = resolveRunSessionPath(runId);
1585
- const actionScriptPath = path13.join(sessionPath, ACTION_SCRIPT_FILE_NAME);
1585
+ const actionScriptPath = path14.join(sessionPath, ACTION_SCRIPT_FILE_NAME);
1586
1586
  if (!fs4.existsSync(actionScriptPath)) {
1587
1587
  throw new RunViewError(
1588
- `Run ${path13.basename(sessionPath)} has no ${ACTION_SCRIPT_FILE_NAME} \u2014 it died before writing one. Looked in ${sessionPath}`
1588
+ `Run ${path14.basename(sessionPath)} has no ${ACTION_SCRIPT_FILE_NAME} \u2014 it died before writing one. Looked in ${sessionPath}`
1589
1589
  );
1590
1590
  }
1591
1591
  let actionScript;
@@ -1596,7 +1596,7 @@ function readRunView(runId) {
1596
1596
  `Could not read ${actionScriptPath}: ${parseError instanceof Error ? parseError.message : String(parseError)}`
1597
1597
  );
1598
1598
  }
1599
- const resolvedRunId = path13.basename(sessionPath);
1599
+ const resolvedRunId = path14.basename(sessionPath);
1600
1600
  const recordedOutcome = getRunResultStorageService().getRunResult(resolvedRunId)?.status ?? null;
1601
1601
  const screenshotFileNames = listScreenshotFileNames(sessionPath);
1602
1602
  const steps = (actionScript.steps ?? []).map((step, index) => ({
@@ -1714,13 +1714,13 @@ ${runView.steps.map(renderStep).join("\n")}
1714
1714
  function writeRunViewHtml(runView, outputDir) {
1715
1715
  const targetDir = outputDir ?? process.cwd();
1716
1716
  fs4.mkdirSync(targetDir, { recursive: true });
1717
- const targetPath = path13.join(targetDir, `run-${runView.runId}.html`);
1717
+ const targetPath = path14.join(targetDir, `run-${runView.runId}.html`);
1718
1718
  fs4.writeFileSync(targetPath, renderRunViewHtml(runView), "utf8");
1719
1719
  return targetPath;
1720
1720
  }
1721
1721
  var API_KEY_FILE2 = "api-key.json";
1722
1722
  function getApiKeyFilePath() {
1723
- return path13.join(getDataDir(), API_KEY_FILE2);
1723
+ return path14.join(getDataDir(), API_KEY_FILE2);
1724
1724
  }
1725
1725
  function ensureDataDir() {
1726
1726
  const dataDir = getDataDir();
@@ -1729,48 +1729,48 @@ function ensureDataDir() {
1729
1729
  }
1730
1730
  }
1731
1731
  function loadApiKeyData() {
1732
- const logger6 = getLogger();
1732
+ const logger7 = getLogger();
1733
1733
  const apiKeyPath = getApiKeyFilePath();
1734
1734
  try {
1735
1735
  if (!fs4.existsSync(apiKeyPath)) {
1736
- logger6.debug("No API key file found", { path: apiKeyPath });
1736
+ logger7.debug("No API key file found", { path: apiKeyPath });
1737
1737
  return null;
1738
1738
  }
1739
1739
  const content = fs4.readFileSync(apiKeyPath, "utf-8");
1740
1740
  const data = JSON.parse(content);
1741
1741
  return data;
1742
1742
  } catch (error) {
1743
- logger6.warn("Failed to load API key data", {
1743
+ logger7.warn("Failed to load API key data", {
1744
1744
  error: error instanceof Error ? error.message : String(error)
1745
1745
  });
1746
1746
  return null;
1747
1747
  }
1748
1748
  }
1749
1749
  function saveApiKeyData(data) {
1750
- const logger6 = getLogger();
1750
+ const logger7 = getLogger();
1751
1751
  const apiKeyPath = getApiKeyFilePath();
1752
1752
  try {
1753
1753
  ensureDataDir();
1754
1754
  const content = JSON.stringify(data, null, 2);
1755
1755
  fs4.writeFileSync(apiKeyPath, content, { mode: 384 });
1756
- logger6.info("API key saved", { path: apiKeyPath });
1756
+ logger7.info("API key saved", { path: apiKeyPath });
1757
1757
  } catch (error) {
1758
- logger6.error("Failed to save API key", {
1758
+ logger7.error("Failed to save API key", {
1759
1759
  error: error instanceof Error ? error.message : String(error)
1760
1760
  });
1761
1761
  throw error;
1762
1762
  }
1763
1763
  }
1764
1764
  function deleteApiKeyData() {
1765
- const logger6 = getLogger();
1765
+ const logger7 = getLogger();
1766
1766
  const apiKeyPath = getApiKeyFilePath();
1767
1767
  try {
1768
1768
  if (fs4.existsSync(apiKeyPath)) {
1769
1769
  fs4.unlinkSync(apiKeyPath);
1770
- logger6.info("API key deleted", { path: apiKeyPath });
1770
+ logger7.info("API key deleted", { path: apiKeyPath });
1771
1771
  }
1772
1772
  } catch (error) {
1773
- logger6.warn("Failed to delete API key", {
1773
+ logger7.warn("Failed to delete API key", {
1774
1774
  error: error instanceof Error ? error.message : String(error)
1775
1775
  });
1776
1776
  }
@@ -1794,7 +1794,7 @@ function getApiKey() {
1794
1794
  return data?.apiKey ?? null;
1795
1795
  }
1796
1796
  function saveApiKey(params) {
1797
- const logger6 = getLogger();
1797
+ const logger7 = getLogger();
1798
1798
  const apiKeyPath = getApiKeyFilePath();
1799
1799
  try {
1800
1800
  ensureDataDir();
@@ -1806,9 +1806,9 @@ function saveApiKey(params) {
1806
1806
  };
1807
1807
  const content = JSON.stringify(data, null, 2);
1808
1808
  fs4.writeFileSync(apiKeyPath, content, { mode: 384 });
1809
- logger6.info("API key saved", { path: apiKeyPath });
1809
+ logger7.info("API key saved", { path: apiKeyPath });
1810
1810
  } catch (error) {
1811
- logger6.error("Failed to save API key", {
1811
+ logger7.error("Failed to save API key", {
1812
1812
  error: error instanceof Error ? error.message : String(error)
1813
1813
  });
1814
1814
  throw error;
@@ -1871,8 +1871,8 @@ var AuthService = class {
1871
1871
  constructor() {
1872
1872
  const config = getConfig();
1873
1873
  this.oauthSessionFilePath = config.localQa.oauthSessionFilePath;
1874
- this.pendingDeviceCodePath = path13.join(
1875
- path13.dirname(config.localQa.oauthSessionFilePath),
1874
+ this.pendingDeviceCodePath = path14.join(
1875
+ path14.dirname(config.localQa.oauthSessionFilePath),
1876
1876
  "pending-device-code.json"
1877
1877
  );
1878
1878
  }
@@ -1880,16 +1880,16 @@ var AuthService = class {
1880
1880
  * Get current authentication status.
1881
1881
  */
1882
1882
  getAuthStatus() {
1883
- const logger6 = getLogger();
1883
+ const logger7 = getLogger();
1884
1884
  const storedAuth = this.loadStoredAuth();
1885
1885
  if (!storedAuth) {
1886
- logger6.debug("No stored auth found");
1886
+ logger7.debug("No stored auth found");
1887
1887
  return { authenticated: false };
1888
1888
  }
1889
1889
  const now = /* @__PURE__ */ new Date();
1890
1890
  const expiresAt = new Date(storedAuth.expiresAt);
1891
1891
  const isExpired = now >= expiresAt;
1892
- logger6.debug("Auth status checked", {
1892
+ logger7.debug("Auth status checked", {
1893
1893
  email: storedAuth.email,
1894
1894
  isExpired,
1895
1895
  expiresAt: storedAuth.expiresAt
@@ -1907,10 +1907,10 @@ var AuthService = class {
1907
1907
  * @param options.forceNewSession - Clear existing Auth0 browser session before login to allow account switching.
1908
1908
  */
1909
1909
  async startDeviceCodeFlow(options) {
1910
- const logger6 = getLogger();
1910
+ const logger7 = getLogger();
1911
1911
  const config = getConfig();
1912
1912
  const { domain, clientId, audience, scopes } = config.localQa.auth0;
1913
- logger6.info("Starting device code flow");
1913
+ logger7.info("Starting device code flow");
1914
1914
  const url = `https://${domain}/oauth/device/code`;
1915
1915
  const body = new URLSearchParams({
1916
1916
  client_id: clientId,
@@ -1926,14 +1926,14 @@ var AuthService = class {
1926
1926
  });
1927
1927
  if (!response.ok) {
1928
1928
  const errorText = await response.text();
1929
- logger6.error("Device code request failed", {
1929
+ logger7.error("Device code request failed", {
1930
1930
  status: response.status,
1931
1931
  error: errorText
1932
1932
  });
1933
1933
  throw new Error(`Failed to start device code flow: ${response.status} ${errorText}`);
1934
1934
  }
1935
1935
  const deviceCodeResponse = await response.json();
1936
- logger6.info("Device code flow started", {
1936
+ logger7.info("Device code flow started", {
1937
1937
  userCode: deviceCodeResponse.user_code,
1938
1938
  verificationUri: deviceCodeResponse.verification_uri,
1939
1939
  expiresIn: deviceCodeResponse.expires_in
@@ -1950,7 +1950,7 @@ var AuthService = class {
1950
1950
  logoutUrl.searchParams.set("client_id", clientId);
1951
1951
  logoutUrl.searchParams.set("returnTo", deviceCodeResponse.verification_uri_complete);
1952
1952
  browserUrl = logoutUrl.toString();
1953
- logger6.info("Force new session: cleared local token, opening logout-redirect URL", {
1953
+ logger7.info("Force new session: cleared local token, opening logout-redirect URL", {
1954
1954
  logoutUrl: browserUrl
1955
1955
  });
1956
1956
  }
@@ -1958,9 +1958,9 @@ var AuthService = class {
1958
1958
  url: browserUrl
1959
1959
  });
1960
1960
  if (browserOpenResult.opened) {
1961
- logger6.info("Browser opened for device code login");
1961
+ logger7.info("Browser opened for device code login");
1962
1962
  } else {
1963
- logger6.warn("Failed to open browser for device code login", {
1963
+ logger7.warn("Failed to open browser for device code login", {
1964
1964
  error: browserOpenResult.error,
1965
1965
  url: browserUrl
1966
1966
  });
@@ -1980,8 +1980,8 @@ var AuthService = class {
1980
1980
  * Store a pending device code for later retrieval.
1981
1981
  */
1982
1982
  storePendingDeviceCode(params) {
1983
- const logger6 = getLogger();
1984
- const dir = path13.dirname(this.pendingDeviceCodePath);
1983
+ const logger7 = getLogger();
1984
+ const dir = path14.dirname(this.pendingDeviceCodePath);
1985
1985
  if (!fs4.existsSync(dir)) {
1986
1986
  fs4.mkdirSync(dir, { recursive: true });
1987
1987
  }
@@ -1989,15 +1989,15 @@ var AuthService = class {
1989
1989
  encoding: "utf-8",
1990
1990
  mode: 384
1991
1991
  });
1992
- logger6.debug("Pending device code stored", { userCode: params.userCode });
1992
+ logger7.debug("Pending device code stored", { userCode: params.userCode });
1993
1993
  }
1994
1994
  /**
1995
1995
  * Get the pending device code if one exists and is not expired.
1996
1996
  */
1997
1997
  getPendingDeviceCode() {
1998
- const logger6 = getLogger();
1998
+ const logger7 = getLogger();
1999
1999
  if (!fs4.existsSync(this.pendingDeviceCodePath)) {
2000
- logger6.debug("No pending device code found");
2000
+ logger7.debug("No pending device code found");
2001
2001
  return null;
2002
2002
  }
2003
2003
  try {
@@ -2006,13 +2006,13 @@ var AuthService = class {
2006
2006
  const now = /* @__PURE__ */ new Date();
2007
2007
  const expiresAt = new Date(pendingDeviceCodeData.expiresAt);
2008
2008
  if (now >= expiresAt) {
2009
- logger6.debug("Pending device code expired");
2009
+ logger7.debug("Pending device code expired");
2010
2010
  this.clearPendingDeviceCode();
2011
2011
  return null;
2012
2012
  }
2013
2013
  return pendingDeviceCodeData.deviceCode;
2014
2014
  } catch (error) {
2015
- logger6.warn("Failed to read pending device code", {
2015
+ logger7.warn("Failed to read pending device code", {
2016
2016
  error: error instanceof Error ? error.message : String(error)
2017
2017
  });
2018
2018
  return null;
@@ -2022,13 +2022,13 @@ var AuthService = class {
2022
2022
  * Clear the pending device code file.
2023
2023
  */
2024
2024
  clearPendingDeviceCode() {
2025
- const logger6 = getLogger();
2025
+ const logger7 = getLogger();
2026
2026
  if (fs4.existsSync(this.pendingDeviceCodePath)) {
2027
2027
  try {
2028
2028
  fs4.unlinkSync(this.pendingDeviceCodePath);
2029
- logger6.debug("Pending device code cleared");
2029
+ logger7.debug("Pending device code cleared");
2030
2030
  } catch (error) {
2031
- logger6.warn("Failed to clear pending device code", {
2031
+ logger7.warn("Failed to clear pending device code", {
2032
2032
  error: error instanceof Error ? error.message : String(error)
2033
2033
  });
2034
2034
  }
@@ -2038,10 +2038,10 @@ var AuthService = class {
2038
2038
  * Poll for device code authorization completion.
2039
2039
  */
2040
2040
  async pollDeviceCode(deviceCode) {
2041
- const logger6 = getLogger();
2041
+ const logger7 = getLogger();
2042
2042
  const config = getConfig();
2043
2043
  const { domain, clientId } = config.localQa.auth0;
2044
- logger6.debug("Polling for device code authorization");
2044
+ logger7.debug("Polling for device code authorization");
2045
2045
  const url = `https://${domain}/oauth/token`;
2046
2046
  const body = new URLSearchParams({
2047
2047
  grant_type: "urn:ietf:params:oauth:grant-type:device_code",
@@ -2071,7 +2071,7 @@ var AuthService = class {
2071
2071
  userId: userInfo.sub
2072
2072
  });
2073
2073
  this.clearPendingDeviceCode();
2074
- logger6.info("Device code authorization complete", { email: userInfo.email });
2074
+ logger7.info("Device code authorization complete", { email: userInfo.email });
2075
2075
  return {
2076
2076
  status: "complete" /* Complete */,
2077
2077
  message: "Authentication successful!",
@@ -2080,35 +2080,35 @@ var AuthService = class {
2080
2080
  }
2081
2081
  const errorData = await response.json();
2082
2082
  if (errorData.error === "authorization_pending") {
2083
- logger6.debug("Authorization pending");
2083
+ logger7.debug("Authorization pending");
2084
2084
  return {
2085
2085
  status: "pending" /* Pending */,
2086
2086
  message: "Waiting for user to complete authorization..."
2087
2087
  };
2088
2088
  }
2089
2089
  if (errorData.error === "slow_down") {
2090
- logger6.debug("Polling too fast");
2090
+ logger7.debug("Polling too fast");
2091
2091
  return {
2092
2092
  status: "pending" /* Pending */,
2093
2093
  message: "Polling too fast, slowing down..."
2094
2094
  };
2095
2095
  }
2096
2096
  if (errorData.error === "expired_token") {
2097
- logger6.warn("Device code expired");
2097
+ logger7.warn("Device code expired");
2098
2098
  return {
2099
2099
  status: "expired" /* Expired */,
2100
2100
  message: "The authorization code has expired. Please start again."
2101
2101
  };
2102
2102
  }
2103
2103
  if (errorData.error === "access_denied") {
2104
- logger6.warn("Access denied");
2104
+ logger7.warn("Access denied");
2105
2105
  return {
2106
2106
  status: "error" /* Error */,
2107
2107
  message: "Access was denied by the user.",
2108
2108
  error: errorData.error_description ?? errorData.error
2109
2109
  };
2110
2110
  }
2111
- logger6.error("Unexpected error during polling", { error: errorData });
2111
+ logger7.error("Unexpected error during polling", { error: errorData });
2112
2112
  return {
2113
2113
  status: "error" /* Error */,
2114
2114
  message: errorData.error_description ?? errorData.error,
@@ -2116,7 +2116,7 @@ var AuthService = class {
2116
2116
  };
2117
2117
  } catch (error) {
2118
2118
  const errorMessage = error instanceof Error ? error.message : String(error);
2119
- logger6.error("Poll request failed", { error: errorMessage });
2119
+ logger7.error("Poll request failed", { error: errorMessage });
2120
2120
  return {
2121
2121
  status: "error" /* Error */,
2122
2122
  message: `Poll request failed: ${errorMessage}`,
@@ -2128,11 +2128,11 @@ var AuthService = class {
2128
2128
  * Poll for device code authorization until completion or timeout.
2129
2129
  */
2130
2130
  async waitForDeviceCodeAuthorization(params) {
2131
- const logger6 = getLogger();
2131
+ const logger7 = getLogger();
2132
2132
  const timeoutMs = params.timeoutMs ?? DEFAULT_LOGIN_WAIT_TIMEOUT_MS;
2133
2133
  const pollIntervalMs = Math.max(params.intervalSeconds, 1) * 1e3;
2134
2134
  const startedAt = Date.now();
2135
- logger6.info("Waiting for device code authorization", {
2135
+ logger7.info("Waiting for device code authorization", {
2136
2136
  timeoutMs,
2137
2137
  pollIntervalMs
2138
2138
  });
@@ -2156,7 +2156,7 @@ var AuthService = class {
2156
2156
  * Get user info from Auth0.
2157
2157
  */
2158
2158
  async getUserInfo(accessToken) {
2159
- const logger6 = getLogger();
2159
+ const logger7 = getLogger();
2160
2160
  const config = getConfig();
2161
2161
  const { domain } = config.localQa.auth0;
2162
2162
  const url = `https://${domain}/userinfo`;
@@ -2168,13 +2168,13 @@ var AuthService = class {
2168
2168
  }
2169
2169
  });
2170
2170
  if (!response.ok) {
2171
- logger6.warn("Failed to get user info", { status: response.status });
2171
+ logger7.warn("Failed to get user info", { status: response.status });
2172
2172
  return {};
2173
2173
  }
2174
2174
  const userInfoData = await response.json();
2175
2175
  return userInfoData;
2176
2176
  } catch (error) {
2177
- logger6.warn("User info request failed", {
2177
+ logger7.warn("User info request failed", {
2178
2178
  error: error instanceof Error ? error.message : String(error)
2179
2179
  });
2180
2180
  return {};
@@ -2185,7 +2185,7 @@ var AuthService = class {
2185
2185
  */
2186
2186
  async storeAuth(params) {
2187
2187
  const { tokenResponse, email, userId } = params;
2188
- const logger6 = getLogger();
2188
+ const logger7 = getLogger();
2189
2189
  const expiresAt = new Date(Date.now() + tokenResponse.expiresIn * 1e3).toISOString();
2190
2190
  const storedAuth = {
2191
2191
  accessToken: tokenResponse.accessToken,
@@ -2195,7 +2195,7 @@ var AuthService = class {
2195
2195
  userId,
2196
2196
  runtimeTarget: getActiveRuntimeTarget()
2197
2197
  };
2198
- const dir = path13.dirname(this.oauthSessionFilePath);
2198
+ const dir = path14.dirname(this.oauthSessionFilePath);
2199
2199
  if (!fs4.existsSync(dir)) {
2200
2200
  fs4.mkdirSync(dir, { recursive: true });
2201
2201
  }
@@ -2203,14 +2203,14 @@ var AuthService = class {
2203
2203
  encoding: "utf-8",
2204
2204
  mode: 384
2205
2205
  });
2206
- logger6.info("Auth stored successfully", { email, expiresAt });
2206
+ logger7.info("Auth stored successfully", { email, expiresAt });
2207
2207
  }
2208
2208
  /**
2209
2209
  * Load stored authentication for the active runtime target.
2210
2210
  * @returns Stored auth, or null when it is absent, unreadable, or was issued for another target.
2211
2211
  */
2212
2212
  loadStoredAuth() {
2213
- const logger6 = getLogger();
2213
+ const logger7 = getLogger();
2214
2214
  if (!fs4.existsSync(this.oauthSessionFilePath)) {
2215
2215
  return null;
2216
2216
  }
@@ -2227,7 +2227,7 @@ var AuthService = class {
2227
2227
  tokenIssuer,
2228
2228
  expectedAuth0Domain
2229
2229
  })) {
2230
- logger6.warn("Ignoring stored auth issued for a different runtime target", {
2230
+ logger7.warn("Ignoring stored auth issued for a different runtime target", {
2231
2231
  storedRuntimeTarget: storedAuth.runtimeTarget ?? "unrecorded",
2232
2232
  activeRuntimeTarget,
2233
2233
  tokenIssuer: tokenIssuer ?? "undecodable",
@@ -2237,7 +2237,7 @@ var AuthService = class {
2237
2237
  }
2238
2238
  return storedAuth;
2239
2239
  } catch (error) {
2240
- logger6.error("Failed to load stored auth", {
2240
+ logger7.error("Failed to load stored auth", {
2241
2241
  error: error instanceof Error ? error.message : String(error)
2242
2242
  });
2243
2243
  return null;
@@ -2278,15 +2278,15 @@ var AuthService = class {
2278
2278
  * @returns New access token or null if refresh failed.
2279
2279
  */
2280
2280
  async refreshAccessToken() {
2281
- const logger6 = getLogger();
2281
+ const logger7 = getLogger();
2282
2282
  const storedAuth = this.loadStoredAuth();
2283
2283
  if (!storedAuth?.refreshToken) {
2284
- logger6.debug("No refresh token available");
2284
+ logger7.debug("No refresh token available");
2285
2285
  return null;
2286
2286
  }
2287
2287
  const config = getConfig();
2288
2288
  const { domain, clientId } = config.localQa.auth0;
2289
- logger6.info("Refreshing access token");
2289
+ logger7.info("Refreshing access token");
2290
2290
  const url = `https://${domain}/oauth/token`;
2291
2291
  const body = new URLSearchParams({
2292
2292
  grant_type: "refresh_token",
@@ -2303,7 +2303,7 @@ var AuthService = class {
2303
2303
  });
2304
2304
  if (!response.ok) {
2305
2305
  const errorText = await response.text();
2306
- logger6.error("Token refresh failed", {
2306
+ logger7.error("Token refresh failed", {
2307
2307
  status: response.status,
2308
2308
  error: errorText
2309
2309
  });
@@ -2319,7 +2319,7 @@ var AuthService = class {
2319
2319
  userId: storedAuth.userId,
2320
2320
  runtimeTarget: storedAuth.runtimeTarget ?? getActiveRuntimeTarget()
2321
2321
  };
2322
- const dir = path13.dirname(this.oauthSessionFilePath);
2322
+ const dir = path14.dirname(this.oauthSessionFilePath);
2323
2323
  if (!fs4.existsSync(dir)) {
2324
2324
  fs4.mkdirSync(dir, { recursive: true });
2325
2325
  }
@@ -2327,10 +2327,10 @@ var AuthService = class {
2327
2327
  encoding: "utf-8",
2328
2328
  mode: 384
2329
2329
  });
2330
- logger6.info("Access token refreshed", { expiresAt: newExpiresAt });
2330
+ logger7.info("Access token refreshed", { expiresAt: newExpiresAt });
2331
2331
  return tokenData.access_token;
2332
2332
  } catch (error) {
2333
- logger6.error("Token refresh request failed", {
2333
+ logger7.error("Token refresh request failed", {
2334
2334
  error: error instanceof Error ? error.message : String(error)
2335
2335
  });
2336
2336
  return null;
@@ -2342,10 +2342,10 @@ var AuthService = class {
2342
2342
  * @returns Valid access token or null if not authenticated or refresh failed.
2343
2343
  */
2344
2344
  async getValidAccessToken() {
2345
- const logger6 = getLogger();
2345
+ const logger7 = getLogger();
2346
2346
  const storedAuth = this.loadStoredAuth();
2347
2347
  if (!storedAuth) {
2348
- logger6.debug("No stored auth, cannot get valid token");
2348
+ logger7.debug("No stored auth, cannot get valid token");
2349
2349
  return null;
2350
2350
  }
2351
2351
  const now = /* @__PURE__ */ new Date();
@@ -2355,36 +2355,36 @@ var AuthService = class {
2355
2355
  return storedAuth.accessToken;
2356
2356
  }
2357
2357
  if (!isStrictlyExpired) {
2358
- logger6.debug("Access token in buffer zone, attempting proactive refresh");
2358
+ logger7.debug("Access token in buffer zone, attempting proactive refresh");
2359
2359
  } else {
2360
- logger6.info("Access token expired, attempting refresh");
2360
+ logger7.info("Access token expired, attempting refresh");
2361
2361
  }
2362
2362
  const refreshedToken = await this.refreshAccessToken();
2363
2363
  if (refreshedToken) {
2364
2364
  return refreshedToken;
2365
2365
  }
2366
2366
  if (!isStrictlyExpired) {
2367
- logger6.warn("Token refresh failed, but token not yet expired - using existing token");
2367
+ logger7.warn("Token refresh failed, but token not yet expired - using existing token");
2368
2368
  return storedAuth.accessToken;
2369
2369
  }
2370
- logger6.warn("Token refresh failed and token is expired, user needs to re-authenticate");
2370
+ logger7.warn("Token refresh failed and token is expired, user needs to re-authenticate");
2371
2371
  return null;
2372
2372
  }
2373
2373
  /**
2374
2374
  * Clear stored authentication (logout).
2375
2375
  */
2376
2376
  logout() {
2377
- const logger6 = getLogger();
2377
+ const logger7 = getLogger();
2378
2378
  if (!fs4.existsSync(this.oauthSessionFilePath)) {
2379
- logger6.debug("No auth to clear");
2379
+ logger7.debug("No auth to clear");
2380
2380
  return false;
2381
2381
  }
2382
2382
  try {
2383
2383
  fs4.unlinkSync(this.oauthSessionFilePath);
2384
- logger6.info("Auth cleared successfully");
2384
+ logger7.info("Auth cleared successfully");
2385
2385
  return true;
2386
2386
  } catch (error) {
2387
- logger6.error("Failed to clear auth", {
2387
+ logger7.error("Failed to clear auth", {
2388
2388
  error: error instanceof Error ? error.message : String(error)
2389
2389
  });
2390
2390
  return false;
@@ -2623,7 +2623,7 @@ var PREFERENCES_SCHEMA = {
2623
2623
 
2624
2624
  // packages/mcps/src/shared/llm-env-service.ts
2625
2625
  function resolveLlmEnvOverrides(dataDirOverride2) {
2626
- const filePath = path13.join(getDataDir(), PREFERENCES_FILE_NAME);
2626
+ const filePath = path14.join(getDataDir(), PREFERENCES_FILE_NAME);
2627
2627
  let block;
2628
2628
  try {
2629
2629
  if (!fs4.existsSync(filePath)) {
@@ -2854,6 +2854,47 @@ function buildReplayActionScript(params) {
2854
2854
  };
2855
2855
  }
2856
2856
 
2857
+ // packages/mcps/src/mcp/local/services/execution-stop-constants.ts
2858
+ var STOP_REQUEST_GRACE_MS = 9e4;
2859
+ var STOP_REQUEST_FILE_SUFFIX = "_stop_requested";
2860
+
2861
+ // packages/mcps/src/mcp/local/services/execution-stop.ts
2862
+ var logger4 = getLogger();
2863
+ function buildStopRequestFilePath(params) {
2864
+ return path14.join(params.tempDir, `${params.runId}${STOP_REQUEST_FILE_SUFFIX}`);
2865
+ }
2866
+ async function requestGracefulStopAsync(params) {
2867
+ try {
2868
+ await fs13.writeFile(buildStopRequestFilePath(params), params.reason, "utf-8");
2869
+ } catch (writeError) {
2870
+ logger4.warn("Could not write the stop request; the run will be hard-killed after the grace period", {
2871
+ runId: params.runId,
2872
+ error: writeError instanceof Error ? writeError.message : String(writeError)
2873
+ });
2874
+ }
2875
+ return setTimeout(() => {
2876
+ if (params.child.exitCode === null && params.child.signalCode === null) {
2877
+ logger4.warn("Run did not stop within the grace period; killing it", {
2878
+ runId: params.runId,
2879
+ graceMs: STOP_REQUEST_GRACE_MS
2880
+ });
2881
+ params.child.kill("SIGTERM");
2882
+ }
2883
+ }, STOP_REQUEST_GRACE_MS);
2884
+ }
2885
+ async function removeStopRequestFileAsync(params) {
2886
+ await fs13.unlink(buildStopRequestFilePath(params)).catch(() => void 0);
2887
+ }
2888
+ function resolveStoppedRunStatus(reason) {
2889
+ return reason === "cancelled" /* Cancelled */ ? "cancelled" : "failed";
2890
+ }
2891
+ function describeStoppedRun(params) {
2892
+ if (params.reason === "cancelled" /* Cancelled */) {
2893
+ return "Run cancelled by user.";
2894
+ }
2895
+ return `Run stopped: it exceeded its ${params.timeoutMs}ms time limit.`;
2896
+ }
2897
+
2857
2898
  // packages/mcps/src/mcp/local/services/local-execution-lock-constants.ts
2858
2899
  var LOCK_FILE_NAME = "local-execution.lock";
2859
2900
  var MODIFY_LOCK_SUFFIX = ".modify";
@@ -2864,13 +2905,13 @@ var MODIFY_LOCK_STALE_MS = 5e3;
2864
2905
 
2865
2906
  // packages/mcps/src/mcp/local/services/local-execution-lock.ts
2866
2907
  function lockFilePath() {
2867
- return path13.join(getDataDir(), LOCK_FILE_NAME);
2908
+ return path14.join(getDataDir(), LOCK_FILE_NAME);
2868
2909
  }
2869
2910
  function modifyLockPath() {
2870
2911
  return lockFilePath() + MODIFY_LOCK_SUFFIX;
2871
2912
  }
2872
2913
  function normalizeCwd(cwd) {
2873
- const resolved = path13.resolve(cwd);
2914
+ const resolved = path14.resolve(cwd);
2874
2915
  return os4.platform() === "win32" ? resolved.toLowerCase() : resolved;
2875
2916
  }
2876
2917
  function pidIsAlive(pid) {
@@ -2886,7 +2927,7 @@ function pidIsAlive(pid) {
2886
2927
  }
2887
2928
  async function readState() {
2888
2929
  try {
2889
- const raw = await fs12.readFile(lockFilePath(), "utf-8");
2930
+ const raw = await fs13.readFile(lockFilePath(), "utf-8");
2890
2931
  return JSON.parse(raw);
2891
2932
  } catch (error) {
2892
2933
  if (error.code === "ENOENT") return null;
@@ -2894,28 +2935,28 @@ async function readState() {
2894
2935
  }
2895
2936
  }
2896
2937
  async function writeState(state2) {
2897
- await fs12.writeFile(lockFilePath(), JSON.stringify(state2, null, 2), "utf-8");
2938
+ await fs13.writeFile(lockFilePath(), JSON.stringify(state2, null, 2), "utf-8");
2898
2939
  }
2899
2940
  async function deleteStateFile() {
2900
2941
  try {
2901
- await fs12.unlink(lockFilePath());
2942
+ await fs13.unlink(lockFilePath());
2902
2943
  } catch (error) {
2903
2944
  if (error.code !== "ENOENT") throw error;
2904
2945
  }
2905
2946
  }
2906
2947
  async function withModifyLock(fn) {
2907
- await fs12.mkdir(path13.dirname(modifyLockPath()), { recursive: true });
2948
+ await fs13.mkdir(path14.dirname(modifyLockPath()), { recursive: true });
2908
2949
  const modifyPath = modifyLockPath();
2909
2950
  let fileHandle = null;
2910
2951
  while (fileHandle === null) {
2911
2952
  try {
2912
- fileHandle = await fs12.open(modifyPath, "wx");
2953
+ fileHandle = await fs13.open(modifyPath, "wx");
2913
2954
  } catch (error) {
2914
2955
  if (error.code !== "EEXIST") throw error;
2915
2956
  try {
2916
- const stat3 = await fs12.stat(modifyPath);
2957
+ const stat3 = await fs13.stat(modifyPath);
2917
2958
  if (Date.now() - stat3.mtimeMs > MODIFY_LOCK_STALE_MS) {
2918
- await fs12.unlink(modifyPath).catch(() => void 0);
2959
+ await fs13.unlink(modifyPath).catch(() => void 0);
2919
2960
  continue;
2920
2961
  }
2921
2962
  } catch {
@@ -2928,7 +2969,7 @@ async function withModifyLock(fn) {
2928
2969
  return await fn();
2929
2970
  } finally {
2930
2971
  await fileHandle.close().catch(() => void 0);
2931
- await fs12.unlink(modifyPath).catch(() => void 0);
2972
+ await fs13.unlink(modifyPath).catch(() => void 0);
2932
2973
  }
2933
2974
  }
2934
2975
  async function tryAcquireOnce(params) {
@@ -3050,7 +3091,7 @@ function describeElectronSpawnFailure(params) {
3050
3091
  }
3051
3092
 
3052
3093
  // packages/mcps/src/mcp/local/services/execution-service.ts
3053
- var logger4 = getLogger();
3094
+ var logger5 = getLogger();
3054
3095
  function extractStudioCloudRefs(studioReturnedResult) {
3055
3096
  if (typeof studioReturnedResult !== "object" || studioReturnedResult === null) {
3056
3097
  return {};
@@ -3067,12 +3108,12 @@ function extractStudioCloudRefs(studioReturnedResult) {
3067
3108
  return refs;
3068
3109
  }
3069
3110
  async function readCloudRefsFile(inputFilePath) {
3070
- const cloudRefsPath = path13.join(
3071
- path13.dirname(inputFilePath),
3072
- `cloudrefs_${path13.basename(inputFilePath)}`
3111
+ const cloudRefsPath = path14.join(
3112
+ path14.dirname(inputFilePath),
3113
+ `cloudrefs_${path14.basename(inputFilePath)}`
3073
3114
  );
3074
3115
  try {
3075
- return JSON.parse(await fs12.readFile(cloudRefsPath, "utf-8"));
3116
+ return JSON.parse(await fs13.readFile(cloudRefsPath, "utf-8"));
3076
3117
  } catch {
3077
3118
  return void 0;
3078
3119
  }
@@ -3091,15 +3132,15 @@ function getAuthenticatedUserId() {
3091
3132
  }
3092
3133
  async function findPackageJsonAsync() {
3093
3134
  const currentFileUrl = import.meta.url;
3094
- const currentDir = path13.dirname(fileURLToPath(currentFileUrl));
3135
+ const currentDir = path14.dirname(fileURLToPath(currentFileUrl));
3095
3136
  const candidatePaths = [
3096
- path13.resolve(currentDir, "../../../package.json"),
3097
- path13.resolve(currentDir, "../package.json"),
3098
- path13.resolve(currentDir, "../../package.json")
3137
+ path14.resolve(currentDir, "../../../package.json"),
3138
+ path14.resolve(currentDir, "../package.json"),
3139
+ path14.resolve(currentDir, "../../package.json")
3099
3140
  ];
3100
3141
  for (const candidatePath of candidatePaths) {
3101
3142
  try {
3102
- const packageJsonRaw = await fs12.readFile(candidatePath, "utf-8");
3143
+ const packageJsonRaw = await fs13.readFile(candidatePath, "utf-8");
3103
3144
  const packageJson = JSON.parse(packageJsonRaw);
3104
3145
  if (packageJson.name === "@muggleai/works" && packageJson.version && packageJson.muggleConfig?.electronAppVersion) {
3105
3146
  return {
@@ -3145,20 +3186,20 @@ function buildStudioAuthContent() {
3145
3186
  }
3146
3187
  async function ensureTempDir() {
3147
3188
  const config = getConfig();
3148
- const tempDir = path13.join(config.localQa.dataDir, "temp");
3149
- await fs12.mkdir(tempDir, { recursive: true });
3189
+ const tempDir = path14.join(config.localQa.dataDir, "temp");
3190
+ await fs13.mkdir(tempDir, { recursive: true });
3150
3191
  return tempDir;
3151
3192
  }
3152
3193
  async function writeTempFile(params) {
3153
3194
  const tempDir = await ensureTempDir();
3154
- const filePath = path13.join(tempDir, params.filename);
3155
- await fs12.writeFile(filePath, JSON.stringify(params.data, null, 2));
3195
+ const filePath = path14.join(tempDir, params.filename);
3196
+ await fs13.writeFile(filePath, JSON.stringify(params.data, null, 2));
3156
3197
  return filePath;
3157
3198
  }
3158
3199
  async function cleanupTempFiles(params) {
3159
3200
  for (const filePath of params.filePaths) {
3160
3201
  try {
3161
- await fs12.unlink(filePath);
3202
+ await fs13.unlink(filePath);
3162
3203
  } catch {
3163
3204
  }
3164
3205
  }
@@ -3166,12 +3207,12 @@ async function cleanupTempFiles(params) {
3166
3207
  async function moveResultsToArtifacts(params) {
3167
3208
  const storageService = getStorageService();
3168
3209
  const sessionsDir = storageService.getSessionsDir();
3169
- const artifactsDir = path13.join(sessionsDir, params.runId);
3170
- const actionScriptPath = path13.join(artifactsDir, "action-script.json");
3171
- await fs12.mkdir(artifactsDir, { recursive: true });
3172
- await fs12.copyFile(params.generatedScriptPath, actionScriptPath);
3210
+ const artifactsDir = path14.join(sessionsDir, params.runId);
3211
+ const actionScriptPath = path14.join(artifactsDir, "action-script.json");
3212
+ await fs13.mkdir(artifactsDir, { recursive: true });
3213
+ await fs13.copyFile(params.generatedScriptPath, actionScriptPath);
3173
3214
  try {
3174
- await fs12.unlink(params.generatedScriptPath);
3215
+ await fs13.unlink(params.generatedScriptPath);
3175
3216
  } catch {
3176
3217
  }
3177
3218
  return artifactsDir;
@@ -3179,15 +3220,15 @@ async function moveResultsToArtifacts(params) {
3179
3220
  async function writeExecutionLogs(params) {
3180
3221
  const storageService = getStorageService();
3181
3222
  const sessionsDir = storageService.getSessionsDir();
3182
- const artifactsDir = path13.join(sessionsDir, params.runId);
3183
- await fs12.mkdir(artifactsDir, { recursive: true });
3184
- const stdoutPath = path13.join(artifactsDir, "stdout.log");
3185
- const stderrPath = path13.join(artifactsDir, "stderr.log");
3223
+ const artifactsDir = path14.join(sessionsDir, params.runId);
3224
+ await fs13.mkdir(artifactsDir, { recursive: true });
3225
+ const stdoutPath = path14.join(artifactsDir, "stdout.log");
3226
+ const stderrPath = path14.join(artifactsDir, "stderr.log");
3186
3227
  await Promise.all([
3187
- fs12.writeFile(stdoutPath, params.stdout, "utf-8"),
3188
- fs12.writeFile(stderrPath, params.stderr, "utf-8")
3228
+ fs13.writeFile(stdoutPath, params.stdout, "utf-8"),
3229
+ fs13.writeFile(stderrPath, params.stderr, "utf-8")
3189
3230
  ]);
3190
- logger4.info("Wrote execution logs to artifacts directory", {
3231
+ logger5.info("Wrote execution logs to artifacts directory", {
3191
3232
  runId: params.runId,
3192
3233
  artifactsDir
3193
3234
  });
@@ -3195,15 +3236,15 @@ async function writeExecutionLogs(params) {
3195
3236
  async function preserveElectronRuntimeArtifacts(params) {
3196
3237
  try {
3197
3238
  const tempDir = await ensureTempDir();
3198
- const markerPath = path13.join(tempDir, `${params.runId}_runtime_dir.txt`);
3239
+ const markerPath = path14.join(tempDir, `${params.runId}_runtime_dir.txt`);
3199
3240
  let runtimeDir = null;
3200
3241
  try {
3201
- const marker = await fs12.readFile(markerPath, "utf-8");
3242
+ const marker = await fs13.readFile(markerPath, "utf-8");
3202
3243
  const trimmed = marker.trim();
3203
3244
  if (trimmed.length > 0) runtimeDir = trimmed;
3204
3245
  } catch (markerReadError) {
3205
3246
  if (markerReadError.code !== "ENOENT") {
3206
- logger4.warn("Failed to read runtime-dir marker", {
3247
+ logger5.warn("Failed to read runtime-dir marker", {
3207
3248
  runId: params.runId,
3208
3249
  error: String(markerReadError)
3209
3250
  });
@@ -3216,45 +3257,45 @@ async function preserveElectronRuntimeArtifacts(params) {
3216
3257
  });
3217
3258
  }
3218
3259
  if (runtimeDir === null) {
3219
- logger4.info("No Electron runtime dir found to preserve", { runId: params.runId });
3260
+ logger5.info("No Electron runtime dir found to preserve", { runId: params.runId });
3220
3261
  return;
3221
3262
  }
3222
3263
  try {
3223
- await fs12.access(runtimeDir);
3264
+ await fs13.access(runtimeDir);
3224
3265
  } catch {
3225
- logger4.warn("Electron runtime dir referenced but missing on disk", {
3266
+ logger5.warn("Electron runtime dir referenced but missing on disk", {
3226
3267
  runId: params.runId,
3227
3268
  runtimeDir
3228
3269
  });
3229
- await fs12.unlink(markerPath).catch(() => void 0);
3270
+ await fs13.unlink(markerPath).catch(() => void 0);
3230
3271
  return;
3231
3272
  }
3232
3273
  const storage = getStorageService();
3233
- const destDir = path13.join(storage.getSessionsDir(), params.runId, "electron-runtime");
3234
- await fs12.mkdir(destDir, { recursive: true });
3235
- await fs12.cp(runtimeDir, destDir, { recursive: true });
3236
- logger4.info("Preserved Electron runtime artifacts", {
3274
+ const destDir = path14.join(storage.getSessionsDir(), params.runId, "electron-runtime");
3275
+ await fs13.mkdir(destDir, { recursive: true });
3276
+ await fs13.cp(runtimeDir, destDir, { recursive: true });
3277
+ logger5.info("Preserved Electron runtime artifacts", {
3237
3278
  runId: params.runId,
3238
3279
  sourceDir: runtimeDir,
3239
3280
  destDir
3240
3281
  });
3241
- await fs12.unlink(markerPath).catch(() => void 0);
3282
+ await fs13.unlink(markerPath).catch(() => void 0);
3242
3283
  } catch (preserveError) {
3243
- logger4.warn("Failed to preserve Electron runtime artifacts", {
3284
+ logger5.warn("Failed to preserve Electron runtime artifacts", {
3244
3285
  runId: params.runId,
3245
3286
  error: preserveError instanceof Error ? preserveError.message : String(preserveError)
3246
3287
  });
3247
3288
  }
3248
3289
  }
3249
3290
  async function scanForRuntimeDirByMtime(params) {
3250
- const runtimeRoot = path13.join(params.electronCwd, "user_data", "runtime");
3291
+ const runtimeRoot = path14.join(params.electronCwd, "user_data", "runtime");
3251
3292
  try {
3252
- const entries = await fs12.readdir(runtimeRoot, { withFileTypes: true });
3293
+ const entries = await fs13.readdir(runtimeRoot, { withFileTypes: true });
3253
3294
  let bestCandidate = null;
3254
3295
  for (const entry of entries) {
3255
3296
  if (!entry.isDirectory()) continue;
3256
- const fullPath = path13.join(runtimeRoot, entry.name);
3257
- const stat3 = await fs12.stat(fullPath);
3297
+ const fullPath = path14.join(runtimeRoot, entry.name);
3298
+ const stat3 = await fs13.stat(fullPath);
3258
3299
  if (stat3.mtimeMs < params.spawnAtMs) continue;
3259
3300
  if (bestCandidate === null || stat3.mtimeMs > bestCandidate.mtimeMs) {
3260
3301
  bestCandidate = { path: fullPath, mtimeMs: stat3.mtimeMs };
@@ -3289,6 +3330,37 @@ function getElectronAppPathOrThrow() {
3289
3330
  errorLines.push("Or set ELECTRON_APP_PATH to the path of the MuggleAI executable.");
3290
3331
  throw new Error(errorLines.join("\n"));
3291
3332
  }
3333
+ async function stopExecutionGracefullyAsync(params) {
3334
+ const { processInfo } = params;
3335
+ if (processInfo.stopReason !== void 0 || processInfo.hasSettled) {
3336
+ return;
3337
+ }
3338
+ processInfo.stopReason = params.reason;
3339
+ logger5.info("Asking the studio to stop the run", { runId: processInfo.runId, reason: params.reason });
3340
+ const hardKillTimer = await requestGracefulStopAsync({
3341
+ tempDir: await ensureTempDir(),
3342
+ runId: processInfo.runId,
3343
+ reason: params.reason,
3344
+ child: processInfo.process
3345
+ });
3346
+ if (processInfo.hasSettled) {
3347
+ clearTimeout(hardKillTimer);
3348
+ return;
3349
+ }
3350
+ processInfo.hardKillTimer = hardKillTimer;
3351
+ }
3352
+ function describeElectronFailure(params) {
3353
+ const { executionResult } = params;
3354
+ const headline = executionResult.stopReason !== void 0 ? describeStoppedRun({ reason: executionResult.stopReason, timeoutMs: params.timeoutMs }) : `Electron exited with code ${executionResult.exitCode}.`;
3355
+ return `${headline}
3356
+ STDOUT:
3357
+ ${executionResult.stdout}
3358
+ STDERR:
3359
+ ${executionResult.stderr}`;
3360
+ }
3361
+ function resolveFailedRunStatus(executionResult) {
3362
+ return executionResult.stopReason !== void 0 ? resolveStoppedRunStatus(executionResult.stopReason) : "failed";
3363
+ }
3292
3364
  async function executeElectronAppAsync(params) {
3293
3365
  const mode = params.runType === "generation" ? "explore" : "engine";
3294
3366
  const electronAppPath = getElectronAppPathOrThrow();
@@ -3303,14 +3375,14 @@ async function executeElectronAppAsync(params) {
3303
3375
  ...process.env
3304
3376
  });
3305
3377
  delete electronEnv.ELECTRON_RUN_AS_NODE;
3306
- logger4.info("Spawning electron-app for local execution", {
3378
+ logger5.info("Spawning electron-app for local execution", {
3307
3379
  runId: params.runId,
3308
3380
  mode,
3309
3381
  electronAppPath,
3310
3382
  spawnArgs,
3311
3383
  llmEnvOverrideNames
3312
3384
  });
3313
- const electronCwd = path13.dirname(electronAppPath);
3385
+ const electronCwd = path14.dirname(electronAppPath);
3314
3386
  const child = spawn(electronAppPath, spawnArgs, {
3315
3387
  stdio: ["ignore", "pipe", "pipe"],
3316
3388
  env: electronEnv,
@@ -3321,21 +3393,27 @@ async function executeElectronAppAsync(params) {
3321
3393
  process: child,
3322
3394
  status: "running",
3323
3395
  startedAt: Date.now(),
3396
+ hasSettled: false,
3324
3397
  capturedStdout: "",
3325
3398
  capturedStderr: ""
3326
3399
  };
3327
3400
  activeProcesses.set(params.runId, processInfo);
3328
3401
  return await new Promise((resolve6, reject) => {
3329
- let settled = false;
3330
3402
  const finalize = (result) => {
3331
- if (settled) {
3403
+ if (processInfo.hasSettled) {
3332
3404
  return;
3333
3405
  }
3334
- settled = true;
3406
+ processInfo.hasSettled = true;
3335
3407
  if (processInfo.timeoutTimer) {
3336
3408
  clearTimeout(processInfo.timeoutTimer);
3337
3409
  }
3410
+ if (processInfo.hardKillTimer) {
3411
+ clearTimeout(processInfo.hardKillTimer);
3412
+ }
3338
3413
  activeProcesses.delete(params.runId);
3414
+ if (processInfo.stopReason !== void 0) {
3415
+ void ensureTempDir().then((tempDir) => removeStopRequestFileAsync({ tempDir, runId: params.runId }));
3416
+ }
3339
3417
  if (result.ok) {
3340
3418
  resolve6(result.payload);
3341
3419
  } else {
@@ -3343,17 +3421,7 @@ async function executeElectronAppAsync(params) {
3343
3421
  }
3344
3422
  };
3345
3423
  processInfo.timeoutTimer = setTimeout(() => {
3346
- processInfo.process.kill("SIGTERM");
3347
- finalize({
3348
- ok: false,
3349
- payload: new Error(
3350
- `Electron execution timed out after ${params.timeoutMs}ms.
3351
- STDOUT:
3352
- ${processInfo.capturedStdout}
3353
- STDERR:
3354
- ${processInfo.capturedStderr}`
3355
- )
3356
- });
3424
+ void stopExecutionGracefullyAsync({ processInfo, reason: "timeout" /* Timeout */ });
3357
3425
  }, params.timeoutMs);
3358
3426
  if (child.stdout) {
3359
3427
  child.stdout.on("data", (chunk) => {
@@ -3378,6 +3446,19 @@ ${processInfo.capturedStderr}`
3378
3446
  });
3379
3447
  child.on("close", (code, signal) => {
3380
3448
  const exitCode = code ?? -1;
3449
+ if (processInfo.stopReason !== void 0) {
3450
+ finalize({
3451
+ ok: true,
3452
+ payload: {
3453
+ exitCode,
3454
+ stdout: processInfo.capturedStdout,
3455
+ stderr: processInfo.capturedStderr,
3456
+ electronCwd,
3457
+ stopReason: processInfo.stopReason
3458
+ }
3459
+ });
3460
+ return;
3461
+ }
3381
3462
  if (signal) {
3382
3463
  finalize({
3383
3464
  ok: false,
@@ -3486,30 +3567,26 @@ async function runTestGenerationLocked(params) {
3486
3567
  electronCwd: executionResult.electronCwd,
3487
3568
  spawnAtMs: startedAt
3488
3569
  });
3489
- if (executionResult.exitCode !== 0) {
3490
- const failureMessage = `Electron exited with code ${executionResult.exitCode}.
3491
- STDOUT:
3492
- ${executionResult.stdout}
3493
- STDERR:
3494
- ${executionResult.stderr}`;
3570
+ if (executionResult.exitCode !== 0 || executionResult.stopReason !== void 0) {
3571
+ const failureMessage = describeElectronFailure({ executionResult, timeoutMs });
3495
3572
  const sessionsDir = getStorageService().getSessionsDir();
3496
- const artifactsDir2 = path13.join(sessionsDir, runId);
3497
- const generatedScriptPath2 = path13.join(
3498
- path13.dirname(inputFilePath),
3499
- `gen_${path13.basename(inputFilePath)}`
3573
+ const artifactsDir2 = path14.join(sessionsDir, runId);
3574
+ const generatedScriptPath2 = path14.join(
3575
+ path14.dirname(inputFilePath),
3576
+ `gen_${path14.basename(inputFilePath)}`
3500
3577
  );
3501
3578
  let failedStudioResult;
3502
3579
  try {
3503
- const failedScriptRaw = await fs12.readFile(generatedScriptPath2, "utf-8");
3580
+ const failedScriptRaw = await fs13.readFile(generatedScriptPath2, "utf-8");
3504
3581
  failedStudioResult = JSON.parse(failedScriptRaw);
3505
- await fs12.copyFile(generatedScriptPath2, path13.join(artifactsDir2, "action-script.json"));
3506
- await fs12.unlink(generatedScriptPath2).catch(() => {
3582
+ await fs13.copyFile(generatedScriptPath2, path14.join(artifactsDir2, "action-script.json"));
3583
+ await fs13.unlink(generatedScriptPath2).catch(() => {
3507
3584
  });
3508
3585
  } catch {
3509
3586
  }
3510
3587
  const failedStudioCloudRefs = extractStudioCloudRefs(await readCloudRefsFile(inputFilePath));
3511
3588
  storage.updateRunResult(runId, {
3512
- status: "failed",
3589
+ status: resolveFailedRunStatus(executionResult),
3513
3590
  testScriptId: localTestScript.id,
3514
3591
  executionTimeMs,
3515
3592
  errorMessage: failureMessage,
@@ -3532,11 +3609,11 @@ ${executionResult.stderr}`;
3532
3609
  errorMessage: failureMessage
3533
3610
  };
3534
3611
  }
3535
- const generatedScriptPath = path13.join(
3536
- path13.dirname(inputFilePath),
3537
- `gen_${path13.basename(inputFilePath)}`
3612
+ const generatedScriptPath = path14.join(
3613
+ path14.dirname(inputFilePath),
3614
+ `gen_${path14.basename(inputFilePath)}`
3538
3615
  );
3539
- const generatedScriptRaw = await fs12.readFile(generatedScriptPath, "utf-8");
3616
+ const generatedScriptRaw = await fs13.readFile(generatedScriptPath, "utf-8");
3540
3617
  const generatedScript = JSON.parse(generatedScriptRaw);
3541
3618
  const generatedSteps = generatedScript.steps;
3542
3619
  if (!Array.isArray(generatedSteps)) {
@@ -3674,18 +3751,17 @@ async function runReplayLocked(params) {
3674
3751
  electronCwd: executionResult.electronCwd,
3675
3752
  spawnAtMs: startedAt
3676
3753
  });
3677
- if (executionResult.exitCode !== 0) {
3678
- const failureMessage = `Electron exited with code ${executionResult.exitCode}.
3679
- STDOUT:
3680
- ${executionResult.stdout}
3681
- STDERR:
3682
- ${executionResult.stderr}`;
3683
- const artifactsDir2 = path13.join(getStorageService().getSessionsDir(), runId);
3754
+ if (executionResult.exitCode !== 0 || executionResult.stopReason !== void 0) {
3755
+ const failureMessage = describeElectronFailure({ executionResult, timeoutMs });
3756
+ const artifactsDir2 = path14.join(getStorageService().getSessionsDir(), runId);
3757
+ const failedReplayStudioResult = await readCloudRefsFile(inputFilePath);
3684
3758
  storage.updateRunResult(runId, {
3685
- status: "failed",
3759
+ status: resolveFailedRunStatus(executionResult),
3686
3760
  executionTimeMs,
3687
3761
  errorMessage: failureMessage,
3688
3762
  artifactsDir: artifactsDir2,
3763
+ studioReturnedResult: failedReplayStudioResult,
3764
+ ...extractStudioCloudRefs(failedReplayStudioResult),
3689
3765
  localExecutionContext: {
3690
3766
  ...localExecutionContextBase,
3691
3767
  localExecutionCompletedAt: completedAt
@@ -3698,7 +3774,7 @@ ${executionResult.stderr}`;
3698
3774
  errorMessage: failureMessage
3699
3775
  };
3700
3776
  }
3701
- const artifactsDir = path13.join(getStorageService().getSessionsDir(), runId);
3777
+ const artifactsDir = path14.join(getStorageService().getSessionsDir(), runId);
3702
3778
  const replayStudioResult = await readCloudRefsFile(inputFilePath);
3703
3779
  const replayStudioCloudRefs = extractStudioCloudRefs(replayStudioResult);
3704
3780
  storage.updateRunResult(runId, {
@@ -3746,9 +3822,8 @@ function cancelExecution(params) {
3746
3822
  if (!process2) {
3747
3823
  return false;
3748
3824
  }
3749
- process2.process.kill("SIGTERM");
3825
+ void stopExecutionGracefullyAsync({ processInfo: process2, reason: "cancelled" /* Cancelled */ });
3750
3826
  process2.status = "cancelled";
3751
- activeProcesses.delete(params.runId);
3752
3827
  const storage = getRunResultStorageService();
3753
3828
  storage.updateRunResult(params.runId, {
3754
3829
  status: "cancelled",
@@ -3764,11 +3839,11 @@ function listActiveExecutions() {
3764
3839
  }
3765
3840
 
3766
3841
  // packages/mcps/src/shared/auth.ts
3767
- var logger5 = getLogger();
3842
+ var logger6 = getLogger();
3768
3843
  async function startDeviceCodeFlow(config, options) {
3769
3844
  const deviceCodeUrl = `https://${config.domain}/oauth/device/code`;
3770
3845
  try {
3771
- logger5.info("[Auth] Starting device code flow", {
3846
+ logger6.info("[Auth] Starting device code flow", {
3772
3847
  domain: config.domain,
3773
3848
  clientId: config.clientId
3774
3849
  });
@@ -3786,7 +3861,7 @@ async function startDeviceCodeFlow(config, options) {
3786
3861
  }
3787
3862
  );
3788
3863
  const data = response.data;
3789
- logger5.info("[Auth] Device code flow started successfully", {
3864
+ logger6.info("[Auth] Device code flow started successfully", {
3790
3865
  userCode: data.user_code,
3791
3866
  expiresIn: data.expires_in
3792
3867
  });
@@ -3796,15 +3871,15 @@ async function startDeviceCodeFlow(config, options) {
3796
3871
  logoutUrl.searchParams.set("client_id", config.clientId);
3797
3872
  logoutUrl.searchParams.set("returnTo", data.verification_uri_complete);
3798
3873
  browserUrl = logoutUrl.toString();
3799
- logger5.info("[Auth] Force new session: opening logout-redirect URL");
3874
+ logger6.info("[Auth] Force new session: opening logout-redirect URL");
3800
3875
  }
3801
3876
  const browserOpenResult = await openBrowserUrl({
3802
3877
  url: browserUrl
3803
3878
  });
3804
3879
  if (browserOpenResult.opened) {
3805
- logger5.info("[Auth] Browser opened for device code login");
3880
+ logger6.info("[Auth] Browser opened for device code login");
3806
3881
  } else {
3807
- logger5.warn("[Auth] Failed to open browser", {
3882
+ logger6.warn("[Auth] Failed to open browser", {
3808
3883
  error: browserOpenResult.error,
3809
3884
  verificationUriComplete: data.verification_uri_complete
3810
3885
  });
@@ -3821,7 +3896,7 @@ async function startDeviceCodeFlow(config, options) {
3821
3896
  };
3822
3897
  } catch (error) {
3823
3898
  if (error instanceof AxiosError) {
3824
- logger5.error("[Auth] Failed to start device code flow", {
3899
+ logger6.error("[Auth] Failed to start device code flow", {
3825
3900
  status: error.response?.status,
3826
3901
  data: error.response?.data
3827
3902
  });
@@ -3849,7 +3924,7 @@ async function pollDeviceCode(config, deviceCode) {
3849
3924
  }
3850
3925
  }
3851
3926
  );
3852
- logger5.info("[Auth] Authorization successful");
3927
+ logger6.info("[Auth] Authorization successful");
3853
3928
  return {
3854
3929
  status: "authorized",
3855
3930
  accessToken: response.data.access_token,
@@ -3888,7 +3963,7 @@ async function pollDeviceCode(config, deviceCode) {
3888
3963
  errorDescription: data.error_description || "User denied access"
3889
3964
  };
3890
3965
  }
3891
- logger5.error("[Auth] Unexpected error during poll", {
3966
+ logger6.error("[Auth] Unexpected error during poll", {
3892
3967
  status: error.response.status,
3893
3968
  error: errorCode,
3894
3969
  description: data.error_description
@@ -3905,7 +3980,7 @@ async function createApiKeyWithToken(accessToken, keyName, expiry = "90d") {
3905
3980
  const config = getConfig();
3906
3981
  const apiKeyUrl = `${config.e2e.promptServiceBaseUrl}/v1/protected/api-keys`;
3907
3982
  try {
3908
- logger5.info("[Auth] Creating API key", {
3983
+ logger6.info("[Auth] Creating API key", {
3909
3984
  keyName,
3910
3985
  expiry
3911
3986
  });
@@ -3922,13 +3997,13 @@ async function createApiKeyWithToken(accessToken, keyName, expiry = "90d") {
3922
3997
  }
3923
3998
  }
3924
3999
  );
3925
- logger5.info("[Auth] API key created successfully", {
4000
+ logger6.info("[Auth] API key created successfully", {
3926
4001
  keyId: response.data.id
3927
4002
  });
3928
4003
  return response.data;
3929
4004
  } catch (error) {
3930
4005
  if (error instanceof AxiosError) {
3931
- logger5.error("[Auth] Failed to create API key", {
4006
+ logger6.error("[Auth] Failed to create API key", {
3932
4007
  status: error.response?.status,
3933
4008
  data: error.response?.data
3934
4009
  });
@@ -3968,7 +4043,7 @@ async function performLogin(keyName, keyExpiry = "90d", timeoutMs = 12e4) {
3968
4043
  userId: storedAuth?.userId
3969
4044
  };
3970
4045
  if (keyName && storedAuth?.accessToken) {
3971
- logger5.info("[Auth] Creating API key as explicitly requested", {
4046
+ logger6.info("[Auth] Creating API key as explicitly requested", {
3972
4047
  keyName
3973
4048
  });
3974
4049
  const apiKeyResult = await createApiKeyWithToken(
@@ -4016,7 +4091,7 @@ function performLogout() {
4016
4091
  const authService = getAuthService();
4017
4092
  authService.logout();
4018
4093
  deleteApiKeyData();
4019
- logger5.info("[Auth] Logged out successfully");
4094
+ logger6.info("[Auth] Logged out successfully");
4020
4095
  }
4021
4096
  function getCallerCredentials() {
4022
4097
  const apiKeyData = getValidApiKeyData();
@@ -4165,7 +4240,7 @@ function getInstallId() {
4165
4240
  var CONFLICT_STATUS = 409;
4166
4241
  var THROTTLED_STATUS = 429;
4167
4242
  async function registerAccount(email, userProvidedPassword) {
4168
- const logger6 = getLogger();
4243
+ const logger7 = getLogger();
4169
4244
  const config = getConfig();
4170
4245
  const registerUrl = `${config.e2e.promptServiceBaseUrl}/v1/public/auth/register`;
4171
4246
  try {
@@ -4180,7 +4255,7 @@ async function registerAccount(email, userProvidedPassword) {
4180
4255
  );
4181
4256
  const created = response.data;
4182
4257
  saveApiKey({ apiKey: created.apiKey, apiKeyId: created.userId });
4183
- logger6.info("[Register] Account created and credential stored", {
4258
+ logger7.info("[Register] Account created and credential stored", {
4184
4259
  userId: created.userId,
4185
4260
  plan: created.plan
4186
4261
  });
@@ -4211,7 +4286,7 @@ async function registerAccount(email, userProvidedPassword) {
4211
4286
  message: retryAfterSeconds ? `Too many registrations from this machine. Try again in ${retryAfterSeconds} seconds.` : "Too many registrations from this machine. Try again later."
4212
4287
  };
4213
4288
  }
4214
- logger6.error("[Register] Registration failed", {
4289
+ logger7.error("[Register] Registration failed", {
4215
4290
  error: error instanceof Error ? error.message : String(error)
4216
4291
  });
4217
4292
  throw error;
@@ -4228,7 +4303,7 @@ var PREFS_FILENAME = "preferences.json";
4228
4303
  var OAUTH_SESSION_FILENAME = "oauth-session.json";
4229
4304
  var RELEASE_MANIFEST_FILENAME = "release-manifest.json";
4230
4305
  function getDataDir3() {
4231
- return path13.join(os4.homedir(), DATA_DIR_NAME2);
4306
+ return path14.join(os4.homedir(), DATA_DIR_NAME2);
4232
4307
  }
4233
4308
 
4234
4309
  var cachedInstallId2;
@@ -4293,9 +4368,9 @@ function isValid3(value) {
4293
4368
  function readReleaseManifest2() {
4294
4369
  if (cachedManifest2 !== void 0)
4295
4370
  return cachedManifest2;
4296
- const path19 = MANIFEST_PATH2;
4371
+ const path20 = MANIFEST_PATH2;
4297
4372
  try {
4298
- const raw = readFileSync(path19, "utf8");
4373
+ const raw = readFileSync(path20, "utf8");
4299
4374
  const parsed = JSON.parse(raw);
4300
4375
  cachedManifest2 = isValid3(parsed) ? parsed : DEV_MANIFEST2;
4301
4376
  return cachedManifest2;
@@ -5062,17 +5137,17 @@ var PromptServiceClient = class {
5062
5137
  * @param path - Path to validate.
5063
5138
  * @throws GatewayError if path is not allowed.
5064
5139
  */
5065
- validatePath(path19) {
5066
- const isAllowed = ALLOWED_UPSTREAM_PREFIXES.some((prefix) => path19.startsWith(prefix));
5140
+ validatePath(path20) {
5141
+ const isAllowed = ALLOWED_UPSTREAM_PREFIXES.some((prefix) => path20.startsWith(prefix));
5067
5142
  if (!isAllowed) {
5068
- const logger6 = getLogger();
5069
- logger6.error("Path not in allowlist", {
5070
- path: path19,
5143
+ const logger7 = getLogger();
5144
+ logger7.error("Path not in allowlist", {
5145
+ path: path20,
5071
5146
  allowedPrefixes: ALLOWED_UPSTREAM_PREFIXES
5072
5147
  });
5073
5148
  throw new GatewayError({
5074
5149
  code: "FORBIDDEN" /* FORBIDDEN */,
5075
- message: `Path '${path19}' is not allowed`
5150
+ message: `Path '${path20}' is not allowed`
5076
5151
  });
5077
5152
  }
5078
5153
  }
@@ -5181,7 +5256,7 @@ var PromptServiceClient = class {
5181
5256
  * @throws GatewayError on validation or upstream errors.
5182
5257
  */
5183
5258
  async execute(call, credentials, correlationId) {
5184
- const logger6 = getLogger();
5259
+ const logger7 = getLogger();
5185
5260
  if (!credentials.bearerToken && !credentials.apiKey) {
5186
5261
  throw new GatewayError({
5187
5262
  code: "UNAUTHORIZED" /* UNAUTHORIZED */,
@@ -5193,7 +5268,7 @@ var PromptServiceClient = class {
5193
5268
  const headers = this.buildHeaders(credentials, correlationId);
5194
5269
  const timeout = call.timeoutMs || this.requestTimeoutMs;
5195
5270
  const startTime = Date.now();
5196
- logger6.info("Upstream request", {
5271
+ logger7.info("Upstream request", {
5197
5272
  correlationId,
5198
5273
  method: call.method,
5199
5274
  path: call.path,
@@ -5220,7 +5295,7 @@ var PromptServiceClient = class {
5220
5295
  }
5221
5296
  const response = await this.httpClient.request(requestConfig);
5222
5297
  const latency = Date.now() - startTime;
5223
- logger6.info("Upstream response", {
5298
+ logger7.info("Upstream response", {
5224
5299
  correlationId,
5225
5300
  statusCode: response.status,
5226
5301
  latencyMs: latency
@@ -5251,7 +5326,7 @@ var PromptServiceClient = class {
5251
5326
  throw error;
5252
5327
  }
5253
5328
  if (error instanceof AxiosError) {
5254
- logger6.error("Upstream request failed", {
5329
+ logger7.error("Upstream request failed", {
5255
5330
  correlationId,
5256
5331
  error: error.message,
5257
5332
  code: error.code,
@@ -5270,7 +5345,7 @@ var PromptServiceClient = class {
5270
5345
  details: { upstreamPath: call.path }
5271
5346
  });
5272
5347
  }
5273
- logger6.error("Unknown upstream error", {
5348
+ logger7.error("Unknown upstream error", {
5274
5349
  correlationId,
5275
5350
  error: String(error),
5276
5351
  latencyMs: latency
@@ -6962,7 +7037,7 @@ function defaultResponseMapper(response) {
6962
7037
  return response.data;
6963
7038
  }
6964
7039
  async function executeQaTool(toolName, input, correlationId) {
6965
- const logger6 = createChildLogger(correlationId);
7040
+ const logger7 = createChildLogger(correlationId);
6966
7041
  const tool = getQaToolByName(toolName);
6967
7042
  if (!tool) {
6968
7043
  return {
@@ -7012,7 +7087,7 @@ async function executeQaTool(toolName, input, correlationId) {
7012
7087
  outcome = Outcome.Error;
7013
7088
  if (error instanceof GatewayError) {
7014
7089
  errorCode = error.code;
7015
- logger6.warn("Tool call failed with gateway error", {
7090
+ logger7.warn("Tool call failed with gateway error", {
7016
7091
  tool: toolName,
7017
7092
  code: error.code,
7018
7093
  message: error.message
@@ -7024,7 +7099,7 @@ async function executeQaTool(toolName, input, correlationId) {
7024
7099
  }
7025
7100
  errorCode = error instanceof Error ? error.name : "UnknownError";
7026
7101
  const errorMessage = error instanceof Error ? error.message : String(error);
7027
- logger6.error("Tool call failed", { tool: toolName, error: errorMessage });
7102
+ logger7.error("Tool call failed", { tool: toolName, error: errorMessage });
7028
7103
  return {
7029
7104
  content: JSON.stringify({ error: "INTERNAL_ERROR", message: errorMessage }),
7030
7105
  isError: true
@@ -7248,9 +7323,9 @@ var TELEMETRY_DIR_NAME = "telemetry";
7248
7323
  var FAILURE_EVENTS_FILE_NAME = "failure-events.jsonl";
7249
7324
  function appendFailureEvent(record) {
7250
7325
  try {
7251
- const dir = path13.join(getDataDir(), TELEMETRY_DIR_NAME);
7326
+ const dir = path14.join(getDataDir(), TELEMETRY_DIR_NAME);
7252
7327
  fs4.mkdirSync(dir, { recursive: true });
7253
- const filePath = path13.join(dir, FAILURE_EVENTS_FILE_NAME);
7328
+ const filePath = path14.join(dir, FAILURE_EVENTS_FILE_NAME);
7254
7329
  const full = { ts: (/* @__PURE__ */ new Date()).toISOString(), ...record };
7255
7330
  fs4.appendFileSync(filePath, `${JSON.stringify(full)}
7256
7331
  `, "utf-8");
@@ -7271,7 +7346,7 @@ var ProjectPreferencesReconcileOutcome = /* @__PURE__ */ ((ProjectPreferencesRec
7271
7346
 
7272
7347
  // packages/mcps/src/shared/preferences-service.ts
7273
7348
  function getGlobalPreferencesFilePath(dataDirOverride2) {
7274
- return path13.join(dataDirOverride2 ?? getDataDir(), PREFERENCES_FILE_NAME);
7349
+ return path14.join(dataDirOverride2 ?? getDataDir(), PREFERENCES_FILE_NAME);
7275
7350
  }
7276
7351
  function isFirstRun(dataDirOverride2) {
7277
7352
  return !fs4.existsSync(getGlobalPreferencesFilePath(dataDirOverride2));
@@ -7317,7 +7392,7 @@ function resolvePreferences(dataDirOverride2) {
7317
7392
  function writePreferences2(prefs, dataDirOverride2) {
7318
7393
  const dir = dataDirOverride2 ?? getDataDir();
7319
7394
  fs4.mkdirSync(dir, { recursive: true });
7320
- const filePath = path13.join(dir, PREFERENCES_FILE_NAME);
7395
+ const filePath = path14.join(dir, PREFERENCES_FILE_NAME);
7321
7396
  const existing = readPreferencesFile(filePath);
7322
7397
  writePreferencesFile(filePath, { ...existing, ...prefs });
7323
7398
  }
@@ -7331,7 +7406,7 @@ function readPreferencesMetadata(dataDirOverride2) {
7331
7406
  function writePreferencesWithMetadata(prefs, metadata, dataDirOverride2) {
7332
7407
  const dir = dataDirOverride2 ?? getDataDir();
7333
7408
  fs4.mkdirSync(dir, { recursive: true });
7334
- const filePath = path13.join(dir, PREFERENCES_FILE_NAME);
7409
+ const filePath = path14.join(dir, PREFERENCES_FILE_NAME);
7335
7410
  const existing = readRawPreferencesFile(filePath);
7336
7411
  const file = {
7337
7412
  ...existing,
@@ -7356,7 +7431,7 @@ function resetPreference(key, dataDirOverride2) {
7356
7431
  writePreferencesFile(filePath, existing);
7357
7432
  }
7358
7433
  function reconcileProjectPreferences(cwd, dataDirOverride2) {
7359
- const projectFilePath = path13.join(cwd, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_FILE_NAME);
7434
+ const projectFilePath = path14.join(cwd, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_FILE_NAME);
7360
7435
  const projectPreferences = readPreferencesFile(projectFilePath);
7361
7436
  const projectKeys = Object.keys(projectPreferences);
7362
7437
  if (projectKeys.length === 0) {
@@ -7401,10 +7476,10 @@ var MUGGLE_HOME_DISPLAY_DIR = "~/.muggle-ai";
7401
7476
 
7402
7477
  // packages/mcps/src/shared/cwd-keyed-cache.ts
7403
7478
  function resolveHomeFilePath(cache) {
7404
- return path13.join(getDataDir(), cache.fileName);
7479
+ return path14.join(getDataDir(), cache.fileName);
7405
7480
  }
7406
7481
  function resolveLegacyFilePath(cache, cwd) {
7407
- return path13.join(cwd, LEGACY_CACHE_DIR_NAME, cache.fileName);
7482
+ return path14.join(cwd, LEGACY_CACHE_DIR_NAME, cache.fileName);
7408
7483
  }
7409
7484
  function parseJsonFile(filePath) {
7410
7485
  try {
@@ -7444,7 +7519,7 @@ function readLegacyEntry(cache, cwd) {
7444
7519
  return parsed?.[cache.legacyEntryKey] ?? null;
7445
7520
  }
7446
7521
  function readCwdEntry(cache, cwd) {
7447
- const cwdKey = path13.resolve(cwd);
7522
+ const cwdKey = path14.resolve(cwd);
7448
7523
  const entries = readHomeEntries(cache);
7449
7524
  const homeEntry = entries[cwdKey];
7450
7525
  if (homeEntry) {
@@ -7466,11 +7541,11 @@ function readCwdEntry(cache, cwd) {
7466
7541
  }
7467
7542
  function writeCwdEntry(cache, cwd, entry) {
7468
7543
  const entries = readHomeEntries(cache);
7469
- writeHomeEntries(cache, { ...entries, [path13.resolve(cwd)]: entry });
7544
+ writeHomeEntries(cache, { ...entries, [path14.resolve(cwd)]: entry });
7470
7545
  }
7471
7546
  function clearCwdEntry(cache, cwd) {
7472
7547
  const entries = readHomeEntries(cache);
7473
- const cwdKey = path13.resolve(cwd);
7548
+ const cwdKey = path14.resolve(cwd);
7474
7549
  if (cwdKey in entries) {
7475
7550
  delete entries[cwdKey];
7476
7551
  writeHomeEntries(cache, entries);
@@ -7525,12 +7600,12 @@ function clearLastHost(cwd) {
7525
7600
 
7526
7601
  // packages/mcps/src/mcp/tools/local/tool-registry.ts
7527
7602
  function createChildLogger2(correlationId) {
7528
- const logger6 = getLogger();
7603
+ const logger7 = getLogger();
7529
7604
  return {
7530
- info: (msg, meta) => logger6.info(msg, { ...meta, correlationId }),
7531
- error: (msg, meta) => logger6.error(msg, { ...meta, correlationId }),
7532
- warn: (msg, meta) => logger6.warn(msg, { ...meta, correlationId }),
7533
- debug: (msg, meta) => logger6.debug(msg, { ...meta, correlationId })
7605
+ info: (msg, meta) => logger7.info(msg, { ...meta, correlationId }),
7606
+ error: (msg, meta) => logger7.error(msg, { ...meta, correlationId }),
7607
+ warn: (msg, meta) => logger7.warn(msg, { ...meta, correlationId }),
7608
+ debug: (msg, meta) => logger7.debug(msg, { ...meta, correlationId })
7534
7609
  };
7535
7610
  }
7536
7611
  var checkStatusTool = {
@@ -7538,8 +7613,8 @@ var checkStatusTool = {
7538
7613
  description: "Check the status of Muggle Test Local. This verifies the connection to web-service and shows current session information.",
7539
7614
  inputSchema: EmptyInputSchema2,
7540
7615
  execute: async (ctx) => {
7541
- const logger6 = createChildLogger2(ctx.correlationId);
7542
- logger6.info("Executing muggle-local-check-status");
7616
+ const logger7 = createChildLogger2(ctx.correlationId);
7617
+ logger7.info("Executing muggle-local-check-status");
7543
7618
  const authService = getAuthService();
7544
7619
  const storageService = getStorageService();
7545
7620
  const authStatus = authService.getAuthStatus();
@@ -7562,8 +7637,8 @@ var listSessionsTool = {
7562
7637
  description: "List all stored testing sessions. Shows session IDs, status, and metadata for each session.",
7563
7638
  inputSchema: ListSessionsInputSchema,
7564
7639
  execute: async (ctx) => {
7565
- const logger6 = createChildLogger2(ctx.correlationId);
7566
- logger6.info("Executing muggle-local-list-sessions");
7640
+ const logger7 = createChildLogger2(ctx.correlationId);
7641
+ logger7.info("Executing muggle-local-list-sessions");
7567
7642
  const input = ListSessionsInputSchema.parse(ctx.input);
7568
7643
  const storageService = getStorageService();
7569
7644
  const sessions = storageService.listSessionsWithMetadata();
@@ -7590,8 +7665,8 @@ var runResultListTool = {
7590
7665
  description: "List run results (test generation and replay history), optionally filtered by cloud test case ID.",
7591
7666
  inputSchema: RunResultListInputSchema,
7592
7667
  execute: async (ctx) => {
7593
- const logger6 = createChildLogger2(ctx.correlationId);
7594
- logger6.info("Executing muggle-local-run-result-list");
7668
+ const logger7 = createChildLogger2(ctx.correlationId);
7669
+ logger7.info("Executing muggle-local-run-result-list");
7595
7670
  const input = RunResultListInputSchema.parse(ctx.input);
7596
7671
  const storage = getRunResultStorageService();
7597
7672
  let results = storage.listRunResults();
@@ -7615,8 +7690,8 @@ var runStepsGetTool = {
7615
7690
  description: "Read a local run's steps beside the frames they produced, so the run's own verdict can be shown against its own evidence. Returns the ordered steps (action, the agent's explanation, screenshot path) plus the run's status and closing verdict. Takes a run id or a unique prefix; omit it for the most recent run. Read-only \u2014 it never modifies a session. Reach for this after a failed local run instead of parsing action-script.json by hand.",
7616
7691
  inputSchema: RunStepsGetInputSchema,
7617
7692
  execute: async (ctx) => {
7618
- const logger6 = createChildLogger2(ctx.correlationId);
7619
- logger6.info("Executing muggle-local-run-steps-get");
7693
+ const logger7 = createChildLogger2(ctx.correlationId);
7694
+ logger7.info("Executing muggle-local-run-steps-get");
7620
7695
  const input = RunStepsGetInputSchema.parse(ctx.input);
7621
7696
  try {
7622
7697
  const runView = readRunView(input.runId);
@@ -7638,8 +7713,8 @@ var runResultGetTool = {
7638
7713
  description: "Get detailed information about a run result including screenshots and action script output.",
7639
7714
  inputSchema: RunResultGetInputSchema,
7640
7715
  execute: async (ctx) => {
7641
- const logger6 = createChildLogger2(ctx.correlationId);
7642
- logger6.info("Executing muggle-local-run-result-get");
7716
+ const logger7 = createChildLogger2(ctx.correlationId);
7717
+ logger7.info("Executing muggle-local-run-result-get");
7643
7718
  const input = RunResultGetInputSchema.parse(ctx.input);
7644
7719
  const storage = getRunResultStorageService();
7645
7720
  const storedRunResult = storage.getRunResult(input.runId);
@@ -7673,11 +7748,11 @@ var runResultGetTool = {
7673
7748
  `**Location:** \`${storedRunResult.artifactsDir}\``,
7674
7749
  ""
7675
7750
  );
7676
- const actionScriptPath = path13.join(storedRunResult.artifactsDir, "action-script.json");
7677
- const resultsMdPath = path13.join(storedRunResult.artifactsDir, "results.md");
7678
- const screenshotsDir = path13.join(storedRunResult.artifactsDir, "screenshots");
7679
- const stdoutLogPath = path13.join(storedRunResult.artifactsDir, "stdout.log");
7680
- const stderrLogPath = path13.join(storedRunResult.artifactsDir, "stderr.log");
7751
+ const actionScriptPath = path14.join(storedRunResult.artifactsDir, "action-script.json");
7752
+ const resultsMdPath = path14.join(storedRunResult.artifactsDir, "results.md");
7753
+ const screenshotsDir = path14.join(storedRunResult.artifactsDir, "screenshots");
7754
+ const stdoutLogPath = path14.join(storedRunResult.artifactsDir, "stdout.log");
7755
+ const stderrLogPath = path14.join(storedRunResult.artifactsDir, "stderr.log");
7681
7756
  const artifactItems = [];
7682
7757
  if (fs4.existsSync(actionScriptPath)) {
7683
7758
  artifactItems.push("- `action-script.json` \u2014 generated test steps");
@@ -7717,8 +7792,8 @@ var testScriptListTool = {
7717
7792
  description: "List locally generated test scripts, optionally filtered by cloud test case ID.",
7718
7793
  inputSchema: TestScriptListInputSchema2,
7719
7794
  execute: async (ctx) => {
7720
- const logger6 = createChildLogger2(ctx.correlationId);
7721
- logger6.info("Executing muggle-local-test-script-list");
7795
+ const logger7 = createChildLogger2(ctx.correlationId);
7796
+ logger7.info("Executing muggle-local-test-script-list");
7722
7797
  const input = TestScriptListInputSchema2.parse(ctx.input);
7723
7798
  const storage = getRunResultStorageService();
7724
7799
  let scripts = storage.listTestScripts();
@@ -7738,8 +7813,8 @@ var testScriptGetTool = {
7738
7813
  description: "Get details of a locally generated test script including action script steps.",
7739
7814
  inputSchema: TestScriptGetInputSchema2,
7740
7815
  execute: async (ctx) => {
7741
- const logger6 = createChildLogger2(ctx.correlationId);
7742
- logger6.info("Executing muggle-local-test-script-get");
7816
+ const logger7 = createChildLogger2(ctx.correlationId);
7817
+ logger7.info("Executing muggle-local-test-script-get");
7743
7818
  const input = TestScriptGetInputSchema2.parse(ctx.input);
7744
7819
  const storage = getRunResultStorageService();
7745
7820
  const testScript = storage.getTestScript(input.testScriptId);
@@ -7764,8 +7839,8 @@ var executeTestGenerationTool = {
7764
7839
  description: "Generate an end-to-end (E2E) acceptance test script by launching a real browser against your web app. The browser navigates your app, executes the test case steps (like signing up, filling forms, clicking through flows), and produces a replayable test script with screenshots. Use this to create new browser tests for any user flow. Requires a test case (from muggle-remote-test-case-get) and a localhost URL. Launches an Electron browser \u2014 defaults to a visible window; pass showUi: false to run headless.",
7765
7840
  inputSchema: ExecuteTestGenerationInputSchema,
7766
7841
  execute: async (ctx) => {
7767
- const logger6 = createChildLogger2(ctx.correlationId);
7768
- logger6.info("Executing muggle-local-execute-test-generation");
7842
+ const logger7 = createChildLogger2(ctx.correlationId);
7843
+ logger7.info("Executing muggle-local-execute-test-generation");
7769
7844
  const input = ExecuteTestGenerationInputSchema.parse(ctx.input);
7770
7845
  const showUi = input.showUi !== false;
7771
7846
  try {
@@ -7796,7 +7871,7 @@ var executeTestGenerationTool = {
7796
7871
  };
7797
7872
  } catch (error) {
7798
7873
  const errorMessage = error instanceof Error ? error.message : String(error);
7799
- logger6.error("Test generation failed", { error: errorMessage });
7874
+ logger7.error("Test generation failed", { error: errorMessage });
7800
7875
  return { content: `Test generation failed: ${errorMessage}`, isError: true };
7801
7876
  }
7802
7877
  }
@@ -7806,8 +7881,8 @@ var executeReplayTool = {
7806
7881
  description: "Replay an existing E2E acceptance test script in a real browser to verify your app still works correctly \u2014 use this for regression testing after code changes. The browser executes each saved step and captures screenshots so you can see what happened. Requires: (1) test script metadata from muggle-remote-test-script-get, (2) actionScript content from muggle-remote-action-script-get using the testScript.actionScriptId, and (3) a localhost URL. Launches an Electron browser \u2014 defaults to a visible window; pass showUi: false to run headless.",
7807
7882
  inputSchema: ExecuteReplayInputSchema,
7808
7883
  execute: async (ctx) => {
7809
- const logger6 = createChildLogger2(ctx.correlationId);
7810
- logger6.info("Executing muggle-local-execute-replay");
7884
+ const logger7 = createChildLogger2(ctx.correlationId);
7885
+ logger7.info("Executing muggle-local-execute-replay");
7811
7886
  const input = ExecuteReplayInputSchema.parse(ctx.input);
7812
7887
  const showUi = input.showUi !== false;
7813
7888
  try {
@@ -7839,7 +7914,7 @@ var executeReplayTool = {
7839
7914
  };
7840
7915
  } catch (error) {
7841
7916
  const errorMessage = error instanceof Error ? error.message : String(error);
7842
- logger6.error("Test replay failed", { error: errorMessage });
7917
+ logger7.error("Test replay failed", { error: errorMessage });
7843
7918
  return { content: `Test replay failed: ${errorMessage}`, isError: true };
7844
7919
  }
7845
7920
  }
@@ -7849,8 +7924,8 @@ var cancelExecutionTool = {
7849
7924
  description: "Cancel an active test generation or replay execution.",
7850
7925
  inputSchema: CancelExecutionInputSchema,
7851
7926
  execute: async (ctx) => {
7852
- const logger6 = createChildLogger2(ctx.correlationId);
7853
- logger6.info("Executing muggle-local-cancel-execution");
7927
+ const logger7 = createChildLogger2(ctx.correlationId);
7928
+ logger7.info("Executing muggle-local-cancel-execution");
7854
7929
  const input = CancelExecutionInputSchema.parse(ctx.input);
7855
7930
  const cancelled = cancelExecution({ runId: input.runId });
7856
7931
  if (cancelled) {
@@ -7864,8 +7939,8 @@ var preferencesSetTool = {
7864
7939
  description: "Set a Muggle AI user preference. Preferences control automation behavior (auto-login, show browser, suggest test cases, etc.). Values: 'always' (proceed without asking), 'ask' (prompt each time), 'never' (skip without asking). Preferences are user-level: they always write to ~/.muggle-ai/preferences.json and apply to every repo.",
7865
7940
  inputSchema: PreferencesSetInputSchema,
7866
7941
  execute: async (ctx) => {
7867
- const logger6 = createChildLogger2(ctx.correlationId);
7868
- logger6.info("Executing muggle-local-preferences-set");
7942
+ const logger7 = createChildLogger2(ctx.correlationId);
7943
+ logger7.info("Executing muggle-local-preferences-set");
7869
7944
  const input = PreferencesSetInputSchema.parse(ctx.input);
7870
7945
  writePreferences2({ [input.key]: input.value });
7871
7946
  return {
@@ -7879,8 +7954,8 @@ var lastProjectGetTool = {
7879
7954
  description: `Get the cached last-used Muggle Test project for a repo (read from the entry keyed on <cwd> in ${MUGGLE_HOME_DISPLAY_DIR}/${LAST_PROJECT_FILE_NAME}). Returns the project ID, URL, name, and saved-at timestamp, or null if no cache exists. Skills consult this when 'autoSelectProject = always' to silently reuse the project the user picked previously, instead of presenting the project picker every time.`,
7880
7955
  inputSchema: LastProjectGetInputSchema,
7881
7956
  execute: async (ctx) => {
7882
- const logger6 = createChildLogger2(ctx.correlationId);
7883
- logger6.info("Executing muggle-local-last-project-get");
7957
+ const logger7 = createChildLogger2(ctx.correlationId);
7958
+ logger7.info("Executing muggle-local-last-project-get");
7884
7959
  const input = LastProjectGetInputSchema.parse(ctx.input);
7885
7960
  const cached = readLastProject(input.cwd);
7886
7961
  if (!cached) {
@@ -7909,8 +7984,8 @@ var lastProjectSetTool = {
7909
7984
  description: `Save the user's selected Muggle Test project as the cached last-used project for this repo. Writes the entry keyed on <cwd> in ${MUGGLE_HOME_DISPLAY_DIR}/${LAST_PROJECT_FILE_NAME}. Subsequent skill invocations honor 'autoSelectProject = always' by silently reusing this entry \u2014 no project picker shown. Always pair this call with 'muggle-local-preferences-set autoSelectProject=always' when the user chose 'Yes, save it'.`,
7910
7985
  inputSchema: LastProjectSetInputSchema,
7911
7986
  execute: async (ctx) => {
7912
- const logger6 = createChildLogger2(ctx.correlationId);
7913
- logger6.info("Executing muggle-local-last-project-set");
7987
+ const logger7 = createChildLogger2(ctx.correlationId);
7988
+ logger7.info("Executing muggle-local-last-project-set");
7914
7989
  const input = LastProjectSetInputSchema.parse(ctx.input);
7915
7990
  writeLastProject(input.cwd, {
7916
7991
  projectId: input.projectId,
@@ -7932,8 +8007,8 @@ var lastProjectClearTool = {
7932
8007
  description: "Remove the cached last-used project for this repo. After this, `autoSelectProject = always` will fall through to ask until the user picks a new project. No-op if no cache exists.",
7933
8008
  inputSchema: LastProjectClearInputSchema,
7934
8009
  execute: async (ctx) => {
7935
- const logger6 = createChildLogger2(ctx.correlationId);
7936
- logger6.info("Executing muggle-local-last-project-clear");
8010
+ const logger7 = createChildLogger2(ctx.correlationId);
8011
+ logger7.info("Executing muggle-local-last-project-clear");
7937
8012
  const input = LastProjectClearInputSchema.parse(ctx.input);
7938
8013
  clearLastProject(input.cwd);
7939
8014
  const content = [
@@ -7949,8 +8024,8 @@ var lastHostGetTool = {
7949
8024
  description: `Get the cached last-used local dev server URL for a repo (read from the entry keyed on <cwd> in ${MUGGLE_HOME_DISPLAY_DIR}/${LAST_HOST_FILE_NAME}). Returns the URL and saved-at timestamp, or null if no cache exists. Skills consult this when 'autoSelectLocalHost = always' to silently reuse the URL the user used previously.`,
7950
8025
  inputSchema: LastHostGetInputSchema,
7951
8026
  execute: async (ctx) => {
7952
- const logger6 = createChildLogger2(ctx.correlationId);
7953
- logger6.info("Executing muggle-local-last-host-get");
8027
+ const logger7 = createChildLogger2(ctx.correlationId);
8028
+ logger7.info("Executing muggle-local-last-host-get");
7954
8029
  const input = LastHostGetInputSchema.parse(ctx.input);
7955
8030
  const cached = readLastHost(input.cwd);
7956
8031
  if (!cached) {
@@ -7975,8 +8050,8 @@ var lastHostSetTool = {
7975
8050
  description: `Save the user's chosen local dev server URL as the cached last-used host for this repo. Writes the entry keyed on <cwd> in ${MUGGLE_HOME_DISPLAY_DIR}/${LAST_HOST_FILE_NAME}. Call this on every host pick (independent of 'Remember this URL?' Picker 2) so future runs can offer 'Use {lastHost}' regardless of whether the user opted to set autoSelectLocalHost=always.`,
7976
8051
  inputSchema: LastHostSetInputSchema,
7977
8052
  execute: async (ctx) => {
7978
- const logger6 = createChildLogger2(ctx.correlationId);
7979
- logger6.info("Executing muggle-local-last-host-set");
8053
+ const logger7 = createChildLogger2(ctx.correlationId);
8054
+ logger7.info("Executing muggle-local-last-host-set");
7980
8055
  const input = LastHostSetInputSchema.parse(ctx.input);
7981
8056
  writeLastHost(input.cwd, input.host);
7982
8057
  return {
@@ -7990,8 +8065,8 @@ var lastHostClearTool = {
7990
8065
  description: "Remove the cached last-used host for this repo. After this, `autoSelectLocalHost = always` will fall through to ask until the user picks a new URL. No-op if no cache exists.",
7991
8066
  inputSchema: LastHostClearInputSchema,
7992
8067
  execute: async (ctx) => {
7993
- const logger6 = createChildLogger2(ctx.correlationId);
7994
- logger6.info("Executing muggle-local-last-host-clear");
8068
+ const logger7 = createChildLogger2(ctx.correlationId);
8069
+ logger7.info("Executing muggle-local-last-host-clear");
7995
8070
  const input = LastHostClearInputSchema.parse(ctx.input);
7996
8071
  clearLastHost(input.cwd);
7997
8072
  return {