Compare commits

...

5 Commits
v1.0.2 ... main

Author SHA1 Message Date
ywkj 5430437bfd fix: 补充 ClientConfig 接口和 clientConfig() 方法 2026-04-26 20:14:59 +08:00
ywkj 0d72c189b3 feat: 模块级 session ID 自动生成
Build and Release auth-rt / release (push) Successful in 1m50s Details
- auth-cli.ts 加载时自动生成 SKILL_SESSION_ID(格式: skill-YYYYMMDD-HHMMSS-xxxx)
- 优先级: 已有 SKILL_SESSION_ID env > 自动生成
- 所有 import 此文件的 skill 自动获得 session 追踪

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 19:00:37 +08:00
ywkj 39ef2f59b6 fix: go.mod 降级到 1.22,CI 加 GOTOOLCHAIN=local
Build and Release auth-rt / release (push) Successful in 1m42s Details
避免 CI 里 Go 1.22 尝试下载 1.25.7 toolchain。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 21:24:22 +08:00
ywkj 48a03f3376 fix: CI 用 node 替代 jq 解析 JSON
Build and Release auth-rt / release (push) Failing after 51s Details
node:20-bookworm 没有 jq,改用 node -e 解析 API 响应。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 21:21:42 +08:00
ywkj 9fd284e556 fix: CI 去掉 golang container,在 node:20-bookworm 里直接装 Go
Build and Release auth-rt / release (push) Failing after 2m25s Details
避免拉 golang 镜像的网络延迟,直接下载 Go tarball 编译。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 21:17:45 +08:00
3 changed files with 51 additions and 14 deletions

View File

@ -8,19 +8,24 @@ on:
jobs: jobs:
release: release:
runs-on: docker runs-on: docker
container:
image: golang:1.22-bookworm
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Go
run: |
curl -fsSL https://go.dev/dl/go1.22.12.linux-amd64.tar.gz | tar -C /usr/local -xz
echo "/usr/local/go/bin" >> $GITHUB_PATH
- name: Build all platforms - name: Build all platforms
run: | run: |
export PATH="/usr/local/go/bin:$PATH"
export GOTOOLCHAIN=local
cd cli cd cli
for pair in darwin/arm64 darwin/amd64 linux/amd64 linux/arm64; do for pair in darwin/arm64 darwin/amd64 linux/amd64 linux/arm64; do
os="${pair%/*}" os="${pair%/*}"
arch="${pair#*/}" arch="${pair#*/}"
echo "Building auth-rt-${os}-${arch}..." echo "Building auth-rt-${os}-${arch}..."
GOOS="$os" GOARCH="$arch" go build -ldflags="-s -w" -o "../auth-rt-${os}-${arch}" . GOOS="$os" GOARCH="$arch" CGO_ENABLED=0 go build -ldflags="-s -w" -o "../auth-rt-${os}-${arch}" .
done done
ls -lh ../auth-rt-* ls -lh ../auth-rt-*
@ -30,14 +35,14 @@ jobs:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
API_URL: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} API_URL: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
run: | run: |
apt-get update -qq && apt-get install -y -qq curl jq > /dev/null 2>&1 json_get() { node -e "process.stdout.write(String(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).$1 || ''))"; }
# Create release # Create release
RELEASE_ID=$(curl -s -X POST "$API_URL/releases" \ RELEASE_ID=$(curl -s -X POST "$API_URL/releases" \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"auth-rt $TAG\"}" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"auth-rt $TAG\"}" \
| jq -r '.id') | json_get id)
echo "Created release ID: $RELEASE_ID" echo "Created release ID: $RELEASE_ID"
@ -51,32 +56,31 @@ jobs:
echo "" echo ""
done done
# Also maintain a "latest" release # Maintain "latest" release
LATEST_ID=$(curl -s "$API_URL/releases/tags/latest" \ LATEST_ID=$(curl -s "$API_URL/releases/tags/latest" \
-H "Authorization: token $FORGEJO_TOKEN" | jq -r '.id // empty') -H "Authorization: token $FORGEJO_TOKEN" | json_get id)
if [ -n "$LATEST_ID" ]; then if [ -n "$LATEST_ID" ]; then
# Delete old assets # Delete old assets
curl -s "$API_URL/releases/$LATEST_ID/assets" \ ASSET_IDS=$(curl -s "$API_URL/releases/$LATEST_ID/assets" \
-H "Authorization: token $FORGEJO_TOKEN" | jq -r '.[].id' | while read aid; do -H "Authorization: token $FORGEJO_TOKEN" \
| node -e "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).forEach(a=>console.log(a.id))")
for aid in $ASSET_IDS; do
curl -s -X DELETE "$API_URL/releases/$LATEST_ID/assets/$aid" \ curl -s -X DELETE "$API_URL/releases/$LATEST_ID/assets/$aid" \
-H "Authorization: token $FORGEJO_TOKEN" -H "Authorization: token $FORGEJO_TOKEN"
done done
# Update release body
curl -s -X PATCH "$API_URL/releases/$LATEST_ID" \ curl -s -X PATCH "$API_URL/releases/$LATEST_ID" \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"body\":\"auth-rt latest (from $TAG)\"}" -d "{\"body\":\"auth-rt latest (from $TAG)\"}"
else else
# Create latest release
LATEST_ID=$(curl -s -X POST "$API_URL/releases" \ LATEST_ID=$(curl -s -X POST "$API_URL/releases" \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"tag_name":"latest","name":"latest","body":"auth-rt latest","prerelease":true}' \ -d '{"tag_name":"latest","name":"latest","body":"auth-rt latest","prerelease":true}' \
| jq -r '.id') | json_get id)
fi fi
# Upload to latest
for f in auth-rt-*; do for f in auth-rt-*; do
curl -s -X POST "$API_URL/releases/$LATEST_ID/assets?name=$f" \ curl -s -X POST "$API_URL/releases/$LATEST_ID/assets?name=$f" \
-H "Authorization: token $FORGEJO_TOKEN" \ -H "Authorization: token $FORGEJO_TOKEN" \

View File

@ -1,3 +1,3 @@
module github.com/agent-skills/auth-rt module github.com/agent-skills/auth-rt
go 1.25.7 go 1.22

View File

@ -20,6 +20,18 @@ import * as path from 'path';
import * as os from 'os'; import * as os from 'os';
const home = process.env.HOME || os.homedir(); const home = process.env.HOME || os.homedir();
// ── session ID (Langfuse tracing) ──
// Priority: SKILL_SESSION_ID env > auto-generate
const SESSION_ID = process.env.SKILL_SESSION_ID || (() => {
const ts = new Date();
const pad = (n: number) => String(n).padStart(2, '0');
const tsPart = `${ts.getFullYear()}${pad(ts.getMonth()+1)}${pad(ts.getDate())}-${pad(ts.getHours())}${pad(ts.getMinutes())}${pad(ts.getSeconds())}`;
const rand = Math.random().toString(36).slice(2, 6);
return `skill-${tsPart}-${rand}`;
})();
process.env.SKILL_SESSION_ID = SESSION_ID;
const AUTH_RT_BIN = process.env.AUTH_RT_BIN const AUTH_RT_BIN = process.env.AUTH_RT_BIN
|| (() => { || (() => {
// Check if auth-rt is in PATH // Check if auth-rt is in PATH
@ -43,6 +55,20 @@ export interface SessionResponse {
hookToken?: string; hookToken?: string;
} }
export interface ClientConfig {
clientId: string;
name: string;
status: string;
metadata: {
provider?: {
api_key?: string;
base_url?: string;
model?: string;
};
[key: string]: unknown;
};
}
export interface SkillClientOptions { export interface SkillClientOptions {
apiBase?: string; apiBase?: string;
dryRun?: boolean; dryRun?: boolean;
@ -79,6 +105,13 @@ export class SkillClient {
return JSON.parse(runCli('session')); return JSON.parse(runCli('session'));
} }
async clientConfig(): Promise<ClientConfig> {
if (this.dryRun) {
return { clientId: '<dry-run>', name: '<dry-run>', status: 'active', metadata: {} };
}
return JSON.parse(runCli('client-config'));
}
async get(urlPath: string): Promise<ApiResponse> { async get(urlPath: string): Promise<ApiResponse> {
return this.request('GET', urlPath); return this.request('GET', urlPath);
} }