opencode-copilot-account-switcher 0.14.16 → 0.14.17
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.
|
@@ -26,10 +26,10 @@ type LaunchOptions = {
|
|
|
26
26
|
onLockAcquired?: (lock: LaunchLockContent) => void;
|
|
27
27
|
};
|
|
28
28
|
type ResolveBrokerSpawnCommandOptions = {
|
|
29
|
-
platform?: NodeJS.Platform;
|
|
30
29
|
execPath?: string;
|
|
31
|
-
bunPathExists?: (candidate: string) => boolean;
|
|
32
30
|
};
|
|
31
|
+
type ResolveBrokerSpawnEnv = NodeJS.ProcessEnv;
|
|
32
|
+
export declare function resolveBrokerSpawnEnv(env?: ResolveBrokerSpawnEnv): NodeJS.ProcessEnv;
|
|
33
33
|
export { createDefaultBrokerEndpoint };
|
|
34
34
|
export declare function resolveBrokerSpawnCommand(options?: ResolveBrokerSpawnCommandOptions): string;
|
|
35
35
|
export declare function connectOrSpawnBroker(options?: LaunchOptions): Promise<BrokerMetadata>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
3
|
import { mkdir, open, readFile, rm } from "node:fs/promises";
|
|
5
4
|
import { spawn } from "node:child_process";
|
|
6
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -9,6 +8,12 @@ import { wechatStateRoot } from "./state-paths.js";
|
|
|
9
8
|
import { parseEnvelopeLine, serializeEnvelope } from "./protocol.js";
|
|
10
9
|
const DEFAULT_BACKOFF_MS = 250;
|
|
11
10
|
const DEFAULT_MAX_ATTEMPTS = 20;
|
|
11
|
+
export function resolveBrokerSpawnEnv(env = process.env) {
|
|
12
|
+
return {
|
|
13
|
+
...env,
|
|
14
|
+
BUN_BE_BUN: "1",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
12
17
|
function isNonEmptyString(value) {
|
|
13
18
|
return typeof value === "string" && value.trim().length > 0;
|
|
14
19
|
}
|
|
@@ -20,17 +25,8 @@ function delay(ms) {
|
|
|
20
25
|
}
|
|
21
26
|
export { createDefaultBrokerEndpoint };
|
|
22
27
|
export function resolveBrokerSpawnCommand(options = {}) {
|
|
23
|
-
const platform = options.platform ?? process.platform;
|
|
24
28
|
const execPath = options.execPath ?? process.execPath;
|
|
25
|
-
|
|
26
|
-
if (platform !== "win32") {
|
|
27
|
-
return execPath;
|
|
28
|
-
}
|
|
29
|
-
if (path.win32.basename(execPath).toLowerCase() !== "opencode.exe") {
|
|
30
|
-
return execPath;
|
|
31
|
-
}
|
|
32
|
-
const bunPath = path.win32.join(path.win32.dirname(execPath), "bun.exe");
|
|
33
|
-
return bunPathExists(bunPath) ? bunPath : execPath;
|
|
29
|
+
return execPath;
|
|
34
30
|
}
|
|
35
31
|
async function readCurrentPackageVersion() {
|
|
36
32
|
try {
|
|
@@ -163,6 +159,7 @@ function defaultSpawnImpl(endpoint, stateRoot) {
|
|
|
163
159
|
const child = spawn(resolveBrokerSpawnCommand(), [entry, `--endpoint=${endpoint}`, `--state-root=${stateRoot}`], {
|
|
164
160
|
cwd: path.resolve(fileURLToPath(new URL("../..", import.meta.url))),
|
|
165
161
|
detached: true,
|
|
162
|
+
env: resolveBrokerSpawnEnv(process.env),
|
|
166
163
|
stdio: "ignore",
|
|
167
164
|
});
|
|
168
165
|
child.unref();
|