@memoraone/mcp 0.1.66 → 0.1.68

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.
@@ -1000,12 +1000,18 @@ async function readLinuxDeviceId() {
1000
1000
  throw new Error("[memoraone-mcp] Unable to read Linux machine-id");
1001
1001
  }
1002
1002
  async function readWindowsDeviceId() {
1003
- const { stdout } = await execFileAsync("reg", [
1004
- "query",
1005
- "HKLM\\SOFTWARE\\Microsoft\\Cryptography",
1006
- "/v",
1007
- "MachineGuid"
1008
- ]);
1003
+ const { stdout } = await execFileAsync(
1004
+ "reg",
1005
+ [
1006
+ "query",
1007
+ "HKLM\\SOFTWARE\\Microsoft\\Cryptography",
1008
+ "/v",
1009
+ "MachineGuid"
1010
+ ],
1011
+ {
1012
+ windowsHide: true
1013
+ }
1014
+ );
1009
1015
  const match = stdout.match(/MachineGuid\s+REG_SZ\s+(.+)/i);
1010
1016
  if (!match?.[1]) {
1011
1017
  throw new Error("[memoraone-mcp] Unable to read Windows MachineGuid");
@@ -2310,35 +2316,74 @@ var WINDOWS_LIST_PROCESSES_PS = [
2310
2316
  " [Console]::Error.WriteLine([string]$_)",
2311
2317
  " exit 1",
2312
2318
  "}",
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."',
2319
+ "$currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()",
2320
+ "$currentUserSid = [string]$currentIdentity.User.Value",
2321
+ "if ([string]::IsNullOrWhiteSpace($currentUserSid)) {",
2322
+ ' throw "Unable to determine the current Windows identity SID."',
2320
2323
  "}",
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."',
2324
+ "$ownerLookupSource = @'",
2325
+ "using System;",
2326
+ "using System.Collections.Generic;",
2327
+ "using System.Runtime.InteropServices;",
2328
+ "using System.Security.Principal;",
2329
+ "",
2330
+ "public static class MemoraOneProcessOwner {",
2331
+ " private const uint ProcessQueryLimitedInformation = 0x1000;",
2332
+ " private const uint TokenQuery = 0x0008;",
2333
+ " private const int TokenUser = 1;",
2334
+ "",
2335
+ ' [DllImport("kernel32.dll", SetLastError = true)]',
2336
+ " private static extern IntPtr OpenProcess(uint access, bool inheritHandle, int processId);",
2337
+ ' [DllImport("advapi32.dll", SetLastError = true)]',
2338
+ " private static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);",
2339
+ ' [DllImport("advapi32.dll", SetLastError = true)]',
2340
+ " private static extern bool GetTokenInformation(IntPtr tokenHandle, int tokenInformationClass, IntPtr tokenInformation, int tokenInformationLength, out int returnLength);",
2341
+ ' [DllImport("kernel32.dll")]',
2342
+ " private static extern bool CloseHandle(IntPtr handle);",
2343
+ "",
2344
+ " public static int[] OwnedProcessIds(int[] processIds, string currentSid) {",
2345
+ " var expectedSid = new SecurityIdentifier(currentSid);",
2346
+ " var owned = new List<int>();",
2347
+ " foreach (int processId in processIds) {",
2348
+ " IntPtr processHandle = OpenProcess(ProcessQueryLimitedInformation, false, processId);",
2349
+ " if (processHandle == IntPtr.Zero) continue;",
2350
+ " try {",
2351
+ " IntPtr tokenHandle;",
2352
+ " if (!OpenProcessToken(processHandle, TokenQuery, out tokenHandle)) continue;",
2353
+ " try {",
2354
+ " int tokenLength;",
2355
+ " GetTokenInformation(tokenHandle, TokenUser, IntPtr.Zero, 0, out tokenLength);",
2356
+ " if (tokenLength <= 0) continue;",
2357
+ " IntPtr tokenBuffer = Marshal.AllocHGlobal(tokenLength);",
2358
+ " try {",
2359
+ " if (!GetTokenInformation(tokenHandle, TokenUser, tokenBuffer, tokenLength, out tokenLength)) continue;",
2360
+ " IntPtr sidPointer = Marshal.ReadIntPtr(tokenBuffer);",
2361
+ " if (expectedSid.Equals(new SecurityIdentifier(sidPointer))) owned.Add(processId);",
2362
+ " } finally {",
2363
+ " Marshal.FreeHGlobal(tokenBuffer);",
2364
+ " }",
2365
+ " } finally {",
2366
+ " CloseHandle(tokenHandle);",
2367
+ " }",
2368
+ " } finally {",
2369
+ " CloseHandle(processHandle);",
2370
+ " }",
2371
+ " }",
2372
+ " return owned.ToArray();",
2373
+ " }",
2327
2374
  "}",
2375
+ "'@",
2376
+ "Add-Type -TypeDefinition $ownerLookupSource -Language CSharp",
2377
+ "$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
2378
+ "$processIds = [int[]]@($processes | ForEach-Object { [int]$_.ProcessId })",
2379
+ "$ownedProcessIds = [MemoraOneProcessOwner]::OwnedProcessIds($processIds, $currentUserSid)",
2328
2380
  '$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)",
2381
+ "foreach ($ownedProcessId in $ownedProcessIds) {",
2382
+ " $null = $currentUserPids.Add([int]$ownedProcessId)",
2337
2383
  "}",
2338
2384
  "if (-not $currentUserPids.Contains([int]$PID)) {",
2339
- ' throw "tasklist.exe results did not include the running PowerShell process."',
2385
+ ' throw "Process token results did not include the running PowerShell process."',
2340
2386
  "}",
2341
- "$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
2342
2387
  "foreach ($proc in $processes) {",
2343
2388
  " if ($null -eq $proc.ProcessId) { continue }",
2344
2389
  " $procId = [int]$proc.ProcessId",
@@ -2425,7 +2470,8 @@ async function listProcessCommandLineRows(deps = {}) {
2425
2470
  const { file, args } = windowsProcessListInvocation();
2426
2471
  const { stdout: stdout2 } = await execFileImpl(file, args, {
2427
2472
  maxBuffer: PROCESS_LIST_MAX_BUFFER,
2428
- timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
2473
+ timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS,
2474
+ windowsHide: true
2429
2475
  });
2430
2476
  return parseWindowsProcessJsonLines(stdoutToString(stdout2));
2431
2477
  }
@@ -6431,7 +6477,6 @@ function buildMemoraoneAntigravityMcpServer(options) {
6431
6477
  environment,
6432
6478
  apiUrl: options.apiUrl ?? (environment === "local" ? DEV_API_URL : void 0)
6433
6479
  }),
6434
- MEMORAONE_IDE_TYPE: "antigravity",
6435
6480
  [MEMORAONE_WORKSPACE_ROOT_ENV]: path35.resolve(options.workspaceRoot)
6436
6481
  };
6437
6482
  if (environment === "local" || options.devMode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoraone/mcp",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "exports": {