oh-langfuse 0.1.49 → 0.1.50
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/package.json
CHANGED
|
@@ -95,9 +95,18 @@ function runUpdate(target, args) {
|
|
|
95
95
|
return result.status ?? (result.error ? 1 : 0);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
function autoUpdateMode(args, env = process.env) {
|
|
99
|
+
const raw = String(env.OH_LANGFUSE_AUTO_UPDATE || "").trim().toLowerCase();
|
|
100
|
+
if (/^(0|false|no|off)$/i.test(raw)) return "off";
|
|
101
|
+
if (args.yes || args.y || raw === "auto" || raw === "yes" || raw === "1" || raw === "true") return "auto";
|
|
102
|
+
if (args["notify-only"] || args.notifyOnly || raw === "notify" || raw === "prompt") return "notify";
|
|
103
|
+
return "ask";
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
async function main() {
|
|
99
107
|
const args = parseArgs(process.argv.slice(2));
|
|
100
|
-
|
|
108
|
+
const mode = autoUpdateMode(args);
|
|
109
|
+
if (mode === "off") return 0;
|
|
101
110
|
|
|
102
111
|
const target = String(args._[0] || "").trim().toLowerCase();
|
|
103
112
|
if (!ALLOWED_TARGETS.has(target)) {
|
|
@@ -123,13 +132,13 @@ async function main() {
|
|
|
123
132
|
: `oh-langfuse ${target} runtime may need update. Latest package: ${latest}.`;
|
|
124
133
|
const updateCommand = `npx oh-langfuse@latest update ${target}`;
|
|
125
134
|
|
|
126
|
-
if (
|
|
135
|
+
if (mode === "notify") {
|
|
127
136
|
printUpdateAvailable(target, message, updateCommand);
|
|
128
137
|
console.log(`[INFO] To update safely, close the agent and run: ${updateCommand}`);
|
|
129
138
|
return 0;
|
|
130
139
|
}
|
|
131
140
|
|
|
132
|
-
if (
|
|
141
|
+
if (mode === "auto") {
|
|
133
142
|
printUpdateAvailable(target, message, updateCommand);
|
|
134
143
|
printUpdateCommand(target, updateCommand);
|
|
135
144
|
const code = runUpdate(target, args);
|
|
@@ -81,12 +81,57 @@ function autoUpdateRuntimePath() {
|
|
|
81
81
|
return path.join(packageRoot, "scripts", "auto-update-runtime.mjs");
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
function autoUpdateHelperDir() {
|
|
85
|
+
return path.join(os.homedir(), ".config", "oh-langfuse", "bin");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function writeAutoUpdateHelper(target) {
|
|
89
|
+
const helperDir = autoUpdateHelperDir();
|
|
90
|
+
ensureDir(helperDir);
|
|
91
|
+
const runtimePath = autoUpdateRuntimePath();
|
|
92
|
+
const fallbackArgs = ["-y", "oh-langfuse@latest", "auto-update", target, "--skip-check"];
|
|
93
|
+
|
|
94
|
+
if (process.platform === "win32") {
|
|
95
|
+
const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}.cmd`);
|
|
96
|
+
const lines = [
|
|
97
|
+
"@echo off",
|
|
98
|
+
"REM Auto-generated by scripts/codex-langfuse-setup.mjs",
|
|
99
|
+
`if exist ${cmdQuote(runtimePath)} (`,
|
|
100
|
+
` call ${cmdQuote(process.execPath)} ${cmdQuote(runtimePath)} ${target} --skip-check %*`,
|
|
101
|
+
") else (",
|
|
102
|
+
` call npx.cmd ${fallbackArgs.map(cmdQuote).join(" ")} %*`,
|
|
103
|
+
")",
|
|
104
|
+
"exit /b 0",
|
|
105
|
+
""
|
|
106
|
+
];
|
|
107
|
+
fs.writeFileSync(helper, lines.join(os.EOL), "utf8");
|
|
108
|
+
return helper;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}`);
|
|
112
|
+
const lines = [
|
|
113
|
+
"#!/usr/bin/env sh",
|
|
114
|
+
"# Auto-generated by scripts/codex-langfuse-setup.mjs",
|
|
115
|
+
"set +e",
|
|
116
|
+
`if [ -f ${shQuote(runtimePath)} ]; then`,
|
|
117
|
+
` ${shQuote(process.execPath)} ${shQuote(runtimePath)} ${shQuote(target)} --skip-check "$@"`,
|
|
118
|
+
"else",
|
|
119
|
+
` npx ${fallbackArgs.map(shQuote).join(" ")} "$@"`,
|
|
120
|
+
"fi",
|
|
121
|
+
"exit 0",
|
|
122
|
+
""
|
|
123
|
+
];
|
|
124
|
+
fs.writeFileSync(helper, lines.join("\n"), "utf8");
|
|
125
|
+
fs.chmodSync(helper, 0o755);
|
|
126
|
+
return helper;
|
|
127
|
+
}
|
|
128
|
+
|
|
84
129
|
function windowsAutoUpdateCommand(target) {
|
|
85
|
-
return `call ${cmdQuote(
|
|
130
|
+
return `call ${cmdQuote(writeAutoUpdateHelper(target))}`;
|
|
86
131
|
}
|
|
87
132
|
|
|
88
133
|
function unixAutoUpdateCommand(target) {
|
|
89
|
-
return `${shQuote(
|
|
134
|
+
return `${shQuote(writeAutoUpdateHelper(target))} || true`;
|
|
90
135
|
}
|
|
91
136
|
|
|
92
137
|
function isPathInsideDir(candidate, dir) {
|
|
@@ -153,12 +153,57 @@ function autoUpdateRuntimePath() {
|
|
|
153
153
|
return path.join(packageRoot, "scripts", "auto-update-runtime.mjs");
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
function autoUpdateHelperDir() {
|
|
157
|
+
return path.join(os.homedir(), ".config", "oh-langfuse", "bin");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function writeAutoUpdateHelper(target) {
|
|
161
|
+
const helperDir = autoUpdateHelperDir();
|
|
162
|
+
ensureDir(helperDir);
|
|
163
|
+
const runtimePath = autoUpdateRuntimePath();
|
|
164
|
+
const fallbackArgs = ["-y", "oh-langfuse@latest", "auto-update", target, "--skip-check"];
|
|
165
|
+
|
|
166
|
+
if (process.platform === "win32") {
|
|
167
|
+
const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}.cmd`);
|
|
168
|
+
const lines = [
|
|
169
|
+
"@echo off",
|
|
170
|
+
"REM Auto-generated by scripts/langfuse-setup.mjs",
|
|
171
|
+
`if exist ${cmdQuote(runtimePath)} (`,
|
|
172
|
+
` call ${cmdQuote(process.execPath)} ${cmdQuote(runtimePath)} ${target} --skip-check %*`,
|
|
173
|
+
") else (",
|
|
174
|
+
` call npx.cmd ${fallbackArgs.map(cmdQuote).join(" ")} %*`,
|
|
175
|
+
")",
|
|
176
|
+
"exit /b 0",
|
|
177
|
+
""
|
|
178
|
+
];
|
|
179
|
+
fs.writeFileSync(helper, lines.join(os.EOL), "utf8");
|
|
180
|
+
return helper;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}`);
|
|
184
|
+
const lines = [
|
|
185
|
+
"#!/usr/bin/env sh",
|
|
186
|
+
"# Auto-generated by scripts/langfuse-setup.mjs",
|
|
187
|
+
"set +e",
|
|
188
|
+
`if [ -f ${shQuote(runtimePath)} ]; then`,
|
|
189
|
+
` ${shQuote(process.execPath)} ${shQuote(runtimePath)} ${shQuote(target)} --skip-check "$@"`,
|
|
190
|
+
"else",
|
|
191
|
+
` npx ${fallbackArgs.map(shQuote).join(" ")} "$@"`,
|
|
192
|
+
"fi",
|
|
193
|
+
"exit 0",
|
|
194
|
+
""
|
|
195
|
+
];
|
|
196
|
+
fs.writeFileSync(helper, lines.join("\n"), "utf8");
|
|
197
|
+
fs.chmodSync(helper, 0o755);
|
|
198
|
+
return helper;
|
|
199
|
+
}
|
|
200
|
+
|
|
156
201
|
function windowsAutoUpdateCommand(target) {
|
|
157
|
-
return `call ${cmdQuote(
|
|
202
|
+
return `call ${cmdQuote(writeAutoUpdateHelper(target))}`;
|
|
158
203
|
}
|
|
159
204
|
|
|
160
205
|
function unixAutoUpdateCommand(target) {
|
|
161
|
-
return `${shQuote(
|
|
206
|
+
return `${shQuote(writeAutoUpdateHelper(target))} || true`;
|
|
162
207
|
}
|
|
163
208
|
|
|
164
209
|
function isPathInsideDir(candidate, dir) {
|
|
@@ -700,12 +700,57 @@ function autoUpdateRuntimePath() {
|
|
|
700
700
|
return path.join(rootDir, "scripts", "auto-update-runtime.mjs");
|
|
701
701
|
}
|
|
702
702
|
|
|
703
|
+
function autoUpdateHelperDir() {
|
|
704
|
+
return path.join(os.homedir(), ".config", "oh-langfuse", "bin");
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function writeAutoUpdateHelper(target) {
|
|
708
|
+
const helperDir = autoUpdateHelperDir();
|
|
709
|
+
ensureDir(helperDir);
|
|
710
|
+
const runtimePath = autoUpdateRuntimePath();
|
|
711
|
+
const fallbackArgs = ["-y", "oh-langfuse@latest", "auto-update", target, "--skip-check"];
|
|
712
|
+
|
|
713
|
+
if (process.platform === "win32") {
|
|
714
|
+
const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}.cmd`);
|
|
715
|
+
const lines = [
|
|
716
|
+
"@echo off",
|
|
717
|
+
"REM Auto-generated by scripts/opencode-langfuse-setup.mjs",
|
|
718
|
+
`if exist ${cmdQuote(runtimePath)} (`,
|
|
719
|
+
` call ${cmdQuote(process.execPath)} ${cmdQuote(runtimePath)} ${target} --skip-check %*`,
|
|
720
|
+
") else (",
|
|
721
|
+
` call npx.cmd ${fallbackArgs.map(cmdQuote).join(" ")} %*`,
|
|
722
|
+
")",
|
|
723
|
+
"exit /b 0",
|
|
724
|
+
""
|
|
725
|
+
];
|
|
726
|
+
fs.writeFileSync(helper, lines.join(os.EOL), "utf8");
|
|
727
|
+
return helper;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
const helper = path.join(helperDir, `oh-langfuse-auto-update-${target}`);
|
|
731
|
+
const lines = [
|
|
732
|
+
"#!/usr/bin/env sh",
|
|
733
|
+
"# Auto-generated by scripts/opencode-langfuse-setup.mjs",
|
|
734
|
+
"set +e",
|
|
735
|
+
`if [ -f ${shQuote(runtimePath)} ]; then`,
|
|
736
|
+
` ${shQuote(process.execPath)} ${shQuote(runtimePath)} ${shQuote(target)} --skip-check "$@"`,
|
|
737
|
+
"else",
|
|
738
|
+
` npx ${fallbackArgs.map(shQuote).join(" ")} "$@"`,
|
|
739
|
+
"fi",
|
|
740
|
+
"exit 0",
|
|
741
|
+
""
|
|
742
|
+
];
|
|
743
|
+
fs.writeFileSync(helper, lines.join("\n"), "utf8");
|
|
744
|
+
fs.chmodSync(helper, 0o755);
|
|
745
|
+
return helper;
|
|
746
|
+
}
|
|
747
|
+
|
|
703
748
|
function windowsAutoUpdateCommand(target) {
|
|
704
|
-
return `call ${cmdQuote(
|
|
749
|
+
return `call ${cmdQuote(writeAutoUpdateHelper(target))}`;
|
|
705
750
|
}
|
|
706
751
|
|
|
707
752
|
function unixAutoUpdateCommand(target) {
|
|
708
|
-
return `${shQuote(
|
|
753
|
+
return `${shQuote(writeAutoUpdateHelper(target))} || true`;
|
|
709
754
|
}
|
|
710
755
|
|
|
711
756
|
function writeWindowsUpdateCheckScript(dir) {
|