oasis_test 0.1.82 → 0.1.84
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/_base/wrapper-base.sh +28 -14
- package/dist/index.js +496 -132
- package/package.json +2 -2
|
@@ -18,26 +18,32 @@
|
|
|
18
18
|
set -euo pipefail
|
|
19
19
|
|
|
20
20
|
# Resolve the real binary path (avoid recursion into self).
|
|
21
|
-
# If ${OASIS_BIN_VAR} is already set (injected by inject()), use it
|
|
22
|
-
# Otherwise
|
|
21
|
+
# If ${OASIS_BIN_VAR} is already set (injected by inject()), use it — unless it points
|
|
22
|
+
# back at this very wrapper. Otherwise scan PATH for the first executable that isn't us.
|
|
23
23
|
oasis_resolve_bin() {
|
|
24
24
|
local bin_var="${OASIS_BIN_VAR:?OASIS_BIN_VAR must be set}"
|
|
25
25
|
local cmd_name="${OASIS_CMD_NAME:?OASIS_CMD_NAME must be set}"
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
|
|
27
|
+
local SELF
|
|
28
|
+
SELF="$(realpath "$0" 2>/dev/null || echo "$0")"
|
|
29
|
+
|
|
30
|
+
# If already set by inject() AND executable on THIS machine, skip the PATH scan —
|
|
31
|
+
# but **only if it isn't this wrapper itself**.
|
|
32
|
+
#
|
|
33
|
+
# 为什么要查自指(2026-08-03 实测踩到):inject() 用 `which <cmd>` 在 **daemon 进程的
|
|
34
|
+
# PATH** 下解析真实二进制,而 daemon 的 PATH 可能被 agent 会话的 wrapper 目录污染
|
|
35
|
+
# (`oasis daemon start` 会把当时 shell 的 PATH 固化进 systemd unit;在 agent 会话里
|
|
36
|
+
# 触发更新就会把 /tmp/oasis-conn-* 带进去)。于是 GH_BIN 指向 wrapper 自己 →
|
|
37
|
+
# 这里的快路径直接 return → 后面 exec "$GH_BIN" 就是无限递归调用自身。
|
|
38
|
+
# 症状还特别误导:递归被 oasis_check_available 拦下,报的是「cli is upgrading」。
|
|
39
|
+
if [ -n "${!bin_var:-}" ] && [ -x "${!bin_var:-}" ] \
|
|
40
|
+
&& [ "$(realpath "${!bin_var}" 2>/dev/null)" != "$SELF" ]; then
|
|
33
41
|
return 0
|
|
34
42
|
fi
|
|
35
|
-
#
|
|
43
|
+
# 空 / 不可执行 / 指向自己:清掉,让下面的 PATH 扫描重新填。
|
|
36
44
|
unset "$bin_var" 2>/dev/null || true
|
|
37
45
|
|
|
38
46
|
# Fallback: scan PATH for real binary (skip self to avoid recursion)
|
|
39
|
-
local SELF
|
|
40
|
-
SELF="$(realpath "$0" 2>/dev/null || echo "$0")"
|
|
41
47
|
local candidate
|
|
42
48
|
while IFS= read -r dir; do
|
|
43
49
|
candidate="$dir/$cmd_name"
|
|
@@ -55,13 +61,21 @@ oasis_check_available() {
|
|
|
55
61
|
local bin_var="${OASIS_BIN_VAR:?OASIS_BIN_VAR must be set}"
|
|
56
62
|
local bin_path="${!bin_var:-}"
|
|
57
63
|
|
|
64
|
+
# 报错要分流:说清是「PATH 上根本没有真实 CLI」还是「找到了但跑不起来」。
|
|
65
|
+
# 旧实现两种都打「cli is upgrading, try again in 30 seconds」——那句话在真正的
|
|
66
|
+
# 升级窗口里是对的,但在「PATH 被污染、解析到 wrapper 自己」时纯属误导:等多久都不会好。
|
|
58
67
|
if [ -z "$bin_path" ]; then
|
|
59
|
-
echo "error:
|
|
68
|
+
echo "error: ${OASIS_CMD_NAME:-cli} not found on PATH — 连接器需要的真实 CLI 未安装,或 PATH 上只剩 oasis wrapper。" >&2
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
if [ ! -x "$bin_path" ]; then
|
|
73
|
+
echo "error: ${OASIS_BIN_VAR} 指向的 $bin_path 不可执行。" >&2
|
|
60
74
|
exit 1
|
|
61
75
|
fi
|
|
62
76
|
|
|
63
|
-
if
|
|
64
|
-
echo "error:
|
|
77
|
+
if ! "$bin_path" --version >/dev/null 2>&1; then
|
|
78
|
+
echo "error: $bin_path --version 失败——真实 CLI 可能正在升级,30 秒后重试;若持续失败请检查该路径是否指向 oasis wrapper 自身。" >&2
|
|
65
79
|
exit 1
|
|
66
80
|
fi
|
|
67
81
|
}
|