@memoraone/mcp 0.1.63 → 0.1.64

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.64",
235
235
  type: "module",
236
236
  main: "dist/index.cjs",
237
237
  exports: {
@@ -2742,6 +2742,128 @@ 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
+ });
2823
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
2824
+ }
2825
+ const psArgs = posixPsArgs(resolveProcessListUser());
2826
+ const { stdout } = await execFileImpl("ps", psArgs, {
2827
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
2828
+ });
2829
+ return stdoutToString(stdout).split("\n");
2830
+ }
2831
+ var import_node_child_process3, import_node_util3, execFileAsync3, PROCESS_LIST_MAX_BUFFER, WINDOWS_LIST_PROCESSES_PS;
2832
+ var init_processCommandLines = __esm({
2833
+ "src/processCommandLines.ts"() {
2834
+ import_node_child_process3 = require("child_process");
2835
+ import_node_util3 = require("util");
2836
+ execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
2837
+ PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
2838
+ WINDOWS_LIST_PROCESSES_PS = [
2839
+ "$ErrorActionPreference = 'Stop'",
2840
+ '$ProgressPreference = "SilentlyContinue"',
2841
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
2842
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
2843
+ "$user = [string]$env:USERNAME",
2844
+ "if (-not $user) { $user = [string]$env:USER }",
2845
+ "if (-not $user) { $user = [string]$env:LOGNAME }",
2846
+ "$processes = Get-CimInstance -ClassName Win32_Process",
2847
+ "foreach ($proc in $processes) {",
2848
+ " if ($null -eq $proc.ProcessId) { continue }",
2849
+ " if ($user) {",
2850
+ " $owner = $null",
2851
+ " try {",
2852
+ " $owner = Invoke-CimMethod -InputObject $proc -MethodName GetOwner -ErrorAction SilentlyContinue",
2853
+ " } catch {",
2854
+ " continue",
2855
+ " }",
2856
+ " if ($null -eq $owner -or $owner.ReturnValue -ne 0 -or $owner.User -ne $user) { continue }",
2857
+ " }",
2858
+ ' $commandLine = ""',
2859
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
2860
+ " $row = [PSCustomObject]@{ pid = [int]$proc.ProcessId; commandLine = $commandLine }",
2861
+ " ConvertTo-Json -InputObject $row -Compress",
2862
+ "}"
2863
+ ].join("\n");
2864
+ }
2865
+ });
2866
+
2745
2867
  // src/cleanup.ts
2746
2868
  var cleanup_exports = {};
2747
2869
  __export(cleanup_exports, {
@@ -2929,13 +3051,9 @@ function normalizeCleanupProjectId(projectId) {
2929
3051
  }
2930
3052
  return trimmed.toLowerCase();
2931
3053
  }
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"));
3054
+ async function defaultListDaemonProcesses(deps) {
3055
+ const lines = await listProcessCommandLineRows(deps);
3056
+ return parseDaemonProcessLines(lines);
2939
3057
  }
2940
3058
  async function defaultListSocketPaths(projectId) {
2941
3059
  const baseDir = getMcpBaseDir();
@@ -3431,24 +3549,22 @@ async function cliCleanup(argv) {
3431
3549
  }
3432
3550
  return result.exitCode;
3433
3551
  }
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;
3552
+ 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
3553
  var init_cleanup = __esm({
3436
3554
  "src/cleanup.ts"() {
3437
3555
  fs9 = __toESM(require("fs/promises"), 1);
3438
3556
  path17 = __toESM(require("path"), 1);
3439
3557
  readline = __toESM(require("readline/promises"), 1);
3440
- import_node_child_process3 = require("child_process");
3441
- import_node_util3 = require("util");
3442
3558
  import_node_process = require("process");
3443
3559
  init_socketPaths();
3444
3560
  init_bindingSidecar();
3445
3561
  init_projectBinding();
3446
3562
  init_cursorGlobalMcpConfig();
3447
- execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
3563
+ init_processCommandLines();
3448
3564
  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
3565
  DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
3450
3566
  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/;
3567
+ MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
3452
3568
  CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
3453
3569
  }
3454
3570
  });
@@ -12154,13 +12270,9 @@ function parseClineHubProcessLines(lines) {
12154
12270
  }
12155
12271
  return processes;
12156
12272
  }
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"));
12273
+ async function defaultListClineHubProcesses(deps) {
12274
+ const lines = await listProcessCommandLineRows(deps);
12275
+ return parseClineHubProcessLines(lines);
12164
12276
  }
12165
12277
  async function defaultRemoveSocket2(socketPath) {
12166
12278
  await fs34.unlink(socketPath);
@@ -12358,16 +12470,14 @@ async function runConnectRuntimeCleanup(options) {
12358
12470
  staleRuntimeRemains
12359
12471
  };
12360
12472
  }
12361
- var path42, import_node_child_process6, import_node_util5, fs34, execFileAsync5, CLINE_HUB_DAEMON_MARKER;
12473
+ var path42, fs34, CLINE_HUB_DAEMON_MARKER;
12362
12474
  var init_connectRuntimeCleanup = __esm({
12363
12475
  "src/connectRuntimeCleanup.ts"() {
12364
12476
  path42 = __toESM(require("path"), 1);
12365
- import_node_child_process6 = require("child_process");
12366
- import_node_util5 = require("util");
12367
12477
  fs34 = __toESM(require("fs/promises"), 1);
12368
12478
  init_cleanup();
12369
12479
  init_bindingSidecar();
12370
- execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
12480
+ init_processCommandLines();
12371
12481
  CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
12372
12482
  }
12373
12483
  });
@@ -13510,7 +13620,7 @@ function defaultSpawnGateway(cliPath, env2) {
13510
13620
  return new Promise((resolve45, reject) => {
13511
13621
  let child;
13512
13622
  try {
13513
- child = (0, import_node_child_process7.spawn)(process.execPath, buildGatewaySpawnArgs(cliPath), {
13623
+ child = (0, import_node_child_process6.spawn)(process.execPath, buildGatewaySpawnArgs(cliPath), {
13514
13624
  detached: true,
13515
13625
  stdio: "ignore",
13516
13626
  env: { ...env2 }
@@ -13597,10 +13707,10 @@ async function cliEnsureGateway(_argv = [], options = {}) {
13597
13707
  return 1;
13598
13708
  }
13599
13709
  }
13600
- var import_node_child_process7, log;
13710
+ var import_node_child_process6, log;
13601
13711
  var init_gatewayEnsure = __esm({
13602
13712
  "src/gatewayEnsure.ts"() {
13603
- import_node_child_process7 = require("child_process");
13713
+ import_node_child_process6 = require("child_process");
13604
13714
  init_localLocks();
13605
13715
  init_resolveBuiltCliPath();
13606
13716
  init_gatewayConfig();
@@ -14225,7 +14335,7 @@ function redactStartupDiagnostic(text) {
14225
14335
  async function spawnDaemonAndConnect(binding, socketPath, options) {
14226
14336
  const timeoutMs = options.timeoutMs ?? 1e4;
14227
14337
  const delayMs = options.retryDelayMs ?? 50;
14228
- const child = (0, import_node_child_process8.spawn)(
14338
+ const child = (0, import_node_child_process7.spawn)(
14229
14339
  process.execPath,
14230
14340
  buildDaemonSpawnArgs(options.cliPath, binding.repositoryBindingId, options.env, options.ideType),
14231
14341
  {
@@ -14430,12 +14540,12 @@ async function runBridgeProxy(options) {
14430
14540
  router.close();
14431
14541
  }
14432
14542
  }
14433
- var net, readline4, import_node_child_process8, defaultLog, JSONRPC_METHOD_NOT_FOUND, SETUP_REQUIRED_FINISH_SETUP_TOOL, BridgeDaemonRouter;
14543
+ var net, readline4, import_node_child_process7, defaultLog, JSONRPC_METHOD_NOT_FOUND, SETUP_REQUIRED_FINISH_SETUP_TOOL, BridgeDaemonRouter;
14434
14544
  var init_bridgeProxy = __esm({
14435
14545
  "src/bridgeProxy.ts"() {
14436
14546
  net = __toESM(require("net"), 1);
14437
14547
  readline4 = __toESM(require("readline"), 1);
14438
- import_node_child_process8 = require("child_process");
14548
+ import_node_child_process7 = require("child_process");
14439
14549
  init_bindingIdentity();
14440
14550
  init_bindingSidecar();
14441
14551
  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,128 @@ 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_LIST_PROCESSES_PS = [
4131
+ "$ErrorActionPreference = 'Stop'",
4132
+ '$ProgressPreference = "SilentlyContinue"',
4133
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
4134
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
4135
+ "$user = [string]$env:USERNAME",
4136
+ "if (-not $user) { $user = [string]$env:USER }",
4137
+ "if (-not $user) { $user = [string]$env:LOGNAME }",
4138
+ "$processes = Get-CimInstance -ClassName Win32_Process",
4139
+ "foreach ($proc in $processes) {",
4140
+ " if ($null -eq $proc.ProcessId) { continue }",
4141
+ " if ($user) {",
4142
+ " $owner = $null",
4143
+ " try {",
4144
+ " $owner = Invoke-CimMethod -InputObject $proc -MethodName GetOwner -ErrorAction SilentlyContinue",
4145
+ " } catch {",
4146
+ " continue",
4147
+ " }",
4148
+ " if ($null -eq $owner -or $owner.ReturnValue -ne 0 -or $owner.User -ne $user) { continue }",
4149
+ " }",
4150
+ ' $commandLine = ""',
4151
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
4152
+ " $row = [PSCustomObject]@{ pid = [int]$proc.ProcessId; commandLine = $commandLine }",
4153
+ " ConvertTo-Json -InputObject $row -Compress",
4154
+ "}"
4155
+ ].join("\n");
4156
+ function resolveProcessListUser(env2 = process.env) {
4157
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
4158
+ return user && user.trim() ? user.trim() : void 0;
4159
+ }
4160
+ function posixPsArgs(user) {
4161
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
4162
+ }
4163
+ function resolveWindowsPowerShellPath(env2 = process.env) {
4164
+ const systemRoot = env2.SystemRoot || env2.windir;
4165
+ if (systemRoot && systemRoot.trim()) {
4166
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
4167
+ }
4168
+ return "powershell.exe";
4169
+ }
4170
+ function windowsProcessListInvocation(env2 = process.env) {
4171
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
4172
+ return {
4173
+ file: resolveWindowsPowerShellPath(env2),
4174
+ args: [
4175
+ "-NoLogo",
4176
+ "-NoProfile",
4177
+ "-NonInteractive",
4178
+ "-ExecutionPolicy",
4179
+ "Bypass",
4180
+ "-EncodedCommand",
4181
+ encoded
4182
+ ]
4183
+ };
4184
+ }
4185
+ function stdoutToString(stdout) {
4186
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
4187
+ }
4188
+ function rowFromWindowsProcessJson(item) {
4189
+ if (!item || typeof item !== "object") return null;
4190
+ const rec = item;
4191
+ const pidRaw = rec.pid ?? rec.ProcessId;
4192
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
4193
+ if (!Number.isFinite(pid) || pid <= 0) return null;
4194
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
4195
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
4196
+ return `${pid} ${command}`;
4197
+ }
4198
+ function rowsFromWindowsJson(parsed2) {
4199
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
4200
+ const rows = [];
4201
+ for (const item of items) {
4202
+ const row = rowFromWindowsProcessJson(item);
4203
+ if (row) rows.push(row);
4204
+ }
4205
+ return rows;
4206
+ }
4207
+ function parseWindowsProcessJsonLines(stdout) {
4208
+ const text = stdout.replace(/^\uFEFF/, "").trim();
4209
+ if (!text) return [];
4210
+ try {
4211
+ return rowsFromWindowsJson(JSON.parse(text));
4212
+ } catch {
4213
+ }
4214
+ const rows = [];
4215
+ for (const line of text.split(/\r?\n/)) {
4216
+ const trimmed = line.trim();
4217
+ if (!trimmed) continue;
4218
+ try {
4219
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
4220
+ } catch {
4221
+ }
4222
+ }
4223
+ return rows;
4224
+ }
4225
+ async function listProcessCommandLineRows(deps = {}) {
4226
+ const platform2 = deps.platform ?? process.platform;
4227
+ const execFileImpl = deps.execFile ?? execFileAsync3;
4228
+ if (platform2 === "win32") {
4229
+ const { file, args } = windowsProcessListInvocation();
4230
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
4231
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
4232
+ });
4233
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
4234
+ }
4235
+ const psArgs = posixPsArgs(resolveProcessListUser());
4236
+ const { stdout } = await execFileImpl("ps", psArgs, {
4237
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
4238
+ });
4239
+ return stdoutToString(stdout).split("\n");
4240
+ }
4241
+
4242
+ // src/cleanup.ts
4129
4243
  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
4244
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
4131
4245
  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/;
4246
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
4133
4247
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
4134
4248
  function isMemoraoneMcpCommandLine(commandLine) {
4135
4249
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -4247,13 +4361,9 @@ function normalizeCleanupProjectId(projectId) {
4247
4361
  }
4248
4362
  return trimmed.toLowerCase();
4249
4363
  }
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"));
4364
+ async function defaultListDaemonProcesses(deps) {
4365
+ const lines = await listProcessCommandLineRows(deps);
4366
+ return parseDaemonProcessLines(lines);
4257
4367
  }
4258
4368
  async function defaultListSocketPaths(projectId) {
4259
4369
  const baseDir = getMcpBaseDir();
@@ -11257,10 +11367,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
11257
11367
 
11258
11368
  // src/connectRuntimeCleanup.ts
11259
11369
  var path43 = __toESM(require("path"), 1);
11260
- var import_node_child_process6 = require("child_process");
11261
- var import_node_util5 = require("util");
11262
11370
  var fs34 = __toESM(require("fs/promises"), 1);
11263
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
11264
11371
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
11265
11372
  function parseClineHubCwdFromCommandLine(commandLine) {
11266
11373
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -11297,13 +11404,9 @@ function parseClineHubProcessLines(lines) {
11297
11404
  }
11298
11405
  return processes;
11299
11406
  }
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"));
11407
+ async function defaultListClineHubProcesses(deps) {
11408
+ const lines = await listProcessCommandLineRows(deps);
11409
+ return parseClineHubProcessLines(lines);
11307
11410
  }
11308
11411
  async function defaultRemoveSocket2(socketPath) {
11309
11412
  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,128 @@ 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_LIST_PROCESSES_PS = [
3395
+ "$ErrorActionPreference = 'Stop'",
3396
+ '$ProgressPreference = "SilentlyContinue"',
3397
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
3398
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
3399
+ "$user = [string]$env:USERNAME",
3400
+ "if (-not $user) { $user = [string]$env:USER }",
3401
+ "if (-not $user) { $user = [string]$env:LOGNAME }",
3402
+ "$processes = Get-CimInstance -ClassName Win32_Process",
3403
+ "foreach ($proc in $processes) {",
3404
+ " if ($null -eq $proc.ProcessId) { continue }",
3405
+ " if ($user) {",
3406
+ " $owner = $null",
3407
+ " try {",
3408
+ " $owner = Invoke-CimMethod -InputObject $proc -MethodName GetOwner -ErrorAction SilentlyContinue",
3409
+ " } catch {",
3410
+ " continue",
3411
+ " }",
3412
+ " if ($null -eq $owner -or $owner.ReturnValue -ne 0 -or $owner.User -ne $user) { continue }",
3413
+ " }",
3414
+ ' $commandLine = ""',
3415
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
3416
+ " $row = [PSCustomObject]@{ pid = [int]$proc.ProcessId; commandLine = $commandLine }",
3417
+ " ConvertTo-Json -InputObject $row -Compress",
3418
+ "}"
3419
+ ].join("\n");
3420
+ function resolveProcessListUser(env2 = process.env) {
3421
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
3422
+ return user && user.trim() ? user.trim() : void 0;
3423
+ }
3424
+ function posixPsArgs(user) {
3425
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
3426
+ }
3427
+ function resolveWindowsPowerShellPath(env2 = process.env) {
3428
+ const systemRoot = env2.SystemRoot || env2.windir;
3429
+ if (systemRoot && systemRoot.trim()) {
3430
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
3431
+ }
3432
+ return "powershell.exe";
3433
+ }
3434
+ function windowsProcessListInvocation(env2 = process.env) {
3435
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
3436
+ return {
3437
+ file: resolveWindowsPowerShellPath(env2),
3438
+ args: [
3439
+ "-NoLogo",
3440
+ "-NoProfile",
3441
+ "-NonInteractive",
3442
+ "-ExecutionPolicy",
3443
+ "Bypass",
3444
+ "-EncodedCommand",
3445
+ encoded
3446
+ ]
3447
+ };
3448
+ }
3449
+ function stdoutToString(stdout) {
3450
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
3451
+ }
3452
+ function rowFromWindowsProcessJson(item) {
3453
+ if (!item || typeof item !== "object") return null;
3454
+ const rec = item;
3455
+ const pidRaw = rec.pid ?? rec.ProcessId;
3456
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
3457
+ if (!Number.isFinite(pid) || pid <= 0) return null;
3458
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
3459
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
3460
+ return `${pid} ${command}`;
3461
+ }
3462
+ function rowsFromWindowsJson(parsed2) {
3463
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
3464
+ const rows = [];
3465
+ for (const item of items) {
3466
+ const row = rowFromWindowsProcessJson(item);
3467
+ if (row) rows.push(row);
3468
+ }
3469
+ return rows;
3470
+ }
3471
+ function parseWindowsProcessJsonLines(stdout) {
3472
+ const text2 = stdout.replace(/^\uFEFF/, "").trim();
3473
+ if (!text2) return [];
3474
+ try {
3475
+ return rowsFromWindowsJson(JSON.parse(text2));
3476
+ } catch {
3477
+ }
3478
+ const rows = [];
3479
+ for (const line of text2.split(/\r?\n/)) {
3480
+ const trimmed = line.trim();
3481
+ if (!trimmed) continue;
3482
+ try {
3483
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
3484
+ } catch {
3485
+ }
3486
+ }
3487
+ return rows;
3488
+ }
3489
+ async function listProcessCommandLineRows(deps = {}) {
3490
+ const platform2 = deps.platform ?? process.platform;
3491
+ const execFileImpl = deps.execFile ?? execFileAsync3;
3492
+ if (platform2 === "win32") {
3493
+ const { file, args } = windowsProcessListInvocation();
3494
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
3495
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
3496
+ });
3497
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
3498
+ }
3499
+ const psArgs = posixPsArgs(resolveProcessListUser());
3500
+ const { stdout } = await execFileImpl("ps", psArgs, {
3501
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
3502
+ });
3503
+ return stdoutToString(stdout).split("\n");
3504
+ }
3505
+
3506
+ // src/cleanup.ts
3393
3507
  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
3508
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
3395
3509
  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/;
3510
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
3397
3511
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
3398
3512
  function isMemoraoneMcpCommandLine(commandLine) {
3399
3513
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -3511,13 +3625,9 @@ function normalizeCleanupProjectId(projectId) {
3511
3625
  }
3512
3626
  return trimmed.toLowerCase();
3513
3627
  }
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"));
3628
+ async function defaultListDaemonProcesses(deps) {
3629
+ const lines = await listProcessCommandLineRows(deps);
3630
+ return parseDaemonProcessLines(lines);
3521
3631
  }
3522
3632
  async function defaultListSocketPaths(projectId) {
3523
3633
  const baseDir = getMcpBaseDir();
@@ -10521,10 +10631,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
10521
10631
 
10522
10632
  // src/connectRuntimeCleanup.ts
10523
10633
  var path45 = __toESM(require("path"), 1);
10524
- var import_node_child_process6 = require("child_process");
10525
- var import_node_util5 = require("util");
10526
10634
  var fs35 = __toESM(require("fs/promises"), 1);
10527
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
10528
10635
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
10529
10636
  function parseClineHubCwdFromCommandLine(commandLine) {
10530
10637
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -10561,13 +10668,9 @@ function parseClineHubProcessLines(lines) {
10561
10668
  }
10562
10669
  return processes;
10563
10670
  }
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"));
10671
+ async function defaultListClineHubProcesses(deps) {
10672
+ const lines = await listProcessCommandLineRows(deps);
10673
+ return parseClineHubProcessLines(lines);
10571
10674
  }
10572
10675
  async function defaultRemoveSocket2(socketPath) {
10573
10676
  await fs35.unlink(socketPath);
@@ -14774,9 +14877,9 @@ async function handleGatewayMcpAuthRequest(req, res, url, options = {}) {
14774
14877
  var path51 = __toESM(require("path"), 1);
14775
14878
 
14776
14879
  // 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);
14880
+ var import_node_child_process6 = require("child_process");
14881
+ var import_node_util5 = require("util");
14882
+ var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
14780
14883
  function assertHttpOrHttpsUrl(url) {
14781
14884
  let parsed2;
14782
14885
  try {
@@ -14791,7 +14894,7 @@ function assertHttpOrHttpsUrl(url) {
14791
14894
  async function openUrlInBrowser(url, deps = {}) {
14792
14895
  assertHttpOrHttpsUrl(url);
14793
14896
  const platform2 = deps.platform ?? process.platform;
14794
- const execFileImpl = deps.execFile ?? execFileAsync6;
14897
+ const execFileImpl = deps.execFile ?? execFileAsync5;
14795
14898
  if (platform2 === "darwin") {
14796
14899
  await execFileImpl("open", [url]);
14797
14900
  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,128 @@ 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_LIST_PROCESSES_PS = [
4114
+ "$ErrorActionPreference = 'Stop'",
4115
+ '$ProgressPreference = "SilentlyContinue"',
4116
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
4117
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
4118
+ "$user = [string]$env:USERNAME",
4119
+ "if (-not $user) { $user = [string]$env:USER }",
4120
+ "if (-not $user) { $user = [string]$env:LOGNAME }",
4121
+ "$processes = Get-CimInstance -ClassName Win32_Process",
4122
+ "foreach ($proc in $processes) {",
4123
+ " if ($null -eq $proc.ProcessId) { continue }",
4124
+ " if ($user) {",
4125
+ " $owner = $null",
4126
+ " try {",
4127
+ " $owner = Invoke-CimMethod -InputObject $proc -MethodName GetOwner -ErrorAction SilentlyContinue",
4128
+ " } catch {",
4129
+ " continue",
4130
+ " }",
4131
+ " if ($null -eq $owner -or $owner.ReturnValue -ne 0 -or $owner.User -ne $user) { continue }",
4132
+ " }",
4133
+ ' $commandLine = ""',
4134
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
4135
+ " $row = [PSCustomObject]@{ pid = [int]$proc.ProcessId; commandLine = $commandLine }",
4136
+ " ConvertTo-Json -InputObject $row -Compress",
4137
+ "}"
4138
+ ].join("\n");
4139
+ function resolveProcessListUser(env2 = process.env) {
4140
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
4141
+ return user && user.trim() ? user.trim() : void 0;
4142
+ }
4143
+ function posixPsArgs(user) {
4144
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
4145
+ }
4146
+ function resolveWindowsPowerShellPath(env2 = process.env) {
4147
+ const systemRoot = env2.SystemRoot || env2.windir;
4148
+ if (systemRoot && systemRoot.trim()) {
4149
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
4150
+ }
4151
+ return "powershell.exe";
4152
+ }
4153
+ function windowsProcessListInvocation(env2 = process.env) {
4154
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
4155
+ return {
4156
+ file: resolveWindowsPowerShellPath(env2),
4157
+ args: [
4158
+ "-NoLogo",
4159
+ "-NoProfile",
4160
+ "-NonInteractive",
4161
+ "-ExecutionPolicy",
4162
+ "Bypass",
4163
+ "-EncodedCommand",
4164
+ encoded
4165
+ ]
4166
+ };
4167
+ }
4168
+ function stdoutToString(stdout) {
4169
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
4170
+ }
4171
+ function rowFromWindowsProcessJson(item) {
4172
+ if (!item || typeof item !== "object") return null;
4173
+ const rec = item;
4174
+ const pidRaw = rec.pid ?? rec.ProcessId;
4175
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
4176
+ if (!Number.isFinite(pid) || pid <= 0) return null;
4177
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
4178
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
4179
+ return `${pid} ${command}`;
4180
+ }
4181
+ function rowsFromWindowsJson(parsed2) {
4182
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
4183
+ const rows = [];
4184
+ for (const item of items) {
4185
+ const row = rowFromWindowsProcessJson(item);
4186
+ if (row) rows.push(row);
4187
+ }
4188
+ return rows;
4189
+ }
4190
+ function parseWindowsProcessJsonLines(stdout) {
4191
+ const text = stdout.replace(/^\uFEFF/, "").trim();
4192
+ if (!text) return [];
4193
+ try {
4194
+ return rowsFromWindowsJson(JSON.parse(text));
4195
+ } catch {
4196
+ }
4197
+ const rows = [];
4198
+ for (const line of text.split(/\r?\n/)) {
4199
+ const trimmed = line.trim();
4200
+ if (!trimmed) continue;
4201
+ try {
4202
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
4203
+ } catch {
4204
+ }
4205
+ }
4206
+ return rows;
4207
+ }
4208
+ async function listProcessCommandLineRows(deps = {}) {
4209
+ const platform2 = deps.platform ?? process.platform;
4210
+ const execFileImpl = deps.execFile ?? execFileAsync3;
4211
+ if (platform2 === "win32") {
4212
+ const { file, args } = windowsProcessListInvocation();
4213
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
4214
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
4215
+ });
4216
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
4217
+ }
4218
+ const psArgs = posixPsArgs(resolveProcessListUser());
4219
+ const { stdout } = await execFileImpl("ps", psArgs, {
4220
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
4221
+ });
4222
+ return stdoutToString(stdout).split("\n");
4223
+ }
4224
+
4225
+ // src/cleanup.ts
4112
4226
  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
4227
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
4114
4228
  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/;
4229
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
4116
4230
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
4117
4231
  function isMemoraoneMcpCommandLine(commandLine) {
4118
4232
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -4230,13 +4344,9 @@ function normalizeCleanupProjectId(projectId) {
4230
4344
  }
4231
4345
  return trimmed.toLowerCase();
4232
4346
  }
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"));
4347
+ async function defaultListDaemonProcesses(deps) {
4348
+ const lines = await listProcessCommandLineRows(deps);
4349
+ return parseDaemonProcessLines(lines);
4240
4350
  }
4241
4351
  async function defaultListSocketPaths(projectId) {
4242
4352
  const baseDir = getMcpBaseDir();
@@ -11240,10 +11350,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
11240
11350
 
11241
11351
  // src/connectRuntimeCleanup.ts
11242
11352
  var path43 = __toESM(require("path"), 1);
11243
- var import_node_child_process6 = require("child_process");
11244
- var import_node_util5 = require("util");
11245
11353
  var fs34 = __toESM(require("fs/promises"), 1);
11246
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
11247
11354
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
11248
11355
  function parseClineHubCwdFromCommandLine(commandLine) {
11249
11356
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -11280,13 +11387,9 @@ function parseClineHubProcessLines(lines) {
11280
11387
  }
11281
11388
  return processes;
11282
11389
  }
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"));
11390
+ async function defaultListClineHubProcesses(deps) {
11391
+ const lines = await listProcessCommandLineRows(deps);
11392
+ return parseClineHubProcessLines(lines);
11290
11393
  }
11291
11394
  async function defaultRemoveSocket2(socketPath) {
11292
11395
  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,128 @@ 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_LIST_PROCESSES_PS = [
2304
+ "$ErrorActionPreference = 'Stop'",
2305
+ '$ProgressPreference = "SilentlyContinue"',
2306
+ "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
2307
+ "$OutputEncoding = [System.Text.Encoding]::UTF8",
2308
+ "$user = [string]$env:USERNAME",
2309
+ "if (-not $user) { $user = [string]$env:USER }",
2310
+ "if (-not $user) { $user = [string]$env:LOGNAME }",
2311
+ "$processes = Get-CimInstance -ClassName Win32_Process",
2312
+ "foreach ($proc in $processes) {",
2313
+ " if ($null -eq $proc.ProcessId) { continue }",
2314
+ " if ($user) {",
2315
+ " $owner = $null",
2316
+ " try {",
2317
+ " $owner = Invoke-CimMethod -InputObject $proc -MethodName GetOwner -ErrorAction SilentlyContinue",
2318
+ " } catch {",
2319
+ " continue",
2320
+ " }",
2321
+ " if ($null -eq $owner -or $owner.ReturnValue -ne 0 -or $owner.User -ne $user) { continue }",
2322
+ " }",
2323
+ ' $commandLine = ""',
2324
+ " if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
2325
+ " $row = [PSCustomObject]@{ pid = [int]$proc.ProcessId; commandLine = $commandLine }",
2326
+ " ConvertTo-Json -InputObject $row -Compress",
2327
+ "}"
2328
+ ].join("\n");
2329
+ function resolveProcessListUser(env2 = process.env) {
2330
+ const user = env2.USER || env2.LOGNAME || env2.USERNAME;
2331
+ return user && user.trim() ? user.trim() : void 0;
2332
+ }
2333
+ function posixPsArgs(user) {
2334
+ return user && user.trim() ? ["-u", user.trim(), "-o", "pid=,args="] : ["-eo", "pid=,args="];
2335
+ }
2336
+ function resolveWindowsPowerShellPath(env2 = process.env) {
2337
+ const systemRoot = env2.SystemRoot || env2.windir;
2338
+ if (systemRoot && systemRoot.trim()) {
2339
+ return `${systemRoot.replace(/[\\/]+$/, "")}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
2340
+ }
2341
+ return "powershell.exe";
2342
+ }
2343
+ function windowsProcessListInvocation(env2 = process.env) {
2344
+ const encoded = Buffer.from(WINDOWS_LIST_PROCESSES_PS, "utf16le").toString("base64");
2345
+ return {
2346
+ file: resolveWindowsPowerShellPath(env2),
2347
+ args: [
2348
+ "-NoLogo",
2349
+ "-NoProfile",
2350
+ "-NonInteractive",
2351
+ "-ExecutionPolicy",
2352
+ "Bypass",
2353
+ "-EncodedCommand",
2354
+ encoded
2355
+ ]
2356
+ };
2357
+ }
2358
+ function stdoutToString(stdout) {
2359
+ return typeof stdout === "string" ? stdout : stdout.toString("utf8");
2360
+ }
2361
+ function rowFromWindowsProcessJson(item) {
2362
+ if (!item || typeof item !== "object") return null;
2363
+ const rec = item;
2364
+ const pidRaw = rec.pid ?? rec.ProcessId;
2365
+ const pid = typeof pidRaw === "number" ? pidRaw : Number.parseInt(String(pidRaw ?? ""), 10);
2366
+ if (!Number.isFinite(pid) || pid <= 0) return null;
2367
+ const commandRaw = rec.commandLine ?? rec.CommandLine ?? "";
2368
+ const command = typeof commandRaw === "string" ? commandRaw : String(commandRaw ?? "");
2369
+ return `${pid} ${command}`;
2370
+ }
2371
+ function rowsFromWindowsJson(parsed2) {
2372
+ const items = Array.isArray(parsed2) ? parsed2 : [parsed2];
2373
+ const rows = [];
2374
+ for (const item of items) {
2375
+ const row = rowFromWindowsProcessJson(item);
2376
+ if (row) rows.push(row);
2377
+ }
2378
+ return rows;
2379
+ }
2380
+ function parseWindowsProcessJsonLines(stdout) {
2381
+ const text = stdout.replace(/^\uFEFF/, "").trim();
2382
+ if (!text) return [];
2383
+ try {
2384
+ return rowsFromWindowsJson(JSON.parse(text));
2385
+ } catch {
2386
+ }
2387
+ const rows = [];
2388
+ for (const line of text.split(/\r?\n/)) {
2389
+ const trimmed = line.trim();
2390
+ if (!trimmed) continue;
2391
+ try {
2392
+ rows.push(...rowsFromWindowsJson(JSON.parse(trimmed)));
2393
+ } catch {
2394
+ }
2395
+ }
2396
+ return rows;
2397
+ }
2398
+ async function listProcessCommandLineRows(deps = {}) {
2399
+ const platform2 = deps.platform ?? process.platform;
2400
+ const execFileImpl = deps.execFile ?? execFileAsync3;
2401
+ if (platform2 === "win32") {
2402
+ const { file, args } = windowsProcessListInvocation();
2403
+ const { stdout: stdout2 } = await execFileImpl(file, args, {
2404
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
2405
+ });
2406
+ return parseWindowsProcessJsonLines(stdoutToString(stdout2));
2407
+ }
2408
+ const psArgs = posixPsArgs(resolveProcessListUser());
2409
+ const { stdout } = await execFileImpl("ps", psArgs, {
2410
+ maxBuffer: PROCESS_LIST_MAX_BUFFER
2411
+ });
2412
+ return stdoutToString(stdout).split("\n");
2413
+ }
2414
+
2415
+ // src/cleanup.ts
2302
2416
  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
2417
  var DAEMON_BINDING_ID_RE = /--binding-id\s+(mrb_[A-Za-z0-9_-]+)/i;
2304
2418
  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/;
2419
+ var MEMORAONE_MCP_COMMAND_RE = /memoraone-mcp|memoraOne-mcp|@memoraone[\\/]mcp/;
2306
2420
  var CLEANUP_PROJECT_ID_REQUIRED_ERROR = "Provide --project-id <id> or run from a connected workspace (memoraone-mcp connect).";
2307
2421
  function isMemoraoneMcpCommandLine(commandLine) {
2308
2422
  return MEMORAONE_MCP_COMMAND_RE.test(commandLine);
@@ -2420,13 +2534,9 @@ function normalizeCleanupProjectId(projectId) {
2420
2534
  }
2421
2535
  return trimmed.toLowerCase();
2422
2536
  }
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"));
2537
+ async function defaultListDaemonProcesses(deps) {
2538
+ const lines = await listProcessCommandLineRows(deps);
2539
+ return parseDaemonProcessLines(lines);
2430
2540
  }
2431
2541
  async function defaultListSocketPaths(projectId) {
2432
2542
  const baseDir = getMcpBaseDir();
@@ -9430,10 +9540,7 @@ async function restoreRootLocalState(snapshot, options = {}) {
9430
9540
 
9431
9541
  // src/connectRuntimeCleanup.ts
9432
9542
  var path42 = __toESM(require("path"), 1);
9433
- var import_node_child_process6 = require("child_process");
9434
- var import_node_util5 = require("util");
9435
9543
  var fs34 = __toESM(require("fs/promises"), 1);
9436
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
9437
9544
  var CLINE_HUB_DAEMON_MARKER = "--cline-hub-daemon";
9438
9545
  function parseClineHubCwdFromCommandLine(commandLine) {
9439
9546
  if (!commandLine.includes(CLINE_HUB_DAEMON_MARKER)) {
@@ -9470,13 +9577,9 @@ function parseClineHubProcessLines(lines) {
9470
9577
  }
9471
9578
  return processes;
9472
9579
  }
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"));
9580
+ async function defaultListClineHubProcesses(deps) {
9581
+ const lines = await listProcessCommandLineRows(deps);
9582
+ return parseClineHubProcessLines(lines);
9480
9583
  }
9481
9584
  async function defaultRemoveSocket2(socketPath) {
9482
9585
  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.64",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "exports": {