opencode-copilot-account-switcher 0.14.16 → 0.14.18
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/dist/plugin-hooks.js
CHANGED
|
@@ -322,9 +322,7 @@ function hasWechatBridgeClientShape(value) {
|
|
|
322
322
|
return typeof client.session?.list === "function"
|
|
323
323
|
&& typeof client.session?.status === "function"
|
|
324
324
|
&& typeof client.session?.todo === "function"
|
|
325
|
-
&& typeof client.session?.messages === "function"
|
|
326
|
-
&& typeof client.question?.list === "function"
|
|
327
|
-
&& typeof client.permission?.list === "function";
|
|
325
|
+
&& typeof client.session?.messages === "function";
|
|
328
326
|
}
|
|
329
327
|
function sanitizeLoggedRequestHeadersRecord(headers) {
|
|
330
328
|
const sanitized = { ...headers };
|
package/dist/wechat/bridge.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ type WechatBridgeClient = {
|
|
|
14
14
|
todo: (sessionID: string) => Promise<Todo[]>;
|
|
15
15
|
messages: (sessionID: string) => Promise<SessionMessages>;
|
|
16
16
|
};
|
|
17
|
-
question
|
|
18
|
-
list
|
|
17
|
+
question?: {
|
|
18
|
+
list?: () => Promise<QuestionRequest[]>;
|
|
19
19
|
};
|
|
20
|
-
permission
|
|
21
|
-
list
|
|
20
|
+
permission?: {
|
|
21
|
+
list?: () => Promise<PermissionRequest[]>;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
export type InstanceUnavailableKind = "sessionStatus" | "questionList" | "permissionList";
|
package/dist/wechat/bridge.js
CHANGED
|
@@ -72,11 +72,17 @@ export function createWechatBridge(input) {
|
|
|
72
72
|
? Math.max(1, Math.floor(input.liveReadTimeoutMs))
|
|
73
73
|
: DEFAULT_LIVE_READ_TIMEOUT_MS;
|
|
74
74
|
const unavailable = new Set();
|
|
75
|
+
const questionList = input.client.question?.list;
|
|
76
|
+
const permissionList = input.client.permission?.list;
|
|
75
77
|
const [sessionListResult, statusResult, questionResult, permissionResult] = await Promise.allSettled([
|
|
76
78
|
withTimeout(() => input.client.session.list(), liveReadTimeoutMs, "session.list"),
|
|
77
79
|
withTimeout(() => input.client.session.status(), liveReadTimeoutMs, "session.status"),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
typeof questionList === "function"
|
|
81
|
+
? withTimeout(() => questionList(), liveReadTimeoutMs, "question.list")
|
|
82
|
+
: Promise.reject(new Error("question.list unavailable")),
|
|
83
|
+
typeof permissionList === "function"
|
|
84
|
+
? withTimeout(() => permissionList(), liveReadTimeoutMs, "permission.list")
|
|
85
|
+
: Promise.reject(new Error("permission.list unavailable")),
|
|
80
86
|
]);
|
|
81
87
|
const sessions = sessionListResult.status === "fulfilled" ? sessionListResult.value : [];
|
|
82
88
|
const recentSessions = pickRecentSessions(sessions, 3);
|
|
@@ -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();
|