oh-langfuse 0.1.77 → 0.1.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +30 -21
- package/codex_langfuse_notify.py +19 -6
- package/langfuse_hook.py +19 -6
- package/package.json +1 -1
- package/scripts/codex-langfuse-setup.mjs +25 -14
- package/scripts/langfuse-setup.mjs +27 -16
- package/scripts/opencode-langfuse-run.mjs +21 -10
- package/scripts/opencode-langfuse-setup.mjs +1674 -1581
- package/scripts/real-self-verify.mjs +21 -9
- package/scripts/update-langfuse-runtime.mjs +29 -12
|
@@ -9,8 +9,12 @@ import { resolveOpencodeCli } from "./resolve-opencode-cli.mjs";
|
|
|
9
9
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
10
10
|
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, "package.json"), "utf8"));
|
|
11
11
|
|
|
12
|
-
const DEFAULT_LANGFUSE_BASE_URL = "
|
|
13
|
-
const
|
|
12
|
+
const DEFAULT_LANGFUSE_BASE_URL = "https://metrics.openharmonyinsight.cn";
|
|
13
|
+
const LEGACY_LANGFUSE_BASE_URLS = new Set([
|
|
14
|
+
"http://120.46.221.227:3000",
|
|
15
|
+
"https://120.46.221.227:3000",
|
|
16
|
+
]);
|
|
17
|
+
const DEFAULT_LANGFUSE_PUBLIC_KEY = "pk-lf-da0c90a7-6e93-4eb7-bb86-c1047c8d187d";
|
|
14
18
|
const DEFAULT_LANGFUSE_SECRET_KEY = "sk-lf-0269b85d-bfdc-442c-bfa3-e737954e3315";
|
|
15
19
|
const OPENCODE_NATIVE_AGENT_TURN_NAMES = new Set(["session.llm:ai.streamText.doStream"]);
|
|
16
20
|
|
|
@@ -145,7 +149,7 @@ function findOnPath(names) {
|
|
|
145
149
|
return "";
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
function localCodexCliCandidates() {
|
|
152
|
+
function localCodexCliCandidates() {
|
|
149
153
|
if (process.platform !== "win32") return ["codex"];
|
|
150
154
|
const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local");
|
|
151
155
|
const codexBin = path.join(localAppData, "OpenAI", "Codex", "bin");
|
|
@@ -163,12 +167,20 @@ function localCodexCliCandidates() {
|
|
|
163
167
|
// Fall back to PATH probing below.
|
|
164
168
|
}
|
|
165
169
|
return [...candidates, "codex.cmd", "codex.exe", "codex"].filter(Boolean);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function normalizeLegacyBaseUrl(baseUrl) {
|
|
173
|
+
const value = String(baseUrl || "").trim().replace(/\/+$/, "");
|
|
174
|
+
return LEGACY_LANGFUSE_BASE_URLS.has(value) ? DEFAULT_LANGFUSE_BASE_URL : baseUrl;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function configFromArgs(args) {
|
|
178
|
+
return {
|
|
179
|
+
baseUrl: String(
|
|
180
|
+
normalizeLegacyBaseUrl(
|
|
181
|
+
args.langfuseBaseUrl || args.langfuseHost || args.host || process.env.LANGFUSE_BASEURL || process.env.LANGFUSE_HOST || DEFAULT_LANGFUSE_BASE_URL
|
|
182
|
+
)
|
|
183
|
+
),
|
|
172
184
|
publicKey: String(args.publicKey || process.env.LANGFUSE_PUBLIC_KEY || DEFAULT_LANGFUSE_PUBLIC_KEY),
|
|
173
185
|
secretKey: String(args.secretKey || process.env.LANGFUSE_SECRET_KEY || DEFAULT_LANGFUSE_SECRET_KEY),
|
|
174
186
|
userId: String(args.userId || args.userid || process.env.LANGFUSE_USER_ID || process.env.CC_USER_ID || "").trim(),
|
|
@@ -10,7 +10,11 @@ import { writeRuntimeInstallRecord } from "./runtime-state-utils.mjs";
|
|
|
10
10
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
11
|
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, "package.json"), "utf8"));
|
|
12
12
|
|
|
13
|
-
const DEFAULT_LANGFUSE_BASE_URL = "
|
|
13
|
+
const DEFAULT_LANGFUSE_BASE_URL = "https://metrics.openharmonyinsight.cn";
|
|
14
|
+
const LEGACY_LANGFUSE_BASE_URLS = new Set([
|
|
15
|
+
"http://120.46.221.227:3000",
|
|
16
|
+
"https://120.46.221.227:3000",
|
|
17
|
+
]);
|
|
14
18
|
const DEFAULT_LANGFUSE_PUBLIC_KEY = "pk-lf-da0c90a7-6e93-4eb7-bb86-c1047c8d187d";
|
|
15
19
|
const DEFAULT_LANGFUSE_SECRET_KEY = "sk-lf-0269b85d-bfdc-442c-bfa3-e737954e3315";
|
|
16
20
|
|
|
@@ -98,7 +102,7 @@ function codexConfig(home) {
|
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
function opencodeConfig(home) {
|
|
105
|
+
function opencodeConfig(home) {
|
|
102
106
|
const config = readJsonIfExists(path.join(home, ".config", "opencode-plugin-langfuse", "config.json")) || {};
|
|
103
107
|
return {
|
|
104
108
|
baseUrl: process.env.LANGFUSE_BASEURL || process.env.LANGFUSE_HOST,
|
|
@@ -106,16 +110,29 @@ function opencodeConfig(home) {
|
|
|
106
110
|
secretKey: process.env.LANGFUSE_SECRET_KEY,
|
|
107
111
|
userId: config.userId || config.usrid || process.env.LANGFUSE_USER_ID,
|
|
108
112
|
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function normalizeLegacyBaseUrl(baseUrl) {
|
|
116
|
+
const value = String(baseUrl || "").trim().replace(/\/+$/, "");
|
|
117
|
+
return LEGACY_LANGFUSE_BASE_URLS.has(value) ? DEFAULT_LANGFUSE_BASE_URL : baseUrl;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function mergedConfig(target, args) {
|
|
121
|
+
const home = os.homedir();
|
|
122
|
+
const existing = target === "claude" ? claudeConfig(home) : target === "codex" ? codexConfig(home) : opencodeConfig(home);
|
|
123
|
+
const baseUrl = normalizeLegacyBaseUrl(
|
|
124
|
+
args.langfuseBaseUrl ||
|
|
125
|
+
args.langfuseHost ||
|
|
126
|
+
args.host ||
|
|
127
|
+
existing.baseUrl ||
|
|
128
|
+
process.env.LANGFUSE_BASEURL ||
|
|
129
|
+
DEFAULT_LANGFUSE_BASE_URL
|
|
130
|
+
);
|
|
131
|
+
const config = {
|
|
132
|
+
baseUrl,
|
|
133
|
+
publicKey: args.publicKey || existing.publicKey || process.env.LANGFUSE_PUBLIC_KEY || DEFAULT_LANGFUSE_PUBLIC_KEY,
|
|
134
|
+
secretKey: args.secretKey || existing.secretKey || process.env.LANGFUSE_SECRET_KEY || DEFAULT_LANGFUSE_SECRET_KEY,
|
|
135
|
+
userId: args.userId || args.userid || existing.userId || process.env.LANGFUSE_USER_ID || process.env.CC_USER_ID || "",
|
|
119
136
|
};
|
|
120
137
|
if (!config.userId) throw new Error(`Missing user id for ${target}; provide --userId=<employee-id> or run setup first.`);
|
|
121
138
|
return config;
|