pytxo 1.2.0 → 1.2.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pytxo contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # pytxo (npm)
2
-
3
- npm wrapper for the [Pytxo](https://pytxo.com) CLI. It downloads the same-version prebuilt binary from the public [pytxo-releases](https://github.com/Pytxo-dev/pytxo-releases) repository during `postinstall`.
4
-
5
- Community: [Discord](https://discord.gg/AUFRPFjSYv)
6
-
7
- ```bash
8
- npm i -g pytxo
9
- pytxo doctor
10
- ```
11
-
12
- Set `PYTXO_SKIP_DOWNLOAD=1` and `PYTXO_BINARY=/path/to/pytxo` for local development.
1
+ # pytxo (npm)
2
+
3
+ npm wrapper for the [Pytxo](https://pytxo.com) CLI. It downloads the same-version prebuilt binary from the public [pytxo-releases](https://github.com/Pytxo-dev/pytxo-releases) repository during `postinstall`.
4
+
5
+ Community: [Discord](https://discord.gg/AUFRPFjSYv)
6
+
7
+ ```bash
8
+ npm i -g pytxo
9
+ pytxo doctor
10
+ ```
11
+
12
+ Set `PYTXO_SKIP_DOWNLOAD=1` and `PYTXO_BINARY=/path/to/pytxo` for local development.
package/bin/pytxo.js CHANGED
@@ -1,28 +1,28 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- const { spawnSync } = require("node:child_process");
5
- const fs = require("node:fs");
6
- const path = require("node:path");
7
-
8
- const binName = process.platform === "win32" ? "pytxo.exe" : "pytxo";
9
- const vendor = path.join(__dirname, "..", "vendor", binName);
10
- const envBin = process.env.PYTXO_BINARY;
11
-
12
- const candidates = [envBin, vendor].filter(Boolean);
13
-
14
- for (const bin of candidates) {
15
- if (fs.existsSync(bin)) {
16
- const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
17
- if (result.error) {
18
- console.error(result.error.message);
19
- process.exit(1);
20
- }
21
- process.exit(result.status ?? 1);
22
- }
23
- }
24
-
25
- console.error(
26
- "pytxo binary not found. Re-run npm install or set PYTXO_BINARY to a local build.",
27
- );
28
- process.exit(1);
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+
8
+ const binName = process.platform === "win32" ? "pytxo.exe" : "pytxo";
9
+ const vendor = path.join(__dirname, "..", "vendor", binName);
10
+ const envBin = process.env.PYTXO_BINARY;
11
+
12
+ const candidates = [envBin, vendor].filter(Boolean);
13
+
14
+ for (const bin of candidates) {
15
+ if (fs.existsSync(bin)) {
16
+ const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
17
+ if (result.error) {
18
+ console.error(result.error.message);
19
+ process.exit(1);
20
+ }
21
+ process.exit(result.status ?? 1);
22
+ }
23
+ }
24
+
25
+ console.error(
26
+ "pytxo binary not found. Re-run npm install or set PYTXO_BINARY to a local build.",
27
+ );
28
+ process.exit(1);
package/lib/platform.js CHANGED
@@ -1,21 +1,18 @@
1
- "use strict";
2
-
3
- const { platform, arch } = process;
4
-
5
- function getAssetName() {
6
- if (platform === "win32") {
7
- if (arch === "arm64") return "pytxo-windows-arm64.exe";
8
- return "pytxo-windows-x64.exe";
9
- }
10
- if (platform === "darwin") {
11
- if (arch === "arm64") return "pytxo-darwin-arm64";
12
- return "pytxo-darwin-x64";
13
- }
14
- if (platform === "linux") {
15
- if (arch === "arm64") return "pytxo-linux-arm64";
16
- return "pytxo-linux-x64";
17
- }
18
- throw new Error(`Unsupported platform: ${platform} ${arch}`);
19
- }
20
-
21
- module.exports = { getAssetName };
1
+ "use strict";
2
+
3
+ function getAssetName(platform = process.platform, arch = process.arch) {
4
+ const assets = {
5
+ "win32:x64": "pytxo-windows-x64.exe",
6
+ "darwin:arm64": "pytxo-darwin-arm64",
7
+ "darwin:x64": "pytxo-darwin-x64",
8
+ "linux:arm64": "pytxo-linux-arm64",
9
+ "linux:x64": "pytxo-linux-x64",
10
+ };
11
+ const asset = assets[`${platform}:${arch}`];
12
+ if (!asset) {
13
+ throw new Error(`Unsupported Pytxo release platform: ${platform} ${arch}`);
14
+ }
15
+ return asset;
16
+ }
17
+
18
+ module.exports = { getAssetName };
package/package.json CHANGED
@@ -1,36 +1,38 @@
1
- {
2
- "name": "pytxo",
3
- "version": "1.2.0",
4
- "description": "Pytxo agent hypervisor CLI — local-first PTY orchestration",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/Pytxo-dev/pytxo-releases.git"
9
- },
10
- "homepage": "https://pytxo.com",
11
- "bugs": "https://github.com/Pytxo-dev/pytxo-releases/issues",
12
- "keywords": [
13
- "pytxo",
14
- "cli",
15
- "ai-agents",
16
- "mcp",
17
- "orchestration",
18
- "terminal",
19
- "rust"
20
- ],
21
- "engines": {
22
- "node": ">=18"
23
- },
24
- "bin": {
25
- "pytxo": "bin/pytxo.js"
26
- },
27
- "files": [
28
- "bin",
29
- "lib",
30
- "postinstall.js",
31
- "README.md"
32
- ],
33
- "scripts": {
34
- "postinstall": "node postinstall.js"
35
- }
36
- }
1
+ {
2
+ "name": "pytxo",
3
+ "version": "1.2.1",
4
+ "description": "Pytxo agent hypervisor CLI — local-first PTY orchestration",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Pytxo-dev/pytxo-releases.git"
9
+ },
10
+ "homepage": "https://pytxo.com",
11
+ "bugs": "https://github.com/Pytxo-dev/pytxo-releases/issues",
12
+ "keywords": [
13
+ "pytxo",
14
+ "cli",
15
+ "ai-agents",
16
+ "mcp",
17
+ "orchestration",
18
+ "terminal",
19
+ "rust"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "bin": {
25
+ "pytxo": "bin/pytxo.js"
26
+ },
27
+ "files": [
28
+ "bin",
29
+ "lib",
30
+ "postinstall.js",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "scripts": {
35
+ "postinstall": "node postinstall.js",
36
+ "test": "node --test test/*.test.js"
37
+ }
38
+ }
package/postinstall.js CHANGED
@@ -1,65 +1,167 @@
1
- "use strict";
2
-
3
- const fs = require("node:fs");
4
- const path = require("node:path");
5
- const https = require("node:https");
6
-
7
- const { getAssetName } = require("./lib/platform");
8
-
9
- const REPO = process.env.PYTXO_REPO || "Pytxo-dev/pytxo-releases";
10
- const VERSION = process.env.PYTXO_VERSION || require("./package.json").version;
11
- const TAG = VERSION.startsWith("v") ? VERSION : `v${VERSION}`;
12
-
13
- const vendorDir = path.join(__dirname, "vendor");
14
- const asset = getAssetName();
15
- const destName = process.platform === "win32" ? "pytxo.exe" : "pytxo";
16
- const dest = path.join(vendorDir, destName);
17
-
18
- function download(url) {
19
- return new Promise((resolve, reject) => {
20
- const file = fs.createWriteStream(dest);
21
- https
22
- .get(url, (res) => {
23
- if (res.statusCode === 302 || res.statusCode === 301) {
24
- const loc = res.headers.location;
25
- if (!loc) return reject(new Error("Redirect without location"));
26
- res.resume();
27
- return download(loc).then(resolve, reject);
28
- }
29
- if (res.statusCode !== 200) {
30
- res.resume();
31
- return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
32
- }
33
- res.pipe(file);
34
- file.on("finish", () => file.close(resolve));
35
- })
36
- .on("error", reject);
37
- });
38
- }
39
-
40
- async function main() {
41
- if (process.env.PYTXO_SKIP_DOWNLOAD === "1") {
42
- console.log("pytxo: PYTXO_SKIP_DOWNLOAD=1, skipping binary download");
43
- return;
44
- }
45
- if (fs.existsSync(dest)) {
46
- return;
47
- }
48
- fs.mkdirSync(vendorDir, { recursive: true });
49
- const url = `https://github.com/${REPO}/releases/download/${TAG}/${asset}`;
50
- console.log(`pytxo: downloading ${asset} from ${TAG}…`);
51
- try {
52
- await download(url);
53
- if (process.platform !== "win32") {
54
- fs.chmodSync(dest, 0o755);
55
- }
56
- } catch (err) {
57
- console.warn(
58
- `pytxo: could not download release binary (${err.message}).\n` +
59
- ` Manual download: https://github.com/${REPO}/releases\n` +
60
- ` Or run: curl -fsSL https://raw.githubusercontent.com/${REPO}/main/install.sh | bash`,
61
- );
62
- }
63
- }
64
-
65
- main();
1
+ "use strict";
2
+
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+ const http = require("node:http");
6
+ const https = require("node:https");
7
+ const crypto = require("node:crypto");
8
+ const { spawnSync } = require("node:child_process");
9
+
10
+ const { getAssetName } = require("./lib/platform");
11
+
12
+ const REPO = process.env.PYTXO_REPO || "Pytxo-dev/pytxo-releases";
13
+ const VERSION = process.env.PYTXO_VERSION || require("./package.json").version;
14
+ const TAG = VERSION.startsWith("v") ? VERSION : `v${VERSION}`;
15
+ const NORMALIZED_VERSION = VERSION.replace(/^v/, "");
16
+ const MAX_DOWNLOAD_BYTES = 200 * 1024 * 1024;
17
+ const MAX_REDIRECTS = 8;
18
+
19
+ const vendorDir = process.env.PYTXO_VENDOR_DIR || path.join(__dirname, "vendor");
20
+ const destName = process.platform === "win32" ? "pytxo.exe" : "pytxo";
21
+ const dest = path.join(vendorDir, destName);
22
+
23
+ function downloadBuffer(url, redirects = 0) {
24
+ return new Promise((resolve, reject) => {
25
+ const transport = new URL(url).protocol === "https:" ? https : http;
26
+ transport
27
+ .get(url, (res) => {
28
+ if (res.statusCode === 302 || res.statusCode === 301) {
29
+ const loc = res.headers.location;
30
+ if (!loc) return reject(new Error("Redirect without location"));
31
+ if (redirects >= MAX_REDIRECTS) {
32
+ res.resume();
33
+ return reject(new Error(`Too many redirects for ${url}`));
34
+ }
35
+ res.resume();
36
+ return downloadBuffer(new URL(loc, url).toString(), redirects + 1).then(resolve, reject);
37
+ }
38
+ if (res.statusCode !== 200) {
39
+ res.resume();
40
+ return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
41
+ }
42
+ const chunks = [];
43
+ let bytes = 0;
44
+ res.on("data", (chunk) => {
45
+ bytes += chunk.length;
46
+ if (bytes > MAX_DOWNLOAD_BYTES) {
47
+ res.destroy(new Error(`Download exceeds ${MAX_DOWNLOAD_BYTES} bytes`));
48
+ return;
49
+ }
50
+ chunks.push(chunk);
51
+ });
52
+ res.on("end", () => resolve(Buffer.concat(chunks)));
53
+ res.on("error", reject);
54
+ })
55
+ .on("error", reject);
56
+ });
57
+ }
58
+
59
+ function expectedChecksum(checksumText, asset) {
60
+ for (const line of checksumText.split(/\r?\n/)) {
61
+ const match = line.match(/^([a-fA-F0-9]{64})\s+\*?(.+)$/);
62
+ if (match && match[2].trim() === asset) return match[1].toLowerCase();
63
+ }
64
+ throw new Error(`SHA256SUMS.txt has no exact entry for ${asset}`);
65
+ }
66
+
67
+ function sha256(bytes) {
68
+ return crypto.createHash("sha256").update(bytes).digest("hex");
69
+ }
70
+
71
+ function assertChecksum(bytes, expected, label) {
72
+ const actual = sha256(bytes);
73
+ if (actual !== expected.toLowerCase()) {
74
+ throw new Error(`SHA-256 mismatch for ${label}: expected ${expected}, got ${actual}`);
75
+ }
76
+ }
77
+
78
+ function assertBinaryVersion(binaryPath, expectedVersion = NORMALIZED_VERSION) {
79
+ const result = spawnSync(binaryPath, ["--version"], {
80
+ encoding: "utf8",
81
+ windowsHide: true,
82
+ });
83
+ if (result.error) throw result.error;
84
+ if (result.status !== 0) {
85
+ throw new Error(`${path.basename(binaryPath)} --version exited ${result.status}`);
86
+ }
87
+ const output = `${result.stdout || ""}\n${result.stderr || ""}`.trim();
88
+ const match = output.match(/\bpytxo\s+v?(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)\b/i);
89
+ if (!match || match[1] !== expectedVersion) {
90
+ throw new Error(`Expected pytxo ${expectedVersion}, received ${JSON.stringify(output)}`);
91
+ }
92
+ }
93
+
94
+ function installAtomically(tempPath, destination) {
95
+ const backup = `${destination}.previous-${process.pid}`;
96
+ let movedExisting = false;
97
+ try {
98
+ if (fs.existsSync(destination)) {
99
+ fs.renameSync(destination, backup);
100
+ movedExisting = true;
101
+ }
102
+ fs.renameSync(tempPath, destination);
103
+ if (movedExisting) fs.rmSync(backup, { force: true });
104
+ } catch (error) {
105
+ if (!fs.existsSync(destination) && movedExisting && fs.existsSync(backup)) {
106
+ fs.renameSync(backup, destination);
107
+ }
108
+ throw error;
109
+ }
110
+ }
111
+
112
+ async function main() {
113
+ if (process.env.PYTXO_SKIP_DOWNLOAD === "1") {
114
+ console.log("pytxo: PYTXO_SKIP_DOWNLOAD=1, skipping binary download (development only)");
115
+ return;
116
+ }
117
+ const asset = getAssetName();
118
+ fs.mkdirSync(vendorDir, { recursive: true });
119
+ const releaseBase = process.env.PYTXO_RELEASE_BASE_URL
120
+ ? `${process.env.PYTXO_RELEASE_BASE_URL.replace(/\/$/, "")}/${TAG}`
121
+ : `https://github.com/${REPO}/releases/download/${TAG}`;
122
+ const checksumUrl = `${releaseBase}/SHA256SUMS.txt`;
123
+ const url = `${releaseBase}/${asset}`;
124
+ console.log(`pytxo: downloading ${asset} from ${TAG}…`);
125
+ const checksumText = (await downloadBuffer(checksumUrl)).toString("utf8");
126
+ const checksum = expectedChecksum(checksumText, asset);
127
+
128
+ if (fs.existsSync(dest)) {
129
+ const installed = fs.readFileSync(dest);
130
+ if (sha256(installed) === checksum) {
131
+ assertBinaryVersion(dest);
132
+ return;
133
+ }
134
+ }
135
+
136
+ const bytes = await downloadBuffer(url);
137
+ assertChecksum(bytes, checksum, asset);
138
+ const suffix = process.platform === "win32" ? ".exe" : "";
139
+ const temp = path.join(
140
+ vendorDir,
141
+ `.pytxo-download-${process.pid}-${crypto.randomBytes(6).toString("hex")}${suffix}`,
142
+ );
143
+ try {
144
+ fs.writeFileSync(temp, bytes, { flag: "wx", mode: 0o755 });
145
+ if (process.platform !== "win32") {
146
+ fs.chmodSync(temp, 0o755);
147
+ }
148
+ assertBinaryVersion(temp);
149
+ installAtomically(temp, dest);
150
+ } finally {
151
+ fs.rmSync(temp, { force: true });
152
+ }
153
+ }
154
+
155
+ if (require.main === module) {
156
+ main().catch((error) => {
157
+ console.error(`pytxo: install failed: ${error.message}`);
158
+ process.exitCode = 1;
159
+ });
160
+ }
161
+
162
+ module.exports = {
163
+ assertChecksum,
164
+ expectedChecksum,
165
+ installAtomically,
166
+ sha256,
167
+ };