@remcp/remcp 0.2.229 → 0.2.231
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/package.json
CHANGED
|
@@ -15,7 +15,7 @@ const POST_CONNECT_UPDATE_RECHECK_DELAYS_MS = Object.freeze([60_000, 5 * 60_000,
|
|
|
15
15
|
const POST_CONNECT_UPDATE_RECHECK_JITTER_MS = 30_000;
|
|
16
16
|
const UPDATE_RETRY_COOLDOWN_MS = 30 * 60 * 1000;
|
|
17
17
|
|
|
18
|
-
export function createAgentUpdateMonitor({ options, serverUrl, queueEvent, getRuntimeState, onStopRequested, restartRuntime, isStopping, stop }) {
|
|
18
|
+
export function createAgentUpdateMonitor({ options, serverUrl, queueEvent, getRuntimeState, onStopRequested, restartRuntime, isStopping, stop, resolveCli = globalCliEntry }) {
|
|
19
19
|
const postConnectUpdateRecheckDelaysMs = (Array.isArray(options.updateRecheckDelaysMs)
|
|
20
20
|
? options.updateRecheckDelaysMs : POST_CONNECT_UPDATE_RECHECK_DELAYS_MS)
|
|
21
21
|
.map(Number).filter(delay => Number.isFinite(delay) && delay >= 0 && delay < UPDATE_CHECK_INTERVAL_MS).slice(0, 3);
|
|
@@ -37,6 +37,8 @@ export function createAgentUpdateMonitor({ options, serverUrl, queueEvent, getRu
|
|
|
37
37
|
let lastUpdateCheckError = '';
|
|
38
38
|
let lastUpdateCheckErrorAt = 0;
|
|
39
39
|
let lastDiscoveryAt = 0;
|
|
40
|
+
let lastAnnouncedVersion = '';
|
|
41
|
+
let lastAnnouncedAt = 0;
|
|
40
42
|
|
|
41
43
|
function clearPostConnectUpdateChecks() {
|
|
42
44
|
for (const timer of postConnectUpdateTimers) clearTimeout(timer);
|
|
@@ -86,10 +88,20 @@ export function createAgentUpdateMonitor({ options, serverUrl, queueEvent, getRu
|
|
|
86
88
|
const decision = updateDecision({ advertised, cliVersion: VERSION, runtimeVersion, runtimePackageName: options.runtime?.packageName, runtimeDown });
|
|
87
89
|
if (!decision.needed) return;
|
|
88
90
|
const target = decision.target;
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
+
const availabilityKey = `${target}|${decision.runtime}`;
|
|
92
|
+
const observedAt = Date.now();
|
|
93
|
+
const announce = availabilityKey !== lastAnnouncedVersion ||
|
|
94
|
+
observedAt - lastAnnouncedAt >= UPDATE_RETRY_COOLDOWN_MS;
|
|
95
|
+
if (announce) {
|
|
96
|
+
lastAnnouncedVersion = availabilityKey;
|
|
97
|
+
lastAnnouncedAt = observedAt;
|
|
98
|
+
// Version discovery is not installation success. The running version
|
|
99
|
+
// proves convergence only after the replacement agent reconnects.
|
|
100
|
+
queueEvent({ event: 'agent_update_available', at: observedAt, reason: decision.reason.slice(0, 32) });
|
|
101
|
+
}
|
|
102
|
+
const cli = resolveCli();
|
|
91
103
|
if (!cli || !existsSync(cli)) {
|
|
92
|
-
console.error(`ReMCP ${target} is available; run: remcp update`);
|
|
104
|
+
if (announce) console.error(`ReMCP ${target} is available; run: remcp update`);
|
|
93
105
|
return;
|
|
94
106
|
}
|
|
95
107
|
// A version that already failed to install is retried only after a cooldown, so a broken
|
|
@@ -5,6 +5,41 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
|
|
8
|
+
// Exact npm cmd-shim template; partial markers cannot establish ownership.
|
|
9
|
+
export const WINDOWS_NPM_POWERSHELL_SHIM = String.raw`#!/usr/bin/env pwsh
|
|
10
|
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
11
|
+
|
|
12
|
+
$exe=""
|
|
13
|
+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
14
|
+
# Fix case when both the Windows and Linux builds of Node
|
|
15
|
+
# are installed in the same directory
|
|
16
|
+
$exe=".exe"
|
|
17
|
+
}
|
|
18
|
+
$ret=0
|
|
19
|
+
if (Test-Path "$basedir/node$exe") {
|
|
20
|
+
# Support pipeline input
|
|
21
|
+
if ($MyInvocation.ExpectingInput) {
|
|
22
|
+
$input | & "$basedir/node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
23
|
+
} else {
|
|
24
|
+
& "$basedir/node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
25
|
+
}
|
|
26
|
+
$ret=$LASTEXITCODE
|
|
27
|
+
} else {
|
|
28
|
+
# Support pipeline input
|
|
29
|
+
if ($MyInvocation.ExpectingInput) {
|
|
30
|
+
$input | & "node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
31
|
+
} else {
|
|
32
|
+
& "node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
33
|
+
}
|
|
34
|
+
$ret=$LASTEXITCODE
|
|
35
|
+
}
|
|
36
|
+
exit $ret
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
function normalizedShim(text) {
|
|
40
|
+
return text.replace(/^\uFEFF/, '').replace(/\r\n/g, '\n').replace(/\n+$/, '');
|
|
41
|
+
}
|
|
42
|
+
|
|
8
43
|
export function assertWindowsNpmPowerShellShimOwned(prefix) {
|
|
9
44
|
const powershell = path.join(prefix, 'remcp.ps1');
|
|
10
45
|
let metadata;
|
|
@@ -14,8 +49,7 @@ export function assertWindowsNpmPowerShellShimOwned(prefix) {
|
|
|
14
49
|
throw new Error('Refusing to replace an unknown ReMCP PowerShell launcher');
|
|
15
50
|
}
|
|
16
51
|
const contents = fs.readFileSync(powershell, 'utf8');
|
|
17
|
-
if (contents.length > 16000 ||
|
|
18
|
-
|| !contents.includes('$basedir/node_modules/@remcp/remcp/bin/remcp.mjs')) {
|
|
52
|
+
if (contents.length > 16000 || normalizedShim(contents) !== normalizedShim(WINDOWS_NPM_POWERSHELL_SHIM)) {
|
|
19
53
|
throw new Error('Refusing to remove a non-npm ReMCP PowerShell launcher');
|
|
20
54
|
}
|
|
21
55
|
return true;
|