From f079b68559f0e1d50fa24b67979ea92bd88ec60b Mon Sep 17 00:00:00 2001 From: ywkj Date: Fri, 20 Mar 2026 18:26:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BC=96=E8=AF=91=E4=B8=BA=E7=8B=AC?= =?UTF-8?q?=E7=AB=8B=20auth-rt=20=E4=BA=8C=E8=BF=9B=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=88=B0=20~/.openclaw/bin/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - bun build --compile 生成独立可执行文件 - install.sh 编译并安装到 ~/.openclaw/bin/auth-rt - auth-cli.ts 改为调用 auth-rt 二进制(不再需要 bun run cli.ts) - skill 不再需要 clone auth-runtime 源码 Co-Authored-By: Claude Opus 4.6 --- .gitignore | 1 + install.sh | 35 ++++++++++------------------------- package.json | 3 ++- src/auth-cli.ts | 23 +++++++++++------------ 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index c2658d7..30f8582 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +auth-rt diff --git a/install.sh b/install.sh index b55d973..4b9f7f0 100755 --- a/install.sh +++ b/install.sh @@ -1,33 +1,18 @@ #!/usr/bin/env bash -# Bootstrap auth-runtime into the skill store. -# Run this ONCE before installing any skills. +# Compile auth-rt CLI binary and install to ~/.openclaw/bin/ # # Usage: -# curl -fsSL https://your-forgejo/raw/auth-runtime/main/install.sh | bash -# # or: -# ./install.sh [skill-store-dir] +# ./install.sh +# ./install.sh /custom/bin/dir set -euo pipefail +cd "$(dirname "$0")" -STORE="${1:-$HOME/.openclaw/skills}" -DEST="$STORE/_shared/auth-runtime" -REPO="${AUTH_RUNTIME_REPO:-}" # set via env or hardcode below +BIN_DIR="${1:-$HOME/.openclaw/bin}" +mkdir -p "$BIN_DIR" -# Hardcode your Forgejo URL here: -# REPO="https://git.yourserver.com/you/auth-runtime.git" +echo "Compiling auth-rt..." +bun build --compile src/cli.ts --outfile "$BIN_DIR/auth-rt" -if [[ -z "$REPO" ]]; then - echo "Error: set AUTH_RUNTIME_REPO=https://git.yourserver.com/you/auth-runtime.git" - exit 1 -fi - -if [[ -d "$DEST/.git" ]]; then - echo "Updating auth-runtime..." - git -C "$DEST" pull --ff-only -else - echo "Installing auth-runtime to $DEST..." - mkdir -p "$STORE/_shared" - git clone "$REPO" "$DEST" -fi - -echo "auth-runtime ready at $DEST" +echo "Installed: $BIN_DIR/auth-rt" +echo "Ensure $BIN_DIR is in your PATH." diff --git a/package.json b/package.json index 0820937..eb7351c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ }, "scripts": { "build": "tsc", - "clean": "rm -rf dist" + "compile": "bun build --compile src/cli.ts --outfile auth-rt", + "clean": "rm -rf dist auth-rt" }, "keywords": [ "auth", diff --git a/src/auth-cli.ts b/src/auth-cli.ts index 77c09a9..cb2cb9c 100644 --- a/src/auth-cli.ts +++ b/src/auth-cli.ts @@ -1,9 +1,12 @@ /** * Thin CLI wrapper for auth-runtime. * - * Copy this file into your skill's src/ directory. It spawns - * `bun run /src/cli.ts` as a subprocess, so the - * skill has zero npm dependency on @clawd/auth-runtime. + * Copy this file into your skill's src/ directory. It calls the + * `auth-rt` binary (compiled from auth-runtime), so the skill has + * zero npm dependency on @clawd/auth-runtime. + * + * Prerequisites: + * ~/.openclaw/bin/auth-rt must exist (run auth-runtime/install.sh) * * Usage: * import { createSkillClient } from './auth-cli.ts'; @@ -15,9 +18,8 @@ import { spawnSync } from 'child_process'; import * as path from 'path'; import * as os from 'os'; -const AUTH_RUNTIME_DIR = process.env.AUTH_RUNTIME_DIR - || path.join(os.homedir(), 'clawd', 'skills', 'auth-runtime'); -const CLI_ENTRY = path.join(AUTH_RUNTIME_DIR, 'src', 'cli.ts'); +const AUTH_RT_BIN = process.env.AUTH_RT_BIN + || path.join(os.homedir(), '.openclaw', 'bin', 'auth-rt'); export interface ApiResponse { status: number; @@ -38,19 +40,16 @@ export interface SkillClientOptions { } function runCli(...args: string[]): string { - // Use the same bun binary that's running this process - const bun = process.execPath; - const result = spawnSync(bun, ['run', CLI_ENTRY, ...args], { - cwd: AUTH_RUNTIME_DIR, + const result = spawnSync(AUTH_RT_BIN, args, { encoding: 'utf-8', timeout: 60_000, }); if (result.error) { - throw new Error(`auth-cli spawn failed: ${result.error.message}`); + throw new Error(`auth-rt spawn failed: ${result.error.message}`); } if (result.status !== 0) { - throw new Error(`auth-cli failed (exit ${result.status}): ${(result.stderr || '').trim()}`); + throw new Error(`auth-rt failed (exit ${result.status}): ${(result.stderr || '').trim()}`); } return (result.stdout || '').trim(); }