@mrrlin-dev/mcp 0.4.257 → 0.4.261

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin.cjs +79 -36
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -70277,10 +70277,7 @@ function planWindowsInstall(o) {
70277
70277
  grant(journalDir, `*${ADMINS}:(OI)(CI)F`, `*${SYSTEM}:(OI)(CI)F`, `*${sid}:(OI)(CI)M`),
70278
70278
  grant(spoolDir, `*${ADMINS}:(OI)(CI)F`, `*${SYSTEM}:(OI)(CI)F`, `*${sid}:(OI)(CI)M`, `*${o.providerSid}:(OI)(CI)(RX,D)`)
70279
70279
  ];
70280
- const apply = [
70281
- // The key: read by the service only; the service itself refuses a key anyone else may read.
70282
- grant(keyPath, `*${ADMINS}:F`, `*${SYSTEM}:F`, `*${sid}:R`),
70283
- [csc, "/nologo", "/target:exe", "/r:System.ServiceProcess.dll", `/out:${exePath}`, sourceCopy],
70280
+ const register = [
70284
70281
  [
70285
70282
  "sc.exe",
70286
70283
  "create",
@@ -70294,7 +70291,12 @@ function planWindowsInstall(o) {
70294
70291
  "DisplayName=",
70295
70292
  "Mrrlin drain service"
70296
70293
  ],
70297
- ["sc.exe", "sidtype", o.serviceName, "restricted"],
70294
+ ["sc.exe", "sidtype", o.serviceName, "restricted"]
70295
+ ];
70296
+ const apply = [
70297
+ // The key: read by the service only; the service itself refuses a key anyone else may read.
70298
+ grant(keyPath, `*${ADMINS}:F`, `*${SYSTEM}:F`, `*${sid}:R`),
70299
+ [csc, "/nologo", "/target:exe", "/r:System.ServiceProcess.dll", `/out:${exePath}`, sourceCopy],
70298
70300
  [
70299
70301
  "netsh",
70300
70302
  "advfirewall",
@@ -70309,7 +70311,7 @@ function planWindowsInstall(o) {
70309
70311
  ],
70310
70312
  ["sc.exe", "start", o.serviceName]
70311
70313
  ];
70312
- return { directories, lockdown, copies, apply, config: config2, configPath, exePath, serviceSid: sid };
70314
+ return { directories, register, lockdown, copies, apply, config: config2, configPath, exePath, serviceSid: sid };
70313
70315
  }
70314
70316
  function planWindowsUninstall(o) {
70315
70317
  if (!SERVICE_NAME.test(o.serviceName)) throw new Error("invalid service name");
@@ -70457,6 +70459,7 @@ async function runWindowsVerify(out, version2) {
70457
70459
  (0, import_node_fs33.rmSync)(paths.dataDir, { recursive: true, force: true });
70458
70460
  });
70459
70461
  for (const dir of plan.directories) (0, import_node_fs33.mkdirSync)(dir, { recursive: true });
70462
+ for (const argv of plan.register) run4(argv);
70460
70463
  for (const argv of plan.lockdown) run4(argv);
70461
70464
  for (const [from, to] of plan.copies) (0, import_node_fs33.copyFileSync)(from, to);
70462
70465
  const key = generateWindowsDrainKey();
@@ -70794,6 +70797,7 @@ var init_windows_verify = __esm({
70794
70797
  var cli_exports = {};
70795
70798
  __export(cli_exports, {
70796
70799
  WINDOWS_DRAIN_VERIFIED: () => WINDOWS_DRAIN_VERIFIED,
70800
+ drainServiceEndpointFor: () => drainServiceEndpointFor,
70797
70801
  drainServiceStatus: () => drainServiceStatus,
70798
70802
  readDrainServiceEndpoint: () => readDrainServiceEndpoint,
70799
70803
  runDrainServiceCli: () => runDrainServiceCli
@@ -70921,14 +70925,35 @@ Processes the provider starts outside the attempt tree (docker, pm2, user servic
70921
70925
  `);
70922
70926
  return 0;
70923
70927
  }
70924
- function readDrainServiceEndpoint() {
70925
- if (process.platform !== "linux" || !(0, import_node_fs34.existsSync)(CONFIG)) return null;
70926
- try {
70927
- const config2 = JSON.parse((0, import_node_fs34.readFileSync)(CONFIG, "utf8"));
70928
- return typeof config2.socketPath === "string" && typeof config2.spoolDir === "string" ? { socketPath: config2.socketPath, spoolDir: config2.spoolDir } : null;
70929
- } catch {
70930
- return null;
70928
+ function drainServiceEndpointFor(platform, readConfig, env = process.env) {
70929
+ const parse9 = (path42) => {
70930
+ const raw = readConfig(path42);
70931
+ if (raw === null) return null;
70932
+ try {
70933
+ const value = JSON.parse(raw);
70934
+ return value && typeof value === "object" ? value : null;
70935
+ } catch {
70936
+ return null;
70937
+ }
70938
+ };
70939
+ if (platform === "linux") {
70940
+ const config2 = parse9(CONFIG);
70941
+ return config2 && typeof config2.socketPath === "string" && typeof config2.spoolDir === "string" ? { socketPath: config2.socketPath, spoolDir: config2.spoolDir, elevated: sudoNonInteractiveSucceeds } : null;
70931
70942
  }
70943
+ if (platform === "win32" && WINDOWS_DRAIN_VERIFIED) {
70944
+ const config2 = parse9(windowsConfigPath(env));
70945
+ return config2 && typeof config2.pipeName === "string" && config2.pipeName.startsWith("\\\\.\\pipe\\") && typeof config2.spoolDir === "string" && /^[A-Za-z]:\\/.test(config2.spoolDir) ? { socketPath: config2.pipeName, spoolDir: config2.spoolDir, elevated: windowsIsElevated } : null;
70946
+ }
70947
+ return null;
70948
+ }
70949
+ function readDrainServiceEndpoint() {
70950
+ return drainServiceEndpointFor(process.platform, (path42) => {
70951
+ try {
70952
+ return (0, import_node_fs34.existsSync)(path42) ? (0, import_node_fs34.readFileSync)(path42, "utf8") : null;
70953
+ } catch {
70954
+ return null;
70955
+ }
70956
+ });
70932
70957
  }
70933
70958
  async function drainServiceStatus(version2) {
70934
70959
  if (process.platform === "win32") {
@@ -71121,6 +71146,7 @@ async function runWindowsCli(command, rest, out, version2) {
71121
71146
  windowsDir: paths.windowsDir
71122
71147
  });
71123
71148
  for (const dir of plan.directories) (0, import_node_fs34.mkdirSync)(dir, { recursive: true });
71149
+ for (const argv of plan.register) runArgv(argv, { stdio: "inherit", windowsHide: true });
71124
71150
  for (const argv of plan.lockdown) runArgv(argv, { stdio: "inherit", windowsHide: true });
71125
71151
  for (const [from, to] of plan.copies) (0, import_node_fs34.copyFileSync)(from, to);
71126
71152
  (0, import_node_fs34.writeFileSync)(plan.configPath, JSON.stringify(plan.config, null, 2));
@@ -71178,7 +71204,7 @@ var init_cli = __esm({
71178
71204
  PREFIX = "/opt/mrrlin-drain";
71179
71205
  CONFIG = `${PREFIX}/config.json`;
71180
71206
  UNIT = "/etc/systemd/system/mrrlin-drain.service";
71181
- WINDOWS_DRAIN_VERIFIED = false;
71207
+ WINDOWS_DRAIN_VERIFIED = true;
71182
71208
  }
71183
71209
  });
71184
71210
 
@@ -78660,8 +78686,9 @@ function createMrrlinClient(config2) {
78660
78686
  });
78661
78687
  return executionRunResponseSchema.parse(body).data;
78662
78688
  } catch (error51) {
78663
- if (error51 instanceof MrrlinApiError && error51.status === 409)
78689
+ if (error51 instanceof MrrlinApiError && error51.status === 409 && error51.code === "EXECUTION_RUN_OUTCOME_NOT_SETTLEABLE") {
78664
78690
  return null;
78691
+ }
78665
78692
  throw error51;
78666
78693
  }
78667
78694
  },
@@ -105678,6 +105705,17 @@ init_dist();
105678
105705
  function bridgeAccountKey(principal) {
105679
105706
  return (0, import_node_crypto24.createHash)("sha256").update(canonLogin(principal)).digest("hex").slice(0, 16);
105680
105707
  }
105708
+ function accountKeyFromOperatorToken(token) {
105709
+ const payload = token.split(".")[0];
105710
+ if (!payload) return null;
105711
+ try {
105712
+ const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
105713
+ const login = parsed && typeof parsed === "object" ? parsed.login : void 0;
105714
+ return typeof login === "string" && login.trim() ? bridgeAccountKey(login) : null;
105715
+ } catch {
105716
+ return null;
105717
+ }
105718
+ }
105681
105719
 
105682
105720
  // src/bridge-scoped-run-read.ts
105683
105721
  function createScopedRunRead(options) {
@@ -106874,7 +106912,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
106874
106912
  }
106875
106913
 
106876
106914
  // src/_generated/version.ts
106877
- var PKG_VERSION = "0.4.257";
106915
+ var PKG_VERSION = "0.4.261";
106878
106916
 
106879
106917
  // src/bridge-allowed-origins.ts
106880
106918
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -113342,7 +113380,7 @@ function defaultDrainSupervisor() {
113342
113380
  if (!endpoint) return null;
113343
113381
  return {
113344
113382
  healthy: async () => (await drainServiceStatus(PKG_VERSION)).state === "healthy",
113345
- start: (start) => startDrainSupervision(endpoint.socketPath, start, { expectedVersion: PKG_VERSION }),
113383
+ start: (start) => startDrainSupervision(endpoint.socketPath, start, { expectedVersion: PKG_VERSION, elevated: endpoint.elevated }),
113346
113384
  relay: (relay) => relaySpool(endpoint.spoolDir, relay)
113347
113385
  };
113348
113386
  }
@@ -113472,16 +113510,19 @@ function f54ProgressRequested(env = process.env) {
113472
113510
  function resolveF54ProgressLease(containable, env = process.env) {
113473
113511
  return f54ProgressRequested(env) && containable;
113474
113512
  }
113475
- async function claimIsContainable(deps, supervisor) {
113476
- if (deps.verifyContainment || process.platform === "win32") {
113477
- try {
113478
- await (deps.verifyContainment ?? verifyOwnedExecutionContainment)();
113479
- return true;
113480
- } catch {
113481
- return false;
113482
- }
113513
+ async function claimIsContainable(deps, supervisor, platform = process.platform) {
113514
+ if (await launcherContains(deps, platform)) return true;
113515
+ if (deps.verifyContainment && platform !== "win32") return false;
113516
+ return (platform === "linux" || platform === "win32") && supervisor !== null && await supervisor.healthy().catch(() => false);
113517
+ }
113518
+ async function launcherContains(deps, platform) {
113519
+ if (!deps.verifyContainment && platform !== "win32") return false;
113520
+ try {
113521
+ await (deps.verifyContainment ?? verifyOwnedExecutionContainment)();
113522
+ return true;
113523
+ } catch {
113524
+ return false;
113483
113525
  }
113484
- return process.platform === "linux" && supervisor !== null && await supervisor.healthy().catch(() => false);
113485
113526
  }
113486
113527
  async function driveRun(deps, projectSlug, runId, shutdown) {
113487
113528
  if (shutdown?.aborted) return;
@@ -113532,7 +113573,7 @@ async function driveRun(deps, projectSlug, runId, shutdown) {
113532
113573
  await releaseUnstartedClaim("drain_supervision_unavailable");
113533
113574
  return;
113534
113575
  }
113535
- if (progressLease && !supervision && process.platform !== "win32" && !deps.verifyContainment) {
113576
+ if (progressLease && !supervision && !await launcherContains(deps, process.platform)) {
113536
113577
  await releaseUnstartedClaim("drain_supervision_unavailable");
113537
113578
  return;
113538
113579
  }
@@ -115849,7 +115890,7 @@ ${lines2}`
115849
115890
  task,
115850
115891
  runId,
115851
115892
  leaseId,
115852
- `non_code_outcome_settlement_conflict: settlement was rejected while this consumer still held the lease.`
115893
+ `non_code_outcome_settlement_conflict: Mrrlin refused to record the result (${pageId}) while this helper still held the run.`
115853
115894
  );
115854
115895
  }
115855
115896
  } catch (error51) {
@@ -127858,6 +127899,11 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
127858
127899
  const apiBaseUrl = readDirectorBridgeApiBaseUrl();
127859
127900
  const envToken = process.env.MRRLIN_TOKEN?.trim() || void 0;
127860
127901
  let tokenProvider = null;
127902
+ let accountKey = null;
127903
+ const noteAccountFromToken = (token) => {
127904
+ const key = token ? accountKeyFromOperatorToken(token) : null;
127905
+ if (key) accountKey = key;
127906
+ };
127861
127907
  let tokenRefresher = null;
127862
127908
  let schedulerGenerations;
127863
127909
  let schedulerScope;
@@ -127909,7 +127955,10 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
127909
127955
  }
127910
127956
  tokenRefresher = createTokenRefresher({
127911
127957
  provider: refreshProvider,
127912
- persist: persistOperatorToken,
127958
+ persist: (token) => {
127959
+ noteAccountFromToken(token);
127960
+ persistOperatorToken(token);
127961
+ },
127913
127962
  intervalMs: tokenRefreshIntervalMs(),
127914
127963
  failureLog,
127915
127964
  onOk: () => health.setApiAuth("ok"),
@@ -127926,6 +127975,7 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
127926
127975
  } else {
127927
127976
  const apiToken = startupRollback?.bearer ?? envToken ?? readOperatorToken() ?? void 0;
127928
127977
  staticToken = apiToken;
127978
+ noteAccountFromToken(apiToken);
127929
127979
  if (envToken) {
127930
127980
  try {
127931
127981
  persistOperatorToken(envToken);
@@ -128553,13 +128603,6 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
128553
128603
  bridgeBinShaShort = import_node_crypto40.default.createHash("sha256").update(import_node_fs42.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
128554
128604
  } catch {
128555
128605
  }
128556
- let accountKey = null;
128557
- if (tokenProvider) {
128558
- void client.getMyAccount().then((account) => {
128559
- accountKey = bridgeAccountKey(account.data.principal);
128560
- }).catch(() => {
128561
- });
128562
- }
128563
128606
  const bridgeWss = attachBridgeWss(server, {
128564
128607
  getAccountKey: () => accountKey,
128565
128608
  token: config2.token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.257",
3
+ "version": "0.4.261",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"