@clawos-dev/clawd 0.2.131-beta.258.3b226c3 → 0.2.131-beta.259.b2d18e7

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.
@@ -168,7 +168,7 @@ createProject 成功后 daemon 自动:
168
168
 
169
169
  - 一律走 **FC(函数计算,serverless)**:免 Docker、闲置缩到 0 按量、适合海量小 extension。
170
170
  - Node web 应用走 `custom.debian12` + 官方 Node 层 + `bootstrap` + `fc3-domain` 自定义域名(否则 fcapp.run 默认 URL 强制下载、浏览器不渲染)。
171
- - 工具链:**`aliyun` CLI + Serverless Devs(`s`)**——即 `publish.sh` 内部做的事。
171
+ - 工具链:**`aliyun` CLI + Serverless Devs(`s`)**——即 `publish.sh` 内部做的事。两者由 `extension-kit/scripts/ensure-toolchain.sh` 在 publish/remove 动手前自动检测+安装(缺 `aliyun`:有 brew 走 `brew install aliyun-cli`,否则下官方二进制到 `~/.clawd/bin`;缺 `s`:`npm i -g @serverless-devs/s`),新机器无需手动装。接管发布失败时**不必再排查"CLI 没装"**。
172
172
  - 实时推送用 Supabase Realtime(FC 不维持长连接)。
173
173
 
174
174
  ## 后端:supabase MCP
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================
3
+ # 确保发布/清理用到的工具链就绪:Serverless Devs (s) + 阿里云 CLI (aliyun)。
4
+ # 检测环境、缺啥装啥、已装则跳过(幂等)。被 publish.sh / remove-extension.sh
5
+ # 在调用 aliyun/s 之前 `source` 进来,再调 ensure_toolchain。
6
+ #
7
+ # 为什么需要它:FC 发布全靠 aliyun CLI + s 两个外部命令,二者都不随 clawd 安装。
8
+ # 新机器上它们不在 PATH → publish.sh 第一条 `aliyun sts ...` stdout 为空 →
9
+ # python json.load 空串 → `Expecting value: line 1 column 1`,且死在第一个
10
+ # ::stage:: marker 之前 → daemon 只能报 [unknown] 阶段。这个脚本补的就是这一环。
11
+ # ============================================================
12
+
13
+ # aliyun CLI 官方 release 兜底版本(仅在无 brew、走二进制下载时用;brew 路径不读它)。
14
+ CLAWD_ALIYUN_CLI_VERSION="${CLAWD_ALIYUN_CLI_VERSION:-3.3.21}"
15
+
16
+ ensure_s() {
17
+ command -v s >/dev/null 2>&1 && return 0
18
+ echo "==> 安装 Serverless Devs (s)…"
19
+ command -v npm >/dev/null 2>&1 || { echo "❌ 缺 npm,无法安装 @serverless-devs/s" >&2; return 1; }
20
+ npm install -g @serverless-devs/s
21
+ }
22
+
23
+ ensure_aliyun() {
24
+ command -v aliyun >/dev/null 2>&1 && return 0
25
+ echo "==> 安装阿里云 CLI (aliyun)…"
26
+ # 优先 brew(有 brew 的 mac 最省事,装到已在 PATH 的 /opt/homebrew/bin | /usr/local/bin)
27
+ if command -v brew >/dev/null 2>&1; then
28
+ brew install aliyun-cli
29
+ return 0
30
+ fi
31
+ # 兜底:官方 release 二进制(没装 brew 的新机器 / Linux server)。
32
+ local os arch bindir="$HOME/.clawd/bin"
33
+ case "$(uname -s)" in
34
+ Darwin) os=macosx ;;
35
+ Linux) os=linux ;;
36
+ *) echo "❌ 不支持的系统 $(uname -s),请手动安装 aliyun CLI" >&2; return 1 ;;
37
+ esac
38
+ case "$(uname -m)" in
39
+ arm64|aarch64) arch=arm64 ;;
40
+ x86_64|amd64) arch=amd64 ;;
41
+ *) echo "❌ 不支持的架构 $(uname -m),请手动安装 aliyun CLI" >&2; return 1 ;;
42
+ esac
43
+ local ver="$CLAWD_ALIYUN_CLI_VERSION"
44
+ local url="https://github.com/aliyun/aliyun-cli/releases/download/v${ver}/aliyun-cli-${os}-${ver}-${arch}.tgz"
45
+ echo " 无 brew,下载官方二进制: $url"
46
+ mkdir -p "$bindir"
47
+ curl -fsSL "$url" | tar xz -C "$bindir"
48
+ chmod +x "$bindir/aliyun"
49
+ export PATH="$bindir:$PATH"
50
+ }
51
+
52
+ ensure_toolchain() {
53
+ ensure_s
54
+ ensure_aliyun
55
+ }
56
+
57
+ # 直接执行(bash ensure-toolchain.sh)= 自检;被 source 时不自动跑,留给调用方显式 ensure_toolchain。
58
+ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
59
+ set -euo pipefail
60
+ ensure_toolchain
61
+ echo "✅ 工具链就绪: s=$(command -v s) aliyun=$(command -v aliyun)"
62
+ fi
@@ -20,12 +20,18 @@ CODE_DIR="${CODE_DIR:-./server}"
20
20
  FC_ENTRY="${FC_ENTRY:-dist/main.js}"
21
21
  BUILD_CMD="${BUILD_CMD:-}"
22
22
 
23
- # 2) 阿里云凭证(现读)+ Serverless Devs 认证(必须含 AccountID,SK heredoc 不进命令行)
23
+ # 2) 工具链就绪(检测环境,缺 aliyun CLI / Serverless Devs 则装,已装跳过)+ 阿里云凭证
24
+ source "$KIT_DIR/scripts/ensure-toolchain.sh"
25
+ ensure_toolchain
26
+
27
+ # 阿里云凭证(现读)+ Serverless Devs 认证(必须含 AccountID,SK 走 heredoc 不进命令行)
24
28
  set -a; . "$PERSONA_DIR/.secrets/aliyun.env"; set +a
25
29
  # aliyun CLI 需要 region;新机器没跑过 `aliyun configure`(无 ~/.aliyun/config.json) → "region can't be empty"。
26
30
  # 用 env 给 region(REGION 来自 config.env):一处覆盖脚本里所有 aliyun 调用,不进 argv,和 AK/SK 走 env 的方式对称。
27
31
  export ALIBABA_CLOUD_REGION_ID="$REGION"
28
- ACC="$(aliyun sts GetCallerIdentity 2>/dev/null | python3 -c 'import sys,json;print(json.load(sys.stdin)["AccountId"])')"
32
+ # aliyun 报错不再吞进 2>/dev/null —— 否则凭证失效 / CLI 异常时只剩一条无头 python traceback(老板踩过)
33
+ _ident="$(aliyun sts GetCallerIdentity 2>&1)" || { echo "❌ aliyun sts GetCallerIdentity 失败(检查 .secrets/aliyun.env 凭证):" >&2; echo "$_ident" >&2; exit 1; }
34
+ ACC="$(printf '%s' "$_ident" | python3 -c 'import sys,json;print(json.load(sys.stdin)["AccountId"])')" || { echo "❌ 解析 AccountId 失败,aliyun 输出非 JSON:" >&2; echo "$_ident" >&2; exit 1; }
29
35
  mkdir -p ~/.s
30
36
  cat > ~/.s/access.yaml <<EOF
31
37
  default:
@@ -18,6 +18,10 @@ source "$KIT_DIR/config.env"
18
18
  APP_NAME="${APP_NAME:-$(basename "$EXT_DIR")}"
19
19
  SUPABASE_TABLES="${SUPABASE_TABLES:-}"
20
20
 
21
+ # 确保工具链就绪(缺 s / aliyun 则装,已装跳过)—— 下面 s remove 依赖它
22
+ source "$KIT_DIR/scripts/ensure-toolchain.sh"
23
+ ensure_toolchain
24
+
21
25
  set -a; . "$PERSONA_DIR/.secrets/aliyun.env"; set +a
22
26
 
23
27
  # 1) 删 FC 侧(函数 + 触发器 + 自定义域名)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.131-beta.258.3b226c3",
3
+ "version": "0.2.131-beta.259.b2d18e7",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",