From 0d72c189b34bbb69e2fa1dd383ab19e9ca4ec50d Mon Sep 17 00:00:00 2001 From: ywkj Date: Sun, 26 Apr 2026 19:00:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A8=A1=E5=9D=97=E7=BA=A7=20session?= =?UTF-8?q?=20ID=20=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - auth-cli.ts 加载时自动生成 SKILL_SESSION_ID(格式: skill-YYYYMMDD-HHMMSS-xxxx) - 优先级: 已有 SKILL_SESSION_ID env > 自动生成 - 所有 import 此文件的 skill 自动获得 session 追踪 Co-Authored-By: Claude Opus 4.7 --- src/auth-cli.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/auth-cli.ts b/src/auth-cli.ts index d072a88..e20a343 100644 --- a/src/auth-cli.ts +++ b/src/auth-cli.ts @@ -20,6 +20,18 @@ import * as path from 'path'; import * as os from 'os'; 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 || (() => { // Check if auth-rt is in PATH