diff --git a/install.sh b/install.sh index c324683..325a14e 100755 --- a/install.sh +++ b/install.sh @@ -2,10 +2,10 @@ set -euo pipefail cd "$(dirname "$0")" -# Prerequisite: auth-runtime must be cloned at ~/clawd/skills/auth-runtime -if [ ! -d "$HOME/clawd/skills/auth-runtime/src" ]; then - echo "ERROR: auth-runtime not found at ~/clawd/skills/auth-runtime" - echo "Run: git clone http://192.168.0.108:3030/agent-skills/auth-runtime.git ~/clawd/skills/auth-runtime" +# Prerequisite: auth-rt binary must be installed +if ! command -v auth-rt &>/dev/null && [ ! -x "$HOME/.openclaw/bin/auth-rt" ]; then + echo "ERROR: auth-rt not found. Install it:" + echo " cd ~/clawd/skills/auth-runtime && ./install.sh" exit 1 fi 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(); }