openagent-cli 1.0.1 → 1.0.2
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/open-agent.exe +0 -0
- package/bin/openagent +14 -3
- package/package.json +1 -1
package/bin/open-agent.exe
CHANGED
|
Binary file
|
package/bin/openagent
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { spawn } = require("child_process")
|
|
2
|
+
const { spawn, execSync } = require("child_process")
|
|
3
3
|
const path = require("path")
|
|
4
4
|
|
|
5
|
+
const pkg = require("../package.json")
|
|
6
|
+
const currentVersion = pkg.version
|
|
7
|
+
|
|
5
8
|
const args = process.argv.slice(2)
|
|
6
9
|
if (args.includes("--version") || args.includes("-v")) {
|
|
7
|
-
console.log(
|
|
10
|
+
console.log(currentVersion)
|
|
8
11
|
process.exit(0)
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
const binDir = __dirname
|
|
12
15
|
const exe = path.join(binDir, "open-agent.exe")
|
|
13
16
|
|
|
14
|
-
const
|
|
17
|
+
const env = { ...process.env, OPENAGENT_NPM_VERSION: currentVersion }
|
|
18
|
+
try {
|
|
19
|
+
const latest = execSync("npm view openagent-cli version", { timeout: 3000, encoding: "utf-8" }).trim()
|
|
20
|
+
if (latest && latest !== currentVersion) {
|
|
21
|
+
env.OPENAGENT_UPDATE_AVAILABLE = latest
|
|
22
|
+
}
|
|
23
|
+
} catch {}
|
|
24
|
+
|
|
25
|
+
const child = spawn(exe, args, { stdio: "inherit", env })
|
|
15
26
|
child.on("exit", (code) => process.exit(code ?? 1))
|
|
16
27
|
|
|
17
28
|
process.on("SIGINT", () => child.kill("SIGINT"))
|