@auroraflow/code 0.0.14 → 0.0.16

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.
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { runAuroraClaude } from "../packages/cli/src/index.js";
3
3
 
4
- await runAuroraClaude(process.argv.slice(2));
4
+ try {
5
+ await runAuroraClaude(process.argv.slice(2));
6
+ } catch (error) {
7
+ console.error(`Aurora Claude error: ${error?.message || error}`);
8
+ process.exit(1);
9
+ }
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { runAuroraCodex } from "../packages/cli/src/index.js";
3
3
 
4
- await runAuroraCodex(process.argv.slice(2));
4
+ try {
5
+ await runAuroraCodex(process.argv.slice(2));
6
+ } catch (error) {
7
+ console.error(`Aurora Codex error: ${error?.message || error}`);
8
+ process.exit(1);
9
+ }
@@ -1,13 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { installOfficialClients, isGlobalNpmLifecycle, officialClientStatuses } from "../packages/clients/src/index.js";
3
3
 
4
- if (!process.env.AURORA_SKIP_OFFICIAL_CLIENT_INSTALL && isGlobalNpmLifecycle()) {
4
+ if (process.env.AURORA_INSTALL_OFFICIAL_CLIENTS === "1" && isGlobalNpmLifecycle()) {
5
5
  try {
6
6
  await installOfficialClients();
7
7
  } catch (error) {
8
8
  console.error(`[aurora-code] official client install failed: ${error.message}`);
9
9
  console.error("[aurora-code] run `aurora install-clients` after installation.");
10
10
  }
11
+ } else if (isGlobalNpmLifecycle()) {
12
+ console.error("[aurora-code] installed Aurora launcher. Official Claude/Codex clients are not auto-installed.");
13
+ console.error("[aurora-code] run `aurora install-clients`, or install only what you need: `npm install -g @openai/codex@latest`.");
11
14
  }
12
15
 
13
16
  const statuses = officialClientStatuses();
package/bin/aurora.js CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { runAuroraCLI } from "../packages/cli/src/index.js";
3
3
 
4
- await runAuroraCLI(process.argv.slice(2));
4
+ try {
5
+ await runAuroraCLI(process.argv.slice(2));
6
+ } catch (error) {
7
+ console.error(`Aurora error: ${error?.message || error}`);
8
+ process.exit(1);
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auroraflow/code",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "description": "Aurora launcher and sidecar for official Codex and Claude Code clients.",
6
6
  "repository": {
@@ -8,6 +8,7 @@ import { ensureSidecarRunning } from "../../service/src/index.js";
8
8
 
9
9
  const here = dirname(fileURLToPath(import.meta.url));
10
10
  const packageRoot = resolve(here, "..", "..", "..");
11
+ const CODEX_MODEL_CATALOG_TIMEOUT_MS = 30000;
11
12
 
12
13
  const OFFICIAL_CLIENTS = {
13
14
  claude: {
@@ -23,10 +24,11 @@ const OFFICIAL_CLIENTS = {
23
24
  };
24
25
 
25
26
  export async function createClientLaunchSpec(client, args = []) {
26
- const sidecar = await ensureSidecarRunning();
27
+ const command = officialClientBin(client);
27
28
  const state = await readState();
28
29
  const model = selectedModelAlias(state);
29
30
  const key = selectedKey(state);
31
+ const sidecar = await ensureSidecarRunning();
30
32
  if (client === "claude") {
31
33
  const env = {
32
34
  ...process.env,
@@ -42,7 +44,7 @@ export async function createClientLaunchSpec(client, args = []) {
42
44
  DISABLE_AUTOUPDATER: "1"
43
45
  };
44
46
  env.ANTHROPIC_MODEL = model;
45
- return { command: officialClientBin("claude"), args, env };
47
+ return { command, args, env };
46
48
  }
47
49
  await writeCodexRuntimeFiles({ sidecar, model, key });
48
50
  const env = {
@@ -53,7 +55,7 @@ export async function createClientLaunchSpec(client, args = []) {
53
55
  OPENAI_BASE_URL: `${sidecar.baseURL}/v1`
54
56
  };
55
57
  env.OPENAI_MODEL = model;
56
- return { command: officialClientBin("codex"), args, env };
58
+ return { command, args, env };
57
59
  }
58
60
 
59
61
  export async function runClient(client, args = []) {
@@ -82,9 +84,9 @@ export async function updateOfficialClients() {
82
84
  }
83
85
 
84
86
  export async function installOfficialClients() {
85
- const npm = process.env.npm_execpath || "npm";
87
+ const npm = npmCommandSpec();
86
88
  const args = ["install", "-g", "@anthropic-ai/claude-code@latest", "@openai/codex@latest"];
87
- await spawnAndWait(npm, args, { ...process.env });
89
+ await spawnAndWait(npm.command, [...npm.args, ...args], { ...process.env });
88
90
  }
89
91
 
90
92
  export function isGlobalNpmLifecycle() {
@@ -170,13 +172,18 @@ stream_idle_timeout_ms = 300000
170
172
 
171
173
  async function writeCodexModelCatalog(sidecar, modelCatalogPath) {
172
174
  const clientVersion = "0.137.0";
173
- const response = await fetch(
174
- `${sidecar.baseURL}/v1/models?client_version=${encodeURIComponent(clientVersion)}`,
175
- {
176
- headers: { authorization: `Bearer ${sidecar.token}` },
177
- signal: AbortSignal.timeout(5000)
178
- }
179
- );
175
+ let response;
176
+ try {
177
+ response = await fetch(
178
+ `${sidecar.baseURL}/v1/models?client_version=${encodeURIComponent(clientVersion)}`,
179
+ {
180
+ headers: { authorization: `Bearer ${sidecar.token}` },
181
+ signal: AbortSignal.timeout(CODEX_MODEL_CATALOG_TIMEOUT_MS)
182
+ }
183
+ );
184
+ } catch (error) {
185
+ throw new Error(`Aurora Codex model catalog request timed out after ${CODEX_MODEL_CATALOG_TIMEOUT_MS / 1000}s. Check Aurora Desktop key/model selection and network to Aurora Gateway. (${error?.message || error})`);
186
+ }
180
187
  if (!response.ok) {
181
188
  throw new Error(`Aurora Codex model catalog request failed with HTTP ${response.status}`);
182
189
  }
@@ -249,6 +256,14 @@ function spawnSyncCompat(command, args) {
249
256
  });
250
257
  }
251
258
 
259
+ function npmCommandSpec() {
260
+ const npmExecPath = process.env.npm_execpath || "";
261
+ if (npmExecPath.endsWith(".js")) {
262
+ return { command: process.execPath, args: [npmExecPath] };
263
+ }
264
+ return { command: npmExecPath || "npm", args: [] };
265
+ }
266
+
252
267
  function windowsCommandSpec(command, args) {
253
268
  if (process.platform !== "win32" || !command.toLowerCase().endsWith(".cmd")) {
254
269
  return { command, args, shell: false };
@@ -48,6 +48,7 @@ export async function ensureSidecarIdentity() {
48
48
  }
49
49
 
50
50
  export async function startSidecar(options = {}) {
51
+ installSidecarProcessGuards();
51
52
  const tokenOverride = options.token || readArg("--token") || process.env.AURORA_SIDECAR_TOKEN;
52
53
  const portOverride = options.port || readArg("--port") || process.env.AURORA_SIDECAR_PORT;
53
54
  const identity = await ensureSidecarIdentity();
@@ -134,18 +135,22 @@ async function pingLocalSidecar(port, token) {
134
135
  }
135
136
  }
136
137
 
137
- // The sidecar is a long-lived local proxy that Claude Code / Codex depend on
138
- // for every request. A single bad request (e.g. a mid-stream upstream drop)
139
- // must NOT kill the process: an orphaned sidecar with no live supervisor never
140
- // comes back, leaving the client stuck on ConnectionRefused. Log and keep
141
- // serving; the HTTP server stays healthy for the next request.
142
- process.on("uncaughtException", error => {
143
- console.error(`Aurora sidecar uncaught exception: ${error?.stack || error?.message || error}`);
144
- });
138
+ function installSidecarProcessGuards() {
139
+ if (process.__auroraSidecarProcessGuardsInstalled) return;
140
+ process.__auroraSidecarProcessGuardsInstalled = true;
141
+ // The sidecar is a long-lived local proxy that Claude Code / Codex depend on
142
+ // for every request. A single bad request (e.g. a mid-stream upstream drop)
143
+ // must NOT kill the process: an orphaned sidecar with no live supervisor never
144
+ // comes back, leaving the client stuck on ConnectionRefused. Log and keep
145
+ // serving; the HTTP server stays healthy for the next request.
146
+ process.on("uncaughtException", error => {
147
+ console.error(`Aurora sidecar uncaught exception: ${error?.stack || error?.message || error}`);
148
+ });
145
149
 
146
- process.on("unhandledRejection", reason => {
147
- console.error(`Aurora sidecar unhandled rejection: ${reason?.stack || reason?.message || reason}`);
148
- });
150
+ process.on("unhandledRejection", reason => {
151
+ console.error(`Aurora sidecar unhandled rejection: ${reason?.stack || reason?.message || reason}`);
152
+ });
153
+ }
149
154
 
150
155
  async function handle(request, response, token) {
151
156
  if (!isAuthorized(request, token)) {
@@ -181,12 +186,19 @@ async function proxyModels(response, incomingURL) {
181
186
  const upstreamURL = clientVersion
182
187
  ? `${gatewayURL}/v1/aurora-cli/models?client_version=${encodeURIComponent(clientVersion)}`
183
188
  : `${gatewayURL}/v1/aurora-cli/models`;
184
- const upstream = await fetch(upstreamURL, {
185
- headers: {
186
- ...selectedKeyHeaders(state),
187
- "accept-encoding": "identity"
188
- }
189
- });
189
+ let upstream;
190
+ try {
191
+ upstream = await fetch(upstreamURL, {
192
+ headers: {
193
+ ...selectedKeyHeaders(state),
194
+ "accept-encoding": "identity"
195
+ },
196
+ signal: AbortSignal.timeout(GATEWAY_HEADER_TIMEOUT_MS)
197
+ });
198
+ } catch (error) {
199
+ writeJSON(response, 502, { error: { type: "gateway_unreachable", message: error?.message || String(error) } });
200
+ return;
201
+ }
190
202
  const payload = await upstream.json().catch(() => ({ object: "list", data: [] }));
191
203
  const sourceModels = Array.isArray(payload.data) ? payload.data : [];
192
204
  if (clientVersion) {