@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.
- package/dist/cli.cjs +3373 -372
- package/dist/daemon.cjs +87 -35
- package/dist/gateway.cjs +90 -37
- package/dist/index.cjs +87 -35
- package/dist/pluginPairing.cjs +76 -31
- package/package.json +1 -1
package/dist/daemon.cjs
CHANGED
|
@@ -232,6 +232,7 @@ function formatMissingInitializeWorkspaceError(options) {
|
|
|
232
232
|
|
|
233
233
|
// src/socketPaths.ts
|
|
234
234
|
var BASE_DIR = process.env.MEMORAONE_MCP_LOCK_DIR || path4.join(os2.homedir(), ".memoraone-mcp");
|
|
235
|
+
var WINDOWS_PIPE_PREFIX = "\\\\.\\pipe\\memoraone-";
|
|
235
236
|
var HASH_SOCKET_FILENAME_RE = new RegExp(
|
|
236
237
|
`^mcp-[0-9a-f]{${BINDING_SOCKET_HASH_LENGTH}}\\.sock$`,
|
|
237
238
|
"i"
|
|
@@ -316,6 +317,10 @@ function getBindingSocketFilename(binding, env2 = process.env, ideTypeOverride)
|
|
|
316
317
|
return `mcp-${hash}.sock`;
|
|
317
318
|
}
|
|
318
319
|
function getBindingSocketPath(binding, env2 = process.env, ideTypeOverride) {
|
|
320
|
+
if (process.platform === "win32") {
|
|
321
|
+
const filename = getBindingSocketFilename(binding, env2, ideTypeOverride);
|
|
322
|
+
return `${WINDOWS_PIPE_PREFIX}${filename.slice(0, -".sock".length)}`;
|
|
323
|
+
}
|
|
319
324
|
return path4.join(BASE_DIR, getBindingSocketFilename(binding, env2, ideTypeOverride));
|
|
320
325
|
}
|
|
321
326
|
function ensureBaseDir() {
|
|
@@ -805,12 +810,18 @@ async function readLinuxDeviceId() {
|
|
|
805
810
|
throw new Error("[memoraone-mcp] Unable to read Linux machine-id");
|
|
806
811
|
}
|
|
807
812
|
async function readWindowsDeviceId() {
|
|
808
|
-
const { stdout } = await execFileAsync(
|
|
809
|
-
"
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
813
|
+
const { stdout } = await execFileAsync(
|
|
814
|
+
"reg",
|
|
815
|
+
[
|
|
816
|
+
"query",
|
|
817
|
+
"HKLM\\SOFTWARE\\Microsoft\\Cryptography",
|
|
818
|
+
"/v",
|
|
819
|
+
"MachineGuid"
|
|
820
|
+
],
|
|
821
|
+
{
|
|
822
|
+
windowsHide: true
|
|
823
|
+
}
|
|
824
|
+
);
|
|
814
825
|
const match = stdout.match(/MachineGuid\s+REG_SZ\s+(.+)/i);
|
|
815
826
|
if (!match?.[1]) {
|
|
816
827
|
throw new Error("[memoraone-mcp] Unable to read Windows MachineGuid");
|
|
@@ -4137,35 +4148,74 @@ var WINDOWS_LIST_PROCESSES_PS = [
|
|
|
4137
4148
|
" [Console]::Error.WriteLine([string]$_)",
|
|
4138
4149
|
" exit 1",
|
|
4139
4150
|
"}",
|
|
4140
|
-
"$currentIdentity = [
|
|
4141
|
-
"
|
|
4142
|
-
|
|
4143
|
-
"
|
|
4144
|
-
"$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
|
|
4145
|
-
"if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
|
|
4146
|
-
' throw "Unable to determine the Windows system directory."',
|
|
4151
|
+
"$currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()",
|
|
4152
|
+
"$currentUserSid = [string]$currentIdentity.User.Value",
|
|
4153
|
+
"if ([string]::IsNullOrWhiteSpace($currentUserSid)) {",
|
|
4154
|
+
' throw "Unable to determine the current Windows identity SID."',
|
|
4147
4155
|
"}",
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
"
|
|
4151
|
-
"
|
|
4152
|
-
"
|
|
4153
|
-
|
|
4156
|
+
"$ownerLookupSource = @'",
|
|
4157
|
+
"using System;",
|
|
4158
|
+
"using System.Collections.Generic;",
|
|
4159
|
+
"using System.Runtime.InteropServices;",
|
|
4160
|
+
"using System.Security.Principal;",
|
|
4161
|
+
"",
|
|
4162
|
+
"public static class MemoraOneProcessOwner {",
|
|
4163
|
+
" private const uint ProcessQueryLimitedInformation = 0x1000;",
|
|
4164
|
+
" private const uint TokenQuery = 0x0008;",
|
|
4165
|
+
" private const int TokenUser = 1;",
|
|
4166
|
+
"",
|
|
4167
|
+
' [DllImport("kernel32.dll", SetLastError = true)]',
|
|
4168
|
+
" private static extern IntPtr OpenProcess(uint access, bool inheritHandle, int processId);",
|
|
4169
|
+
' [DllImport("advapi32.dll", SetLastError = true)]',
|
|
4170
|
+
" private static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);",
|
|
4171
|
+
' [DllImport("advapi32.dll", SetLastError = true)]',
|
|
4172
|
+
" private static extern bool GetTokenInformation(IntPtr tokenHandle, int tokenInformationClass, IntPtr tokenInformation, int tokenInformationLength, out int returnLength);",
|
|
4173
|
+
' [DllImport("kernel32.dll")]',
|
|
4174
|
+
" private static extern bool CloseHandle(IntPtr handle);",
|
|
4175
|
+
"",
|
|
4176
|
+
" public static int[] OwnedProcessIds(int[] processIds, string currentSid) {",
|
|
4177
|
+
" var expectedSid = new SecurityIdentifier(currentSid);",
|
|
4178
|
+
" var owned = new List<int>();",
|
|
4179
|
+
" foreach (int processId in processIds) {",
|
|
4180
|
+
" IntPtr processHandle = OpenProcess(ProcessQueryLimitedInformation, false, processId);",
|
|
4181
|
+
" if (processHandle == IntPtr.Zero) continue;",
|
|
4182
|
+
" try {",
|
|
4183
|
+
" IntPtr tokenHandle;",
|
|
4184
|
+
" if (!OpenProcessToken(processHandle, TokenQuery, out tokenHandle)) continue;",
|
|
4185
|
+
" try {",
|
|
4186
|
+
" int tokenLength;",
|
|
4187
|
+
" GetTokenInformation(tokenHandle, TokenUser, IntPtr.Zero, 0, out tokenLength);",
|
|
4188
|
+
" if (tokenLength <= 0) continue;",
|
|
4189
|
+
" IntPtr tokenBuffer = Marshal.AllocHGlobal(tokenLength);",
|
|
4190
|
+
" try {",
|
|
4191
|
+
" if (!GetTokenInformation(tokenHandle, TokenUser, tokenBuffer, tokenLength, out tokenLength)) continue;",
|
|
4192
|
+
" IntPtr sidPointer = Marshal.ReadIntPtr(tokenBuffer);",
|
|
4193
|
+
" if (expectedSid.Equals(new SecurityIdentifier(sidPointer))) owned.Add(processId);",
|
|
4194
|
+
" } finally {",
|
|
4195
|
+
" Marshal.FreeHGlobal(tokenBuffer);",
|
|
4196
|
+
" }",
|
|
4197
|
+
" } finally {",
|
|
4198
|
+
" CloseHandle(tokenHandle);",
|
|
4199
|
+
" }",
|
|
4200
|
+
" } finally {",
|
|
4201
|
+
" CloseHandle(processHandle);",
|
|
4202
|
+
" }",
|
|
4203
|
+
" }",
|
|
4204
|
+
" return owned.ToArray();",
|
|
4205
|
+
" }",
|
|
4154
4206
|
"}",
|
|
4207
|
+
"'@",
|
|
4208
|
+
"Add-Type -TypeDefinition $ownerLookupSource -Language CSharp",
|
|
4209
|
+
"$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
|
|
4210
|
+
"$processIds = [int[]]@($processes | ForEach-Object { [int]$_.ProcessId })",
|
|
4211
|
+
"$ownedProcessIds = [MemoraOneProcessOwner]::OwnedProcessIds($processIds, $currentUserSid)",
|
|
4155
4212
|
'$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
|
|
4156
|
-
"foreach ($
|
|
4157
|
-
"
|
|
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)",
|
|
4213
|
+
"foreach ($ownedProcessId in $ownedProcessIds) {",
|
|
4214
|
+
" $null = $currentUserPids.Add([int]$ownedProcessId)",
|
|
4164
4215
|
"}",
|
|
4165
4216
|
"if (-not $currentUserPids.Contains([int]$PID)) {",
|
|
4166
|
-
' throw "
|
|
4217
|
+
' throw "Process token results did not include the running PowerShell process."',
|
|
4167
4218
|
"}",
|
|
4168
|
-
"$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
|
|
4169
4219
|
"foreach ($proc in $processes) {",
|
|
4170
4220
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
4171
4221
|
" $procId = [int]$proc.ProcessId",
|
|
@@ -4252,7 +4302,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
4252
4302
|
const { file, args } = windowsProcessListInvocation();
|
|
4253
4303
|
const { stdout: stdout2 } = await execFileImpl(file, args, {
|
|
4254
4304
|
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
4255
|
-
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
4305
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS,
|
|
4306
|
+
windowsHide: true
|
|
4256
4307
|
});
|
|
4257
4308
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
4258
4309
|
}
|
|
@@ -8258,7 +8309,6 @@ function buildMemoraoneAntigravityMcpServer(options) {
|
|
|
8258
8309
|
environment,
|
|
8259
8310
|
apiUrl: options.apiUrl ?? (environment === "local" ? DEV_API_URL : void 0)
|
|
8260
8311
|
}),
|
|
8261
|
-
MEMORAONE_IDE_TYPE: "antigravity",
|
|
8262
8312
|
[MEMORAONE_WORKSPACE_ROOT_ENV]: path36.resolve(options.workspaceRoot)
|
|
8263
8313
|
};
|
|
8264
8314
|
if (environment === "local" || options.devMode) {
|
|
@@ -12629,7 +12679,12 @@ function inferIdeType(params, options = {}) {
|
|
|
12629
12679
|
const env2 = options.env ?? process.env;
|
|
12630
12680
|
const argv = (options.argv ?? process.argv).join(" ").toLowerCase();
|
|
12631
12681
|
const hasExplicitConfigOption = Object.prototype.hasOwnProperty.call(options, "configIdeType");
|
|
12632
|
-
const
|
|
12682
|
+
const explicitIdentity = resolveIdeTypeFromEnv(env2) ?? parseIdeType(
|
|
12683
|
+
hasExplicitConfigOption ? options.configIdeType : config2.ideType
|
|
12684
|
+
);
|
|
12685
|
+
if (explicitIdentity) {
|
|
12686
|
+
return explicitIdentity;
|
|
12687
|
+
}
|
|
12633
12688
|
const fromClientInfo = mapReliableClientInfoName(params?.clientInfo?.name);
|
|
12634
12689
|
if (fromClientInfo) {
|
|
12635
12690
|
return fromClientInfo;
|
|
@@ -12638,9 +12693,6 @@ function inferIdeType(params, options = {}) {
|
|
|
12638
12693
|
if (fromHost) {
|
|
12639
12694
|
return fromHost;
|
|
12640
12695
|
}
|
|
12641
|
-
if (explicitHint) {
|
|
12642
|
-
return explicitHint;
|
|
12643
|
-
}
|
|
12644
12696
|
const clientInfoName = String(params?.clientInfo?.name ?? "").toLowerCase();
|
|
12645
12697
|
const clientInfoVersion = String(params?.clientInfo?.version ?? "").toLowerCase();
|
|
12646
12698
|
const termProgram = String(env2.TERM_PROGRAM ?? "").toLowerCase();
|
package/dist/gateway.cjs
CHANGED
|
@@ -89,6 +89,7 @@ function formatMissingInitializeWorkspaceError(options) {
|
|
|
89
89
|
|
|
90
90
|
// src/socketPaths.ts
|
|
91
91
|
var BASE_DIR = process.env.MEMORAONE_MCP_LOCK_DIR || path2.join(os.homedir(), ".memoraone-mcp");
|
|
92
|
+
var WINDOWS_PIPE_PREFIX = "\\\\.\\pipe\\memoraone-";
|
|
92
93
|
var HASH_SOCKET_FILENAME_RE = new RegExp(
|
|
93
94
|
`^mcp-[0-9a-f]{${BINDING_SOCKET_HASH_LENGTH}}\\.sock$`,
|
|
94
95
|
"i"
|
|
@@ -166,6 +167,10 @@ function getBindingSocketFilename(binding, env2 = process.env, ideTypeOverride)
|
|
|
166
167
|
return `mcp-${hash}.sock`;
|
|
167
168
|
}
|
|
168
169
|
function getBindingSocketPath(binding, env2 = process.env, ideTypeOverride) {
|
|
170
|
+
if (process.platform === "win32") {
|
|
171
|
+
const filename = getBindingSocketFilename(binding, env2, ideTypeOverride);
|
|
172
|
+
return `${WINDOWS_PIPE_PREFIX}${filename.slice(0, -".sock".length)}`;
|
|
173
|
+
}
|
|
169
174
|
return path2.join(BASE_DIR, getBindingSocketFilename(binding, env2, ideTypeOverride));
|
|
170
175
|
}
|
|
171
176
|
function ensureBaseDir() {
|
|
@@ -1103,12 +1108,18 @@ async function readLinuxDeviceId() {
|
|
|
1103
1108
|
throw new Error("[memoraone-mcp] Unable to read Linux machine-id");
|
|
1104
1109
|
}
|
|
1105
1110
|
async function readWindowsDeviceId() {
|
|
1106
|
-
const { stdout } = await execFileAsync(
|
|
1107
|
-
"
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1111
|
+
const { stdout } = await execFileAsync(
|
|
1112
|
+
"reg",
|
|
1113
|
+
[
|
|
1114
|
+
"query",
|
|
1115
|
+
"HKLM\\SOFTWARE\\Microsoft\\Cryptography",
|
|
1116
|
+
"/v",
|
|
1117
|
+
"MachineGuid"
|
|
1118
|
+
],
|
|
1119
|
+
{
|
|
1120
|
+
windowsHide: true
|
|
1121
|
+
}
|
|
1122
|
+
);
|
|
1112
1123
|
const match = stdout.match(/MachineGuid\s+REG_SZ\s+(.+)/i);
|
|
1113
1124
|
if (!match?.[1]) {
|
|
1114
1125
|
throw new Error("[memoraone-mcp] Unable to read Windows MachineGuid");
|
|
@@ -1887,10 +1898,11 @@ async function parseGatewayWorkspaceRoot(wsRaw) {
|
|
|
1887
1898
|
if (trimmed.includes("\0")) {
|
|
1888
1899
|
return fail("malformed_ws", "ws query parameter is malformed");
|
|
1889
1900
|
}
|
|
1890
|
-
|
|
1901
|
+
const isAbsoluteFilesystemPath = path12.isAbsolute(trimmed);
|
|
1902
|
+
if (!isAbsoluteFilesystemPath && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
1891
1903
|
return fail("malformed_ws", "ws must be an absolute filesystem path");
|
|
1892
1904
|
}
|
|
1893
|
-
if (!
|
|
1905
|
+
if (!isAbsoluteFilesystemPath) {
|
|
1894
1906
|
return fail("non_absolute", "ws must be an absolute workspace root");
|
|
1895
1907
|
}
|
|
1896
1908
|
const workspaceRoot = path12.resolve(trimmed);
|
|
@@ -3401,35 +3413,74 @@ var WINDOWS_LIST_PROCESSES_PS = [
|
|
|
3401
3413
|
" [Console]::Error.WriteLine([string]$_)",
|
|
3402
3414
|
" exit 1",
|
|
3403
3415
|
"}",
|
|
3404
|
-
"$currentIdentity = [
|
|
3405
|
-
"
|
|
3406
|
-
|
|
3407
|
-
"
|
|
3408
|
-
"$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
|
|
3409
|
-
"if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
|
|
3410
|
-
' throw "Unable to determine the Windows system directory."',
|
|
3416
|
+
"$currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()",
|
|
3417
|
+
"$currentUserSid = [string]$currentIdentity.User.Value",
|
|
3418
|
+
"if ([string]::IsNullOrWhiteSpace($currentUserSid)) {",
|
|
3419
|
+
' throw "Unable to determine the current Windows identity SID."',
|
|
3411
3420
|
"}",
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
"
|
|
3415
|
-
"
|
|
3416
|
-
"
|
|
3417
|
-
|
|
3421
|
+
"$ownerLookupSource = @'",
|
|
3422
|
+
"using System;",
|
|
3423
|
+
"using System.Collections.Generic;",
|
|
3424
|
+
"using System.Runtime.InteropServices;",
|
|
3425
|
+
"using System.Security.Principal;",
|
|
3426
|
+
"",
|
|
3427
|
+
"public static class MemoraOneProcessOwner {",
|
|
3428
|
+
" private const uint ProcessQueryLimitedInformation = 0x1000;",
|
|
3429
|
+
" private const uint TokenQuery = 0x0008;",
|
|
3430
|
+
" private const int TokenUser = 1;",
|
|
3431
|
+
"",
|
|
3432
|
+
' [DllImport("kernel32.dll", SetLastError = true)]',
|
|
3433
|
+
" private static extern IntPtr OpenProcess(uint access, bool inheritHandle, int processId);",
|
|
3434
|
+
' [DllImport("advapi32.dll", SetLastError = true)]',
|
|
3435
|
+
" private static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);",
|
|
3436
|
+
' [DllImport("advapi32.dll", SetLastError = true)]',
|
|
3437
|
+
" private static extern bool GetTokenInformation(IntPtr tokenHandle, int tokenInformationClass, IntPtr tokenInformation, int tokenInformationLength, out int returnLength);",
|
|
3438
|
+
' [DllImport("kernel32.dll")]',
|
|
3439
|
+
" private static extern bool CloseHandle(IntPtr handle);",
|
|
3440
|
+
"",
|
|
3441
|
+
" public static int[] OwnedProcessIds(int[] processIds, string currentSid) {",
|
|
3442
|
+
" var expectedSid = new SecurityIdentifier(currentSid);",
|
|
3443
|
+
" var owned = new List<int>();",
|
|
3444
|
+
" foreach (int processId in processIds) {",
|
|
3445
|
+
" IntPtr processHandle = OpenProcess(ProcessQueryLimitedInformation, false, processId);",
|
|
3446
|
+
" if (processHandle == IntPtr.Zero) continue;",
|
|
3447
|
+
" try {",
|
|
3448
|
+
" IntPtr tokenHandle;",
|
|
3449
|
+
" if (!OpenProcessToken(processHandle, TokenQuery, out tokenHandle)) continue;",
|
|
3450
|
+
" try {",
|
|
3451
|
+
" int tokenLength;",
|
|
3452
|
+
" GetTokenInformation(tokenHandle, TokenUser, IntPtr.Zero, 0, out tokenLength);",
|
|
3453
|
+
" if (tokenLength <= 0) continue;",
|
|
3454
|
+
" IntPtr tokenBuffer = Marshal.AllocHGlobal(tokenLength);",
|
|
3455
|
+
" try {",
|
|
3456
|
+
" if (!GetTokenInformation(tokenHandle, TokenUser, tokenBuffer, tokenLength, out tokenLength)) continue;",
|
|
3457
|
+
" IntPtr sidPointer = Marshal.ReadIntPtr(tokenBuffer);",
|
|
3458
|
+
" if (expectedSid.Equals(new SecurityIdentifier(sidPointer))) owned.Add(processId);",
|
|
3459
|
+
" } finally {",
|
|
3460
|
+
" Marshal.FreeHGlobal(tokenBuffer);",
|
|
3461
|
+
" }",
|
|
3462
|
+
" } finally {",
|
|
3463
|
+
" CloseHandle(tokenHandle);",
|
|
3464
|
+
" }",
|
|
3465
|
+
" } finally {",
|
|
3466
|
+
" CloseHandle(processHandle);",
|
|
3467
|
+
" }",
|
|
3468
|
+
" }",
|
|
3469
|
+
" return owned.ToArray();",
|
|
3470
|
+
" }",
|
|
3418
3471
|
"}",
|
|
3472
|
+
"'@",
|
|
3473
|
+
"Add-Type -TypeDefinition $ownerLookupSource -Language CSharp",
|
|
3474
|
+
"$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
|
|
3475
|
+
"$processIds = [int[]]@($processes | ForEach-Object { [int]$_.ProcessId })",
|
|
3476
|
+
"$ownedProcessIds = [MemoraOneProcessOwner]::OwnedProcessIds($processIds, $currentUserSid)",
|
|
3419
3477
|
'$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
|
|
3420
|
-
"foreach ($
|
|
3421
|
-
"
|
|
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)",
|
|
3478
|
+
"foreach ($ownedProcessId in $ownedProcessIds) {",
|
|
3479
|
+
" $null = $currentUserPids.Add([int]$ownedProcessId)",
|
|
3428
3480
|
"}",
|
|
3429
3481
|
"if (-not $currentUserPids.Contains([int]$PID)) {",
|
|
3430
|
-
' throw "
|
|
3482
|
+
' throw "Process token results did not include the running PowerShell process."',
|
|
3431
3483
|
"}",
|
|
3432
|
-
"$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
|
|
3433
3484
|
"foreach ($proc in $processes) {",
|
|
3434
3485
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
3435
3486
|
" $procId = [int]$proc.ProcessId",
|
|
@@ -3516,7 +3567,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
3516
3567
|
const { file, args } = windowsProcessListInvocation();
|
|
3517
3568
|
const { stdout: stdout2 } = await execFileImpl(file, args, {
|
|
3518
3569
|
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
3519
|
-
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
3570
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS,
|
|
3571
|
+
windowsHide: true
|
|
3520
3572
|
});
|
|
3521
3573
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
3522
3574
|
}
|
|
@@ -7522,7 +7574,6 @@ function buildMemoraoneAntigravityMcpServer(options) {
|
|
|
7522
7574
|
environment,
|
|
7523
7575
|
apiUrl: options.apiUrl ?? (environment === "local" ? DEV_API_URL : void 0)
|
|
7524
7576
|
}),
|
|
7525
|
-
MEMORAONE_IDE_TYPE: "antigravity",
|
|
7526
7577
|
[MEMORAONE_WORKSPACE_ROOT_ENV]: path38.resolve(options.workspaceRoot)
|
|
7527
7578
|
};
|
|
7528
7579
|
if (environment === "local" || options.devMode) {
|
|
@@ -13726,7 +13777,12 @@ function inferIdeType(params, options = {}) {
|
|
|
13726
13777
|
const env2 = options.env ?? process.env;
|
|
13727
13778
|
const argv = (options.argv ?? process.argv).join(" ").toLowerCase();
|
|
13728
13779
|
const hasExplicitConfigOption = Object.prototype.hasOwnProperty.call(options, "configIdeType");
|
|
13729
|
-
const
|
|
13780
|
+
const explicitIdentity = resolveIdeTypeFromEnv(env2) ?? parseIdeType(
|
|
13781
|
+
hasExplicitConfigOption ? options.configIdeType : config2.ideType
|
|
13782
|
+
);
|
|
13783
|
+
if (explicitIdentity) {
|
|
13784
|
+
return explicitIdentity;
|
|
13785
|
+
}
|
|
13730
13786
|
const fromClientInfo = mapReliableClientInfoName(params?.clientInfo?.name);
|
|
13731
13787
|
if (fromClientInfo) {
|
|
13732
13788
|
return fromClientInfo;
|
|
@@ -13735,9 +13791,6 @@ function inferIdeType(params, options = {}) {
|
|
|
13735
13791
|
if (fromHost) {
|
|
13736
13792
|
return fromHost;
|
|
13737
13793
|
}
|
|
13738
|
-
if (explicitHint) {
|
|
13739
|
-
return explicitHint;
|
|
13740
|
-
}
|
|
13741
13794
|
const clientInfoName = String(params?.clientInfo?.name ?? "").toLowerCase();
|
|
13742
13795
|
const clientInfoVersion = String(params?.clientInfo?.version ?? "").toLowerCase();
|
|
13743
13796
|
const termProgram = String(env2.TERM_PROGRAM ?? "").toLowerCase();
|
package/dist/index.cjs
CHANGED
|
@@ -110,6 +110,7 @@ function formatMissingInitializeWorkspaceError(options) {
|
|
|
110
110
|
|
|
111
111
|
// src/socketPaths.ts
|
|
112
112
|
var BASE_DIR = process.env.MEMORAONE_MCP_LOCK_DIR || path2.join(os.homedir(), ".memoraone-mcp");
|
|
113
|
+
var WINDOWS_PIPE_PREFIX = "\\\\.\\pipe\\memoraone-";
|
|
113
114
|
var HASH_SOCKET_FILENAME_RE = new RegExp(
|
|
114
115
|
`^mcp-[0-9a-f]{${BINDING_SOCKET_HASH_LENGTH}}\\.sock$`,
|
|
115
116
|
"i"
|
|
@@ -187,6 +188,10 @@ function getBindingSocketFilename(binding, env2 = process.env, ideTypeOverride)
|
|
|
187
188
|
return `mcp-${hash}.sock`;
|
|
188
189
|
}
|
|
189
190
|
function getBindingSocketPath(binding, env2 = process.env, ideTypeOverride) {
|
|
191
|
+
if (process.platform === "win32") {
|
|
192
|
+
const filename = getBindingSocketFilename(binding, env2, ideTypeOverride);
|
|
193
|
+
return `${WINDOWS_PIPE_PREFIX}${filename.slice(0, -".sock".length)}`;
|
|
194
|
+
}
|
|
190
195
|
return path2.join(BASE_DIR, getBindingSocketFilename(binding, env2, ideTypeOverride));
|
|
191
196
|
}
|
|
192
197
|
function isHashSocketFilename(filename) {
|
|
@@ -1301,12 +1306,18 @@ async function readLinuxDeviceId() {
|
|
|
1301
1306
|
throw new Error("[memoraone-mcp] Unable to read Linux machine-id");
|
|
1302
1307
|
}
|
|
1303
1308
|
async function readWindowsDeviceId() {
|
|
1304
|
-
const { stdout } = await execFileAsync(
|
|
1305
|
-
"
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1309
|
+
const { stdout } = await execFileAsync(
|
|
1310
|
+
"reg",
|
|
1311
|
+
[
|
|
1312
|
+
"query",
|
|
1313
|
+
"HKLM\\SOFTWARE\\Microsoft\\Cryptography",
|
|
1314
|
+
"/v",
|
|
1315
|
+
"MachineGuid"
|
|
1316
|
+
],
|
|
1317
|
+
{
|
|
1318
|
+
windowsHide: true
|
|
1319
|
+
}
|
|
1320
|
+
);
|
|
1310
1321
|
const match = stdout.match(/MachineGuid\s+REG_SZ\s+(.+)/i);
|
|
1311
1322
|
if (!match?.[1]) {
|
|
1312
1323
|
throw new Error("[memoraone-mcp] Unable to read Windows MachineGuid");
|
|
@@ -4120,35 +4131,74 @@ var WINDOWS_LIST_PROCESSES_PS = [
|
|
|
4120
4131
|
" [Console]::Error.WriteLine([string]$_)",
|
|
4121
4132
|
" exit 1",
|
|
4122
4133
|
"}",
|
|
4123
|
-
"$currentIdentity = [
|
|
4124
|
-
"
|
|
4125
|
-
|
|
4126
|
-
"
|
|
4127
|
-
"$systemDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)",
|
|
4128
|
-
"if ([string]::IsNullOrWhiteSpace($systemDirectory)) {",
|
|
4129
|
-
' throw "Unable to determine the Windows system directory."',
|
|
4134
|
+
"$currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()",
|
|
4135
|
+
"$currentUserSid = [string]$currentIdentity.User.Value",
|
|
4136
|
+
"if ([string]::IsNullOrWhiteSpace($currentUserSid)) {",
|
|
4137
|
+
' throw "Unable to determine the current Windows identity SID."',
|
|
4130
4138
|
"}",
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
"
|
|
4134
|
-
"
|
|
4135
|
-
"
|
|
4136
|
-
|
|
4139
|
+
"$ownerLookupSource = @'",
|
|
4140
|
+
"using System;",
|
|
4141
|
+
"using System.Collections.Generic;",
|
|
4142
|
+
"using System.Runtime.InteropServices;",
|
|
4143
|
+
"using System.Security.Principal;",
|
|
4144
|
+
"",
|
|
4145
|
+
"public static class MemoraOneProcessOwner {",
|
|
4146
|
+
" private const uint ProcessQueryLimitedInformation = 0x1000;",
|
|
4147
|
+
" private const uint TokenQuery = 0x0008;",
|
|
4148
|
+
" private const int TokenUser = 1;",
|
|
4149
|
+
"",
|
|
4150
|
+
' [DllImport("kernel32.dll", SetLastError = true)]',
|
|
4151
|
+
" private static extern IntPtr OpenProcess(uint access, bool inheritHandle, int processId);",
|
|
4152
|
+
' [DllImport("advapi32.dll", SetLastError = true)]',
|
|
4153
|
+
" private static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);",
|
|
4154
|
+
' [DllImport("advapi32.dll", SetLastError = true)]',
|
|
4155
|
+
" private static extern bool GetTokenInformation(IntPtr tokenHandle, int tokenInformationClass, IntPtr tokenInformation, int tokenInformationLength, out int returnLength);",
|
|
4156
|
+
' [DllImport("kernel32.dll")]',
|
|
4157
|
+
" private static extern bool CloseHandle(IntPtr handle);",
|
|
4158
|
+
"",
|
|
4159
|
+
" public static int[] OwnedProcessIds(int[] processIds, string currentSid) {",
|
|
4160
|
+
" var expectedSid = new SecurityIdentifier(currentSid);",
|
|
4161
|
+
" var owned = new List<int>();",
|
|
4162
|
+
" foreach (int processId in processIds) {",
|
|
4163
|
+
" IntPtr processHandle = OpenProcess(ProcessQueryLimitedInformation, false, processId);",
|
|
4164
|
+
" if (processHandle == IntPtr.Zero) continue;",
|
|
4165
|
+
" try {",
|
|
4166
|
+
" IntPtr tokenHandle;",
|
|
4167
|
+
" if (!OpenProcessToken(processHandle, TokenQuery, out tokenHandle)) continue;",
|
|
4168
|
+
" try {",
|
|
4169
|
+
" int tokenLength;",
|
|
4170
|
+
" GetTokenInformation(tokenHandle, TokenUser, IntPtr.Zero, 0, out tokenLength);",
|
|
4171
|
+
" if (tokenLength <= 0) continue;",
|
|
4172
|
+
" IntPtr tokenBuffer = Marshal.AllocHGlobal(tokenLength);",
|
|
4173
|
+
" try {",
|
|
4174
|
+
" if (!GetTokenInformation(tokenHandle, TokenUser, tokenBuffer, tokenLength, out tokenLength)) continue;",
|
|
4175
|
+
" IntPtr sidPointer = Marshal.ReadIntPtr(tokenBuffer);",
|
|
4176
|
+
" if (expectedSid.Equals(new SecurityIdentifier(sidPointer))) owned.Add(processId);",
|
|
4177
|
+
" } finally {",
|
|
4178
|
+
" Marshal.FreeHGlobal(tokenBuffer);",
|
|
4179
|
+
" }",
|
|
4180
|
+
" } finally {",
|
|
4181
|
+
" CloseHandle(tokenHandle);",
|
|
4182
|
+
" }",
|
|
4183
|
+
" } finally {",
|
|
4184
|
+
" CloseHandle(processHandle);",
|
|
4185
|
+
" }",
|
|
4186
|
+
" }",
|
|
4187
|
+
" return owned.ToArray();",
|
|
4188
|
+
" }",
|
|
4137
4189
|
"}",
|
|
4190
|
+
"'@",
|
|
4191
|
+
"Add-Type -TypeDefinition $ownerLookupSource -Language CSharp",
|
|
4192
|
+
"$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
|
|
4193
|
+
"$processIds = [int[]]@($processes | ForEach-Object { [int]$_.ProcessId })",
|
|
4194
|
+
"$ownedProcessIds = [MemoraOneProcessOwner]::OwnedProcessIds($processIds, $currentUserSid)",
|
|
4138
4195
|
'$currentUserPids = New-Object "System.Collections.Generic.HashSet[int]"',
|
|
4139
|
-
"foreach ($
|
|
4140
|
-
"
|
|
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)",
|
|
4196
|
+
"foreach ($ownedProcessId in $ownedProcessIds) {",
|
|
4197
|
+
" $null = $currentUserPids.Add([int]$ownedProcessId)",
|
|
4147
4198
|
"}",
|
|
4148
4199
|
"if (-not $currentUserPids.Contains([int]$PID)) {",
|
|
4149
|
-
' throw "
|
|
4200
|
+
' throw "Process token results did not include the running PowerShell process."',
|
|
4150
4201
|
"}",
|
|
4151
|
-
"$processes = @(Get-CimInstance -ClassName Win32_Process -Property ProcessId,CommandLine)",
|
|
4152
4202
|
"foreach ($proc in $processes) {",
|
|
4153
4203
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
4154
4204
|
" $procId = [int]$proc.ProcessId",
|
|
@@ -4235,7 +4285,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
4235
4285
|
const { file, args } = windowsProcessListInvocation();
|
|
4236
4286
|
const { stdout: stdout2 } = await execFileImpl(file, args, {
|
|
4237
4287
|
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
4238
|
-
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
4288
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS,
|
|
4289
|
+
windowsHide: true
|
|
4239
4290
|
});
|
|
4240
4291
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
4241
4292
|
}
|
|
@@ -8241,7 +8292,6 @@ function buildMemoraoneAntigravityMcpServer(options) {
|
|
|
8241
8292
|
environment,
|
|
8242
8293
|
apiUrl: options.apiUrl ?? (environment === "local" ? DEV_API_URL : void 0)
|
|
8243
8294
|
}),
|
|
8244
|
-
MEMORAONE_IDE_TYPE: "antigravity",
|
|
8245
8295
|
[MEMORAONE_WORKSPACE_ROOT_ENV]: path36.resolve(options.workspaceRoot)
|
|
8246
8296
|
};
|
|
8247
8297
|
if (environment === "local" || options.devMode) {
|
|
@@ -12612,7 +12662,12 @@ function inferIdeType(params, options = {}) {
|
|
|
12612
12662
|
const env2 = options.env ?? process.env;
|
|
12613
12663
|
const argv = (options.argv ?? process.argv).join(" ").toLowerCase();
|
|
12614
12664
|
const hasExplicitConfigOption = Object.prototype.hasOwnProperty.call(options, "configIdeType");
|
|
12615
|
-
const
|
|
12665
|
+
const explicitIdentity = resolveIdeTypeFromEnv(env2) ?? parseIdeType(
|
|
12666
|
+
hasExplicitConfigOption ? options.configIdeType : config2.ideType
|
|
12667
|
+
);
|
|
12668
|
+
if (explicitIdentity) {
|
|
12669
|
+
return explicitIdentity;
|
|
12670
|
+
}
|
|
12616
12671
|
const fromClientInfo = mapReliableClientInfoName(params?.clientInfo?.name);
|
|
12617
12672
|
if (fromClientInfo) {
|
|
12618
12673
|
return fromClientInfo;
|
|
@@ -12621,9 +12676,6 @@ function inferIdeType(params, options = {}) {
|
|
|
12621
12676
|
if (fromHost) {
|
|
12622
12677
|
return fromHost;
|
|
12623
12678
|
}
|
|
12624
|
-
if (explicitHint) {
|
|
12625
|
-
return explicitHint;
|
|
12626
|
-
}
|
|
12627
12679
|
const clientInfoName = String(params?.clientInfo?.name ?? "").toLowerCase();
|
|
12628
12680
|
const clientInfoVersion = String(params?.clientInfo?.version ?? "").toLowerCase();
|
|
12629
12681
|
const termProgram = String(env2.TERM_PROGRAM ?? "").toLowerCase();
|