grix-connector 4.2.9 → 4.3.1
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/adapter/claude/activity-status-manager.js +1 -1
- package/dist/adapter/claude/claude-adapter.js +18 -18
- package/dist/adapter/codewhale/codewhale-adapter.js +3 -3
- package/dist/adapter/codex/codex-bridge.js +9 -9
- package/dist/adapter/deepseek-harness/bridge-installer.js +4 -4
- package/dist/adapter/deepseek-harness/profile-catalog.js +1 -1
- package/dist/adapter/pi/pi-adapter.js +4 -4
- package/dist/assets/dsh-bridge/grix-dsh-bridge-4.3.1.tgz +0 -0
- package/dist/assets/dsh-bridge/manifest.json +5 -5
- package/dist/bridge/respawn-manager.js +1 -1
- package/dist/bridge/send-controller.js +3 -3
- package/dist/core/hooks/hook-signal-store.js +2 -2
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/upgrade/upgrade-checker.js +1 -1
- package/dist/core/util/cli-probe.js +2 -2
- package/dist/mcp/stream-http/security.js +1 -1
- package/package.json +1 -1
- package/scripts/upgrade-guardian.mjs +43 -2
- package/dist/assets/dsh-bridge/grix-dsh-bridge-4.2.9.tgz +0 -0
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
existsSync,
|
|
10
10
|
mkdirSync,
|
|
11
11
|
readFileSync,
|
|
12
|
+
realpathSync,
|
|
12
13
|
renameSync,
|
|
13
14
|
rmSync,
|
|
14
15
|
writeFileSync,
|
|
@@ -45,6 +46,43 @@ const TRANSACTION_PHASES = new Set([
|
|
|
45
46
|
]);
|
|
46
47
|
const RENAME_RETRY_DELAYS_MS = [250, 750, 1_500, 3_000, 5_000];
|
|
47
48
|
|
|
49
|
+
/** 逐侧解析真实路径;解析不了的一侧原样保留,另一侧仍然受益。 */
|
|
50
|
+
function toRealPath(value) {
|
|
51
|
+
try {
|
|
52
|
+
return realpathSync(value);
|
|
53
|
+
} catch {
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Windows 路径大小写不敏感(`C:\\Users\\X` 与 `c:\\users\\x` 是同一个文件),
|
|
60
|
+
* 且盘符大小写会随调用方变化;POSIX 必须保持大小写敏感,否则会把两个不同文件
|
|
61
|
+
* 判成同一个。
|
|
62
|
+
*/
|
|
63
|
+
function normalizePathForCompare(value, platform = process.platform) {
|
|
64
|
+
const resolved = resolve(value);
|
|
65
|
+
return platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 判断两个路径是否指向同一个文件。**必须按真实路径比对**:Node 的 ESM 加载器默认
|
|
70
|
+
* 解析软链接,`import.meta.url` 给的是真实路径,而 `process.argv[1]` 是调用方原样
|
|
71
|
+
* 传入的路径。`resolve()` 只做规范化、不解软链,于是 `$GRIX_CONNECTOR_HOME` 只要
|
|
72
|
+
* 含一段软链接(例如 `~/.grix -> /Volumes/disk1/gcf/.grix`),两者就永不相等。
|
|
73
|
+
* 曾导致 guardian 被拉起后 `isMain` 恒为 false、主逻辑一次都没执行:升级包装好、
|
|
74
|
+
* 校验通过、上报 installed,然后 guardian 空转到 10 分钟激活超时,事务被按版本裁决
|
|
75
|
+
* 收口成 rolled_back,错误码还报成误导性的 STARTUP_CRASH。
|
|
76
|
+
*
|
|
77
|
+
* 两侧各自解析、各自归一化,所以"一侧存在一侧不存在"时另一侧的真实路径依然生效;
|
|
78
|
+
* 大小写按平台处理,见 {@link normalizePathForCompare}。
|
|
79
|
+
*/
|
|
80
|
+
export function isSamePath(left, right, platform = process.platform) {
|
|
81
|
+
if (!left || !right) return false;
|
|
82
|
+
return normalizePathForCompare(toRealPath(left), platform)
|
|
83
|
+
=== normalizePathForCompare(toRealPath(right), platform);
|
|
84
|
+
}
|
|
85
|
+
|
|
48
86
|
function pathsFor(rootDir) {
|
|
49
87
|
return {
|
|
50
88
|
pending: join(rootDir, 'data', 'upgrade-pending.json'),
|
|
@@ -739,7 +777,7 @@ function wrapperChildPid(record, runtimeDir, pending, deps = {}) {
|
|
|
739
777
|
&& typeof record?.boot_time === 'number'
|
|
740
778
|
&& Math.abs(record.boot_time - currentBootTime) <= 60_000
|
|
741
779
|
&& typeof record?.cli_path === 'string'
|
|
742
|
-
&&
|
|
780
|
+
&& isSamePath(record.cli_path, expectedCli)
|
|
743
781
|
? record.pid
|
|
744
782
|
: null;
|
|
745
783
|
}
|
|
@@ -1306,6 +1344,9 @@ async function runCli() {
|
|
|
1306
1344
|
? resolve(args[rootIndex + 1])
|
|
1307
1345
|
: resolve(process.env.GRIX_CONNECTOR_HOME || join(homedir(), '.grix'));
|
|
1308
1346
|
const paths = pathsFor(rootDir);
|
|
1347
|
+
// 落一条启动行再做任何判断:guardian 是 detached 起的,早期失败没有任何出口,
|
|
1348
|
+
// 缺这行时"被拉起却什么都没发生"在日志上和"根本没被拉起"完全无法区分。
|
|
1349
|
+
appendLog(paths.log, `${mode}: guardian started pid=${process.pid} node=${process.version} entry=${process.argv[1] ?? ''}`);
|
|
1309
1350
|
const readArg = (name) => {
|
|
1310
1351
|
const index = args.indexOf(name);
|
|
1311
1352
|
return index >= 0 && args[index + 1] ? args[index + 1] : '';
|
|
@@ -1341,5 +1382,5 @@ async function runCli() {
|
|
|
1341
1382
|
}
|
|
1342
1383
|
}
|
|
1343
1384
|
|
|
1344
|
-
const isMain =
|
|
1385
|
+
const isMain = isSamePath(process.argv[1], fileURLToPath(import.meta.url));
|
|
1345
1386
|
if (isMain) process.exitCode = await runCli();
|
|
Binary file
|