@memoraone/mcp 0.1.64 → 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 +41 -17
- package/dist/daemon.cjs +39 -15
- package/dist/gateway.cjs +39 -15
- package/dist/index.cjs +39 -15
- package/dist/pluginPairing.cjs +39 -15
- package/package.json +1 -1
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.
|
|
234
|
+
version: "0.1.65",
|
|
235
235
|
type: "module",
|
|
236
236
|
main: "dist/index.cjs",
|
|
237
237
|
exports: {
|
|
@@ -2818,7 +2818,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
2818
2818
|
if (platform2 === "win32") {
|
|
2819
2819
|
const { file, args: args2 } = windowsProcessListInvocation();
|
|
2820
2820
|
const { stdout: stdout2 } = await execFileImpl(file, args2, {
|
|
2821
|
-
maxBuffer: PROCESS_LIST_MAX_BUFFER
|
|
2821
|
+
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
2822
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
2822
2823
|
});
|
|
2823
2824
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
2824
2825
|
}
|
|
@@ -2828,36 +2829,59 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
2828
2829
|
});
|
|
2829
2830
|
return stdoutToString(stdout).split("\n");
|
|
2830
2831
|
}
|
|
2831
|
-
var import_node_child_process3, import_node_util3, execFileAsync3, PROCESS_LIST_MAX_BUFFER, WINDOWS_LIST_PROCESSES_PS;
|
|
2832
|
+
var import_node_child_process3, import_node_util3, execFileAsync3, PROCESS_LIST_MAX_BUFFER, WINDOWS_PROCESS_LIST_TIMEOUT_MS, WINDOWS_LIST_PROCESSES_PS;
|
|
2832
2833
|
var init_processCommandLines = __esm({
|
|
2833
2834
|
"src/processCommandLines.ts"() {
|
|
2834
2835
|
import_node_child_process3 = require("child_process");
|
|
2835
2836
|
import_node_util3 = require("util");
|
|
2836
2837
|
execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
2837
2838
|
PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
|
|
2839
|
+
WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
|
|
2838
2840
|
WINDOWS_LIST_PROCESSES_PS = [
|
|
2839
2841
|
"$ErrorActionPreference = 'Stop'",
|
|
2840
2842
|
'$ProgressPreference = "SilentlyContinue"',
|
|
2841
2843
|
"[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
2842
2844
|
"$OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
2843
|
-
"
|
|
2844
|
-
"
|
|
2845
|
-
"
|
|
2846
|
-
"
|
|
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)",
|
|
2847
2878
|
"foreach ($proc in $processes) {",
|
|
2848
2879
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
2849
|
-
"
|
|
2850
|
-
"
|
|
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
|
-
" }",
|
|
2880
|
+
" $processId = [int]$proc.ProcessId",
|
|
2881
|
+
" if (-not $currentUserPids.Contains($processId)) { continue }",
|
|
2858
2882
|
' $commandLine = ""',
|
|
2859
2883
|
" if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
|
|
2860
|
-
" $row = [PSCustomObject]@{ pid =
|
|
2884
|
+
" $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
|
|
2861
2885
|
" ConvertTo-Json -InputObject $row -Compress",
|
|
2862
2886
|
"}"
|
|
2863
2887
|
].join("\n");
|
package/dist/daemon.cjs
CHANGED
|
@@ -4127,29 +4127,52 @@ var import_node_child_process3 = require("child_process");
|
|
|
4127
4127
|
var import_node_util3 = require("util");
|
|
4128
4128
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
4129
4129
|
var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
|
|
4130
|
+
var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
|
|
4130
4131
|
var WINDOWS_LIST_PROCESSES_PS = [
|
|
4131
4132
|
"$ErrorActionPreference = 'Stop'",
|
|
4132
4133
|
'$ProgressPreference = "SilentlyContinue"',
|
|
4133
4134
|
"[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
4134
4135
|
"$OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
4135
|
-
"
|
|
4136
|
-
"
|
|
4137
|
-
"
|
|
4138
|
-
"
|
|
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)",
|
|
4139
4169
|
"foreach ($proc in $processes) {",
|
|
4140
4170
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
4141
|
-
"
|
|
4142
|
-
"
|
|
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
|
-
" }",
|
|
4171
|
+
" $processId = [int]$proc.ProcessId",
|
|
4172
|
+
" if (-not $currentUserPids.Contains($processId)) { continue }",
|
|
4150
4173
|
' $commandLine = ""',
|
|
4151
4174
|
" if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
|
|
4152
|
-
" $row = [PSCustomObject]@{ pid =
|
|
4175
|
+
" $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
|
|
4153
4176
|
" ConvertTo-Json -InputObject $row -Compress",
|
|
4154
4177
|
"}"
|
|
4155
4178
|
].join("\n");
|
|
@@ -4228,7 +4251,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
4228
4251
|
if (platform2 === "win32") {
|
|
4229
4252
|
const { file, args } = windowsProcessListInvocation();
|
|
4230
4253
|
const { stdout: stdout2 } = await execFileImpl(file, args, {
|
|
4231
|
-
maxBuffer: PROCESS_LIST_MAX_BUFFER
|
|
4254
|
+
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
4255
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
4232
4256
|
});
|
|
4233
4257
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
4234
4258
|
}
|
package/dist/gateway.cjs
CHANGED
|
@@ -3391,29 +3391,52 @@ var import_node_child_process3 = require("child_process");
|
|
|
3391
3391
|
var import_node_util3 = require("util");
|
|
3392
3392
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
3393
3393
|
var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
|
|
3394
|
+
var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
|
|
3394
3395
|
var WINDOWS_LIST_PROCESSES_PS = [
|
|
3395
3396
|
"$ErrorActionPreference = 'Stop'",
|
|
3396
3397
|
'$ProgressPreference = "SilentlyContinue"',
|
|
3397
3398
|
"[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
3398
3399
|
"$OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
3399
|
-
"
|
|
3400
|
-
"
|
|
3401
|
-
"
|
|
3402
|
-
"
|
|
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)",
|
|
3403
3433
|
"foreach ($proc in $processes) {",
|
|
3404
3434
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
3405
|
-
"
|
|
3406
|
-
"
|
|
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
|
-
" }",
|
|
3435
|
+
" $processId = [int]$proc.ProcessId",
|
|
3436
|
+
" if (-not $currentUserPids.Contains($processId)) { continue }",
|
|
3414
3437
|
' $commandLine = ""',
|
|
3415
3438
|
" if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
|
|
3416
|
-
" $row = [PSCustomObject]@{ pid =
|
|
3439
|
+
" $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
|
|
3417
3440
|
" ConvertTo-Json -InputObject $row -Compress",
|
|
3418
3441
|
"}"
|
|
3419
3442
|
].join("\n");
|
|
@@ -3492,7 +3515,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
3492
3515
|
if (platform2 === "win32") {
|
|
3493
3516
|
const { file, args } = windowsProcessListInvocation();
|
|
3494
3517
|
const { stdout: stdout2 } = await execFileImpl(file, args, {
|
|
3495
|
-
maxBuffer: PROCESS_LIST_MAX_BUFFER
|
|
3518
|
+
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
3519
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
3496
3520
|
});
|
|
3497
3521
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
3498
3522
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -4110,29 +4110,52 @@ var import_node_child_process3 = require("child_process");
|
|
|
4110
4110
|
var import_node_util3 = require("util");
|
|
4111
4111
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
4112
4112
|
var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
|
|
4113
|
+
var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
|
|
4113
4114
|
var WINDOWS_LIST_PROCESSES_PS = [
|
|
4114
4115
|
"$ErrorActionPreference = 'Stop'",
|
|
4115
4116
|
'$ProgressPreference = "SilentlyContinue"',
|
|
4116
4117
|
"[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
4117
4118
|
"$OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
4118
|
-
"
|
|
4119
|
-
"
|
|
4120
|
-
"
|
|
4121
|
-
"
|
|
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)",
|
|
4122
4152
|
"foreach ($proc in $processes) {",
|
|
4123
4153
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
4124
|
-
"
|
|
4125
|
-
"
|
|
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
|
-
" }",
|
|
4154
|
+
" $processId = [int]$proc.ProcessId",
|
|
4155
|
+
" if (-not $currentUserPids.Contains($processId)) { continue }",
|
|
4133
4156
|
' $commandLine = ""',
|
|
4134
4157
|
" if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
|
|
4135
|
-
" $row = [PSCustomObject]@{ pid =
|
|
4158
|
+
" $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
|
|
4136
4159
|
" ConvertTo-Json -InputObject $row -Compress",
|
|
4137
4160
|
"}"
|
|
4138
4161
|
].join("\n");
|
|
@@ -4211,7 +4234,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
4211
4234
|
if (platform2 === "win32") {
|
|
4212
4235
|
const { file, args } = windowsProcessListInvocation();
|
|
4213
4236
|
const { stdout: stdout2 } = await execFileImpl(file, args, {
|
|
4214
|
-
maxBuffer: PROCESS_LIST_MAX_BUFFER
|
|
4237
|
+
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
4238
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
4215
4239
|
});
|
|
4216
4240
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
4217
4241
|
}
|
package/dist/pluginPairing.cjs
CHANGED
|
@@ -2300,29 +2300,52 @@ var import_node_child_process3 = require("child_process");
|
|
|
2300
2300
|
var import_node_util3 = require("util");
|
|
2301
2301
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
2302
2302
|
var PROCESS_LIST_MAX_BUFFER = 10 * 1024 * 1024;
|
|
2303
|
+
var WINDOWS_PROCESS_LIST_TIMEOUT_MS = 3e4;
|
|
2303
2304
|
var WINDOWS_LIST_PROCESSES_PS = [
|
|
2304
2305
|
"$ErrorActionPreference = 'Stop'",
|
|
2305
2306
|
'$ProgressPreference = "SilentlyContinue"',
|
|
2306
2307
|
"[Console]::OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
2307
2308
|
"$OutputEncoding = [System.Text.Encoding]::UTF8",
|
|
2308
|
-
"
|
|
2309
|
-
"
|
|
2310
|
-
"
|
|
2311
|
-
"
|
|
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)",
|
|
2312
2342
|
"foreach ($proc in $processes) {",
|
|
2313
2343
|
" if ($null -eq $proc.ProcessId) { continue }",
|
|
2314
|
-
"
|
|
2315
|
-
"
|
|
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
|
-
" }",
|
|
2344
|
+
" $processId = [int]$proc.ProcessId",
|
|
2345
|
+
" if (-not $currentUserPids.Contains($processId)) { continue }",
|
|
2323
2346
|
' $commandLine = ""',
|
|
2324
2347
|
" if ($null -ne $proc.CommandLine) { $commandLine = [string]$proc.CommandLine }",
|
|
2325
|
-
" $row = [PSCustomObject]@{ pid =
|
|
2348
|
+
" $row = [PSCustomObject]@{ pid = $processId; commandLine = $commandLine }",
|
|
2326
2349
|
" ConvertTo-Json -InputObject $row -Compress",
|
|
2327
2350
|
"}"
|
|
2328
2351
|
].join("\n");
|
|
@@ -2401,7 +2424,8 @@ async function listProcessCommandLineRows(deps = {}) {
|
|
|
2401
2424
|
if (platform2 === "win32") {
|
|
2402
2425
|
const { file, args } = windowsProcessListInvocation();
|
|
2403
2426
|
const { stdout: stdout2 } = await execFileImpl(file, args, {
|
|
2404
|
-
maxBuffer: PROCESS_LIST_MAX_BUFFER
|
|
2427
|
+
maxBuffer: PROCESS_LIST_MAX_BUFFER,
|
|
2428
|
+
timeout: WINDOWS_PROCESS_LIST_TIMEOUT_MS
|
|
2405
2429
|
});
|
|
2406
2430
|
return parseWindowsProcessJsonLines(stdoutToString(stdout2));
|
|
2407
2431
|
}
|