swe-swe 2.20.0 → 2.21.0
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/swe-swe.js +90 -19
- package/package.json +7 -7
package/bin/swe-swe.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// GENERATED by distribute-go-bin v0.1.0 -- do not edit.
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { spawn, execFileSync } from "child_process";
|
|
4
5
|
import { createRequire } from "module";
|
|
5
6
|
import { existsSync, chmodSync } from "fs";
|
|
6
7
|
import { dirname, join } from "path";
|
|
@@ -34,16 +35,44 @@ if (!platform || !arch) {
|
|
|
34
35
|
const pkgName = `@choonkeat/swe-swe-${platform}-${arch}`;
|
|
35
36
|
const binName = process.platform === "win32" ? "swe-swe.exe" : "swe-swe";
|
|
36
37
|
|
|
38
|
+
// Prefer local build in npm-platforms/ (development) over npm-installed package.
|
|
39
|
+
// npm-platforms/ is not published to npm, so this only takes effect during local dev.
|
|
40
|
+
const localPath = join(__dirname, "..", "npm-platforms", `${platform}-${arch}`, "bin", binName);
|
|
41
|
+
|
|
42
|
+
function resolveFromRegistry() {
|
|
43
|
+
try {
|
|
44
|
+
const pkgDir = dirname(require.resolve(`${pkgName}/package.json`));
|
|
45
|
+
return join(pkgDir, "bin", binName);
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
37
51
|
let binPath;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
if (existsSync(localPath)) {
|
|
53
|
+
binPath = localPath;
|
|
54
|
+
} else {
|
|
55
|
+
binPath = resolveFromRegistry();
|
|
56
|
+
// optionalDependencies may not be installed in some environments:
|
|
57
|
+
// - stale npx cache predating the dep being added
|
|
58
|
+
// - `npm install --omit=optional` or `npm ci --omit=optional`
|
|
59
|
+
// - cross-platform install caches (e.g. image built on amd64, run on arm64)
|
|
60
|
+
// - pnpm / yarn with different optional-dep semantics
|
|
61
|
+
// - `npm link` dev workflows
|
|
62
|
+
// Attempt a one-shot install to recover before giving up.
|
|
63
|
+
if (!binPath) {
|
|
64
|
+
try {
|
|
65
|
+
console.error(`Installing ${pkgName}...`);
|
|
66
|
+
execFileSync("npm", ["install", "--no-save", pkgName], {
|
|
67
|
+
stdio: "inherit",
|
|
68
|
+
cwd: join(__dirname, ".."),
|
|
69
|
+
});
|
|
70
|
+
binPath = resolveFromRegistry();
|
|
71
|
+
} catch {
|
|
72
|
+
// fall through to the error exit below
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!binPath) {
|
|
47
76
|
console.error(
|
|
48
77
|
`Could not find package ${pkgName}.\n` +
|
|
49
78
|
`Make sure it is installed -- this usually means your platform is supported\n` +
|
|
@@ -60,18 +89,53 @@ if (!existsSync(binPath)) {
|
|
|
60
89
|
process.exit(1);
|
|
61
90
|
}
|
|
62
91
|
|
|
92
|
+
// Forward these signals from the dispatcher to the spawned Go binary so that
|
|
93
|
+
// `kill <dispatcher-pid>` does not orphan the child. Node does not propagate
|
|
94
|
+
// signals to children automatically; without these handlers, SIGTERM to this
|
|
95
|
+
// script would terminate the dispatcher and leave the child process running.
|
|
96
|
+
const FORWARDED_SIGNALS = ["SIGTERM", "SIGINT", "SIGHUP", "SIGQUIT"];
|
|
97
|
+
|
|
63
98
|
function run() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
let child;
|
|
101
|
+
try {
|
|
102
|
+
child = spawn(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
103
|
+
} catch (error) {
|
|
104
|
+
resolve({ error });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
67
107
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
108
|
+
const handlers = {};
|
|
109
|
+
for (const sig of FORWARDED_SIGNALS) {
|
|
110
|
+
handlers[sig] = () => {
|
|
111
|
+
try {
|
|
112
|
+
child.kill(sig);
|
|
113
|
+
} catch {
|
|
114
|
+
// child may have already exited; nothing to do.
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
process.on(sig, handlers[sig]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const cleanup = () => {
|
|
121
|
+
for (const sig of FORWARDED_SIGNALS) {
|
|
122
|
+
process.off(sig, handlers[sig]);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
child.on("error", (error) => {
|
|
127
|
+
cleanup();
|
|
128
|
+
resolve({ error });
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
child.on("exit", (code, signal) => {
|
|
132
|
+
cleanup();
|
|
133
|
+
resolve({ code, signal });
|
|
134
|
+
});
|
|
135
|
+
});
|
|
72
136
|
}
|
|
73
137
|
|
|
74
|
-
let result = run();
|
|
138
|
+
let result = await run();
|
|
75
139
|
|
|
76
140
|
// Handle EACCES by chmod +x and retrying
|
|
77
141
|
if (result.error && result.error.code === "EACCES") {
|
|
@@ -81,10 +145,17 @@ if (result.error && result.error.code === "EACCES") {
|
|
|
81
145
|
console.error(`Failed to chmod +x ${binPath}: ${e.message}`);
|
|
82
146
|
process.exit(1);
|
|
83
147
|
}
|
|
84
|
-
result = run();
|
|
148
|
+
result = await run();
|
|
85
149
|
}
|
|
86
150
|
|
|
87
151
|
if (result.error) {
|
|
88
152
|
console.error(`Failed to start swe-swe: ${result.error.message}`);
|
|
89
153
|
process.exit(1);
|
|
90
154
|
}
|
|
155
|
+
|
|
156
|
+
if (result.signal) {
|
|
157
|
+
// Re-raise the signal the child died from so our own exit status reflects it.
|
|
158
|
+
process.kill(process.pid, result.signal);
|
|
159
|
+
} else {
|
|
160
|
+
process.exit(result.code ?? 0);
|
|
161
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swe-swe",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"description": "Your agent: containerized with browser, terminal, and parallel sessions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@choonkeat/swe-swe-linux-x64": "2.
|
|
19
|
-
"@choonkeat/swe-swe-linux-arm64": "2.
|
|
20
|
-
"@choonkeat/swe-swe-darwin-x64": "2.
|
|
21
|
-
"@choonkeat/swe-swe-darwin-arm64": "2.
|
|
22
|
-
"@choonkeat/swe-swe-win32-x64": "2.
|
|
23
|
-
"@choonkeat/swe-swe-win32-arm64": "2.
|
|
18
|
+
"@choonkeat/swe-swe-linux-x64": "2.21.0",
|
|
19
|
+
"@choonkeat/swe-swe-linux-arm64": "2.21.0",
|
|
20
|
+
"@choonkeat/swe-swe-darwin-x64": "2.21.0",
|
|
21
|
+
"@choonkeat/swe-swe-darwin-arm64": "2.21.0",
|
|
22
|
+
"@choonkeat/swe-swe-win32-x64": "2.21.0",
|
|
23
|
+
"@choonkeat/swe-swe-win32-arm64": "2.21.0"
|
|
24
24
|
}
|
|
25
25
|
}
|