@leonmw/agw 0.0.0-dev.aaebd2910a50

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.
Files changed (2) hide show
  1. package/bin/agw.js +86 -0
  2. package/package.json +24 -0
package/bin/agw.js ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("node:child_process");
4
+ const fs = require("node:fs");
5
+ const os = require("node:os");
6
+ const path = require("node:path");
7
+
8
+ const platformPackageMap = {
9
+ "linux-x64": { packageName: "@leonmw/agw-linux-x64", binaryPath: "bin/agw" },
10
+ "darwin-arm64": { packageName: "@leonmw/agw-darwin-arm64", binaryPath: "bin/agw" },
11
+ "win32-x64": { packageName: "@leonmw/agw-win32-x64", binaryPath: "bin/agw.exe" }
12
+ };
13
+
14
+ function getPackageForHost() {
15
+ const key = `${process.platform}-${process.arch}`;
16
+ return platformPackageMap[key] ?? null;
17
+ }
18
+
19
+ function resolveHostBinaryPath() {
20
+ const match = getPackageForHost();
21
+ if (!match) {
22
+ const supported = Object.keys(platformPackageMap).join(", ");
23
+ throw new Error(`Unsupported platform '${process.platform}-${process.arch}'. Supported: ${supported}.`);
24
+ }
25
+
26
+ try {
27
+ return require.resolve(`${match.packageName}/${match.binaryPath}`);
28
+ } catch {
29
+ throw new Error(
30
+ `Missing platform binary package '${match.packageName}'. Reinstall with 'npm i -g @leonmw/agw'.`
31
+ );
32
+ }
33
+ }
34
+
35
+ function run() {
36
+ const binaryPath = resolveHostBinaryPath();
37
+ const handoffFile = process.platform === "win32"
38
+ ? path.join(os.tmpdir(), `agw-update-${process.pid}-${Date.now()}.txt`)
39
+ : null;
40
+ const env = handoffFile
41
+ ? { ...process.env, AGW_UPDATE_HANDOFF_FILE: handoffFile }
42
+ : process.env;
43
+
44
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
45
+ stdio: "inherit",
46
+ env
47
+ });
48
+
49
+ if (result.error) {
50
+ throw result.error;
51
+ }
52
+
53
+ if (handoffFile && fs.existsSync(handoffFile)) {
54
+ let packageSpec = "";
55
+ try {
56
+ packageSpec = fs.readFileSync(handoffFile, "utf8").trim();
57
+ } finally {
58
+ try {
59
+ fs.unlinkSync(handoffFile);
60
+ } catch {
61
+ // Best effort cleanup
62
+ }
63
+ }
64
+
65
+ if (packageSpec) {
66
+ const updateResult = spawnSync("npm", ["install", "-g", packageSpec], {
67
+ stdio: "inherit",
68
+ shell: true
69
+ });
70
+ if (updateResult.error) {
71
+ throw updateResult.error;
72
+ }
73
+ process.exit(updateResult.status ?? 1);
74
+ }
75
+ }
76
+
77
+ process.exit(result.status ?? 1);
78
+ }
79
+
80
+ try {
81
+ run();
82
+ } catch (error) {
83
+ const message = error instanceof Error ? error.message : String(error);
84
+ console.error(`agw launcher error: ${message}`);
85
+ process.exit(1);
86
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@leonmw/agw",
3
+ "version": "0.0.0-dev.aaebd2910a50",
4
+ "description": "Run Antigravity CLI in Docker with strict isolation, persistent state, and profile management.",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "agw": "bin/agw.js",
8
+ "agy-wrap": "bin/agw.js"
9
+ },
10
+ "files": [
11
+ "bin/"
12
+ ],
13
+ "optionalDependencies": {
14
+ "@leonmw/agw-linux-x64": "0.0.0-dev.aaebd2910a50",
15
+ "@leonmw/agw-darwin-arm64": "0.0.0-dev.aaebd2910a50",
16
+ "@leonmw/agw-win32-x64": "0.0.0-dev.aaebd2910a50"
17
+ },
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ }
24
+ }