opencode-copilot-account-switcher 0.14.15 → 0.14.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.
|
@@ -25,5 +25,11 @@ type LaunchOptions = {
|
|
|
25
25
|
pingImpl?: (endpoint: string) => Promise<boolean>;
|
|
26
26
|
onLockAcquired?: (lock: LaunchLockContent) => void;
|
|
27
27
|
};
|
|
28
|
+
type ResolveBrokerSpawnCommandOptions = {
|
|
29
|
+
platform?: NodeJS.Platform;
|
|
30
|
+
execPath?: string;
|
|
31
|
+
bunPathExists?: (candidate: string) => boolean;
|
|
32
|
+
};
|
|
28
33
|
export { createDefaultBrokerEndpoint };
|
|
34
|
+
export declare function resolveBrokerSpawnCommand(options?: ResolveBrokerSpawnCommandOptions): string;
|
|
29
35
|
export declare function connectOrSpawnBroker(options?: LaunchOptions): Promise<BrokerMetadata>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
3
4
|
import { mkdir, open, readFile, rm } from "node:fs/promises";
|
|
4
5
|
import { spawn } from "node:child_process";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -18,6 +19,19 @@ function delay(ms) {
|
|
|
18
19
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
19
20
|
}
|
|
20
21
|
export { createDefaultBrokerEndpoint };
|
|
22
|
+
export function resolveBrokerSpawnCommand(options = {}) {
|
|
23
|
+
const platform = options.platform ?? process.platform;
|
|
24
|
+
const execPath = options.execPath ?? process.execPath;
|
|
25
|
+
const bunPathExists = options.bunPathExists ?? existsSync;
|
|
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;
|
|
34
|
+
}
|
|
21
35
|
async function readCurrentPackageVersion() {
|
|
22
36
|
try {
|
|
23
37
|
const packageJsonPath = new URL("../../package.json", import.meta.url);
|
|
@@ -146,7 +160,7 @@ async function isBrokerAlive(brokerFilePath, pingImpl, expectedVersion) {
|
|
|
146
160
|
}
|
|
147
161
|
function defaultSpawnImpl(endpoint, stateRoot) {
|
|
148
162
|
const entry = fileURLToPath(new URL("./broker-entry.js", import.meta.url));
|
|
149
|
-
const child = spawn(
|
|
163
|
+
const child = spawn(resolveBrokerSpawnCommand(), [entry, `--endpoint=${endpoint}`, `--state-root=${stateRoot}`], {
|
|
150
164
|
cwd: path.resolve(fileURLToPath(new URL("../..", import.meta.url))),
|
|
151
165
|
detached: true,
|
|
152
166
|
stdio: "ignore",
|