oasis_test 0.1.67 → 0.1.69

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.
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ # Shared wrapper logic for CLI connectors.
3
+ #
4
+ # Source this from your connector wrapper and call oasis_resolve_bin + oasis_check_available.
5
+ # Before sourcing, set:
6
+ # OASIS_BIN_VAR — name of env var that holds the absolute binary path (e.g., "GH_BIN")
7
+ # OASIS_CMD_NAME — command name to find (e.g., "gh")
8
+ #
9
+ # Example:
10
+ # OASIS_BIN_VAR="GH_BIN"
11
+ # OASIS_CMD_NAME="gh"
12
+ # source "$(dirname "$(realpath "$0")")/../_base/wrapper-base.sh"
13
+ # oasis_resolve_bin
14
+ # oasis_check_available
15
+ # # Add connector-specific env injection here
16
+ # exec "$GH_BIN" "$@"
17
+
18
+ set -euo pipefail
19
+
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, scan PATH for the first executable that isn't this wrapper.
23
+ oasis_resolve_bin() {
24
+ local bin_var="${OASIS_BIN_VAR:?OASIS_BIN_VAR must be set}"
25
+ local cmd_name="${OASIS_CMD_NAME:?OASIS_CMD_NAME must be set}"
26
+
27
+ # If already set by inject() AND executable on THIS machine, skip PATH scan.
28
+ # ${OASIS_BIN_VAR} (LARK_BIN/GH_BIN) is resolved server-side via `which`; on a remote
29
+ # node the real binary may live at a different path than the server's. Don't blindly
30
+ # exec a stale/non-existent path — fall through to the PATH scan below (which skips
31
+ # this wrapper to avoid recursion) so a node-local install is still found.
32
+ if [ -n "${!bin_var:-}" ] && [ -x "${!bin_var:-}" ]; then
33
+ return 0
34
+ fi
35
+ # Stale/non-executable injected path: clear it so the PATH scan can repopulate cleanly.
36
+ unset "$bin_var" 2>/dev/null || true
37
+
38
+ # Fallback: scan PATH for real binary (skip self to avoid recursion)
39
+ local SELF
40
+ SELF="$(realpath "$0" 2>/dev/null || echo "$0")"
41
+ local candidate
42
+ while IFS= read -r dir; do
43
+ candidate="$dir/$cmd_name"
44
+ if [ -x "$candidate" ] && [ "$(realpath "$candidate" 2>/dev/null)" != "$SELF" ]; then
45
+ printf -v "$bin_var" '%s' "$candidate"
46
+ export "$bin_var"
47
+ return 0
48
+ fi
49
+ done <<< "$(echo "$PATH" | tr ':' '\n')"
50
+ }
51
+
52
+ # Check that the resolved binary is accessible and responds to --version.
53
+ # If not (e.g., locked during upgrade), exit with user-friendly message.
54
+ oasis_check_available() {
55
+ local bin_var="${OASIS_BIN_VAR:?OASIS_BIN_VAR must be set}"
56
+ local bin_path="${!bin_var:-}"
57
+
58
+ if [ -z "$bin_path" ]; then
59
+ echo "error: The requested cli is upgrading, please try again in 30 seconds." >&2
60
+ exit 1
61
+ fi
62
+
63
+ if [ ! -x "$bin_path" ] || ! "$bin_path" --version >/dev/null 2>&1; then
64
+ echo "error: The requested cli is upgrading, please try again in 30 seconds." >&2
65
+ exit 1
66
+ fi
67
+ }
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # Feishu CLI wrapper — 通过前置 PATH 替换 lark-cli。
3
+ #
4
+ # 凭据保护:敏感凭据(App Secret / User Access Token)**不**放进 agent 环境变量,
5
+ # 而是写在只有本 wrapper 读取的临时文件里(inject() 写,chmod 600)。agent 环境里
6
+ # 只有一个非敏感的文件路径指针 FEISHU_CREDS_FILE。wrapper 在调用真实 lark-cli 前
7
+ # `source` 该文件,把 LARKSUITE_CLI_* 外部凭据变量注入**本 wrapper 子进程**——
8
+ # 这些秘密从不出现在 agent 自身的 env / /proc/self/environ,也不被 agent 其它子进程继承。
9
+ #
10
+ # 环境变量:
11
+ # LARK_BIN — 真实 lark-cli 绝对路径(避免递归调用自身)
12
+ # FEISHU_CREDS_FILE — 凭据文件路径(内含 export LARKSUITE_CLI_* 行)
13
+
14
+ set -euo pipefail
15
+
16
+ OASIS_BIN_VAR="LARK_BIN"
17
+ OASIS_CMD_NAME="lark-cli"
18
+ # shellcheck source=../_base/wrapper-base.sh
19
+ source "$(dirname "$(realpath "$0")")/../_base/wrapper-base.sh"
20
+
21
+ oasis_resolve_bin
22
+ oasis_check_available
23
+
24
+ # Load feishu credentials into THIS process only (not visible to the agent).
25
+ if [ -n "${FEISHU_CREDS_FILE:-}" ] && [ -f "${FEISHU_CREDS_FILE}" ]; then
26
+ # shellcheck disable=SC1090
27
+ source "${FEISHU_CREDS_FILE}"
28
+ fi
29
+
30
+ exec "$LARK_BIN" "$@"
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bash
2
+ # GitHub CLI wrapper — replaces `gh` in the agent's PATH.
3
+ #
4
+ # The wrapper reads the token from an env var injected by inject(),
5
+ # never exposing it in a way the agent can read directly (the agent
6
+ # sees the wrapper name "gh" on PATH, not the token value).
7
+ #
8
+ # Environment variables (written by inject(), read here only):
9
+ # GH_CREDS_FILE — path to a chmod-600 file with `export GH_TOKEN=...` lines
10
+ # (token value is NOT in the agent env — only this path is)
11
+ # GH_BIN — absolute path to the real gh binary
12
+ # GIT_AUTHOR_NAME / GIT_COMMITTER_NAME — set by inject() directly (non-secret)
13
+
14
+ set -euo pipefail
15
+
16
+ OASIS_BIN_VAR="GH_BIN"
17
+ OASIS_CMD_NAME="gh"
18
+ # shellcheck source=../_base/wrapper-base.sh
19
+ source "$(dirname "$(realpath "$0")")/../_base/wrapper-base.sh"
20
+
21
+ oasis_resolve_bin
22
+ oasis_check_available
23
+
24
+ # Load the GitHub token into THIS process only (not visible to the agent).
25
+ # The token lives in a chmod-600 file the wrapper sources; the agent env only
26
+ # holds the non-secret path GH_CREDS_FILE.
27
+ if [ -n "${GH_CREDS_FILE:-}" ] && [ -f "${GH_CREDS_FILE}" ]; then
28
+ # shellcheck disable=SC1090
29
+ source "${GH_CREDS_FILE}"
30
+ fi
31
+
32
+ exec "$GH_BIN" "$@"