opencode-copilot-account-switcher 0.14.17 → 0.14.19
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 +25 -1
- package/package.json +1 -1
package/dist/plugin-hooks.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { appendFileSync } from "node:fs";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
+
import { OpencodeClient as OpencodeV2Client } from "@opencode-ai/sdk/v2/client";
|
|
4
5
|
import { createCompactionLoopSafetyBypass, createLoopSafetySystemTransform, getLoopSafetyProviderScope, } from "./loop-safety-plugin.js";
|
|
5
6
|
import { COPILOT_PROVIDER_DESCRIPTOR } from "./providers/descriptor.js";
|
|
6
7
|
import { CODEX_PROVIDER_DESCRIPTOR } from "./providers/descriptor.js";
|
|
@@ -326,6 +327,29 @@ function hasWechatBridgeClientShape(value) {
|
|
|
326
327
|
&& typeof client.question?.list === "function"
|
|
327
328
|
&& typeof client.permission?.list === "function";
|
|
328
329
|
}
|
|
330
|
+
function hasWechatBridgeSessionShape(value) {
|
|
331
|
+
if (typeof value !== "object" || value === null)
|
|
332
|
+
return false;
|
|
333
|
+
const client = value;
|
|
334
|
+
return typeof client.session?.list === "function"
|
|
335
|
+
&& typeof client.session?.status === "function"
|
|
336
|
+
&& typeof client.session?.todo === "function"
|
|
337
|
+
&& typeof client.session?.messages === "function";
|
|
338
|
+
}
|
|
339
|
+
function toWechatBridgeClient(value) {
|
|
340
|
+
if (hasWechatBridgeClientShape(value)) {
|
|
341
|
+
return value;
|
|
342
|
+
}
|
|
343
|
+
if (!hasWechatBridgeSessionShape(value)) {
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
const transport = value._client;
|
|
347
|
+
if (typeof transport !== "object" || transport === null) {
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
const wrapped = new OpencodeV2Client({ client: transport });
|
|
351
|
+
return hasWechatBridgeClientShape(wrapped) ? wrapped : undefined;
|
|
352
|
+
}
|
|
329
353
|
function sanitizeLoggedRequestHeadersRecord(headers) {
|
|
330
354
|
const sanitized = { ...headers };
|
|
331
355
|
if (typeof sanitized.authorization === "string" && sanitized.authorization.length > 0) {
|
|
@@ -586,7 +610,7 @@ export function buildPluginHooks(input) {
|
|
|
586
610
|
const triggerBillingCompensation = input.triggerBillingCompensation ?? (async () => { });
|
|
587
611
|
const ensureWechatBrokerStarted = input.ensureWechatBrokerStarted ?? (async () => connectOrSpawnBroker());
|
|
588
612
|
const createWechatBridgeLifecycleImpl = input.createWechatBridgeLifecycleImpl ?? createWechatBridgeLifecycle;
|
|
589
|
-
const wechatBridgeClient =
|
|
613
|
+
const wechatBridgeClient = toWechatBridgeClient(input.client);
|
|
590
614
|
if (wechatBridgeClient) {
|
|
591
615
|
void showStatusToast({
|
|
592
616
|
client: input.client,
|