@gea-ai/cli 0.2.261201-alpha.0 → 0.3.261203-alpha.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/gea.cjs +35 -0
- package/package.json +16 -34
- package/gea-launcher.cjs +0 -86
- package/runtime.d.ts +0 -2
- package/runtime.mjs +0 -54
- package/vite.d.ts +0 -1
- package/vite.mjs +0 -271
package/gea.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require("node:child_process");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
|
|
5
|
+
const target = `${process.platform}-${process.arch}`;
|
|
6
|
+
if (target !== "darwin-arm64" && target !== "linux-x64") {
|
|
7
|
+
process.stderr.write(`GEA CLI 0.3 does not support ${target}.\n`);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const name = `@gea-ai/cli-${target}`;
|
|
11
|
+
let root;
|
|
12
|
+
try {
|
|
13
|
+
root = path.dirname(require.resolve(`${name}/package.json`));
|
|
14
|
+
} catch {
|
|
15
|
+
process.stderr.write(
|
|
16
|
+
`Install @gea-ai/cli with its optional dependency ${name}.\n`,
|
|
17
|
+
);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const child = spawn(path.join(root, "gea"), process.argv.slice(2), {
|
|
21
|
+
stdio: "inherit",
|
|
22
|
+
env: { ...process.env, GEA_CLI_DISTRIBUTION_ROOT: root },
|
|
23
|
+
});
|
|
24
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
25
|
+
const forward = (signal) => child.kill(signal);
|
|
26
|
+
for (const signal of signals) process.on(signal, forward);
|
|
27
|
+
child.once("error", (error) => {
|
|
28
|
+
process.stderr.write(`Unable to start gea: ${error.message}\n`);
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
});
|
|
31
|
+
child.once("close", (code, signal) => {
|
|
32
|
+
for (const name of signals) process.off(name, forward);
|
|
33
|
+
if (signal) process.kill(process.pid, signal);
|
|
34
|
+
else process.exitCode = code ?? 1;
|
|
35
|
+
});
|
package/package.json
CHANGED
|
@@ -1,50 +1,32 @@
|
|
|
1
1
|
{
|
|
2
|
+
"private": false,
|
|
3
|
+
"version": "0.3.261203-alpha.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
2
5
|
"description": "GEA developer CLI.",
|
|
3
6
|
"homepage": "https://musegea.com/developers/cli",
|
|
4
|
-
"license": "Apache-2.0",
|
|
5
|
-
"private": false,
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public",
|
|
8
|
-
"tag": "latest"
|
|
9
|
-
},
|
|
10
7
|
"repository": {
|
|
11
8
|
"type": "git",
|
|
12
9
|
"url": "git+https://github.com/bmrlab/gea.git",
|
|
13
|
-
"directory": "
|
|
10
|
+
"directory": "crates/gea-cli"
|
|
14
11
|
},
|
|
15
|
-
"
|
|
16
|
-
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"tag": "next"
|
|
15
|
+
},
|
|
16
|
+
"name": "@gea-ai/cli",
|
|
17
17
|
"bin": {
|
|
18
|
-
"gea": "gea
|
|
18
|
+
"gea": "gea.cjs"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
|
-
"gea
|
|
22
|
-
"vite.mjs",
|
|
23
|
-
"vite.d.ts",
|
|
24
|
-
"runtime.mjs",
|
|
25
|
-
"runtime.d.ts",
|
|
21
|
+
"gea.cjs",
|
|
26
22
|
"LICENSE"
|
|
27
23
|
],
|
|
28
|
-
"exports": {
|
|
29
|
-
"./package.json": "./package.json",
|
|
30
|
-
"./vite": {
|
|
31
|
-
"types": "./vite.d.ts",
|
|
32
|
-
"import": "./vite.mjs"
|
|
33
|
-
},
|
|
34
|
-
"./runtime": {
|
|
35
|
-
"types": "./runtime.d.ts",
|
|
36
|
-
"import": "./runtime.mjs"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"name": "@gea-ai/cli",
|
|
40
|
-
"optionalDependencies": {
|
|
41
|
-
"@gea-ai/cli-darwin-arm64": "0.2.261201-alpha.0",
|
|
42
|
-
"@gea-ai/cli-win32-x64": "0.2.261201-alpha.0",
|
|
43
|
-
"@gea-ai/cli-linux-x64": "0.2.261201-alpha.0"
|
|
44
|
-
},
|
|
45
24
|
"os": [
|
|
46
25
|
"darwin",
|
|
47
|
-
"win32",
|
|
48
26
|
"linux"
|
|
49
|
-
]
|
|
27
|
+
],
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"@gea-ai/cli-darwin-arm64": "0.3.261203-alpha.0",
|
|
30
|
+
"@gea-ai/cli-linux-x64": "0.3.261203-alpha.0"
|
|
31
|
+
}
|
|
50
32
|
}
|
package/gea-launcher.cjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawn } = require("node:child_process");
|
|
4
|
-
const path = require("node:path");
|
|
5
|
-
|
|
6
|
-
function resolveGeaTarget(platform, arch) {
|
|
7
|
-
if (platform === "darwin" && arch === "arm64") {
|
|
8
|
-
return {
|
|
9
|
-
executable: "gea-darwin-arm64",
|
|
10
|
-
packageName: "@gea-ai/cli-darwin-arm64",
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (platform === "win32" && arch === "x64") {
|
|
15
|
-
return {
|
|
16
|
-
executable: "gea-windows-x64.exe",
|
|
17
|
-
packageName: "@gea-ai/cli-win32-x64",
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (platform === "linux" && arch === "x64") {
|
|
22
|
-
return {
|
|
23
|
-
executable: "gea-linux-x64",
|
|
24
|
-
packageName: "@gea-ai/cli-linux-x64",
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
throw new Error(
|
|
29
|
-
`@gea-ai/cli does not provide an executable for ${platform}/${arch}. ` +
|
|
30
|
-
"Supported platforms are darwin/arm64, win32/x64 and linux/x64.",
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function main() {
|
|
35
|
-
let distributionRoot;
|
|
36
|
-
let target;
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
target = resolveGeaTarget(process.platform, process.arch);
|
|
40
|
-
distributionRoot = path.dirname(
|
|
41
|
-
require.resolve(`${target.packageName}/package.json`),
|
|
42
|
-
);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
const message = target
|
|
45
|
-
? `${target.packageName} is not installed. Reinstall @gea-ai/cli without omitting optional dependencies.`
|
|
46
|
-
: error.message;
|
|
47
|
-
process.stderr.write(`${message}\n`);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const child = spawn(
|
|
52
|
-
path.join(distributionRoot, target.executable),
|
|
53
|
-
process.argv.slice(2),
|
|
54
|
-
{
|
|
55
|
-
env: {
|
|
56
|
-
...process.env,
|
|
57
|
-
GEA_CLI_DISTRIBUTION_ROOT: distributionRoot,
|
|
58
|
-
},
|
|
59
|
-
stdio: "inherit",
|
|
60
|
-
},
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
64
|
-
const forward = (signal) => child.kill(signal);
|
|
65
|
-
for (const signal of signals) process.on(signal, forward);
|
|
66
|
-
const removeSignalHandlers = () => {
|
|
67
|
-
for (const signal of signals) process.off(signal, forward);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
child.once("error", (error) => {
|
|
71
|
-
removeSignalHandlers();
|
|
72
|
-
process.stderr.write(`Failed to start GEA CLI: ${error.message}\n`);
|
|
73
|
-
process.exitCode = 1;
|
|
74
|
-
});
|
|
75
|
-
child.once("exit", (code, signal) => {
|
|
76
|
-
removeSignalHandlers();
|
|
77
|
-
if (signal) process.kill(process.pid, signal);
|
|
78
|
-
else process.exitCode = code ?? 1;
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (require.main === module) {
|
|
83
|
-
main();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = { resolveGeaTarget };
|
package/runtime.d.ts
DELETED
package/runtime.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// src/vite-env.ts
|
|
2
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import { dirname, join as join2, resolve } from "node:path";
|
|
5
|
-
|
|
6
|
-
// ../agent-sdk/src/vite-environment.ts
|
|
7
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
import { parseEnv } from "node:util";
|
|
10
|
-
function developmentEnvironment(root) {
|
|
11
|
-
const file = join(root, ".dev.vars");
|
|
12
|
-
return {
|
|
13
|
-
...existsSync(file) ? parseEnv(readFileSync(file, "utf8")) : {},
|
|
14
|
-
...process.env
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// src/vite-env.ts
|
|
19
|
-
function geaInstallation(environment = process.env) {
|
|
20
|
-
let distributionRoot = environment.GEA_CLI_DISTRIBUTION_ROOT;
|
|
21
|
-
if (!distributionRoot && (!environment.GEA_CLI_BINARY || !environment.GEA_WORKER_RUNTIME_BINARY || !environment.WORKER_RUNTIME_SYSTEM_WORKER_ROOT)) {
|
|
22
|
-
const cliRequire = createRequire(import.meta.url);
|
|
23
|
-
const target = process.platform === "darwin" && process.arch === "arm64" ? "darwin-arm64" : process.platform === "win32" && process.arch === "x64" ? "win32-x64" : process.platform === "linux" && process.arch === "x64" ? "linux-x64" : null;
|
|
24
|
-
if (!target)
|
|
25
|
-
throw new Error(
|
|
26
|
-
"Set GEA_CLI_BINARY, GEA_WORKER_RUNTIME_BINARY and WORKER_RUNTIME_SYSTEM_WORKER_ROOT for this platform."
|
|
27
|
-
);
|
|
28
|
-
distributionRoot = dirname(
|
|
29
|
-
cliRequire.resolve(`@gea-ai/cli-${target}/package.json`)
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
const cli = environment.GEA_CLI_BINARY ?? join2(
|
|
33
|
-
distributionRoot,
|
|
34
|
-
process.platform === "win32" ? "gea-windows-x64.exe" : process.platform === "linux" ? "gea-linux-x64" : "gea-darwin-arm64"
|
|
35
|
-
);
|
|
36
|
-
const runtime = environment.GEA_WORKER_RUNTIME_BINARY ?? join2(
|
|
37
|
-
distributionRoot,
|
|
38
|
-
process.platform === "win32" ? "gea-worker-runtime.exe" : "gea-worker-runtime"
|
|
39
|
-
);
|
|
40
|
-
const systemWorkers = environment.WORKER_RUNTIME_SYSTEM_WORKER_ROOT ?? join2(distributionRoot, "system-workers");
|
|
41
|
-
for (const path of [cli, runtime, join2(systemWorkers, "filesystem.mjs")]) {
|
|
42
|
-
if (!existsSync2(path))
|
|
43
|
-
throw new Error(`GEA installation is incomplete: ${path}`);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
cli: resolve(cli),
|
|
47
|
-
runtime: resolve(runtime),
|
|
48
|
-
systemWorkers: resolve(systemWorkers)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
developmentEnvironment,
|
|
53
|
-
geaInstallation
|
|
54
|
-
};
|
package/vite.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function geaWorker(): import("vite").Plugin;
|
package/vite.mjs
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
// src/vite.ts
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
|
|
4
|
-
// ../agent-sdk/src/vite-plugin.ts
|
|
5
|
-
import { once } from "node:events";
|
|
6
|
-
import { createServer, request as proxyRequest } from "node:http";
|
|
7
|
-
|
|
8
|
-
// ../agent-sdk/src/vite-environment.ts
|
|
9
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import { parseEnv } from "node:util";
|
|
12
|
-
function developmentEnvironment(root) {
|
|
13
|
-
const file = join(root, ".dev.vars");
|
|
14
|
-
return {
|
|
15
|
-
...existsSync(file) ? parseEnv(readFileSync(file, "utf8")) : {},
|
|
16
|
-
...process.env
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// ../agent-sdk/src/vite-plugin.ts
|
|
21
|
-
async function reservePort() {
|
|
22
|
-
const listener = createServer();
|
|
23
|
-
listener.listen(0, "127.0.0.1");
|
|
24
|
-
await once(listener, "listening");
|
|
25
|
-
const address = listener.address();
|
|
26
|
-
if (!address || typeof address === "string")
|
|
27
|
-
throw new Error("Could not allocate development port.");
|
|
28
|
-
await new Promise((resolve2) => listener.close(() => resolve2()));
|
|
29
|
-
return address.port;
|
|
30
|
-
}
|
|
31
|
-
function createGeaWorkerPlugin(startWorker, ownedWorker) {
|
|
32
|
-
let stopWorker;
|
|
33
|
-
return {
|
|
34
|
-
async closeBundle() {
|
|
35
|
-
await stopWorker?.();
|
|
36
|
-
},
|
|
37
|
-
name: "gea-worker",
|
|
38
|
-
enforce: "pre",
|
|
39
|
-
transform(code, id) {
|
|
40
|
-
if (id.endsWith(".md"))
|
|
41
|
-
return { code: `export default ${JSON.stringify(code)};`, map: null };
|
|
42
|
-
},
|
|
43
|
-
config() {
|
|
44
|
-
return {
|
|
45
|
-
environments: {
|
|
46
|
-
ssr: {
|
|
47
|
-
resolve: {
|
|
48
|
-
noExternal: true,
|
|
49
|
-
external: [
|
|
50
|
-
"@gea-ai/agent-sdk",
|
|
51
|
-
"ai",
|
|
52
|
-
"cloudflare:workers",
|
|
53
|
-
"node:async_hooks",
|
|
54
|
-
"node:stream",
|
|
55
|
-
"node:stream/web"
|
|
56
|
-
],
|
|
57
|
-
conditions: ["workerd", "worker", "browser"]
|
|
58
|
-
},
|
|
59
|
-
build: {
|
|
60
|
-
rollupOptions: {
|
|
61
|
-
input: "worker.ts",
|
|
62
|
-
external: [
|
|
63
|
-
/^@gea-ai\/agent-sdk(?:\/|$)/,
|
|
64
|
-
"ai",
|
|
65
|
-
"cloudflare:workers",
|
|
66
|
-
"node:async_hooks",
|
|
67
|
-
"node:stream",
|
|
68
|
-
"node:stream/web"
|
|
69
|
-
],
|
|
70
|
-
output: {
|
|
71
|
-
inlineDynamicImports: true,
|
|
72
|
-
entryFileNames: "index.js"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
async configureServer(server) {
|
|
81
|
-
const environment = developmentEnvironment(server.config.root);
|
|
82
|
-
const agentEnvironment = environment.AGENT_ENVIRONMENT ?? "local";
|
|
83
|
-
if (agentEnvironment === "local" && server.config.server.host !== "127.0.0.1")
|
|
84
|
-
throw new Error(
|
|
85
|
-
"Local Agents API development must bind Vite to 127.0.0.1."
|
|
86
|
-
);
|
|
87
|
-
let origin;
|
|
88
|
-
if (ownedWorker) {
|
|
89
|
-
origin = ownedWorker.origin;
|
|
90
|
-
} else {
|
|
91
|
-
const port = await reservePort();
|
|
92
|
-
origin = `http://127.0.0.1:${port}`;
|
|
93
|
-
const child = startWorker(server.config.root, port, {
|
|
94
|
-
...environment,
|
|
95
|
-
APP_ORIGIN: environment.APP_ORIGIN ?? `http://127.0.0.1:${server.config.server.port ?? 4e3}`,
|
|
96
|
-
AGENT_ENVIRONMENT: agentEnvironment,
|
|
97
|
-
NODE_ENV: "production"
|
|
98
|
-
});
|
|
99
|
-
let output = "";
|
|
100
|
-
let stopping;
|
|
101
|
-
const stop = () => stopping ??= (async () => {
|
|
102
|
-
if (!child.pid || child.exitCode !== null || child.signalCode !== null)
|
|
103
|
-
return;
|
|
104
|
-
const exited = once(child, "exit");
|
|
105
|
-
child.kill("SIGTERM");
|
|
106
|
-
await exited;
|
|
107
|
-
})();
|
|
108
|
-
stopWorker = stop;
|
|
109
|
-
const restart = server.restart.bind(server);
|
|
110
|
-
server.restart = async (force) => {
|
|
111
|
-
await stop();
|
|
112
|
-
await restart(force);
|
|
113
|
-
};
|
|
114
|
-
server.httpServer?.once("close", () => {
|
|
115
|
-
void stop();
|
|
116
|
-
});
|
|
117
|
-
child.stdout.on("data", (chunk) => process.stdout.write(chunk));
|
|
118
|
-
child.stderr.on("data", (chunk) => {
|
|
119
|
-
process.stderr.write(chunk);
|
|
120
|
-
output += chunk;
|
|
121
|
-
const lines = output.split("\n");
|
|
122
|
-
output = lines.pop();
|
|
123
|
-
if (lines.some(
|
|
124
|
-
(line) => line.startsWith("[gea] Agent Worker reloaded at deployment ") || line === "[gea] Agent Worker Runtime restarted." || line.trimEnd() === "[gea] ready"
|
|
125
|
-
))
|
|
126
|
-
server.ws.send({ type: "full-reload" });
|
|
127
|
-
});
|
|
128
|
-
let startupError;
|
|
129
|
-
child.once("error", (error) => {
|
|
130
|
-
startupError = error;
|
|
131
|
-
});
|
|
132
|
-
try {
|
|
133
|
-
const deadline = Date.now() + 6e4;
|
|
134
|
-
while (true) {
|
|
135
|
-
if (startupError) throw startupError;
|
|
136
|
-
if (child.exitCode !== null || child.signalCode !== null)
|
|
137
|
-
throw new Error(
|
|
138
|
-
"GEA development process exited. See its output above."
|
|
139
|
-
);
|
|
140
|
-
try {
|
|
141
|
-
const response = await fetch(`${origin}/gea/agents/run`, {
|
|
142
|
-
method: "OPTIONS"
|
|
143
|
-
});
|
|
144
|
-
await response.body?.cancel();
|
|
145
|
-
if (response.ok) break;
|
|
146
|
-
} catch {
|
|
147
|
-
}
|
|
148
|
-
if (Date.now() > deadline)
|
|
149
|
-
throw new Error("GEA development startup timed out.");
|
|
150
|
-
await new Promise((resolve2) => setTimeout(resolve2, 200));
|
|
151
|
-
}
|
|
152
|
-
} catch (error) {
|
|
153
|
-
await stop();
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
server.middlewares.use((request, response, next) => {
|
|
158
|
-
const { pathname, search } = new URL(request.url ?? "/", origin);
|
|
159
|
-
if (pathname.startsWith("/@vite/") || pathname.startsWith("/@id/") || pathname.startsWith("/@fs/") || pathname.startsWith("/node_modules/.vite/") || pathname === "/@react-refresh" || pathname === "/__vite_ping" || pathname.startsWith("/node_modules/") && pathname.endsWith("/vite/dist/client/env.mjs"))
|
|
160
|
-
return next();
|
|
161
|
-
const target = new URL(origin);
|
|
162
|
-
target.pathname = pathname;
|
|
163
|
-
target.search = search;
|
|
164
|
-
const upstream = proxyRequest(
|
|
165
|
-
target,
|
|
166
|
-
{
|
|
167
|
-
method: request.method,
|
|
168
|
-
headers: {
|
|
169
|
-
...request.headers,
|
|
170
|
-
...ownedWorker ? { "x-gea-vite-worker-token": ownedWorker.token } : {},
|
|
171
|
-
"x-forwarded-host": request.headers.host ?? "",
|
|
172
|
-
"x-forwarded-proto": "http"
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
(incoming) => {
|
|
176
|
-
incoming.on("error", (error) => response.destroy(error));
|
|
177
|
-
const html = incoming.headers["content-type"]?.includes("text/html");
|
|
178
|
-
const headers = { ...incoming.headers };
|
|
179
|
-
if (html) delete headers["content-length"];
|
|
180
|
-
response.writeHead(incoming.statusCode ?? 502, headers);
|
|
181
|
-
if (!html) return void incoming.pipe(response);
|
|
182
|
-
const chunks = [];
|
|
183
|
-
incoming.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
184
|
-
incoming.on(
|
|
185
|
-
"end",
|
|
186
|
-
() => response.end(
|
|
187
|
-
Buffer.concat(chunks).toString("utf8").replace(
|
|
188
|
-
"</head>",
|
|
189
|
-
'<script type="module" src="/@vite/client"></script></head>'
|
|
190
|
-
)
|
|
191
|
-
)
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
upstream.on("error", (error) => {
|
|
196
|
-
if (response.headersSent) response.destroy(error);
|
|
197
|
-
else response.writeHead(502).end("GEA Worker is unavailable.");
|
|
198
|
-
});
|
|
199
|
-
response.once("close", () => {
|
|
200
|
-
if (!response.writableEnded) upstream.destroy();
|
|
201
|
-
});
|
|
202
|
-
request.pipe(upstream);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// src/vite-env.ts
|
|
209
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
210
|
-
import { createRequire } from "node:module";
|
|
211
|
-
import { dirname, join as join2, resolve } from "node:path";
|
|
212
|
-
function geaInstallation(environment = process.env) {
|
|
213
|
-
let distributionRoot = environment.GEA_CLI_DISTRIBUTION_ROOT;
|
|
214
|
-
if (!distributionRoot && (!environment.GEA_CLI_BINARY || !environment.GEA_WORKER_RUNTIME_BINARY || !environment.WORKER_RUNTIME_SYSTEM_WORKER_ROOT)) {
|
|
215
|
-
const cliRequire = createRequire(import.meta.url);
|
|
216
|
-
const target = process.platform === "darwin" && process.arch === "arm64" ? "darwin-arm64" : process.platform === "win32" && process.arch === "x64" ? "win32-x64" : process.platform === "linux" && process.arch === "x64" ? "linux-x64" : null;
|
|
217
|
-
if (!target)
|
|
218
|
-
throw new Error(
|
|
219
|
-
"Set GEA_CLI_BINARY, GEA_WORKER_RUNTIME_BINARY and WORKER_RUNTIME_SYSTEM_WORKER_ROOT for this platform."
|
|
220
|
-
);
|
|
221
|
-
distributionRoot = dirname(
|
|
222
|
-
cliRequire.resolve(`@gea-ai/cli-${target}/package.json`)
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
const cli = environment.GEA_CLI_BINARY ?? join2(
|
|
226
|
-
distributionRoot,
|
|
227
|
-
process.platform === "win32" ? "gea-windows-x64.exe" : process.platform === "linux" ? "gea-linux-x64" : "gea-darwin-arm64"
|
|
228
|
-
);
|
|
229
|
-
const runtime = environment.GEA_WORKER_RUNTIME_BINARY ?? join2(
|
|
230
|
-
distributionRoot,
|
|
231
|
-
process.platform === "win32" ? "gea-worker-runtime.exe" : "gea-worker-runtime"
|
|
232
|
-
);
|
|
233
|
-
const systemWorkers = environment.WORKER_RUNTIME_SYSTEM_WORKER_ROOT ?? join2(distributionRoot, "system-workers");
|
|
234
|
-
for (const path of [cli, runtime, join2(systemWorkers, "filesystem.mjs")]) {
|
|
235
|
-
if (!existsSync2(path))
|
|
236
|
-
throw new Error(`GEA installation is incomplete: ${path}`);
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
cli: resolve(cli),
|
|
240
|
-
runtime: resolve(runtime),
|
|
241
|
-
systemWorkers: resolve(systemWorkers)
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// src/vite.ts
|
|
246
|
-
function geaWorker() {
|
|
247
|
-
return createGeaWorkerPlugin((root, port, environment) => {
|
|
248
|
-
const installation = geaInstallation(environment);
|
|
249
|
-
return spawn(
|
|
250
|
-
installation.cli,
|
|
251
|
-
[
|
|
252
|
-
"agent",
|
|
253
|
-
"dev",
|
|
254
|
-
"--json",
|
|
255
|
-
JSON.stringify({ cwd: root, host: "127.0.0.1", port, vite: false })
|
|
256
|
-
],
|
|
257
|
-
{
|
|
258
|
-
cwd: root,
|
|
259
|
-
env: {
|
|
260
|
-
...environment,
|
|
261
|
-
GEA_WORKER_RUNTIME_BINARY: installation.runtime,
|
|
262
|
-
WORKER_RUNTIME_SYSTEM_WORKER_ROOT: installation.systemWorkers
|
|
263
|
-
},
|
|
264
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
export {
|
|
270
|
-
geaWorker
|
|
271
|
-
};
|