opencode-usage 0.5.2 → 0.5.4
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/commander-ui/assets/index-BQeHKMP0.css +1 -0
- package/dist/commander-ui/assets/index-ybRDM9XN.js +20 -0
- package/dist/commander-ui/assets/instrument-sans-latin-ext-wght-normal-B5bTHO_g.woff2 +0 -0
- package/dist/commander-ui/assets/instrument-sans-latin-wght-normal-BbzFLZTg.woff2 +0 -0
- package/dist/commander-ui/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/commander-ui/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/commander-ui/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/commander-ui/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/commander-ui/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/commander-ui/dist/assets/index-BQeHKMP0.css +1 -0
- package/dist/commander-ui/dist/assets/index-ybRDM9XN.js +20 -0
- package/dist/commander-ui/dist/assets/instrument-sans-latin-ext-wght-normal-B5bTHO_g.woff2 +0 -0
- package/dist/commander-ui/dist/assets/instrument-sans-latin-wght-normal-BbzFLZTg.woff2 +0 -0
- package/dist/commander-ui/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/commander-ui/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/commander-ui/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/commander-ui/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/commander-ui/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/commander-ui/dist/index.html +23 -0
- package/dist/commander-ui/dist/vite.svg +1 -0
- package/dist/commander-ui/index.html +23 -0
- package/dist/commander-ui/vite.svg +1 -0
- package/dist/index.js +124 -32
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>commander-ui</title>
|
|
8
|
+
<script>
|
|
9
|
+
(function () {
|
|
10
|
+
var t = localStorage.getItem("commander-theme");
|
|
11
|
+
var d =
|
|
12
|
+
t === "dark" ||
|
|
13
|
+
(t !== "light" && matchMedia("(prefers-color-scheme:dark)").matches);
|
|
14
|
+
if (d) document.documentElement.classList.add("dark");
|
|
15
|
+
})();
|
|
16
|
+
</script>
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-ybRDM9XN.js"></script>
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BQeHKMP0.css">
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="root"></div>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>commander-ui</title>
|
|
8
|
+
<script>
|
|
9
|
+
(function () {
|
|
10
|
+
var t = localStorage.getItem("commander-theme");
|
|
11
|
+
var d =
|
|
12
|
+
t === "dark" ||
|
|
13
|
+
(t !== "light" && matchMedia("(prefers-color-scheme:dark)").matches);
|
|
14
|
+
if (d) document.documentElement.classList.add("dark");
|
|
15
|
+
})();
|
|
16
|
+
</script>
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-ybRDM9XN.js"></script>
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BQeHKMP0.css">
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="root"></div>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/dist/index.js
CHANGED
|
@@ -241,36 +241,106 @@ function resolveSource2(provider) {
|
|
|
241
241
|
}
|
|
242
242
|
return source;
|
|
243
243
|
}
|
|
244
|
+
async function directCodexPing(alias) {
|
|
245
|
+
console.log(`[directCodexPing] pinging "${alias}"\u2026`);
|
|
246
|
+
const STORE_PATHS = [
|
|
247
|
+
join8(homedir6(), ".config", "opencode", "codex-multi-account-accounts.json"),
|
|
248
|
+
join8(homedir6(), ".config", "opencode", "codex-multi-accounts.json"),
|
|
249
|
+
join8(homedir6(), ".config", "oc-codex-multi-account", "accounts.json")
|
|
250
|
+
];
|
|
251
|
+
let store = null;
|
|
252
|
+
for (const p of STORE_PATHS) {
|
|
253
|
+
try {
|
|
254
|
+
store = JSON.parse(await Bun.file(p).text());
|
|
255
|
+
break;
|
|
256
|
+
} catch {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (!store)
|
|
261
|
+
return { status: "error", error: "No codex store found" };
|
|
262
|
+
console.log(`[directCodexPing] found account "${alias}", calling ChatGPT Codex API\u2026`);
|
|
263
|
+
const accounts = store.accounts ?? {};
|
|
264
|
+
const account = accounts[alias];
|
|
265
|
+
if (!account)
|
|
266
|
+
return { status: "error", error: `Account "${alias}" not found` };
|
|
267
|
+
const token = account.accessToken;
|
|
268
|
+
const accountId = account.accountId;
|
|
269
|
+
if (typeof token !== "string" || !token) {
|
|
270
|
+
return { status: "error", error: "Missing access token" };
|
|
271
|
+
}
|
|
272
|
+
if (typeof accountId !== "string" || !accountId) {
|
|
273
|
+
return { status: "error", error: "Missing accountId" };
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const res = await fetch("https://chatgpt.com/backend-api/codex/responses", {
|
|
277
|
+
method: "POST",
|
|
278
|
+
headers: {
|
|
279
|
+
Authorization: `Bearer ${token}`,
|
|
280
|
+
"Content-Type": "application/json",
|
|
281
|
+
"chatgpt-account-id": accountId,
|
|
282
|
+
"OpenAI-Beta": "responses=experimental",
|
|
283
|
+
originator: "codex_cli_rs",
|
|
284
|
+
accept: "text/event-stream"
|
|
285
|
+
},
|
|
286
|
+
body: JSON.stringify({
|
|
287
|
+
model: "gpt-5.3-codex",
|
|
288
|
+
instructions: "reply ok",
|
|
289
|
+
input: [{ type: "message", role: "user", content: "hi" }],
|
|
290
|
+
store: false,
|
|
291
|
+
stream: true
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
if (res.ok || res.status === 429) {
|
|
295
|
+
console.log(`[directCodexPing] "${alias}" \u2192 ok (HTTP ${res.status})`);
|
|
296
|
+
return { status: "ok" };
|
|
297
|
+
}
|
|
298
|
+
if (res.status === 401 || res.status === 403) {
|
|
299
|
+
console.log(`[directCodexPing] "${alias}" \u2192 expired (HTTP ${res.status})`);
|
|
300
|
+
return { status: "expired", error: `HTTP ${res.status}` };
|
|
301
|
+
}
|
|
302
|
+
console.log(`[directCodexPing] "${alias}" \u2192 error (HTTP ${res.status})`);
|
|
303
|
+
return { status: "error", error: `HTTP ${res.status}` };
|
|
304
|
+
} catch (err) {
|
|
305
|
+
return {
|
|
306
|
+
status: "error",
|
|
307
|
+
error: err instanceof Error ? err.message : String(err)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
244
311
|
async function readCredentialFile(filename) {
|
|
245
312
|
const filePath = join8(homedir6(), ".config", "opencode", filename);
|
|
246
313
|
const text = await Bun.file(filePath).text();
|
|
247
314
|
return JSON.parse(text);
|
|
248
315
|
}
|
|
249
316
|
async function spawnPluginCli(command, args, timeoutMs = 15000) {
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
317
|
+
const candidates = [
|
|
318
|
+
`./node_modules/${command}/dist/cli.js`,
|
|
319
|
+
join8(homedir6(), ".config", "opencode", "node_modules", command, "dist", "cli.js")
|
|
320
|
+
];
|
|
321
|
+
let localBin = null;
|
|
322
|
+
for (const c of candidates) {
|
|
323
|
+
if (await Bun.file(c).exists()) {
|
|
324
|
+
localBin = c;
|
|
325
|
+
break;
|
|
258
326
|
}
|
|
259
|
-
|
|
260
|
-
|
|
327
|
+
}
|
|
328
|
+
const useLocal = localBin !== null;
|
|
329
|
+
if (!useLocal) {
|
|
330
|
+
const prev = bunxQueue.get(command) ?? Promise.resolve();
|
|
331
|
+
const run = prev.catch(() => {
|
|
332
|
+
}).then(() => runPluginCli(command, args, timeoutMs, null));
|
|
333
|
+
bunxQueue.set(command, run.then(() => {
|
|
261
334
|
}, () => {
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
barrier.finally(() => bunxBarrier.delete(command));
|
|
265
|
-
return warmup;
|
|
335
|
+
}));
|
|
336
|
+
return run;
|
|
266
337
|
}
|
|
267
|
-
return runPluginCli(command, args, timeoutMs,
|
|
338
|
+
return runPluginCli(command, args, timeoutMs, localBin);
|
|
268
339
|
}
|
|
269
|
-
async function runPluginCli(command, args, timeoutMs,
|
|
340
|
+
async function runPluginCli(command, args, timeoutMs, localBin) {
|
|
270
341
|
const t0 = Date.now();
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
const cwd = useLocal ? undefined : join8(tmpdir(), `bunx-${crypto.randomUUID()}`);
|
|
342
|
+
const cmd = localBin ? ["bun", localBin, ...args] : ["bunx", `${command}@latest`, ...args];
|
|
343
|
+
const cwd = localBin ? undefined : join8(tmpdir(), `bunx-${crypto.randomUUID()}`);
|
|
274
344
|
if (cwd)
|
|
275
345
|
await Bun.$`mkdir -p ${cwd}`.quiet();
|
|
276
346
|
console.log(`[spawnPluginCli] starting: ${cmd.join(" ")}`);
|
|
@@ -391,7 +461,7 @@ function reauthCliCommand(provider) {
|
|
|
391
461
|
throw new Error(`Re-auth not supported for provider: ${provider}`);
|
|
392
462
|
return cmd;
|
|
393
463
|
}
|
|
394
|
-
var isBun4, PROVIDER_SOURCE,
|
|
464
|
+
var isBun4, PROVIDER_SOURCE, bunxQueue, REAUTH_PROVIDERS;
|
|
395
465
|
var init_plugin_adapters = __esm(() => {
|
|
396
466
|
init_command_runner();
|
|
397
467
|
init_config_service();
|
|
@@ -492,7 +562,7 @@ var init_plugin_adapters = __esm(() => {
|
|
|
492
562
|
return { ok: true };
|
|
493
563
|
}
|
|
494
564
|
});
|
|
495
|
-
|
|
565
|
+
bunxQueue = new Map;
|
|
496
566
|
registerCommand({
|
|
497
567
|
id: "accounts.ping",
|
|
498
568
|
timeoutMs: 30000,
|
|
@@ -527,19 +597,41 @@ var init_plugin_adapters = __esm(() => {
|
|
|
527
597
|
};
|
|
528
598
|
}
|
|
529
599
|
case "codex": {
|
|
530
|
-
ctx.log("info",
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
]);
|
|
535
|
-
const status = String(result.status ?? "error");
|
|
536
|
-
ctx.log("info", `Result: ${status}`);
|
|
537
|
-
if (status === "ok") {
|
|
600
|
+
ctx.log("info", `Direct-pinging codex account "${input.alias}"\u2026`);
|
|
601
|
+
const direct = await directCodexPing(input.alias);
|
|
602
|
+
ctx.log("info", `Direct ping result: ${direct.status}`);
|
|
603
|
+
if (direct.status === "ok") {
|
|
538
604
|
await clearStaleMetrics(input.provider, input.alias);
|
|
605
|
+
return { status: "ok", message: "pong" };
|
|
606
|
+
}
|
|
607
|
+
if (direct.status === "expired") {
|
|
608
|
+
ctx.log("info", "Token expired \u2014 trying plugin CLI for refresh\u2026");
|
|
609
|
+
try {
|
|
610
|
+
const result = await spawnPluginCli("oc-codex-multi-account", [
|
|
611
|
+
"ping",
|
|
612
|
+
input.alias
|
|
613
|
+
]);
|
|
614
|
+
const cliStatus = String(result.status ?? "error");
|
|
615
|
+
ctx.log("info", `Plugin CLI result: ${cliStatus}`);
|
|
616
|
+
if (cliStatus === "ok") {
|
|
617
|
+
await clearStaleMetrics(input.provider, input.alias);
|
|
618
|
+
return { status: "ok", message: "pong (token refreshed)" };
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
status: cliStatus,
|
|
622
|
+
message: String(result.error ?? "Token refresh failed")
|
|
623
|
+
};
|
|
624
|
+
} catch (cliErr) {
|
|
625
|
+
ctx.log("info", `Plugin CLI failed: ${cliErr instanceof Error ? cliErr.message : String(cliErr)}`);
|
|
626
|
+
return {
|
|
627
|
+
status: "error",
|
|
628
|
+
message: direct.error ?? "Token expired and plugin refresh failed"
|
|
629
|
+
};
|
|
630
|
+
}
|
|
539
631
|
}
|
|
540
632
|
return {
|
|
541
|
-
status,
|
|
542
|
-
message:
|
|
633
|
+
status: "error",
|
|
634
|
+
message: direct.error ?? "unknown error"
|
|
543
635
|
};
|
|
544
636
|
}
|
|
545
637
|
case "antigravity": {
|
|
@@ -30887,4 +30979,4 @@ async function main2() {
|
|
|
30887
30979
|
var WATCH_INTERVAL_MS = 5 * 60 * 1000;
|
|
30888
30980
|
main2().catch(console.error);
|
|
30889
30981
|
|
|
30890
|
-
//# debugId=
|
|
30982
|
+
//# debugId=E047BEB14D24A3D264756E2164756E21
|