@memoraone/mcp 0.1.63 → 0.1.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -231,7 +231,7 @@ var require_package = __commonJS({
231
231
  "package.json"(exports2, module2) {
232
232
  module2.exports = {
233
233
  name: "@memoraone/mcp",
234
- version: "0.1.63",
234
+ version: "0.1.65",
235
235
  type: "module",
236
236
  main: "dist/index.cjs",
237
237
  exports: {
@@ -2742,6 +2742,152 @@ var init_cursorGlobalMcpConfig = __esm({
2742
2742
  }
2743
2743
  });
2744
2744
 
2745
+ // src/processCommandLines.ts
2746
+ function resolveProcessListUser(env2 = process.env) {
2747
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
2748
+ return user && user.trim() ? user.trim() : void 0;
2749
+ }
2750
+ function posixPsArgs(user) {
2751
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
2752
+ }
2753
+ function resolveWindowsPowerShellPath(env2 = process.env) {
2754
+ const systemRoot = env2.SystemRoot || env2.windir;
2755
+ if (systemRoot && systemRoot.trim()) {
2756
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
2757
+ }
2758
+ return "powershell.exe";
2759
+ }
2760
+ function windowsProcessListInvocation(env2 = process.env) {
2761
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
2762
+ return {
2763
+ file: resolveWindowsPowerShellPath(env2),
2764
+ args: [
2765
+ "-NoLogo",
2766
+ "-NoProfile",
2767
+ "-NonInteractive",
2768
+ "-ExecutionPolicy",
2769
+ "Bypass",
2770
+ "-EncodedCommand",
2771
+ encoded
2772
+ ]
2773
+ };
2774
+ }
2775
+ function stdoutToString(stdout) {
2776
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
2777
+ }
2778
+ function rowFromWindowsProcessJson(item) {
2779
+ if (!item || typeof item !== "object") return null;
2780
+ const rec = item;
2781
+ const pidRaw = rec.pid ?? rec.ProcessId;
2782
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
2783
+ if (!Number.isFinite(pid) || pid <= 0) return null;
2784
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
2785
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
2786
+ return `${pid} ${command}`;
2787
+ }
2788
+ function rowsFromWindowsJson(parsed2) {
2789
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
2790
+ const rows = [];
2791
+ for (const item of items) {
2792
+ const row = rowFromWindowsProcessJson(item);
2793
+ if (row) rows.push(row);
2794
+ }
2795
+ return rows;
2796
+ }
2797
+ function parseWindowsProcessJsonLines(stdout) {
2798
+ const text = stdout.replace(/^\uFEFF/, "").trim();
2799
+ if (!text) return [];
2800
+ try {
2801
+ return rowsFromWindowsJson(JSON.parse(text));
2802
+ } catch {
2803
+ }
2804
+ const rows = [];
2805
+ for (const line of text.split(/\r?\n/)) {
2806
+ const trimmed = line.trim();
2807
+ if (!trimmed) continue;
2808
+ try {
2809
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
2810
+ } catch {
2811
+ }
2812
+ }
2813
+ return rows;
2814
+ }
2815
+ async function listProcessCommandLineRows(deps = {}) {
2816
+ const platform2 = deps.platform ?? process.platform;
2817
+ const execFileImpl = deps.execFile ?? execFileAsync3;
2818
+ if (platform2 === "win32") {
2819
+ const { file, args: args2 } = windowsProcessListInvocation();
2820
+ const { stdout: stdout2 } = await execFileImpl(file, args2, {
2821
+ maxBuffer: PROCESS_LIST_MAX_BUFFER,
2822
+ timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
2823
+ });
2824
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
2825
+ }
2826
+ const psArgs = posixPsArgs(resolveProcessListUser());
2827
+ const { stdout } = await execFileImpl("ps", psArgs, {
2828
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
2829
+ });
2830
+ return stdoutToString(stdout).split("\n");
2831
+ }
2832
+ var import_node_child_process3, import_node_util3, execFileAsync3, PROCESS_LIST_MAX_BUFFER, WINDOWS_PROCESS_LIST_TIMEOUT_MS, WINDOWS_LIST_PROCESSES_PS;
2833
+ var init_processCommandLines = __esm({
2834
+ "src/processCommandLines.ts"() {
2835
+ import_node_child_process3 = require("child_process");
2836
+ import_node_util3 = require("util");
2837
+ execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
2838
+ PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
2839
+ WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
2840
+ WINDOWS_LIST_PROCESSES_PS = [
2841
+ "$ErrorActionPreference = 'Stop'",
2842
+ '$ProgressPreference = "SilentlyContinue"',
2843
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
2844
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
2845
+ "trap {",
2846
+ " [Console]::Error.WriteLine([string]$_)",
2847
+ " exit 1",
2848
+ "}",
2849
+ "$currentIdentity = [string][System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
2850
+ "if ([string]::IsNullOrWhiteSpace($currentIdentity)) {",
2851
+ ' throw "Unable to determine the current Windows identity."',
2852
+ "}",
2853
+ "$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
2854
+ "if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
2855
+ ' throw "Unable to determine the Windows system directory."',
2856
+ "}",
2857
+ '$tasklistPath = [System.IO.Path]::Combine($systemDirectory, "tasklist.exe")',
2858
+ '$tasklistArgs = @("/FI", "USERNAME eq $currentIdentity", "/FO", "CSV", "/NH")',
2859
+ "$tasklistRows = @(& $tasklistPath $tasklistArgs)",
2860
+ "$tasklistExitCode = $LASTEXITCODE",
2861
+ "if ($tasklistExitCode -ne 0) {",
2862
+ ' throw "tasklist.exe failed with exit code $tasklistExitCode."',
2863
+ "}",
2864
+ '$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
2865
+ "foreach ($tasklistRow in $tasklistRows) {",
2866
+ " if ([string]::IsNullOrWhiteSpace([string]$tasklistRow)) { continue }",
2867
+ ' $task = $tasklistRow | ConvertFrom-Csv -Header "ImageName","ProcessId","SessionName","SessionNumber","MemoryUsage"',
2868
+ " $taskPid = 0",
2869
+ " if ($null -eq $task -or -not [int]::TryParse([string]$task.ProcessId, [ref]$taskPid) -or $taskPid -le 0) {",
2870
+ ' throw "tasklist.exe returned an invalid process row."',
2871
+ " }",
2872
+ " $null = $currentUserPids.Add($taskPid)",
2873
+ "}",
2874
+ "if (-not $currentUserPids.Contains([int]$PID)) {",
2875
+ ' throw "tasklist.exe results did not include the running PowerShell process."',
2876
+ "}",
2877
+ "$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
2878
+ "foreach ($proc in $processes) {",
2879
+ " if ($null -eq $proc.ProcessId) { continue }",
2880
+ " $processId = [int]$proc.ProcessId",
2881
+ " if (-not $currentUserPids.Contains($processId)) { continue }",
2882
+ ' $commandLine = ""',
2883
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
2884
+ " $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
2885
+ " ConvertTo-Json -InputObject $row -Compress",
2886
+ "}"
2887
+ ].join("\n");
2888
+ }
2889
+ });
2890
+
2745
2891
  // src/cleanup.ts
2746
2892
  var cleanup_exports = {};
2747
2893
  __export(cleanup_exports, {
@@ -2929,13 +3075,9 @@ function normalizeCleanupProjectId(projectId) {
2929
3075
  }
2930
3076
  return trimmed.toLowerCase();
2931
3077
  }
2932
- async function defaultListDaemonProcesses() {
2933
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
2934
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
2935
- const { stdout } = await execFileAsync3("ps", psArgs, {
2936
- maxBuffer: 10 * 1024 * 1024
2937
- });
2938
- return parseDaemonProcessLines(stdout.split("\n"));
3078
+ async function defaultListDaemonProcesses(deps) {
3079
+ const lines = await listProcessCommandLineRows(deps);
3080
+ return parseDaemonProcessLines(lines);
2939
3081
  }
2940
3082
  async function defaultListSocketPaths(projectId) {
2941
3083
  const baseDir = getMcpBaseDir();
@@ -3431,24 +3573,22 @@ async function cliCleanup(argv) {
3431
3573
  }
3432
3574
  return result.exitCode;
3433
3575
  }
3434
- var fs9, path17, readline, import_node_child_process3, import_node_util3, import_node_process, execFileAsync3, DAEMON_PROJECT_ID_RE, DAEMON_BINDING_ID_RE, PROJECT_ID_RE, MEMORAONE_MCP_COMMAND_RE, CLEANUP_PROJECT_ID_REQUIRED_ERROR;
3576
+ var fs9, path17, readline, import_node_process, DAEMON_PROJECT_ID_RE, DAEMON_BINDING_ID_RE, PROJECT_ID_RE, MEMORAONE_MCP_COMMAND_RE, CLEANUP_PROJECT_ID_REQUIRED_ERROR;
3435
3577
  var init_cleanup = __esm({
3436
3578
  "src/cleanup.ts"() {
3437
3579
  fs9 = __toESM(require("fs/promises"), 1);
3438
3580
  path17 = __toESM(require("path"), 1);
3439
3581
  readline = __toESM(require("readline/promises"), 1);
3440
- import_node_child_process3 = require("child_process");
3441
- import_node_util3 = require("util");
3442
3582
  import_node_process = require("process");
3443
3583
  init_socketPaths();
3444
3584
  init_bindingSidecar();
3445
3585
  init_projectBinding();
3446
3586
  init_cursorGlobalMcpConfig();
3447
- execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
3587
+ init_processCommandLines();
3448
3588
  DAEMON_PROJECT_ID_RE = /--project-id\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
3449
3589
  DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
3450
3590
  PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3451
- MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone\/mcp/;
3591
+ MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
3452
3592
  CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
3453
3593
  }
3454
3594
  });
@@ -12154,13 +12294,9 @@ function parseClineHubProcessLines(lines) {
12154
12294
  }
12155
12295
  return processes;
12156
12296
  }
12157
- async function defaultListClineHubProcesses() {
12158
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
12159
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
12160
- const { stdout } = await execFileAsync5("ps", psArgs, {
12161
- maxBuffer: 10 * 1024 * 1024
12162
- });
12163
- return parseClineHubProcessLines(stdout.split("\n"));
12297
+ async function defaultListClineHubProcesses(deps) {
12298
+ const lines = await listProcessCommandLineRows(deps);
12299
+ return parseClineHubProcessLines(lines);
12164
12300
  }
12165
12301
  async function defaultRemoveSocket2(socketPath) {
12166
12302
  await fs34.unlink(socketPath);
@@ -12358,16 +12494,14 @@ async function runConnectRuntimeCleanup(options) {
12358
12494
  staleRuntimeRemains
12359
12495
  };
12360
12496
  }
12361
- var path42, import_node_child_process6, import_node_util5, fs34, execFileAsync5, CLINE_HUB_DAEMON_MARKER;
12497
+ var path42, fs34, CLINE_HUB_DAEMON_MARKER;
12362
12498
  var init_connectRuntimeCleanup = __esm({
12363
12499
  "src/connectRuntimeCleanup.ts"() {
12364
12500
  path42 = __toESM(require("path"), 1);
12365
- import_node_child_process6 = require("child_process");
12366
- import_node_util5 = require("util");
12367
12501
  fs34 = __toESM(require("fs/promises"), 1);
12368
12502
  init_cleanup();
12369
12503
  init_bindingSidecar();
12370
- execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
12504
+ init_processCommandLines();
12371
12505
  CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
12372
12506
  }
12373
12507
  });
@@ -13510,7 +13644,7 @@ function defaultSpawnGateway(cliPath, env2) {
13510
13644
  return new Promise((resolve45, reject) => {
13511
13645
  let child;
13512
13646
  try {
13513
- child = (0, import_node_child_process7.spawn)(process.execPath, buildGatewaySpawnArgs(cliPath), {
13647
+ child = (0, import_node_child_process6.spawn)(process.execPath, buildGatewaySpawnArgs(cliPath), {
13514
13648
  detached: true,
13515
13649
  stdio: "ignore",
13516
13650
  env: { ...env2 }
@@ -13597,10 +13731,10 @@ async function cliEnsureGateway(_argv = [], options = {}) {
13597
13731
  return 1;
13598
13732
  }
13599
13733
  }
13600
- var import_node_child_process7, log;
13734
+ var import_node_child_process6, log;
13601
13735
  var init_gatewayEnsure = __esm({
13602
13736
  "src/gatewayEnsure.ts"() {
13603
- import_node_child_process7 = require("child_process");
13737
+ import_node_child_process6 = require("child_process");
13604
13738
  init_localLocks();
13605
13739
  init_resolveBuiltCliPath();
13606
13740
  init_gatewayConfig();
@@ -14225,7 +14359,7 @@ function redactStartupDiagnostic(text) {
14225
14359
  async function spawnDaemonAndConnect(binding, socketPath, options) {
14226
14360
  const timeoutMs = options.timeoutMs ?? 1e4;
14227
14361
  const delayMs = options.retryDelayMs ?? 50;
14228
- const child = (0, import_node_child_process8.spawn)(
14362
+ const child = (0, import_node_child_process7.spawn)(
14229
14363
  process.execPath,
14230
14364
  buildDaemonSpawnArgs(options.cliPath, binding.repositoryBindingId, options.env, options.ideType),
14231
14365
  {
@@ -14430,12 +14564,12 @@ async function runBridgeProxy(options) {
14430
14564
  router.close();
14431
14565
  }
14432
14566
  }
14433
- var net, readline4, import_node_child_process8, defaultLog, JSONRPC_METHOD_NOT_FOUND, SETUP_REQUIRED_FINISH_SETUP_TOOL, BridgeDaemonRouter;
14567
+ var net, readline4, import_node_child_process7, defaultLog, JSONRPC_METHOD_NOT_FOUND, SETUP_REQUIRED_FINISH_SETUP_TOOL, BridgeDaemonRouter;
14434
14568
  var init_bridgeProxy = __esm({
14435
14569
  "src/bridgeProxy.ts"() {
14436
14570
  net = __toESM(require("net"), 1);
14437
14571
  readline4 = __toESM(require("readline"), 1);
14438
- import_node_child_process8 = require("child_process");
14572
+ import_node_child_process7 = require("child_process");
14439
14573
  init_bindingIdentity();
14440
14574
  init_bindingSidecar();
14441
14575
  init_bridgeClientRoots();
package/dist/daemon.cjs CHANGED
@@ -3589,8 +3589,6 @@ var import_node_crypto25 = require("crypto");
3589
3589
  var fs11 = __toESM(require("fs/promises"), 1);
3590
3590
  var path20 = __toESM(require("path"), 1);
3591
3591
  var readline2 = __toESM(require("readline/promises"), 1);
3592
- var import_node_child_process3 = require("child_process");
3593
- var import_node_util3 = require("util");
3594
3592
  var import_node_process = require("process");
3595
3593
 
3596
3594
  // src/cursorGlobalMcpConfig.ts
@@ -4124,12 +4122,152 @@ function logCursorMcpConfigAudit(prefix, audit) {
4124
4122
  }
4125
4123
  }
4126
4124
 
4127
- // src/cleanup.ts
4125
+ // src/processCommandLines.ts
4126
+ var import_node_child_process3 = require("child_process");
4127
+ var import_node_util3 = require("util");
4128
4128
  var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
4129
+ var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
4130
+ var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
4131
+ var WINDOWS_LIST_PROCESSES_PS = [
4132
+ "$ErrorActionPreference = 'Stop'",
4133
+ '$ProgressPreference = "SilentlyContinue"',
4134
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
4135
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
4136
+ "trap {",
4137
+ " [Console]::Error.WriteLine([string]$_)",
4138
+ " exit 1",
4139
+ "}",
4140
+ "$currentIdentity = [string][System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
4141
+ "if ([string]::IsNullOrWhiteSpace($currentIdentity)) {",
4142
+ ' throw "Unable to determine the current Windows identity."',
4143
+ "}",
4144
+ "$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
4145
+ "if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
4146
+ ' throw "Unable to determine the Windows system directory."',
4147
+ "}",
4148
+ '$tasklistPath = [System.IO.Path]::Combine($systemDirectory, "tasklist.exe")',
4149
+ '$tasklistArgs = @("/FI", "USERNAME eq $currentIdentity", "/FO", "CSV", "/NH")',
4150
+ "$tasklistRows = @(& $tasklistPath $tasklistArgs)",
4151
+ "$tasklistExitCode = $LASTEXITCODE",
4152
+ "if ($tasklistExitCode -ne 0) {",
4153
+ ' throw "tasklist.exe failed with exit code $tasklistExitCode."',
4154
+ "}",
4155
+ '$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
4156
+ "foreach ($tasklistRow in $tasklistRows) {",
4157
+ " if ([string]::IsNullOrWhiteSpace([string]$tasklistRow)) { continue }",
4158
+ ' $task = $tasklistRow | ConvertFrom-Csv -Header "ImageName","ProcessId","SessionName","SessionNumber","MemoryUsage"',
4159
+ " $taskPid = 0",
4160
+ " if ($null -eq $task -or -not [int]::TryParse([string]$task.ProcessId, [ref]$taskPid) -or $taskPid -le 0) {",
4161
+ ' throw "tasklist.exe returned an invalid process row."',
4162
+ " }",
4163
+ " $null = $currentUserPids.Add($taskPid)",
4164
+ "}",
4165
+ "if (-not $currentUserPids.Contains([int]$PID)) {",
4166
+ ' throw "tasklist.exe results did not include the running PowerShell process."',
4167
+ "}",
4168
+ "$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
4169
+ "foreach ($proc in $processes) {",
4170
+ " if ($null -eq $proc.ProcessId) { continue }",
4171
+ " $processId = [int]$proc.ProcessId",
4172
+ " if (-not $currentUserPids.Contains($processId)) { continue }",
4173
+ ' $commandLine = ""',
4174
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
4175
+ " $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
4176
+ " ConvertTo-Json -InputObject $row -Compress",
4177
+ "}"
4178
+ ].join("\n");
4179
+ function resolveProcessListUser(env2 = process.env) {
4180
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
4181
+ return user && user.trim() ? user.trim() : void 0;
4182
+ }
4183
+ function posixPsArgs(user) {
4184
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
4185
+ }
4186
+ function resolveWindowsPowerShellPath(env2 = process.env) {
4187
+ const systemRoot = env2.SystemRoot || env2.windir;
4188
+ if (systemRoot && systemRoot.trim()) {
4189
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
4190
+ }
4191
+ return "powershell.exe";
4192
+ }
4193
+ function windowsProcessListInvocation(env2 = process.env) {
4194
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
4195
+ return {
4196
+ file: resolveWindowsPowerShellPath(env2),
4197
+ args: [
4198
+ "-NoLogo",
4199
+ "-NoProfile",
4200
+ "-NonInteractive",
4201
+ "-ExecutionPolicy",
4202
+ "Bypass",
4203
+ "-EncodedCommand",
4204
+ encoded
4205
+ ]
4206
+ };
4207
+ }
4208
+ function stdoutToString(stdout) {
4209
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
4210
+ }
4211
+ function rowFromWindowsProcessJson(item) {
4212
+ if (!item || typeof item !== "object") return null;
4213
+ const rec = item;
4214
+ const pidRaw = rec.pid ?? rec.ProcessId;
4215
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
4216
+ if (!Number.isFinite(pid) || pid <= 0) return null;
4217
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
4218
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
4219
+ return `${pid} ${command}`;
4220
+ }
4221
+ function rowsFromWindowsJson(parsed2) {
4222
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
4223
+ const rows = [];
4224
+ for (const item of items) {
4225
+ const row = rowFromWindowsProcessJson(item);
4226
+ if (row) rows.push(row);
4227
+ }
4228
+ return rows;
4229
+ }
4230
+ function parseWindowsProcessJsonLines(stdout) {
4231
+ const text = stdout.replace(/^\uFEFF/, "").trim();
4232
+ if (!text) return [];
4233
+ try {
4234
+ return rowsFromWindowsJson(JSON.parse(text));
4235
+ } catch {
4236
+ }
4237
+ const rows = [];
4238
+ for (const line of text.split(/\r?\n/)) {
4239
+ const trimmed = line.trim();
4240
+ if (!trimmed) continue;
4241
+ try {
4242
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
4243
+ } catch {
4244
+ }
4245
+ }
4246
+ return rows;
4247
+ }
4248
+ async function listProcessCommandLineRows(deps = {}) {
4249
+ const platform2 = deps.platform ?? process.platform;
4250
+ const execFileImpl = deps.execFile ?? execFileAsync3;
4251
+ if (platform2 === "win32") {
4252
+ const { file, args } = windowsProcessListInvocation();
4253
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
4254
+ maxBuffer: PROCESS_LIST_MAX_BUFFER,
4255
+ timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
4256
+ });
4257
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
4258
+ }
4259
+ const psArgs = posixPsArgs(resolveProcessListUser());
4260
+ const { stdout } = await execFileImpl("ps", psArgs, {
4261
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
4262
+ });
4263
+ return stdoutToString(stdout).split("\n");
4264
+ }
4265
+
4266
+ // src/cleanup.ts
4129
4267
  var DAEMON_PROJECT_ID_RE = /--project-id\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
4130
4268
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
4131
4269
  var PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4132
- var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone\/mcp/;
4270
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
4133
4271
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
4134
4272
  function isMemoraoneMcpCommandLine(commandLine) {
4135
4273
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -4247,13 +4385,9 @@ function normalizeCleanupProjectId(projectId) {
4247
4385
  }
4248
4386
  return trimmed.toLowerCase();
4249
4387
  }
4250
- async function defaultListDaemonProcesses() {
4251
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
4252
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
4253
- const { stdout } = await execFileAsync3("ps", psArgs, {
4254
- maxBuffer: 10 * 1024 * 1024
4255
- });
4256
- return parseDaemonProcessLines(stdout.split("\n"));
4388
+ async function defaultListDaemonProcesses(deps) {
4389
+ const lines = await listProcessCommandLineRows(deps);
4390
+ return parseDaemonProcessLines(lines);
4257
4391
  }
4258
4392
  async function defaultListSocketPaths(projectId) {
4259
4393
  const baseDir = getMcpBaseDir();
@@ -11257,10 +11391,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
11257
11391
 
11258
11392
  // src/connectRuntimeCleanup.ts
11259
11393
  var path43 = __toESM(require("path"), 1);
11260
- var import_node_child_process6 = require("child_process");
11261
- var import_node_util5 = require("util");
11262
11394
  var fs34 = __toESM(require("fs/promises"), 1);
11263
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
11264
11395
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
11265
11396
  function parseClineHubCwdFromCommandLine(commandLine) {
11266
11397
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -11297,13 +11428,9 @@ function parseClineHubProcessLines(lines) {
11297
11428
  }
11298
11429
  return processes;
11299
11430
  }
11300
- async function defaultListClineHubProcesses() {
11301
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
11302
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
11303
- const { stdout } = await execFileAsync5("ps", psArgs, {
11304
- maxBuffer: 10 * 1024 * 1024
11305
- });
11306
- return parseClineHubProcessLines(stdout.split("\n"));
11431
+ async function defaultListClineHubProcesses(deps) {
11432
+ const lines = await listProcessCommandLineRows(deps);
11433
+ return parseClineHubProcessLines(lines);
11307
11434
  }
11308
11435
  async function defaultRemoveSocket2(socketPath) {
11309
11436
  await fs34.unlink(socketPath);
package/dist/gateway.cjs CHANGED
@@ -2615,8 +2615,6 @@ var import_node_crypto27 = require("crypto");
2615
2615
  var fs12 = __toESM(require("fs/promises"), 1);
2616
2616
  var path22 = __toESM(require("path"), 1);
2617
2617
  var readline = __toESM(require("readline/promises"), 1);
2618
- var import_node_child_process3 = require("child_process");
2619
- var import_node_util3 = require("util");
2620
2618
  var import_node_process = require("process");
2621
2619
 
2622
2620
  // src/bindingSidecar.ts
@@ -3388,12 +3386,152 @@ function logCursorMcpConfigAudit(prefix, audit) {
3388
3386
  }
3389
3387
  }
3390
3388
 
3391
- // src/cleanup.ts
3389
+ // src/processCommandLines.ts
3390
+ var import_node_child_process3 = require("child_process");
3391
+ var import_node_util3 = require("util");
3392
3392
  var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
3393
+ var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
3394
+ var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
3395
+ var WINDOWS_LIST_PROCESSES_PS = [
3396
+ "$ErrorActionPreference = 'Stop'",
3397
+ '$ProgressPreference = "SilentlyContinue"',
3398
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
3399
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
3400
+ "trap {",
3401
+ " [Console]::Error.WriteLine([string]$_)",
3402
+ " exit 1",
3403
+ "}",
3404
+ "$currentIdentity = [string][System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
3405
+ "if ([string]::IsNullOrWhiteSpace($currentIdentity)) {",
3406
+ ' throw "Unable to determine the current Windows identity."',
3407
+ "}",
3408
+ "$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
3409
+ "if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
3410
+ ' throw "Unable to determine the Windows system directory."',
3411
+ "}",
3412
+ '$tasklistPath = [System.IO.Path]::Combine($systemDirectory, "tasklist.exe")',
3413
+ '$tasklistArgs = @("/FI", "USERNAME eq $currentIdentity", "/FO", "CSV", "/NH")',
3414
+ "$tasklistRows = @(& $tasklistPath $tasklistArgs)",
3415
+ "$tasklistExitCode = $LASTEXITCODE",
3416
+ "if ($tasklistExitCode -ne 0) {",
3417
+ ' throw "tasklist.exe failed with exit code $tasklistExitCode."',
3418
+ "}",
3419
+ '$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
3420
+ "foreach ($tasklistRow in $tasklistRows) {",
3421
+ " if ([string]::IsNullOrWhiteSpace([string]$tasklistRow)) { continue }",
3422
+ ' $task = $tasklistRow | ConvertFrom-Csv -Header "ImageName","ProcessId","SessionName","SessionNumber","MemoryUsage"',
3423
+ " $taskPid = 0",
3424
+ " if ($null -eq $task -or -not [int]::TryParse([string]$task.ProcessId, [ref]$taskPid) -or $taskPid -le 0) {",
3425
+ ' throw "tasklist.exe returned an invalid process row."',
3426
+ " }",
3427
+ " $null = $currentUserPids.Add($taskPid)",
3428
+ "}",
3429
+ "if (-not $currentUserPids.Contains([int]$PID)) {",
3430
+ ' throw "tasklist.exe results did not include the running PowerShell process."',
3431
+ "}",
3432
+ "$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
3433
+ "foreach ($proc in $processes) {",
3434
+ " if ($null -eq $proc.ProcessId) { continue }",
3435
+ " $processId = [int]$proc.ProcessId",
3436
+ " if (-not $currentUserPids.Contains($processId)) { continue }",
3437
+ ' $commandLine = ""',
3438
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
3439
+ " $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
3440
+ " ConvertTo-Json -InputObject $row -Compress",
3441
+ "}"
3442
+ ].join("\n");
3443
+ function resolveProcessListUser(env2 = process.env) {
3444
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
3445
+ return user && user.trim() ? user.trim() : void 0;
3446
+ }
3447
+ function posixPsArgs(user) {
3448
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
3449
+ }
3450
+ function resolveWindowsPowerShellPath(env2 = process.env) {
3451
+ const systemRoot = env2.SystemRoot || env2.windir;
3452
+ if (systemRoot && systemRoot.trim()) {
3453
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
3454
+ }
3455
+ return "powershell.exe";
3456
+ }
3457
+ function windowsProcessListInvocation(env2 = process.env) {
3458
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
3459
+ return {
3460
+ file: resolveWindowsPowerShellPath(env2),
3461
+ args: [
3462
+ "-NoLogo",
3463
+ "-NoProfile",
3464
+ "-NonInteractive",
3465
+ "-ExecutionPolicy",
3466
+ "Bypass",
3467
+ "-EncodedCommand",
3468
+ encoded
3469
+ ]
3470
+ };
3471
+ }
3472
+ function stdoutToString(stdout) {
3473
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
3474
+ }
3475
+ function rowFromWindowsProcessJson(item) {
3476
+ if (!item || typeof item !== "object") return null;
3477
+ const rec = item;
3478
+ const pidRaw = rec.pid ?? rec.ProcessId;
3479
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
3480
+ if (!Number.isFinite(pid) || pid <= 0) return null;
3481
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
3482
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
3483
+ return `${pid} ${command}`;
3484
+ }
3485
+ function rowsFromWindowsJson(parsed2) {
3486
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
3487
+ const rows = [];
3488
+ for (const item of items) {
3489
+ const row = rowFromWindowsProcessJson(item);
3490
+ if (row) rows.push(row);
3491
+ }
3492
+ return rows;
3493
+ }
3494
+ function parseWindowsProcessJsonLines(stdout) {
3495
+ const text2 = stdout.replace(/^\uFEFF/, "").trim();
3496
+ if (!text2) return [];
3497
+ try {
3498
+ return rowsFromWindowsJson(JSON.parse(text2));
3499
+ } catch {
3500
+ }
3501
+ const rows = [];
3502
+ for (const line of text2.split(/\r?\n/)) {
3503
+ const trimmed = line.trim();
3504
+ if (!trimmed) continue;
3505
+ try {
3506
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
3507
+ } catch {
3508
+ }
3509
+ }
3510
+ return rows;
3511
+ }
3512
+ async function listProcessCommandLineRows(deps = {}) {
3513
+ const platform2 = deps.platform ?? process.platform;
3514
+ const execFileImpl = deps.execFile ?? execFileAsync3;
3515
+ if (platform2 === "win32") {
3516
+ const { file, args } = windowsProcessListInvocation();
3517
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
3518
+ maxBuffer: PROCESS_LIST_MAX_BUFFER,
3519
+ timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
3520
+ });
3521
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
3522
+ }
3523
+ const psArgs = posixPsArgs(resolveProcessListUser());
3524
+ const { stdout } = await execFileImpl("ps", psArgs, {
3525
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
3526
+ });
3527
+ return stdoutToString(stdout).split("\n");
3528
+ }
3529
+
3530
+ // src/cleanup.ts
3393
3531
  var DAEMON_PROJECT_ID_RE = /--project-id\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
3394
3532
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
3395
3533
  var PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3396
- var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone\/mcp/;
3534
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
3397
3535
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
3398
3536
  function isMemoraoneMcpCommandLine(commandLine) {
3399
3537
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -3511,13 +3649,9 @@ function normalizeCleanupProjectId(projectId) {
3511
3649
  }
3512
3650
  return trimmed.toLowerCase();
3513
3651
  }
3514
- async function defaultListDaemonProcesses() {
3515
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
3516
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
3517
- const { stdout } = await execFileAsync3("ps", psArgs, {
3518
- maxBuffer: 10 * 1024 * 1024
3519
- });
3520
- return parseDaemonProcessLines(stdout.split("\n"));
3652
+ async function defaultListDaemonProcesses(deps) {
3653
+ const lines = await listProcessCommandLineRows(deps);
3654
+ return parseDaemonProcessLines(lines);
3521
3655
  }
3522
3656
  async function defaultListSocketPaths(projectId) {
3523
3657
  const baseDir = getMcpBaseDir();
@@ -10521,10 +10655,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
10521
10655
 
10522
10656
  // src/connectRuntimeCleanup.ts
10523
10657
  var path45 = __toESM(require("path"), 1);
10524
- var import_node_child_process6 = require("child_process");
10525
- var import_node_util5 = require("util");
10526
10658
  var fs35 = __toESM(require("fs/promises"), 1);
10527
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
10528
10659
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
10529
10660
  function parseClineHubCwdFromCommandLine(commandLine) {
10530
10661
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -10561,13 +10692,9 @@ function parseClineHubProcessLines(lines) {
10561
10692
  }
10562
10693
  return processes;
10563
10694
  }
10564
- async function defaultListClineHubProcesses() {
10565
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
10566
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
10567
- const { stdout } = await execFileAsync5("ps", psArgs, {
10568
- maxBuffer: 10 * 1024 * 1024
10569
- });
10570
- return parseClineHubProcessLines(stdout.split("\n"));
10695
+ async function defaultListClineHubProcesses(deps) {
10696
+ const lines = await listProcessCommandLineRows(deps);
10697
+ return parseClineHubProcessLines(lines);
10571
10698
  }
10572
10699
  async function defaultRemoveSocket2(socketPath) {
10573
10700
  await fs35.unlink(socketPath);
@@ -14774,9 +14901,9 @@ async function handleGatewayMcpAuthRequest(req, res, url, options = {}) {
14774
14901
  var path51 = __toESM(require("path"), 1);
14775
14902
 
14776
14903
  // src/openUrlInBrowser.ts
14777
- var import_node_child_process7 = require("child_process");
14778
- var import_node_util6 = require("util");
14779
- var execFileAsync6 = (0, import_node_util6.promisify)(import_node_child_process7.execFile);
14904
+ var import_node_child_process6 = require("child_process");
14905
+ var import_node_util5 = require("util");
14906
+ var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
14780
14907
  function assertHttpOrHttpsUrl(url) {
14781
14908
  let parsed2;
14782
14909
  try {
@@ -14791,7 +14918,7 @@ function assertHttpOrHttpsUrl(url) {
14791
14918
  async function openUrlInBrowser(url, deps = {}) {
14792
14919
  assertHttpOrHttpsUrl(url);
14793
14920
  const platform2 = deps.platform ?? process.platform;
14794
- const execFileImpl = deps.execFile ?? execFileAsync6;
14921
+ const execFileImpl = deps.execFile ?? execFileAsync5;
14795
14922
  if (platform2 === "darwin") {
14796
14923
  await execFileImpl("open", [url]);
14797
14924
  return;
package/dist/index.cjs CHANGED
@@ -3572,8 +3572,6 @@ var import_node_crypto25 = require("crypto");
3572
3572
  var fs11 = __toESM(require("fs/promises"), 1);
3573
3573
  var path20 = __toESM(require("path"), 1);
3574
3574
  var readline2 = __toESM(require("readline/promises"), 1);
3575
- var import_node_child_process3 = require("child_process");
3576
- var import_node_util3 = require("util");
3577
3575
  var import_node_process = require("process");
3578
3576
 
3579
3577
  // src/cursorGlobalMcpConfig.ts
@@ -4107,12 +4105,152 @@ function logCursorMcpConfigAudit(prefix, audit) {
4107
4105
  }
4108
4106
  }
4109
4107
 
4110
- // src/cleanup.ts
4108
+ // src/processCommandLines.ts
4109
+ var import_node_child_process3 = require("child_process");
4110
+ var import_node_util3 = require("util");
4111
4111
  var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
4112
+ var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
4113
+ var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
4114
+ var WINDOWS_LIST_PROCESSES_PS = [
4115
+ "$ErrorActionPreference = 'Stop'",
4116
+ '$ProgressPreference = "SilentlyContinue"',
4117
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
4118
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
4119
+ "trap {",
4120
+ " [Console]::Error.WriteLine([string]$_)",
4121
+ " exit 1",
4122
+ "}",
4123
+ "$currentIdentity = [string][System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
4124
+ "if ([string]::IsNullOrWhiteSpace($currentIdentity)) {",
4125
+ ' throw "Unable to determine the current Windows identity."',
4126
+ "}",
4127
+ "$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
4128
+ "if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
4129
+ ' throw "Unable to determine the Windows system directory."',
4130
+ "}",
4131
+ '$tasklistPath = [System.IO.Path]::Combine($systemDirectory, "tasklist.exe")',
4132
+ '$tasklistArgs = @("/FI", "USERNAME eq $currentIdentity", "/FO", "CSV", "/NH")',
4133
+ "$tasklistRows = @(& $tasklistPath $tasklistArgs)",
4134
+ "$tasklistExitCode = $LASTEXITCODE",
4135
+ "if ($tasklistExitCode -ne 0) {",
4136
+ ' throw "tasklist.exe failed with exit code $tasklistExitCode."',
4137
+ "}",
4138
+ '$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
4139
+ "foreach ($tasklistRow in $tasklistRows) {",
4140
+ " if ([string]::IsNullOrWhiteSpace([string]$tasklistRow)) { continue }",
4141
+ ' $task = $tasklistRow | ConvertFrom-Csv -Header "ImageName","ProcessId","SessionName","SessionNumber","MemoryUsage"',
4142
+ " $taskPid = 0",
4143
+ " if ($null -eq $task -or -not [int]::TryParse([string]$task.ProcessId, [ref]$taskPid) -or $taskPid -le 0) {",
4144
+ ' throw "tasklist.exe returned an invalid process row."',
4145
+ " }",
4146
+ " $null = $currentUserPids.Add($taskPid)",
4147
+ "}",
4148
+ "if (-not $currentUserPids.Contains([int]$PID)) {",
4149
+ ' throw "tasklist.exe results did not include the running PowerShell process."',
4150
+ "}",
4151
+ "$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
4152
+ "foreach ($proc in $processes) {",
4153
+ " if ($null -eq $proc.ProcessId) { continue }",
4154
+ " $processId = [int]$proc.ProcessId",
4155
+ " if (-not $currentUserPids.Contains($processId)) { continue }",
4156
+ ' $commandLine = ""',
4157
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
4158
+ " $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
4159
+ " ConvertTo-Json -InputObject $row -Compress",
4160
+ "}"
4161
+ ].join("\n");
4162
+ function resolveProcessListUser(env2 = process.env) {
4163
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
4164
+ return user && user.trim() ? user.trim() : void 0;
4165
+ }
4166
+ function posixPsArgs(user) {
4167
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
4168
+ }
4169
+ function resolveWindowsPowerShellPath(env2 = process.env) {
4170
+ const systemRoot = env2.SystemRoot || env2.windir;
4171
+ if (systemRoot && systemRoot.trim()) {
4172
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
4173
+ }
4174
+ return "powershell.exe";
4175
+ }
4176
+ function windowsProcessListInvocation(env2 = process.env) {
4177
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
4178
+ return {
4179
+ file: resolveWindowsPowerShellPath(env2),
4180
+ args: [
4181
+ "-NoLogo",
4182
+ "-NoProfile",
4183
+ "-NonInteractive",
4184
+ "-ExecutionPolicy",
4185
+ "Bypass",
4186
+ "-EncodedCommand",
4187
+ encoded
4188
+ ]
4189
+ };
4190
+ }
4191
+ function stdoutToString(stdout) {
4192
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
4193
+ }
4194
+ function rowFromWindowsProcessJson(item) {
4195
+ if (!item || typeof item !== "object") return null;
4196
+ const rec = item;
4197
+ const pidRaw = rec.pid ?? rec.ProcessId;
4198
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
4199
+ if (!Number.isFinite(pid) || pid <= 0) return null;
4200
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
4201
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
4202
+ return `${pid} ${command}`;
4203
+ }
4204
+ function rowsFromWindowsJson(parsed2) {
4205
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
4206
+ const rows = [];
4207
+ for (const item of items) {
4208
+ const row = rowFromWindowsProcessJson(item);
4209
+ if (row) rows.push(row);
4210
+ }
4211
+ return rows;
4212
+ }
4213
+ function parseWindowsProcessJsonLines(stdout) {
4214
+ const text = stdout.replace(/^\uFEFF/, "").trim();
4215
+ if (!text) return [];
4216
+ try {
4217
+ return rowsFromWindowsJson(JSON.parse(text));
4218
+ } catch {
4219
+ }
4220
+ const rows = [];
4221
+ for (const line of text.split(/\r?\n/)) {
4222
+ const trimmed = line.trim();
4223
+ if (!trimmed) continue;
4224
+ try {
4225
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
4226
+ } catch {
4227
+ }
4228
+ }
4229
+ return rows;
4230
+ }
4231
+ async function listProcessCommandLineRows(deps = {}) {
4232
+ const platform2 = deps.platform ?? process.platform;
4233
+ const execFileImpl = deps.execFile ?? execFileAsync3;
4234
+ if (platform2 === "win32") {
4235
+ const { file, args } = windowsProcessListInvocation();
4236
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
4237
+ maxBuffer: PROCESS_LIST_MAX_BUFFER,
4238
+ timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
4239
+ });
4240
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
4241
+ }
4242
+ const psArgs = posixPsArgs(resolveProcessListUser());
4243
+ const { stdout } = await execFileImpl("ps", psArgs, {
4244
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
4245
+ });
4246
+ return stdoutToString(stdout).split("\n");
4247
+ }
4248
+
4249
+ // src/cleanup.ts
4112
4250
  var DAEMON_PROJECT_ID_RE = /--project-id\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
4113
4251
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
4114
4252
  var PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4115
- var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone\/mcp/;
4253
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
4116
4254
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
4117
4255
  function isMemoraoneMcpCommandLine(commandLine) {
4118
4256
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -4230,13 +4368,9 @@ function normalizeCleanupProjectId(projectId) {
4230
4368
  }
4231
4369
  return trimmed.toLowerCase();
4232
4370
  }
4233
- async function defaultListDaemonProcesses() {
4234
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
4235
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
4236
- const { stdout } = await execFileAsync3("ps", psArgs, {
4237
- maxBuffer: 10 * 1024 * 1024
4238
- });
4239
- return parseDaemonProcessLines(stdout.split("\n"));
4371
+ async function defaultListDaemonProcesses(deps) {
4372
+ const lines = await listProcessCommandLineRows(deps);
4373
+ return parseDaemonProcessLines(lines);
4240
4374
  }
4241
4375
  async function defaultListSocketPaths(projectId) {
4242
4376
  const baseDir = getMcpBaseDir();
@@ -11240,10 +11374,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
11240
11374
 
11241
11375
  // src/connectRuntimeCleanup.ts
11242
11376
  var path43 = __toESM(require("path"), 1);
11243
- var import_node_child_process6 = require("child_process");
11244
- var import_node_util5 = require("util");
11245
11377
  var fs34 = __toESM(require("fs/promises"), 1);
11246
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
11247
11378
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
11248
11379
  function parseClineHubCwdFromCommandLine(commandLine) {
11249
11380
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -11280,13 +11411,9 @@ function parseClineHubProcessLines(lines) {
11280
11411
  }
11281
11412
  return processes;
11282
11413
  }
11283
- async function defaultListClineHubProcesses() {
11284
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
11285
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
11286
- const { stdout } = await execFileAsync5("ps", psArgs, {
11287
- maxBuffer: 10 * 1024 * 1024
11288
- });
11289
- return parseClineHubProcessLines(stdout.split("\n"));
11414
+ async function defaultListClineHubProcesses(deps) {
11415
+ const lines = await listProcessCommandLineRows(deps);
11416
+ return parseClineHubProcessLines(lines);
11290
11417
  }
11291
11418
  async function defaultRemoveSocket2(socketPath) {
11292
11419
  await fs34.unlink(socketPath);
@@ -1716,8 +1716,6 @@ var import_node_crypto25 = require("crypto");
1716
1716
  var fs11 = __toESM(require("fs/promises"), 1);
1717
1717
  var path19 = __toESM(require("path"), 1);
1718
1718
  var readline = __toESM(require("readline/promises"), 1);
1719
- var import_node_child_process3 = require("child_process");
1720
- var import_node_util3 = require("util");
1721
1719
  var import_node_process = require("process");
1722
1720
 
1723
1721
  // src/bindingSidecar.ts
@@ -2297,12 +2295,152 @@ function logCursorMcpConfigAudit(prefix, audit) {
2297
2295
  }
2298
2296
  }
2299
2297
 
2300
- // src/cleanup.ts
2298
+ // src/processCommandLines.ts
2299
+ var import_node_child_process3 = require("child_process");
2300
+ var import_node_util3 = require("util");
2301
2301
  var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
2302
+ var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
2303
+ var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
2304
+ var WINDOWS_LIST_PROCESSES_PS = [
2305
+ "$ErrorActionPreference = 'Stop'",
2306
+ '$ProgressPreference = "SilentlyContinue"',
2307
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
2308
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
2309
+ "trap {",
2310
+ " [Console]::Error.WriteLine([string]$_)",
2311
+ " exit 1",
2312
+ "}",
2313
+ "$currentIdentity = [string][System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
2314
+ "if ([string]::IsNullOrWhiteSpace($currentIdentity)) {",
2315
+ ' throw "Unable to determine the current Windows identity."',
2316
+ "}",
2317
+ "$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
2318
+ "if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
2319
+ ' throw "Unable to determine the Windows system directory."',
2320
+ "}",
2321
+ '$tasklistPath = [System.IO.Path]::Combine($systemDirectory, "tasklist.exe")',
2322
+ '$tasklistArgs = @("/FI", "USERNAME eq $currentIdentity", "/FO", "CSV", "/NH")',
2323
+ "$tasklistRows = @(& $tasklistPath $tasklistArgs)",
2324
+ "$tasklistExitCode = $LASTEXITCODE",
2325
+ "if ($tasklistExitCode -ne 0) {",
2326
+ ' throw "tasklist.exe failed with exit code $tasklistExitCode."',
2327
+ "}",
2328
+ '$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
2329
+ "foreach ($tasklistRow in $tasklistRows) {",
2330
+ " if ([string]::IsNullOrWhiteSpace([string]$tasklistRow)) { continue }",
2331
+ ' $task = $tasklistRow | ConvertFrom-Csv -Header "ImageName","ProcessId","SessionName","SessionNumber","MemoryUsage"',
2332
+ " $taskPid = 0",
2333
+ " if ($null -eq $task -or -not [int]::TryParse([string]$task.ProcessId, [ref]$taskPid) -or $taskPid -le 0) {",
2334
+ ' throw "tasklist.exe returned an invalid process row."',
2335
+ " }",
2336
+ " $null = $currentUserPids.Add($taskPid)",
2337
+ "}",
2338
+ "if (-not $currentUserPids.Contains([int]$PID)) {",
2339
+ ' throw "tasklist.exe results did not include the running PowerShell process."',
2340
+ "}",
2341
+ "$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
2342
+ "foreach ($proc in $processes) {",
2343
+ " if ($null -eq $proc.ProcessId) { continue }",
2344
+ " $processId = [int]$proc.ProcessId",
2345
+ " if (-not $currentUserPids.Contains($processId)) { continue }",
2346
+ ' $commandLine = ""',
2347
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
2348
+ " $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
2349
+ " ConvertTo-Json -InputObject $row -Compress",
2350
+ "}"
2351
+ ].join("\n");
2352
+ function resolveProcessListUser(env2 = process.env) {
2353
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
2354
+ return user && user.trim() ? user.trim() : void 0;
2355
+ }
2356
+ function posixPsArgs(user) {
2357
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
2358
+ }
2359
+ function resolveWindowsPowerShellPath(env2 = process.env) {
2360
+ const systemRoot = env2.SystemRoot || env2.windir;
2361
+ if (systemRoot && systemRoot.trim()) {
2362
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
2363
+ }
2364
+ return "powershell.exe";
2365
+ }
2366
+ function windowsProcessListInvocation(env2 = process.env) {
2367
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
2368
+ return {
2369
+ file: resolveWindowsPowerShellPath(env2),
2370
+ args: [
2371
+ "-NoLogo",
2372
+ "-NoProfile",
2373
+ "-NonInteractive",
2374
+ "-ExecutionPolicy",
2375
+ "Bypass",
2376
+ "-EncodedCommand",
2377
+ encoded
2378
+ ]
2379
+ };
2380
+ }
2381
+ function stdoutToString(stdout) {
2382
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
2383
+ }
2384
+ function rowFromWindowsProcessJson(item) {
2385
+ if (!item || typeof item !== "object") return null;
2386
+ const rec = item;
2387
+ const pidRaw = rec.pid ?? rec.ProcessId;
2388
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
2389
+ if (!Number.isFinite(pid) || pid <= 0) return null;
2390
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
2391
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
2392
+ return `${pid} ${command}`;
2393
+ }
2394
+ function rowsFromWindowsJson(parsed2) {
2395
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
2396
+ const rows = [];
2397
+ for (const item of items) {
2398
+ const row = rowFromWindowsProcessJson(item);
2399
+ if (row) rows.push(row);
2400
+ }
2401
+ return rows;
2402
+ }
2403
+ function parseWindowsProcessJsonLines(stdout) {
2404
+ const text = stdout.replace(/^\uFEFF/, "").trim();
2405
+ if (!text) return [];
2406
+ try {
2407
+ return rowsFromWindowsJson(JSON.parse(text));
2408
+ } catch {
2409
+ }
2410
+ const rows = [];
2411
+ for (const line of text.split(/\r?\n/)) {
2412
+ const trimmed = line.trim();
2413
+ if (!trimmed) continue;
2414
+ try {
2415
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
2416
+ } catch {
2417
+ }
2418
+ }
2419
+ return rows;
2420
+ }
2421
+ async function listProcessCommandLineRows(deps = {}) {
2422
+ const platform2 = deps.platform ?? process.platform;
2423
+ const execFileImpl = deps.execFile ?? execFileAsync3;
2424
+ if (platform2 === "win32") {
2425
+ const { file, args } = windowsProcessListInvocation();
2426
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
2427
+ maxBuffer: PROCESS_LIST_MAX_BUFFER,
2428
+ timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
2429
+ });
2430
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
2431
+ }
2432
+ const psArgs = posixPsArgs(resolveProcessListUser());
2433
+ const { stdout } = await execFileImpl("ps", psArgs, {
2434
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
2435
+ });
2436
+ return stdoutToString(stdout).split("\n");
2437
+ }
2438
+
2439
+ // src/cleanup.ts
2302
2440
  var DAEMON_PROJECT_ID_RE = /--project-id\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
2303
2441
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
2304
2442
  var PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2305
- var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone\/mcp/;
2443
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
2306
2444
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
2307
2445
  function isMemoraoneMcpCommandLine(commandLine) {
2308
2446
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -2420,13 +2558,9 @@ function normalizeCleanupProjectId(projectId) {
2420
2558
  }
2421
2559
  return trimmed.toLowerCase();
2422
2560
  }
2423
- async function defaultListDaemonProcesses() {
2424
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
2425
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
2426
- const { stdout } = await execFileAsync3("ps", psArgs, {
2427
- maxBuffer: 10 * 1024 * 1024
2428
- });
2429
- return parseDaemonProcessLines(stdout.split("\n"));
2561
+ async function defaultListDaemonProcesses(deps) {
2562
+ const lines = await listProcessCommandLineRows(deps);
2563
+ return parseDaemonProcessLines(lines);
2430
2564
  }
2431
2565
  async function defaultListSocketPaths(projectId) {
2432
2566
  const baseDir = getMcpBaseDir();
@@ -9430,10 +9564,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
9430
9564
 
9431
9565
  // src/connectRuntimeCleanup.ts
9432
9566
  var path42 = __toESM(require("path"), 1);
9433
- var import_node_child_process6 = require("child_process");
9434
- var import_node_util5 = require("util");
9435
9567
  var fs34 = __toESM(require("fs/promises"), 1);
9436
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
9437
9568
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
9438
9569
  function parseClineHubCwdFromCommandLine(commandLine) {
9439
9570
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -9470,13 +9601,9 @@ function parseClineHubProcessLines(lines) {
9470
9601
  }
9471
9602
  return processes;
9472
9603
  }
9473
- async function defaultListClineHubProcesses() {
9474
- const user = process.env.USER || process.env.LOGNAME || process.env.USERNAME;
9475
- const psArgs = user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
9476
- const { stdout } = await execFileAsync5("ps", psArgs, {
9477
- maxBuffer: 10 * 1024 * 1024
9478
- });
9479
- return parseClineHubProcessLines(stdout.split("\n"));
9604
+ async function defaultListClineHubProcesses(deps) {
9605
+ const lines = await listProcessCommandLineRows(deps);
9606
+ return parseClineHubProcessLines(lines);
9480
9607
  }
9481
9608
  async function defaultRemoveSocket2(socketPath) {
9482
9609
  await fs34.unlink(socketPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoraone/mcp",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "exports": {