openclaw-multi-auto 1.2.5 → 1.2.6
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/{audio-preflight-DDBLZBdb.js → audio-preflight-5FEeDooz.js} +4 -4
- package/dist/{audio-transcription-runner-DZbSWT9E.js → audio-transcription-runner-B-UvoDjZ.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{chrome-CMU2WVFh.js → chrome-D45SyhQL.js} +8 -8
- package/dist/{deliver-BXVcFIHL.js → deliver-B9cys0EZ.js} +1 -1
- package/dist/{deliver-runtime-DTaIS-1i.js → deliver-runtime-DhaQJ0pI.js} +3 -3
- package/dist/{deps-send-whatsapp.runtime-CIZqFAqb.js → deps-send-whatsapp.runtime-DvTL2tzN.js} +7 -7
- package/dist/extensionAPI.js +6 -6
- package/dist/{image-BCVLo0qw.js → image-DAOPwVXi.js} +1 -1
- package/dist/{image-runtime-DtCKpMPZ.js → image-runtime-wlCLVvVv.js} +3 -3
- package/dist/{pi-embedded-CgQ_W6Xs.js → pi-embedded-DYU79yGe.js} +24 -24
- package/dist/{pi-embedded-helpers-CwuBTKza.js → pi-embedded-helpers-uTRAmQ4n.js} +3 -3
- package/dist/plugin-sdk/{accounts-C3m65--E.js → accounts-BJAXxY46.js} +2 -2
- package/dist/plugin-sdk/{accounts-CNCCkdEF.js → accounts-C1j7HSL0.js} +3 -3
- package/dist/plugin-sdk/{accounts-BslAlVYS.js → accounts-DyFCXtHv.js} +2 -2
- package/dist/plugin-sdk/{active-listener-CkPnMUkB.js → active-listener-CftX5jLD.js} +2 -2
- package/dist/plugin-sdk/{api-key-rotation-BRE4X2tf.js → api-key-rotation-8nyyt1kx.js} +2 -2
- package/dist/plugin-sdk/{audio-preflight-CtO4fFvp.js → audio-preflight-C_aSAPR1.js} +26 -26
- package/dist/plugin-sdk/{audio-transcription-runner-DnxvOS1-.js → audio-transcription-runner-CB53F7_7.js} +11 -11
- package/dist/plugin-sdk/{audit-membership-runtime-BpfoSk8M.js → audit-membership-runtime-BXndI4LG.js} +2 -2
- package/dist/plugin-sdk/{channel-activity-WJYxcJ3S.js → channel-activity-C5y8AgAV.js} +3 -3
- package/dist/plugin-sdk/{channel-web-dO5k3ubM.js → channel-web-DBTRO03V.js} +18 -18
- package/dist/plugin-sdk/{chrome-CjNTuJML.js → chrome-f00sZkDX.js} +6 -6
- package/dist/plugin-sdk/{commands-registry-CdYjoI0i.js → commands-registry-BJ_NxG2F.js} +4 -4
- package/dist/plugin-sdk/{common-oYc5vPFl.js → common-Cf27Jwxu.js} +2 -2
- package/dist/plugin-sdk/{config-B1z-UxQ3.js → config-CHQrpx-Q.js} +7 -7
- package/dist/plugin-sdk/{deliver-D5_6T567.js → deliver-DNEuetST.js} +10 -10
- package/dist/plugin-sdk/deliver-runtime-BFdqklJM.js +32 -0
- package/dist/plugin-sdk/deps-send-discord.runtime-DuqpYwU0.js +23 -0
- package/dist/plugin-sdk/deps-send-imessage.runtime-CZ2rS8Lb.js +22 -0
- package/dist/plugin-sdk/deps-send-signal.runtime-BdqiWhIh.js +21 -0
- package/dist/plugin-sdk/deps-send-slack.runtime-04s36qiC.js +19 -0
- package/dist/plugin-sdk/deps-send-telegram.runtime-LE5tkPvr.js +24 -0
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-Bz57lobC.js +57 -0
- package/dist/plugin-sdk/{diagnostic-Bxxu0ig-.js → diagnostic-LYUUmjJ5.js} +2 -2
- package/dist/plugin-sdk/{errors-B3cHyZZA.js → errors-CtMWwS2Z.js} +1 -1
- package/dist/plugin-sdk/{fetch-guard-Dcgod0tg.js → fetch-guard-CxYB5Kg6.js} +2 -2
- package/dist/plugin-sdk/{fs-safe-BaKqI3G4.js → fs-safe-DtfhxbrI.js} +3 -3
- package/dist/plugin-sdk/{image-B2mQW9Rb.js → image-BwjYjRHx.js} +6 -6
- package/dist/plugin-sdk/{image-ops-Cbzr4U9l.js → image-ops-BnZKcbd6.js} +2 -2
- package/dist/plugin-sdk/image-runtime-B8twoubs.js +25 -0
- package/dist/plugin-sdk/index.js +50 -50
- package/dist/plugin-sdk/{ir-ZEmrTr4J.js → ir-Z4hX67TJ.js} +7 -7
- package/dist/plugin-sdk/{local-roots-CIPRxA-4.js → local-roots-KhjQw04O.js} +4 -4
- package/dist/plugin-sdk/{logger-CvPFVOgT.js → logger-DHIIvMxj.js} +2 -2
- package/dist/plugin-sdk/{login-CCTew9bt.js → login-C31642Ld.js} +4 -4
- package/dist/plugin-sdk/{login-qr-BI3Vi_wJ.js → login-qr--y2SG_Ue.js} +5 -5
- package/dist/plugin-sdk/{manager-BEoYPn7R.js → manager-2UZBMCc7.js} +8 -8
- package/dist/plugin-sdk/manager-runtime-CMeLwose.js +15 -0
- package/dist/plugin-sdk/{outbound-ByOw1K6W.js → outbound-Ba0QUI5h.js} +5 -5
- package/dist/plugin-sdk/{outbound-attachment-BzVhxRRw.js → outbound-attachment-B1Laso-8.js} +2 -2
- package/dist/plugin-sdk/{path-alias-guards-DBjLbIX_.js → path-alias-guards-C7Vm5DZ1.js} +1 -1
- package/dist/plugin-sdk/{paths-Dpg3qxcl.js → paths-DopV9PQG.js} +1 -1
- package/dist/plugin-sdk/{pi-embedded-helpers-DIxXkGJf.js → pi-embedded-helpers-DnA_OCzP.js} +16 -16
- package/dist/plugin-sdk/{pi-model-discovery-DM_2uFtj.js → pi-model-discovery-DdPqXk8f.js} +1 -1
- package/dist/plugin-sdk/pi-model-discovery-runtime-D8CJhtJY.js +8 -0
- package/dist/plugin-sdk/{pi-tools.before-tool-call.runtime-w1dqL_ty.js → pi-tools.before-tool-call.runtime-DxFHiLUE.js} +4 -4
- package/dist/plugin-sdk/{plugins-C4USiH29.js → plugins-CbCt4osF.js} +4 -4
- package/dist/plugin-sdk/{proxy-env-ET-rp8eg.js → proxy-env-C63mMdas.js} +1 -1
- package/dist/plugin-sdk/{proxy-fetch-ChxOhWF4.js → proxy-fetch-Ch95c_Y2.js} +1 -1
- package/dist/plugin-sdk/{pw-ai-CyOt3RDA.js → pw-ai-DpJk62D4.js} +9 -9
- package/dist/plugin-sdk/{qmd-manager-BySdoVR7.js → qmd-manager-Ca-iSfEE.js} +7 -7
- package/dist/plugin-sdk/{query-expansion-C6uS-7lj.js → query-expansion-B_Xe41Ab.js} +4 -4
- package/dist/plugin-sdk/{redact-DjVX-1N3.js → redact-hp9TOulW.js} +1 -1
- package/dist/plugin-sdk/{reply-CTCSeQqW.js → reply-CovBlFea.js} +73 -73
- package/dist/plugin-sdk/{resolve-outbound-target-Bw8YNANu.js → resolve-outbound-target-BbrHgyUk.js} +2 -2
- package/dist/plugin-sdk/{run-with-concurrency-C_KCHwvf.js → run-with-concurrency-BR1DXa8T.js} +1 -1
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-SkO91TZH.js +10 -0
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-B0VWK5hm.js +19 -0
- package/dist/plugin-sdk/{send-C0w6xP2x.js → send-BTztm3D2.js} +6 -6
- package/dist/plugin-sdk/{send-qPyNGSe4.js → send-BXpXBwM_.js} +13 -13
- package/dist/plugin-sdk/{send-BZ6nYFZr.js → send-BvAtLLPl.js} +5 -5
- package/dist/plugin-sdk/{send-CFf-1V89.js → send-CWJUuG0i.js} +8 -8
- package/dist/plugin-sdk/{send-CY-Qfwia.js → send-EcglC4cG.js} +7 -7
- package/dist/plugin-sdk/{session-COrvpvUQ.js → session-k256LJZT.js} +3 -3
- package/dist/plugin-sdk/{skill-commands-DZqhtmiv.js → skill-commands-DoRqLzxm.js} +4 -4
- package/dist/plugin-sdk/{skills-Cw_vXEJb.js → skills-QudILG6e.js} +6 -6
- package/dist/plugin-sdk/slash-commands.runtime-DS6vCNSL.js +13 -0
- package/dist/plugin-sdk/slash-dispatch.runtime-BXrxb2wd.js +52 -0
- package/dist/plugin-sdk/slash-skill-commands.runtime-Bd6qQ2oT.js +16 -0
- package/dist/plugin-sdk/{store-CMHj6IIw.js → store-BbDQw3g6.js} +2 -2
- package/dist/plugin-sdk/subagent-registry-runtime-1uwQbuXj.js +52 -0
- package/dist/plugin-sdk/{tables-CSqrHsKL.js → tables-BhvloMKN.js} +1 -1
- package/dist/plugin-sdk/{thinking-DOnsR_A8.js → thinking-URzkT-3p.js} +7 -7
- package/dist/plugin-sdk/{tokens-DgNRBwIg.js → tokens-B1PW5Ayy.js} +1 -1
- package/dist/plugin-sdk/{tool-images-Gk_-0y2N.js → tool-images-xpqbP6RR.js} +2 -2
- package/dist/plugin-sdk/web-B74yhL2N.js +56 -0
- package/dist/plugin-sdk/{whatsapp-actions-xcleMoMv.js → whatsapp-actions-RcZ6vp61.js} +17 -17
- package/dist/plugin-sdk/whatsapp.js +50 -50
- package/dist/{pw-ai-CmphSzHx.js → pw-ai-GcYO6HPE.js} +1 -1
- package/dist/{slash-dispatch.runtime-131yup2e.js → slash-dispatch.runtime-Dh053pQK.js} +6 -6
- package/dist/{subagent-registry-runtime-DbSf_Je6.js → subagent-registry-runtime-DSi5mnCQ.js} +6 -6
- package/dist/{web-MR9d7KyB.js → web-1hWJDzNA.js} +6 -6
- package/package.json +1 -1
- package/scripts/create-instance.sh +104 -71
- package/dist/plugin-sdk/accounts-CJWOBzwB.js +0 -35
- package/dist/plugin-sdk/accounts-DP1-L-QS.js +0 -288
- package/dist/plugin-sdk/accounts-DZhWlEg3.js +0 -46
- package/dist/plugin-sdk/active-listener-B_sLJTXM.js +0 -50
- package/dist/plugin-sdk/api-key-rotation-BXnNsojA.js +0 -181
- package/dist/plugin-sdk/audio-preflight-DGEUDxxR.js +0 -69
- package/dist/plugin-sdk/audio-transcription-runner-DkoPNPYt.js +0 -2176
- package/dist/plugin-sdk/audit-membership-runtime-DSBHHw7o.js +0 -58
- package/dist/plugin-sdk/channel-activity-F3d0yUwy.js +0 -94
- package/dist/plugin-sdk/channel-web-QF7EpjeP.js +0 -2256
- package/dist/plugin-sdk/chrome-BXoCyCkY.js +0 -2415
- package/dist/plugin-sdk/commands-registry-t7cXBTfN.js +0 -1125
- package/dist/plugin-sdk/config-BkEnz2Po.js +0 -17913
- package/dist/plugin-sdk/deliver-B6AG_l67.js +0 -1694
- package/dist/plugin-sdk/deliver-runtime-C5dgvvga.js +0 -32
- package/dist/plugin-sdk/deliver-runtime-D585kJZc.js +0 -32
- package/dist/plugin-sdk/deps-send-discord.runtime-Dg4N7PHJ.js +0 -23
- package/dist/plugin-sdk/deps-send-discord.runtime-a_OKY2js.js +0 -23
- package/dist/plugin-sdk/deps-send-imessage.runtime-0OEwzMQm.js +0 -22
- package/dist/plugin-sdk/deps-send-imessage.runtime-Baxy9TD4.js +0 -22
- package/dist/plugin-sdk/deps-send-signal.runtime-BM1jRt3G.js +0 -21
- package/dist/plugin-sdk/deps-send-signal.runtime-BwXoCrFl.js +0 -21
- package/dist/plugin-sdk/deps-send-slack.runtime-1E3BYRdF.js +0 -19
- package/dist/plugin-sdk/deps-send-slack.runtime-CLmKjgso.js +0 -19
- package/dist/plugin-sdk/deps-send-telegram.runtime-BKfdBKnZ.js +0 -24
- package/dist/plugin-sdk/deps-send-telegram.runtime-DNCxIflA.js +0 -24
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-BOTwkbx_.js +0 -57
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-OLwr-9c8.js +0 -57
- package/dist/plugin-sdk/diagnostic-CsP-lEkI.js +0 -319
- package/dist/plugin-sdk/errors-DaiAM-yU.js +0 -54
- package/dist/plugin-sdk/fetch-guard-DETCcJzQ.js +0 -156
- package/dist/plugin-sdk/fs-safe-B8y811FR.js +0 -352
- package/dist/plugin-sdk/image-DjTEkYZE.js +0 -2310
- package/dist/plugin-sdk/image-ops-BSiMpAw4.js +0 -584
- package/dist/plugin-sdk/image-runtime-6xPp8m5a.js +0 -25
- package/dist/plugin-sdk/image-runtime-BFm45j49.js +0 -25
- package/dist/plugin-sdk/ir-DQ7_HbvK.js +0 -1296
- package/dist/plugin-sdk/local-roots-BUP4YBmR.js +0 -186
- package/dist/plugin-sdk/logger-CZY9KIoY.js +0 -1163
- package/dist/plugin-sdk/login-BxEKLlCo.js +0 -57
- package/dist/plugin-sdk/login-qr-BQIpMPr9.js +0 -320
- package/dist/plugin-sdk/manager-I6KbPihW.js +0 -3917
- package/dist/plugin-sdk/manager-runtime-CFfYYWIQ.js +0 -15
- package/dist/plugin-sdk/manager-runtime-DxclHQ4U.js +0 -15
- package/dist/plugin-sdk/outbound-NS6UHnB6.js +0 -212
- package/dist/plugin-sdk/outbound-attachment-Dy6fyf6H.js +0 -19
- package/dist/plugin-sdk/path-alias-guards-sWayacde.js +0 -43
- package/dist/plugin-sdk/paths-vTM3Lh3X.js +0 -166
- package/dist/plugin-sdk/pi-embedded-helpers-1R1gu7eX.js +0 -9627
- package/dist/plugin-sdk/pi-model-discovery-runtime-BuzvkvNR.js +0 -8
- package/dist/plugin-sdk/pi-model-discovery-runtime-Do9o-dUd.js +0 -8
- package/dist/plugin-sdk/pi-model-discovery-v-XPUOOf.js +0 -134
- package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-D4sFsIks.js +0 -354
- package/dist/plugin-sdk/plugins-DeBZB9l_.js +0 -864
- package/dist/plugin-sdk/proxy-fetch-uDXGKG3Z.js +0 -38
- package/dist/plugin-sdk/pw-ai-DEOmCSSC.js +0 -1938
- package/dist/plugin-sdk/qmd-manager-HyYKoEch.js +0 -1448
- package/dist/plugin-sdk/query-expansion-CeyKUeDW.js +0 -1011
- package/dist/plugin-sdk/redact-Bvxt1T_Q.js +0 -319
- package/dist/plugin-sdk/reply-DAo_Jt8K.js +0 -97916
- package/dist/plugin-sdk/resolve-outbound-target-B42qgQS9.js +0 -40
- package/dist/plugin-sdk/run-with-concurrency-Bt_ks0Qa.js +0 -1994
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-B6W989eF.js +0 -10
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-BxgRDkhc.js +0 -10
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-c_GDFy37.js +0 -19
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-elOqrkfg.js +0 -19
- package/dist/plugin-sdk/send-CQpMudwO.js +0 -2587
- package/dist/plugin-sdk/send-DQHLzVyO.js +0 -414
- package/dist/plugin-sdk/send-DTB24bEF.js +0 -3135
- package/dist/plugin-sdk/send-DfHadjZ_.js +0 -503
- package/dist/plugin-sdk/send-XXlW2iny.js +0 -540
- package/dist/plugin-sdk/session-6TF6MyaC.js +0 -169
- package/dist/plugin-sdk/skill-commands-CkGeFUMl.js +0 -342
- package/dist/plugin-sdk/skills-CBkHBYPq.js +0 -1428
- package/dist/plugin-sdk/slash-commands.runtime-CxliuGaP.js +0 -13
- package/dist/plugin-sdk/slash-commands.runtime-D67JLweo.js +0 -13
- package/dist/plugin-sdk/slash-dispatch.runtime-DFaeYlJQ.js +0 -52
- package/dist/plugin-sdk/slash-dispatch.runtime-DvcpvCJ0.js +0 -52
- package/dist/plugin-sdk/slash-skill-commands.runtime-0M0OLCxq.js +0 -16
- package/dist/plugin-sdk/slash-skill-commands.runtime-BM1x3azR.js +0 -16
- package/dist/plugin-sdk/ssrf-cFtplYtS.js +0 -202
- package/dist/plugin-sdk/store-5nyxY3WU.js +0 -81
- package/dist/plugin-sdk/subagent-registry-runtime-1lbDyRzz.js +0 -52
- package/dist/plugin-sdk/subagent-registry-runtime-DCtmDwna.js +0 -52
- package/dist/plugin-sdk/tables-C47P4GTN.js +0 -55
- package/dist/plugin-sdk/target-errors-Blia4S69.js +0 -195
- package/dist/plugin-sdk/thinking-Bo2eosVa.js +0 -1206
- package/dist/plugin-sdk/tokens-BDr0Z9o3.js +0 -52
- package/dist/plugin-sdk/tool-images-eEfOVkzf.js +0 -274
- package/dist/plugin-sdk/web-BLyT64pW.js +0 -56
- package/dist/plugin-sdk/web-CVxZbXyH.js +0 -56
- package/dist/plugin-sdk/whatsapp-actions-Bw0H9g-n.js +0 -80
|
@@ -13,36 +13,60 @@ YELLOW='\033[1;33m'
|
|
|
13
13
|
BLUE='\033[0;34m'
|
|
14
14
|
NC='\033[0m'
|
|
15
15
|
|
|
16
|
+
# --- 检查必要命令 ---
|
|
17
|
+
for cmd in node pnpm; do
|
|
18
|
+
if ! command -v "$cmd" &> /dev/null; then
|
|
19
|
+
echo -e "${RED}❌ 错误: 未找到命令 '$cmd',请先安装${NC}"
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
done
|
|
23
|
+
|
|
16
24
|
# --- 1. 路径溯源与环境检查 ---
|
|
17
25
|
GLOBAL_PREFIX=$(npm config get prefix)
|
|
18
26
|
INSTANCES_BASE=$(eval echo "$HOME/openclaws")
|
|
19
27
|
DEFAULT_SOURCE="${GLOBAL_PREFIX}/lib/node_modules/openclaw-multi-auto"
|
|
20
|
-
#[ -d "$HOME/projects/openclaw" ] && DEFAULT_SOURCE=$(eval echo "$HOME/projects/openclaw")
|
|
21
|
-
|
|
28
|
+
# [ -d "$HOME/projects/openclaw" ] && DEFAULT_SOURCE=$(eval echo "$HOME/projects/openclaw")
|
|
22
29
|
SOURCE_CODE="$DEFAULT_SOURCE"
|
|
23
|
-
echo "SOURCE_CODE = $SOURCE_CODE"
|
|
24
30
|
|
|
31
|
+
# --- 2. 获取实例名称 ---
|
|
32
|
+
INSTANCE_NAME="${1:-}"
|
|
33
|
+
if [ -z "$INSTANCE_NAME" ]; then
|
|
34
|
+
read -p "请输入实例名称 (默认: yunwei): " INPUT_NAME
|
|
35
|
+
INSTANCE_NAME="${INPUT_NAME:-yunwei}"
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# --- 3. 获取端口 ---
|
|
39
|
+
if [ -n "$2" ]; then
|
|
40
|
+
PORT="$2"
|
|
41
|
+
else
|
|
42
|
+
# 更稳健的现有实例计数:使用 find 统计目录数
|
|
43
|
+
EXISTING_COUNT=$(find "$INSTANCES_BASE" -maxdepth 1 -type d -name "*" ! -name ".*" 2>/dev/null | wc -l | tr -d ' ')
|
|
44
|
+
PORT=$((18790 + EXISTING_COUNT))
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
# --- 4. 定义实例目录并清理旧残留 ---
|
|
25
48
|
INSTANCE_DIR="$INSTANCES_BASE/${INSTANCE_NAME}"
|
|
26
49
|
DIST_DIR="${INSTANCE_DIR}/dist"
|
|
27
50
|
|
|
28
|
-
|
|
51
|
+
echo -e "${BLUE}🏗️ 正在深度初始化实例: ${INSTANCE_NAME} (端口 ${PORT})${NC}"
|
|
52
|
+
echo "SOURCE_CODE = $SOURCE_CODE"
|
|
53
|
+
|
|
54
|
+
# 清理旧实例目录(如果存在)
|
|
29
55
|
if [ -d "$INSTANCE_DIR" ]; then
|
|
30
56
|
echo -e "${YELLOW}⚠️ 清理旧实例目录...${NC}"
|
|
31
57
|
rm -rf "$INSTANCE_DIR"
|
|
32
58
|
fi
|
|
33
|
-
# 删除可能存在的父目录 node_modules 和 workspace
|
|
59
|
+
# 删除可能存在的父目录 node_modules 和 workspace 文件(避免干扰)
|
|
34
60
|
[ -d "${INSTANCES_BASE}/node_modules" ] && rm -rf "${INSTANCES_BASE}/node_modules"
|
|
35
61
|
[ -f "${INSTANCES_BASE}/pnpm-workspace.yaml" ] && rm -f "${INSTANCES_BASE}/pnpm-workspace.yaml"
|
|
36
62
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# --- 2. 完整目录结构创建 ---
|
|
63
|
+
# --- 5. 完整目录结构创建 ---
|
|
40
64
|
mkdir -p "${INSTANCE_DIR}/config" "${INSTANCE_DIR}/tmp" "${INSTANCE_DIR}/workspace"
|
|
41
65
|
mkdir -p "${INSTANCE_DIR}/workspace/memory"
|
|
42
66
|
mkdir -p "${INSTANCE_DIR}/agents/main/agent/sessions"
|
|
43
67
|
mkdir -p "${INSTANCE_DIR}/credentials" "${INSTANCE_DIR}/media"
|
|
44
68
|
|
|
45
|
-
# ---
|
|
69
|
+
# --- 6. 动态提取母本版本号 ---
|
|
46
70
|
echo -e "${BLUE}🔍 正在提取母本版本信息...${NC}"
|
|
47
71
|
PKG_PATH="${SOURCE_CODE}/package.json"
|
|
48
72
|
if [ -f "$PKG_PATH" ]; then
|
|
@@ -53,23 +77,26 @@ else
|
|
|
53
77
|
echo -e "${YELLOW}⚠️ 未找到 package.json,使用兜底版本: ${CURRENT_VERSION}${NC}"
|
|
54
78
|
fi
|
|
55
79
|
|
|
56
|
-
# ---
|
|
57
|
-
echo -e "${BLUE}🔄
|
|
80
|
+
# --- 7. 核心代码同步 (物理对齐) ---
|
|
81
|
+
echo -e "${BLUE}🔄 分发代码产物...${NC}"
|
|
58
82
|
rm -rf "$DIST_DIR" && mkdir -p "$DIST_DIR"
|
|
59
83
|
if [ -d "${SOURCE_CODE}/dist" ]; then
|
|
60
84
|
cp -r "${SOURCE_CODE}/dist/." "${DIST_DIR}/"
|
|
61
85
|
echo "cp exit code: $?"
|
|
62
86
|
|
|
63
87
|
# 检查所有被引用的 utils 文件是否存在
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
if [ -f "${DIST_DIR}/index.js" ]; then
|
|
89
|
+
for chunk in $(grep -oE "utils-[A-Za-z0-9]+\.js" "${DIST_DIR}/index.js" 2>/dev/null | sort -u); do
|
|
90
|
+
if [ ! -f "${DIST_DIR}/${chunk}" ]; then
|
|
91
|
+
echo -e "${RED}❌ 致命错误: dist 缺失关键模块 ${chunk}${NC}"
|
|
92
|
+
echo -e "${YELLOW}请在源码端执行: rm -rf dist && pnpm build && npm publish${NC}"
|
|
93
|
+
exit 1
|
|
94
|
+
fi
|
|
95
|
+
done
|
|
96
|
+
fi
|
|
71
97
|
else
|
|
72
|
-
echo -e "${RED}❌ 错误: 母本 dist 不存在${NC}"
|
|
98
|
+
echo -e "${RED}❌ 错误: 母本 dist 不存在${NC}"
|
|
99
|
+
exit 1
|
|
73
100
|
fi
|
|
74
101
|
|
|
75
102
|
cp "${SOURCE_CODE}/package.json" "${INSTANCE_DIR}/package.json"
|
|
@@ -97,20 +124,7 @@ if [ ! -d "node_modules" ]; then
|
|
|
97
124
|
fi
|
|
98
125
|
echo -e "${GREEN}✅ 依赖安装成功,node_modules 已生成在实例目录${NC}"
|
|
99
126
|
|
|
100
|
-
# ---
|
|
101
|
-
INSTANCE_NAME="${1:-}"
|
|
102
|
-
if [ -z "$INSTANCE_NAME" ]; then
|
|
103
|
-
read -p "请输入实例名称 (默认: yunwei): " INPUT_NAME
|
|
104
|
-
INSTANCE_NAME="${INPUT_NAME:-yunwei}"
|
|
105
|
-
fi
|
|
106
|
-
|
|
107
|
-
if [ -n "$2" ]; then
|
|
108
|
-
PORT="$2"
|
|
109
|
-
else
|
|
110
|
-
EXISTING_COUNT=$(ls -d "$INSTANCES_BASE"/*/ 2>/dev/null | wc -l | tr -d ' ')
|
|
111
|
-
PORT=$((18790 + EXISTING_COUNT))
|
|
112
|
-
fi
|
|
113
|
-
|
|
127
|
+
# --- 8. 参数与交互式获取 ---
|
|
114
128
|
MODEL_PROVIDER="${3:-}"
|
|
115
129
|
if [ -z "$MODEL_PROVIDER" ]; then
|
|
116
130
|
echo -e "${BLUE}--- 请选择模型供应商 ---${NC}"
|
|
@@ -131,7 +145,7 @@ if [ -z "$API_KEY" ]; then
|
|
|
131
145
|
read -p "请输入您的 ${MODEL_PROVIDER} API Key: " API_KEY
|
|
132
146
|
fi
|
|
133
147
|
|
|
134
|
-
# ---
|
|
148
|
+
# --- 9. 生成深度配置文件 ---
|
|
135
149
|
DEFAULT_MODEL="zai/glm-5"
|
|
136
150
|
ZAI_KEY=""; DS_KEY=""; MX_KEY=""; KIMI_KEY=""; QWEN_KEY=""
|
|
137
151
|
|
|
@@ -143,11 +157,19 @@ case "$MODEL_PROVIDER" in
|
|
|
143
157
|
qwen) PRIMARY_MODEL="qwen/qwen-plus"; QWEN_KEY="$API_KEY" ;;
|
|
144
158
|
esac
|
|
145
159
|
|
|
160
|
+
# 生成时间戳(兼容 macOS/Linux)
|
|
161
|
+
if date -u +"%Y-%m-%dT%H:%M:%S.%3NZ" 2>/dev/null; then
|
|
162
|
+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
|
|
163
|
+
else
|
|
164
|
+
# macOS 不支持 %3N,改用秒级精度
|
|
165
|
+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
|
|
166
|
+
fi
|
|
167
|
+
|
|
146
168
|
cat > "${INSTANCE_DIR}/config/openclaw.json" << EOF
|
|
147
169
|
{
|
|
148
170
|
"meta": {
|
|
149
171
|
"lastTouchedVersion": "${CURRENT_VERSION}",
|
|
150
|
-
"lastTouchedAt": "$
|
|
172
|
+
"lastTouchedAt": "${TIMESTAMP}"
|
|
151
173
|
},
|
|
152
174
|
"models": {
|
|
153
175
|
"providers": {
|
|
@@ -221,7 +243,7 @@ cat > "${INSTANCE_DIR}/config/openclaw.json" << EOF
|
|
|
221
243
|
}
|
|
222
244
|
EOF
|
|
223
245
|
|
|
224
|
-
# ---
|
|
246
|
+
# --- 10. 预装可选技能 (失败不影响主流程) ---
|
|
225
247
|
echo -e "${BLUE}🤖 正在注入飞书运维机器人引导...${NC}"
|
|
226
248
|
SKILLS_DIR="${INSTANCE_DIR}/workspace/skills"
|
|
227
249
|
mkdir -p "$SKILLS_DIR"
|
|
@@ -229,17 +251,16 @@ mkdir -p "$SKILLS_DIR"
|
|
|
229
251
|
SKILL_PKG="jinyu-skill-feishu-config"
|
|
230
252
|
REGISTRY="https://registry.npmmirror.com"
|
|
231
253
|
|
|
232
|
-
# 创建临时目录用于下载
|
|
233
254
|
TEMP_DIR=$(mktemp -d)
|
|
234
255
|
cd "$TEMP_DIR"
|
|
235
256
|
|
|
236
|
-
if npm pack "$SKILL_PKG@latest" --registry="$REGISTRY" --quiet > /dev/null
|
|
257
|
+
if npm pack "$SKILL_PKG@latest" --registry="$REGISTRY" --quiet > /dev/null; then
|
|
237
258
|
TARBALL=$(ls *.tgz)
|
|
238
259
|
mkdir -p "$SKILLS_DIR/feishu-config"
|
|
239
260
|
tar -xzf "$TARBALL" -C "$SKILLS_DIR/feishu-config" --strip-components=1
|
|
240
261
|
echo -e "${GREEN}✅ 技能 feishu-config 安装成功${NC}"
|
|
241
262
|
else
|
|
242
|
-
echo -e "${YELLOW}⚠️ 技能 feishu-config
|
|
263
|
+
echo -e "${YELLOW}⚠️ 技能 feishu-config 下载失败,跳过(可手动安装)${NC}"
|
|
243
264
|
fi
|
|
244
265
|
|
|
245
266
|
cd - > /dev/null
|
|
@@ -248,31 +269,26 @@ rm -rf "$TEMP_DIR"
|
|
|
248
269
|
# --- 如果实例是 yunwei,安装角色包并初始化 workspace ---
|
|
249
270
|
if [ "$INSTANCE_NAME" = "yunwei" ]; then
|
|
250
271
|
echo -e "${BLUE}🛠️ 检测到运维实例,正在安装角色包 role-openclaw-yunwei...${NC}"
|
|
251
|
-
|
|
252
|
-
# 创建临时目录用于下载和解压
|
|
272
|
+
|
|
253
273
|
TEMP_ROLE_DIR=$(mktemp -d)
|
|
254
274
|
cd "$TEMP_ROLE_DIR"
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
# 清理临时目录
|
|
275
|
+
|
|
276
|
+
if npm pack role-openclaw-yunwei@latest --registry=https://registry.npmmirror.com --quiet > /dev/null; then
|
|
277
|
+
TARBALL=$(ls *.tgz)
|
|
278
|
+
tar -xzf "$TARBALL" --strip-components=1
|
|
279
|
+
rm "$TARBALL"
|
|
280
|
+
# 使用 . 复制所有内容,避免 * 在空目录时出错
|
|
281
|
+
cp -rn "$TEMP_ROLE_DIR"/. "$INSTANCE_DIR/workspace/"
|
|
282
|
+
echo -e "${GREEN}✅ 角色包安装完成,workspace 已初始化${NC}"
|
|
283
|
+
else
|
|
284
|
+
echo -e "${YELLOW}⚠️ 角色包下载失败,请检查网络或手动安装${NC}"
|
|
285
|
+
fi
|
|
286
|
+
|
|
269
287
|
cd - > /dev/null
|
|
270
288
|
rm -rf "$TEMP_ROLE_DIR"
|
|
271
|
-
|
|
272
|
-
echo -e "${GREEN}✅ 角色包安装完成,workspace 已初始化${NC}"
|
|
273
289
|
fi
|
|
274
290
|
|
|
275
|
-
# ---
|
|
291
|
+
# --- 11. 生成增强型启动脚本 ---
|
|
276
292
|
cat > "${INSTANCE_DIR}/start.sh" << 'EOF'
|
|
277
293
|
#!/usr/bin/env bash
|
|
278
294
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
@@ -281,12 +297,12 @@ INSTANCE_NAME=$(basename "$SCRIPT_DIR")
|
|
|
281
297
|
export OPENCLAW_CONFIG_PATH="$SCRIPT_DIR/config/openclaw.json"
|
|
282
298
|
export OPENCLAW_TMP_DIR="$SCRIPT_DIR/tmp"
|
|
283
299
|
|
|
284
|
-
# 从配置导出 API Key
|
|
300
|
+
# 从配置导出 API Key(如果存在 env 字段)
|
|
285
301
|
if [ -f "$OPENCLAW_CONFIG_PATH" ]; then
|
|
286
302
|
eval $(node -e "const env = require('$OPENCLAW_CONFIG_PATH').env || {}; Object.keys(env).forEach(k => { if(env[k]) console.log('export ' + k + '=\"' + env[k] + '\"'); })")
|
|
287
303
|
fi
|
|
288
304
|
|
|
289
|
-
# macOS launchd
|
|
305
|
+
# macOS launchd 守护配置
|
|
290
306
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
291
307
|
PLIST_LABEL="ai.openclaw.$INSTANCE_NAME"
|
|
292
308
|
PLIST_PATH="$HOME/Library/LaunchAgents/$PLIST_LABEL.plist"
|
|
@@ -328,17 +344,34 @@ fi
|
|
|
328
344
|
EOF
|
|
329
345
|
chmod +x "${INSTANCE_DIR}/start.sh"
|
|
330
346
|
|
|
331
|
-
# ---
|
|
347
|
+
# --- 12. 执行拉起 ---
|
|
332
348
|
echo -e "${BLUE}⚡ 正在后台启动服务...${NC}"
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
349
|
+
# 使用完整路径启动,避免相对路径问题
|
|
350
|
+
nohup "${INSTANCE_DIR}/start.sh" > "${INSTANCE_DIR}/workspace/server.log" 2>&1 &
|
|
351
|
+
PID=$!
|
|
352
|
+
|
|
353
|
+
# 等待几秒检查进程是否存活,并验证端口监听
|
|
354
|
+
sleep 3
|
|
355
|
+
if kill -0 $PID 2>/dev/null; then
|
|
356
|
+
# 额外检查端口是否监听(需要 lsof 或 nc)
|
|
357
|
+
if command -v nc &> /dev/null; then
|
|
358
|
+
if nc -z localhost "$PORT" 2>/dev/null; then
|
|
359
|
+
echo -e "${GREEN}================================================${NC}"
|
|
360
|
+
echo -e "${GREEN}🎉 实例 [${INSTANCE_NAME}] 初始化成功!${NC}"
|
|
361
|
+
echo -e "🌐 本地网关: http://localhost:${PORT}"
|
|
362
|
+
echo -e "📄 实时日志: tail -f ${INSTANCE_DIR}/workspace/server.log"
|
|
363
|
+
echo -e "${GREEN}================================================${NC}"
|
|
364
|
+
else
|
|
365
|
+
echo -e "${YELLOW}⚠️ 进程存在但端口 ${PORT} 未监听,请查看日志: ${INSTANCE_DIR}/workspace/server.log${NC}"
|
|
366
|
+
fi
|
|
367
|
+
else
|
|
368
|
+
# 没有 nc,仅提示进程存在
|
|
369
|
+
echo -e "${GREEN}================================================${NC}"
|
|
370
|
+
echo -e "${GREEN}🎉 实例 [${INSTANCE_NAME}] 启动中(进程 PID: $PID)${NC}"
|
|
371
|
+
echo -e "📄 实时日志: tail -f ${INSTANCE_DIR}/workspace/server.log"
|
|
372
|
+
echo -e "${GREEN}================================================${NC}"
|
|
373
|
+
fi
|
|
342
374
|
else
|
|
343
|
-
echo -e "${RED}❌
|
|
375
|
+
echo -e "${RED}❌ 启动失败,请查看日志: tail -n 20 ${INSTANCE_DIR}/workspace/server.log${NC}"
|
|
376
|
+
exit 1
|
|
344
377
|
fi
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ot as normalizeAccountId } from "./run-with-concurrency-Bt_ks0Qa.js";
|
|
2
|
-
import { v as resolveAccountEntry, y as createAccountListHelpers } from "./accounts-DP1-L-QS.js";
|
|
3
|
-
|
|
4
|
-
//#region src/imessage/accounts.ts
|
|
5
|
-
const { listAccountIds, resolveDefaultAccountId } = createAccountListHelpers("imessage");
|
|
6
|
-
const listIMessageAccountIds = listAccountIds;
|
|
7
|
-
const resolveDefaultIMessageAccountId = resolveDefaultAccountId;
|
|
8
|
-
function resolveAccountConfig(cfg, accountId) {
|
|
9
|
-
return resolveAccountEntry(cfg.channels?.imessage?.accounts, accountId);
|
|
10
|
-
}
|
|
11
|
-
function mergeIMessageAccountConfig(cfg, accountId) {
|
|
12
|
-
const { accounts: _ignored, ...base } = cfg.channels?.imessage ?? {};
|
|
13
|
-
const account = resolveAccountConfig(cfg, accountId) ?? {};
|
|
14
|
-
return {
|
|
15
|
-
...base,
|
|
16
|
-
...account
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function resolveIMessageAccount(params) {
|
|
20
|
-
const accountId = normalizeAccountId(params.accountId);
|
|
21
|
-
const baseEnabled = params.cfg.channels?.imessage?.enabled !== false;
|
|
22
|
-
const merged = mergeIMessageAccountConfig(params.cfg, accountId);
|
|
23
|
-
const accountEnabled = merged.enabled !== false;
|
|
24
|
-
const configured = Boolean(merged.cliPath?.trim() || merged.dbPath?.trim() || merged.service || merged.region?.trim() || merged.allowFrom && merged.allowFrom.length > 0 || merged.groupAllowFrom && merged.groupAllowFrom.length > 0 || merged.dmPolicy || merged.groupPolicy || typeof merged.includeAttachments === "boolean" || merged.attachmentRoots && merged.attachmentRoots.length > 0 || merged.remoteAttachmentRoots && merged.remoteAttachmentRoots.length > 0 || typeof merged.mediaMaxMb === "number" || typeof merged.textChunkLimit === "number" || merged.groups && Object.keys(merged.groups).length > 0);
|
|
25
|
-
return {
|
|
26
|
-
accountId,
|
|
27
|
-
enabled: baseEnabled && accountEnabled,
|
|
28
|
-
name: merged.name?.trim() || void 0,
|
|
29
|
-
config: merged,
|
|
30
|
-
configured
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { resolveDefaultIMessageAccountId as n, resolveIMessageAccount as r, listIMessageAccountIds as t };
|
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { at as DEFAULT_ACCOUNT_ID, ot as normalizeAccountId, st as normalizeOptionalAccountId } from "./run-with-concurrency-Bt_ks0Qa.js";
|
|
2
|
-
import { o as resolveOAuthDir } from "./paths-MKyEVmEb.js";
|
|
3
|
-
import { Pr as formatCliCommand } from "./config-BkEnz2Po.js";
|
|
4
|
-
import { B as success, E as resolveUserPath, G as getChildLogger, I as info, c as defaultRuntime, x as jidToE164 } from "./logger-CZY9KIoY.js";
|
|
5
|
-
import fs from "node:fs";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import fs$1 from "node:fs/promises";
|
|
8
|
-
|
|
9
|
-
//#region src/channels/plugins/account-helpers.ts
|
|
10
|
-
function createAccountListHelpers(channelKey) {
|
|
11
|
-
function resolveConfiguredDefaultAccountId(cfg) {
|
|
12
|
-
const channel = cfg.channels?.[channelKey];
|
|
13
|
-
const preferred = normalizeOptionalAccountId(typeof channel?.defaultAccount === "string" ? channel.defaultAccount : void 0);
|
|
14
|
-
if (!preferred) return;
|
|
15
|
-
if (listAccountIds(cfg).some((id) => normalizeAccountId(id) === preferred)) return preferred;
|
|
16
|
-
}
|
|
17
|
-
function listConfiguredAccountIds(cfg) {
|
|
18
|
-
const accounts = (cfg.channels?.[channelKey])?.accounts;
|
|
19
|
-
if (!accounts || typeof accounts !== "object") return [];
|
|
20
|
-
return Object.keys(accounts).filter(Boolean);
|
|
21
|
-
}
|
|
22
|
-
function listAccountIds(cfg) {
|
|
23
|
-
const ids = listConfiguredAccountIds(cfg);
|
|
24
|
-
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
|
|
25
|
-
return ids.toSorted((a, b) => a.localeCompare(b));
|
|
26
|
-
}
|
|
27
|
-
function resolveDefaultAccountId(cfg) {
|
|
28
|
-
const preferred = resolveConfiguredDefaultAccountId(cfg);
|
|
29
|
-
if (preferred) return preferred;
|
|
30
|
-
const ids = listAccountIds(cfg);
|
|
31
|
-
if (ids.includes(DEFAULT_ACCOUNT_ID)) return DEFAULT_ACCOUNT_ID;
|
|
32
|
-
return ids[0] ?? DEFAULT_ACCOUNT_ID;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
listConfiguredAccountIds,
|
|
36
|
-
listAccountIds,
|
|
37
|
-
resolveDefaultAccountId
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/routing/account-lookup.ts
|
|
43
|
-
function resolveAccountEntry(accounts, accountId) {
|
|
44
|
-
if (!accounts || typeof accounts !== "object") return;
|
|
45
|
-
if (Object.hasOwn(accounts, accountId)) return accounts[accountId];
|
|
46
|
-
const normalized = accountId.toLowerCase();
|
|
47
|
-
const matchKey = Object.keys(accounts).find((key) => key.toLowerCase() === normalized);
|
|
48
|
-
return matchKey ? accounts[matchKey] : void 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/web/auth-store.ts
|
|
53
|
-
function resolveDefaultWebAuthDir() {
|
|
54
|
-
return path.join(resolveOAuthDir(), "whatsapp", DEFAULT_ACCOUNT_ID);
|
|
55
|
-
}
|
|
56
|
-
const WA_WEB_AUTH_DIR = resolveDefaultWebAuthDir();
|
|
57
|
-
function resolveWebCredsPath(authDir) {
|
|
58
|
-
return path.join(authDir, "creds.json");
|
|
59
|
-
}
|
|
60
|
-
function resolveWebCredsBackupPath(authDir) {
|
|
61
|
-
return path.join(authDir, "creds.json.bak");
|
|
62
|
-
}
|
|
63
|
-
function hasWebCredsSync(authDir) {
|
|
64
|
-
try {
|
|
65
|
-
const stats = fs.statSync(resolveWebCredsPath(authDir));
|
|
66
|
-
return stats.isFile() && stats.size > 1;
|
|
67
|
-
} catch {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function readCredsJsonRaw(filePath) {
|
|
72
|
-
try {
|
|
73
|
-
if (!fs.existsSync(filePath)) return null;
|
|
74
|
-
const stats = fs.statSync(filePath);
|
|
75
|
-
if (!stats.isFile() || stats.size <= 1) return null;
|
|
76
|
-
return fs.readFileSync(filePath, "utf-8");
|
|
77
|
-
} catch {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function maybeRestoreCredsFromBackup(authDir) {
|
|
82
|
-
const logger = getChildLogger({ module: "web-session" });
|
|
83
|
-
try {
|
|
84
|
-
const credsPath = resolveWebCredsPath(authDir);
|
|
85
|
-
const backupPath = resolveWebCredsBackupPath(authDir);
|
|
86
|
-
const raw = readCredsJsonRaw(credsPath);
|
|
87
|
-
if (raw) {
|
|
88
|
-
JSON.parse(raw);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const backupRaw = readCredsJsonRaw(backupPath);
|
|
92
|
-
if (!backupRaw) return;
|
|
93
|
-
JSON.parse(backupRaw);
|
|
94
|
-
fs.copyFileSync(backupPath, credsPath);
|
|
95
|
-
try {
|
|
96
|
-
fs.chmodSync(credsPath, 384);
|
|
97
|
-
} catch {}
|
|
98
|
-
logger.warn({ credsPath }, "restored corrupted WhatsApp creds.json from backup");
|
|
99
|
-
} catch {}
|
|
100
|
-
}
|
|
101
|
-
async function webAuthExists(authDir = resolveDefaultWebAuthDir()) {
|
|
102
|
-
const resolvedAuthDir = resolveUserPath(authDir);
|
|
103
|
-
maybeRestoreCredsFromBackup(resolvedAuthDir);
|
|
104
|
-
const credsPath = resolveWebCredsPath(resolvedAuthDir);
|
|
105
|
-
try {
|
|
106
|
-
await fs$1.access(resolvedAuthDir);
|
|
107
|
-
} catch {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
const stats = await fs$1.stat(credsPath);
|
|
112
|
-
if (!stats.isFile() || stats.size <= 1) return false;
|
|
113
|
-
const raw = await fs$1.readFile(credsPath, "utf-8");
|
|
114
|
-
JSON.parse(raw);
|
|
115
|
-
return true;
|
|
116
|
-
} catch {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async function clearLegacyBaileysAuthState(authDir) {
|
|
121
|
-
const entries = await fs$1.readdir(authDir, { withFileTypes: true });
|
|
122
|
-
const shouldDelete = (name) => {
|
|
123
|
-
if (name === "oauth.json") return false;
|
|
124
|
-
if (name === "creds.json" || name === "creds.json.bak") return true;
|
|
125
|
-
if (!name.endsWith(".json")) return false;
|
|
126
|
-
return /^(app-state-sync|session|sender-key|pre-key)-/.test(name);
|
|
127
|
-
};
|
|
128
|
-
await Promise.all(entries.map(async (entry) => {
|
|
129
|
-
if (!entry.isFile()) return;
|
|
130
|
-
if (!shouldDelete(entry.name)) return;
|
|
131
|
-
await fs$1.rm(path.join(authDir, entry.name), { force: true });
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
async function logoutWeb(params) {
|
|
135
|
-
const runtime = params.runtime ?? defaultRuntime;
|
|
136
|
-
const resolvedAuthDir = resolveUserPath(params.authDir ?? resolveDefaultWebAuthDir());
|
|
137
|
-
if (!await webAuthExists(resolvedAuthDir)) {
|
|
138
|
-
runtime.log(info("No WhatsApp Web session found; nothing to delete."));
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
if (params.isLegacyAuthDir) await clearLegacyBaileysAuthState(resolvedAuthDir);
|
|
142
|
-
else await fs$1.rm(resolvedAuthDir, {
|
|
143
|
-
recursive: true,
|
|
144
|
-
force: true
|
|
145
|
-
});
|
|
146
|
-
runtime.log(success("Cleared WhatsApp Web credentials."));
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
function readWebSelfId(authDir = resolveDefaultWebAuthDir()) {
|
|
150
|
-
try {
|
|
151
|
-
const credsPath = resolveWebCredsPath(resolveUserPath(authDir));
|
|
152
|
-
if (!fs.existsSync(credsPath)) return {
|
|
153
|
-
e164: null,
|
|
154
|
-
jid: null
|
|
155
|
-
};
|
|
156
|
-
const raw = fs.readFileSync(credsPath, "utf-8");
|
|
157
|
-
const jid = JSON.parse(raw)?.me?.id ?? null;
|
|
158
|
-
return {
|
|
159
|
-
e164: jid ? jidToE164(jid, { authDir }) : null,
|
|
160
|
-
jid
|
|
161
|
-
};
|
|
162
|
-
} catch {
|
|
163
|
-
return {
|
|
164
|
-
e164: null,
|
|
165
|
-
jid: null
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Return the age (in milliseconds) of the cached WhatsApp web auth state, or null when missing.
|
|
171
|
-
* Helpful for heartbeats/observability to spot stale credentials.
|
|
172
|
-
*/
|
|
173
|
-
function getWebAuthAgeMs(authDir = resolveDefaultWebAuthDir()) {
|
|
174
|
-
try {
|
|
175
|
-
const stats = fs.statSync(resolveWebCredsPath(resolveUserPath(authDir)));
|
|
176
|
-
return Date.now() - stats.mtimeMs;
|
|
177
|
-
} catch {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function logWebSelfId(authDir = resolveDefaultWebAuthDir(), runtime = defaultRuntime, includeChannelPrefix = false) {
|
|
182
|
-
const { e164, jid } = readWebSelfId(authDir);
|
|
183
|
-
const details = e164 || jid ? `${e164 ?? "unknown"}${jid ? ` (jid ${jid})` : ""}` : "unknown";
|
|
184
|
-
const prefix = includeChannelPrefix ? "Web Channel: " : "";
|
|
185
|
-
runtime.log(info(`${prefix}${details}`));
|
|
186
|
-
}
|
|
187
|
-
async function pickWebChannel(pref, authDir = resolveDefaultWebAuthDir()) {
|
|
188
|
-
const choice = pref === "auto" ? "web" : pref;
|
|
189
|
-
if (!await webAuthExists(authDir)) throw new Error(`No WhatsApp Web session found. Run \`${formatCliCommand("openclaw channels login --channel whatsapp --verbose")}\` to link.`);
|
|
190
|
-
return choice;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/web/accounts.ts
|
|
195
|
-
const { listConfiguredAccountIds, listAccountIds, resolveDefaultAccountId } = createAccountListHelpers("whatsapp");
|
|
196
|
-
const listWhatsAppAccountIds = listAccountIds;
|
|
197
|
-
const resolveDefaultWhatsAppAccountId = resolveDefaultAccountId;
|
|
198
|
-
function listWhatsAppAuthDirs(cfg) {
|
|
199
|
-
const oauthDir = resolveOAuthDir();
|
|
200
|
-
const whatsappDir = path.join(oauthDir, "whatsapp");
|
|
201
|
-
const authDirs = new Set([oauthDir, path.join(whatsappDir, DEFAULT_ACCOUNT_ID)]);
|
|
202
|
-
const accountIds = listConfiguredAccountIds(cfg);
|
|
203
|
-
for (const accountId of accountIds) authDirs.add(resolveWhatsAppAuthDir({
|
|
204
|
-
cfg,
|
|
205
|
-
accountId
|
|
206
|
-
}).authDir);
|
|
207
|
-
try {
|
|
208
|
-
const entries = fs.readdirSync(whatsappDir, { withFileTypes: true });
|
|
209
|
-
for (const entry of entries) {
|
|
210
|
-
if (!entry.isDirectory()) continue;
|
|
211
|
-
authDirs.add(path.join(whatsappDir, entry.name));
|
|
212
|
-
}
|
|
213
|
-
} catch {}
|
|
214
|
-
return Array.from(authDirs);
|
|
215
|
-
}
|
|
216
|
-
function hasAnyWhatsAppAuth(cfg) {
|
|
217
|
-
return listWhatsAppAuthDirs(cfg).some((authDir) => hasWebCredsSync(authDir));
|
|
218
|
-
}
|
|
219
|
-
function resolveAccountConfig(cfg, accountId) {
|
|
220
|
-
return resolveAccountEntry(cfg.channels?.whatsapp?.accounts, accountId);
|
|
221
|
-
}
|
|
222
|
-
function resolveDefaultAuthDir(accountId) {
|
|
223
|
-
return path.join(resolveOAuthDir(), "whatsapp", normalizeAccountId(accountId));
|
|
224
|
-
}
|
|
225
|
-
function resolveLegacyAuthDir() {
|
|
226
|
-
return resolveOAuthDir();
|
|
227
|
-
}
|
|
228
|
-
function legacyAuthExists(authDir) {
|
|
229
|
-
try {
|
|
230
|
-
return fs.existsSync(path.join(authDir, "creds.json"));
|
|
231
|
-
} catch {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function resolveWhatsAppAuthDir(params) {
|
|
236
|
-
const accountId = params.accountId.trim() || DEFAULT_ACCOUNT_ID;
|
|
237
|
-
const configured = resolveAccountConfig(params.cfg, accountId)?.authDir?.trim();
|
|
238
|
-
if (configured) return {
|
|
239
|
-
authDir: resolveUserPath(configured),
|
|
240
|
-
isLegacy: false
|
|
241
|
-
};
|
|
242
|
-
const defaultDir = resolveDefaultAuthDir(accountId);
|
|
243
|
-
if (accountId === DEFAULT_ACCOUNT_ID) {
|
|
244
|
-
const legacyDir = resolveLegacyAuthDir();
|
|
245
|
-
if (legacyAuthExists(legacyDir) && !legacyAuthExists(defaultDir)) return {
|
|
246
|
-
authDir: legacyDir,
|
|
247
|
-
isLegacy: true
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return {
|
|
251
|
-
authDir: defaultDir,
|
|
252
|
-
isLegacy: false
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function resolveWhatsAppAccount(params) {
|
|
256
|
-
const rootCfg = params.cfg.channels?.whatsapp;
|
|
257
|
-
const accountId = params.accountId?.trim() || resolveDefaultWhatsAppAccountId(params.cfg);
|
|
258
|
-
const accountCfg = resolveAccountConfig(params.cfg, accountId);
|
|
259
|
-
const enabled = accountCfg?.enabled !== false;
|
|
260
|
-
const { authDir, isLegacy } = resolveWhatsAppAuthDir({
|
|
261
|
-
cfg: params.cfg,
|
|
262
|
-
accountId
|
|
263
|
-
});
|
|
264
|
-
return {
|
|
265
|
-
accountId,
|
|
266
|
-
name: accountCfg?.name?.trim() || void 0,
|
|
267
|
-
enabled,
|
|
268
|
-
sendReadReceipts: accountCfg?.sendReadReceipts ?? rootCfg?.sendReadReceipts ?? true,
|
|
269
|
-
messagePrefix: accountCfg?.messagePrefix ?? rootCfg?.messagePrefix ?? params.cfg.messages?.messagePrefix,
|
|
270
|
-
authDir,
|
|
271
|
-
isLegacyAuthDir: isLegacy,
|
|
272
|
-
selfChatMode: accountCfg?.selfChatMode ?? rootCfg?.selfChatMode,
|
|
273
|
-
dmPolicy: accountCfg?.dmPolicy ?? rootCfg?.dmPolicy,
|
|
274
|
-
allowFrom: accountCfg?.allowFrom ?? rootCfg?.allowFrom,
|
|
275
|
-
groupAllowFrom: accountCfg?.groupAllowFrom ?? rootCfg?.groupAllowFrom,
|
|
276
|
-
groupPolicy: accountCfg?.groupPolicy ?? rootCfg?.groupPolicy,
|
|
277
|
-
textChunkLimit: accountCfg?.textChunkLimit ?? rootCfg?.textChunkLimit,
|
|
278
|
-
chunkMode: accountCfg?.chunkMode ?? rootCfg?.chunkMode,
|
|
279
|
-
mediaMaxMb: accountCfg?.mediaMaxMb ?? rootCfg?.mediaMaxMb,
|
|
280
|
-
blockStreaming: accountCfg?.blockStreaming ?? rootCfg?.blockStreaming,
|
|
281
|
-
ackReaction: accountCfg?.ackReaction ?? rootCfg?.ackReaction,
|
|
282
|
-
groups: accountCfg?.groups ?? rootCfg?.groups,
|
|
283
|
-
debounceMs: accountCfg?.debounceMs ?? rootCfg?.debounceMs
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
//#endregion
|
|
288
|
-
export { webAuthExists as _, resolveWhatsAppAuthDir as a, logWebSelfId as c, pickWebChannel as d, readCredsJsonRaw as f, resolveWebCredsPath as g, resolveWebCredsBackupPath as h, resolveWhatsAppAccount as i, logoutWeb as l, resolveDefaultWebAuthDir as m, listWhatsAppAccountIds as n, WA_WEB_AUTH_DIR as o, readWebSelfId as p, resolveDefaultWhatsAppAccountId as r, getWebAuthAgeMs as s, hasAnyWhatsAppAuth as t, maybeRestoreCredsFromBackup as u, resolveAccountEntry as v, createAccountListHelpers as y };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ot as normalizeAccountId } from "./run-with-concurrency-Bt_ks0Qa.js";
|
|
2
|
-
import { v as resolveAccountEntry, y as createAccountListHelpers } from "./accounts-DP1-L-QS.js";
|
|
3
|
-
|
|
4
|
-
//#region src/signal/accounts.ts
|
|
5
|
-
const { listAccountIds, resolveDefaultAccountId } = createAccountListHelpers("signal");
|
|
6
|
-
const listSignalAccountIds = listAccountIds;
|
|
7
|
-
const resolveDefaultSignalAccountId = resolveDefaultAccountId;
|
|
8
|
-
function resolveAccountConfig(cfg, accountId) {
|
|
9
|
-
return resolveAccountEntry(cfg.channels?.signal?.accounts, accountId);
|
|
10
|
-
}
|
|
11
|
-
function mergeSignalAccountConfig(cfg, accountId) {
|
|
12
|
-
const { accounts: _ignored, ...base } = cfg.channels?.signal ?? {};
|
|
13
|
-
const account = resolveAccountConfig(cfg, accountId) ?? {};
|
|
14
|
-
return {
|
|
15
|
-
...base,
|
|
16
|
-
...account
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function resolveSignalAccount(params) {
|
|
20
|
-
const accountId = normalizeAccountId(params.accountId);
|
|
21
|
-
const baseEnabled = params.cfg.channels?.signal?.enabled !== false;
|
|
22
|
-
const merged = mergeSignalAccountConfig(params.cfg, accountId);
|
|
23
|
-
const accountEnabled = merged.enabled !== false;
|
|
24
|
-
const enabled = baseEnabled && accountEnabled;
|
|
25
|
-
const host = merged.httpHost?.trim() || "127.0.0.1";
|
|
26
|
-
const port = merged.httpPort ?? 8080;
|
|
27
|
-
const baseUrl = merged.httpUrl?.trim() || `http://${host}:${port}`;
|
|
28
|
-
const configured = Boolean(merged.account?.trim() || merged.httpUrl?.trim() || merged.cliPath?.trim() || merged.httpHost?.trim() || typeof merged.httpPort === "number" || typeof merged.autoStart === "boolean");
|
|
29
|
-
return {
|
|
30
|
-
accountId,
|
|
31
|
-
enabled,
|
|
32
|
-
name: merged.name?.trim() || void 0,
|
|
33
|
-
baseUrl,
|
|
34
|
-
configured,
|
|
35
|
-
config: merged
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function listEnabledSignalAccounts(cfg) {
|
|
39
|
-
return listSignalAccountIds(cfg).map((accountId) => resolveSignalAccount({
|
|
40
|
-
cfg,
|
|
41
|
-
accountId
|
|
42
|
-
})).filter((account) => account.enabled);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { resolveSignalAccount as i, listSignalAccountIds as n, resolveDefaultSignalAccountId as r, listEnabledSignalAccounts as t };
|