feat: 编译为独立 auth-rt 二进制,安装到 ~/.openclaw/bin/
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
97a8fd9c7b
commit
f079b68559
|
|
@ -1 +1,2 @@
|
|||
node_modules/
|
||||
auth-rt
|
||||
|
|
|
|||
35
install.sh
35
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."
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
/**
|
||||
* Thin CLI wrapper for auth-runtime.
|
||||
*
|
||||
* Copy this file into your skill's src/ directory. It spawns
|
||||
* `bun run <auth-runtime>/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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue