@auroraflow/code 0.0.8 → 0.0.10
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/package.json
CHANGED
|
@@ -61,35 +61,40 @@ async function startInteractive(args) {
|
|
|
61
61
|
async function init() {
|
|
62
62
|
const existing = await readState();
|
|
63
63
|
const account = await readAccount();
|
|
64
|
+
const controlPlaneURL = account.controlPlaneURL ?? existing.controlPlaneURL ?? "https://auroramos.com/api/v1";
|
|
65
|
+
const gatewayURL = account.gatewayURL ?? existing.gatewayURL ?? "https://auroramos.com";
|
|
66
|
+
console.log(`Welcome to Aurora Code.
|
|
67
|
+
Sign in with your Aurora account to connect the local Claude/Codex launcher.
|
|
68
|
+
API key and model selection are managed in Aurora Desktop > 本机调用.
|
|
69
|
+
`);
|
|
64
70
|
const answers = await promptFields([
|
|
65
|
-
{ name: "controlPlaneURL", label: "Aurora control-plane URL", defaultValue: account.controlPlaneURL ?? existing.controlPlaneURL ?? "https://auroramos.com/api/v1" },
|
|
66
|
-
{ name: "gatewayURL", label: "Aurora gateway URL", defaultValue: account.gatewayURL ?? existing.gatewayURL ?? "https://auroramos.com" },
|
|
67
71
|
{ name: "email", label: "Aurora email", defaultValue: account.user?.email ?? "" },
|
|
68
|
-
{ name: "password", label: "Aurora password", defaultValue: "" }
|
|
69
|
-
{ name: "presentedKey", label: "Initial Aurora API key", defaultValue: existing.selectedKey?.presentedKey ?? "" },
|
|
70
|
-
{ name: "model", label: "Initial Aurora model alias", defaultValue: existing.selectedModel?.alias ?? "" }
|
|
72
|
+
{ name: "password", label: "Aurora password", defaultValue: "" }
|
|
71
73
|
]);
|
|
72
|
-
const login = await loginAurora(
|
|
74
|
+
const login = await loginAurora(controlPlaneURL, answers.email, answers.password);
|
|
73
75
|
const sessionToken = login.session?.token?.trim();
|
|
74
76
|
if (!sessionToken) throw new Error("Aurora login did not return session.token");
|
|
77
|
+
const user = login.user ? {
|
|
78
|
+
id: login.user.id,
|
|
79
|
+
email: login.user.email,
|
|
80
|
+
name: login.user.display_name || login.user.email
|
|
81
|
+
} : null;
|
|
75
82
|
await writeAccount({
|
|
76
|
-
controlPlaneURL
|
|
77
|
-
gatewayURL
|
|
83
|
+
controlPlaneURL,
|
|
84
|
+
gatewayURL,
|
|
78
85
|
sessionToken,
|
|
79
|
-
user
|
|
80
|
-
id: login.user.id,
|
|
81
|
-
email: login.user.email,
|
|
82
|
-
name: login.user.display_name || login.user.email
|
|
83
|
-
} : null
|
|
86
|
+
user
|
|
84
87
|
});
|
|
85
88
|
await writeState({
|
|
86
89
|
...existing,
|
|
87
|
-
controlPlaneURL
|
|
88
|
-
gatewayURL
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
controlPlaneURL,
|
|
91
|
+
gatewayURL,
|
|
92
|
+
account: {
|
|
93
|
+
sessionToken,
|
|
94
|
+
user
|
|
95
|
+
}
|
|
91
96
|
});
|
|
92
|
-
console.log("Aurora
|
|
97
|
+
console.log("Aurora account initialized. Select API key and model in Aurora Desktop > 本机调用.");
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
async function loginAurora(controlPlaneURL, email, password) {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { spawn, spawnSync } from "node:child_process";
|
|
2
2
|
import { randomBytes } from "node:crypto";
|
|
3
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { closeSync, existsSync, openSync, readFileSync } from "node:fs";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import { delimiter, dirname, join, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { AURORA_SIDECAR_PORT } from "../../protocol/src/index.js";
|
|
8
|
-
import { CLAUDE_HOME, CODEX_HOME, readSidecarInfo, readState, writeSidecarInfo } from "../../state/src/index.js";
|
|
8
|
+
import { AURORA_HOME, CLAUDE_HOME, CODEX_HOME, readSidecarInfo, readState, writeSidecarInfo } from "../../state/src/index.js";
|
|
9
9
|
|
|
10
10
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
const packageRoot = resolve(here, "..", "..", "..");
|
|
12
12
|
const rootSidecarBin = join(packageRoot, "bin", "aurora-sidecar.js");
|
|
13
|
+
const sidecarLogPath = join(AURORA_HOME, "log", "sidecar.log");
|
|
14
|
+
let sidecarSupervisor = null;
|
|
13
15
|
|
|
14
16
|
const OFFICIAL_CLIENTS = {
|
|
15
17
|
claude: {
|
|
@@ -150,18 +152,45 @@ async function ensureSidecar() {
|
|
|
150
152
|
// Start below.
|
|
151
153
|
}
|
|
152
154
|
const token = `aurora-local-${randomBytes(24).toString("hex")}`;
|
|
153
|
-
const child = spawn(process.execPath, [process.env.AURORA_SIDECAR_BIN || rootSidecarBin, "--token", token], {
|
|
154
|
-
detached: true,
|
|
155
|
-
stdio: "ignore",
|
|
156
|
-
env: process.env
|
|
157
|
-
});
|
|
158
|
-
child.unref();
|
|
159
155
|
const info = { port: AURORA_SIDECAR_PORT, token, baseURL: `http://127.0.0.1:${AURORA_SIDECAR_PORT}` };
|
|
156
|
+
await startManagedSidecar(info);
|
|
160
157
|
await waitForSidecar(info);
|
|
161
158
|
await writeSidecarInfo(info);
|
|
162
159
|
return info;
|
|
163
160
|
}
|
|
164
161
|
|
|
162
|
+
async function startManagedSidecar(info) {
|
|
163
|
+
if (sidecarSupervisor) return;
|
|
164
|
+
await mkdir(dirname(sidecarLogPath), { recursive: true });
|
|
165
|
+
const launch = () => {
|
|
166
|
+
const logFd = openSync(sidecarLogPath, "a");
|
|
167
|
+
const child = spawn(process.execPath, [
|
|
168
|
+
process.env.AURORA_SIDECAR_BIN || rootSidecarBin,
|
|
169
|
+
"--token",
|
|
170
|
+
info.token,
|
|
171
|
+
"--port",
|
|
172
|
+
String(info.port)
|
|
173
|
+
], {
|
|
174
|
+
detached: true,
|
|
175
|
+
stdio: ["ignore", logFd, logFd],
|
|
176
|
+
env: process.env
|
|
177
|
+
});
|
|
178
|
+
closeSync(logFd);
|
|
179
|
+
sidecarSupervisor.child = child;
|
|
180
|
+
child.on("error", error => {
|
|
181
|
+
console.error(`Aurora sidecar failed to start: ${error.message}`);
|
|
182
|
+
});
|
|
183
|
+
child.on("exit", () => {
|
|
184
|
+
sidecarSupervisor.child = null;
|
|
185
|
+
setTimeout(launch, 1000);
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
sidecarSupervisor = {
|
|
189
|
+
child: null
|
|
190
|
+
};
|
|
191
|
+
launch();
|
|
192
|
+
}
|
|
193
|
+
|
|
165
194
|
async function writeCodexRuntimeFiles({ sidecar, model }) {
|
|
166
195
|
await mkdir(CODEX_HOME, { recursive: true });
|
|
167
196
|
const modelCatalogPath = join(CODEX_HOME, "model_catalog.json");
|
|
@@ -15,12 +15,26 @@ export async function startSidecar(options = {}) {
|
|
|
15
15
|
response.end(JSON.stringify({ error: { type: "sidecar_error", message: error.message } }));
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
|
+
server.on("error", error => {
|
|
19
|
+
console.error(`Aurora sidecar listen error on ${AURORA_LOCALHOST}:${port}: ${error.message}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
|
18
22
|
server.listen(port, AURORA_LOCALHOST, async () => {
|
|
19
23
|
await writeSidecarInfo({ port, token, baseURL: `http://${AURORA_LOCALHOST}:${port}` });
|
|
20
24
|
console.error(`Aurora sidecar listening on http://${AURORA_LOCALHOST}:${port}`);
|
|
21
25
|
});
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
process.on("uncaughtException", error => {
|
|
29
|
+
console.error(`Aurora sidecar uncaught exception: ${error?.stack || error?.message || error}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
process.on("unhandledRejection", reason => {
|
|
34
|
+
console.error(`Aurora sidecar unhandled rejection: ${reason?.stack || reason?.message || reason}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
|
37
|
+
|
|
24
38
|
async function handle(request, response, token) {
|
|
25
39
|
if (!isAuthorized(request, token)) {
|
|
26
40
|
writeJSON(response, 401, { error: { type: "unauthorized", message: "sidecar token required" } });
|