oc-go-usage-display 1.0.2 → 2.0.0
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/README.md +249 -68
- package/bin/lib.js +433 -29
- package/bin/oc-go-usage-display-init.js +42 -13
- package/bin/oc-go-usage-display-remove.js +38 -0
- package/bin/oc-go-usage-display-show.js +47 -39
- package/bin/oc-go-usage-display-status.js +33 -42
- package/bin/oc-go-usage-display-update.js +27 -14
- package/dist/helpers.d.ts +116 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +568 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +5 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +258 -278
- package/dist/index.js.map +1 -1
- package/dist/plugins/oc-go-usage-display.kilo.ts +678 -0
- package/dist/plugins/oc-go-usage-display.kilo.tsx +1272 -0
- package/dist/plugins/oc-go-usage-display.ts +678 -0
- package/dist/plugins/oc-go-usage-display.tsx +1018 -0
- package/dist/shared.d.ts +96 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +575 -0
- package/dist/shared.js.map +1 -0
- package/dist/tui-shared.d.ts +109 -0
- package/dist/tui-shared.d.ts.map +1 -0
- package/dist/tui-shared.js +372 -0
- package/dist/tui-shared.js.map +1 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +226 -377
- package/dist/tui.js.map +1 -1
- package/dist/tui.kilo.d.ts +8 -0
- package/dist/tui.kilo.d.ts.map +1 -0
- package/dist/tui.kilo.js +502 -0
- package/dist/tui.kilo.js.map +1 -0
- package/package.json +47 -13
- package/src/helpers.ts +733 -0
- package/src/index.ts +331 -304
- package/src/shared.ts +696 -0
- package/src/tui-shared.tsx +705 -0
- package/src/tui.kilo.tsx +816 -0
- package/src/tui.tsx +356 -465
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Remove the plugin installation: deletes the installed plugin files (symlink
|
|
3
|
+
// or copy install) and removes the server + TUI config entries for each
|
|
4
|
+
// selected host. Default: every host (removing where nothing is installed is a
|
|
5
|
+
// no-op); --target or --config-dir / --kilo-config-dir narrows it.
|
|
6
|
+
// Secrets are never touched: env vars, auth.json, and
|
|
7
|
+
// oc-go-usage-display.json stay in place (delete them by hand if desired).
|
|
8
|
+
// Restart the host(s) afterwards to pick up the change.
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
exitWithError,
|
|
12
|
+
hostDirFromArgv,
|
|
13
|
+
removePluginFiles,
|
|
14
|
+
removeServerEntry,
|
|
15
|
+
removeTuiEntry,
|
|
16
|
+
resolveRemoveTargets,
|
|
17
|
+
} from "./lib.js";
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const argv = process.argv.slice(2);
|
|
21
|
+
const targets = resolveRemoveTargets(argv);
|
|
22
|
+
|
|
23
|
+
for (const host of targets) {
|
|
24
|
+
const configDir = hostDirFromArgv(host, argv);
|
|
25
|
+
const files = removePluginFiles(configDir, host);
|
|
26
|
+
const server = removeServerEntry(configDir, { host });
|
|
27
|
+
const tui = removeTuiEntry(configDir, host);
|
|
28
|
+
|
|
29
|
+
console.log(`${host}: ${configDir}`);
|
|
30
|
+
for (const fileName of files.removed) console.log(`removed plugin file: ${fileName}`);
|
|
31
|
+
for (const fileName of files.kept) console.log(`kept non-file entry (left alone): ${fileName}`);
|
|
32
|
+
console.log(`${host} server entry: ${server.changed ? "removed" : "already absent"}`);
|
|
33
|
+
console.log(`${host} tui entry: ${tui.changed ? "removed" : "already absent"}`);
|
|
34
|
+
}
|
|
35
|
+
console.log("uninstalled (restart the host(s) to pick up the change)");
|
|
36
|
+
} catch (error) {
|
|
37
|
+
exitWithError(error);
|
|
38
|
+
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Show the effective installation: link targets, config
|
|
2
|
+
// Show the effective installation for both hosts: link targets, config
|
|
3
|
+
// entries, toggles, and detection. The top-level fields stay the opencode
|
|
4
|
+
// report (back-compat); `kilo` carries the Kilo report.
|
|
3
5
|
// Secrets are never printed; only presence (env/file) is reported.
|
|
4
6
|
|
|
5
|
-
import * as path from "node:path";
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fail,
|
|
13
|
-
openCodeDirFromArgv,
|
|
14
|
-
readJsonFile,
|
|
15
|
-
readTuiSelection,
|
|
8
|
+
HOSTS,
|
|
9
|
+
describeHostInstall,
|
|
10
|
+
detectHosts,
|
|
11
|
+
exitWithError,
|
|
12
|
+
hostDirFromArgv,
|
|
16
13
|
repoDirFromArgv,
|
|
17
14
|
secretPresence,
|
|
18
15
|
} from "./lib.js";
|
|
@@ -20,46 +17,57 @@ import {
|
|
|
20
17
|
try {
|
|
21
18
|
const argv = process.argv.slice(2);
|
|
22
19
|
const repoDir = repoDirFromArgv(argv);
|
|
23
|
-
const configDir = openCodeDirFromArgv(argv);
|
|
24
20
|
const asJson = argv.includes("--json");
|
|
21
|
+
const detected = detectHosts();
|
|
25
22
|
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const secrets = secretPresence(configDir);
|
|
23
|
+
const hosts = {};
|
|
24
|
+
for (const host of HOSTS) {
|
|
25
|
+
const configDir = hostDirFromArgv(host, argv);
|
|
26
|
+
hosts[host] = { ...describeHostInstall(host, configDir), detected: detected[host] === true };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const opencode = hosts.opencode;
|
|
30
|
+
const kilo = hosts.kilo;
|
|
31
|
+
const secrets = secretPresence(opencode.configDir);
|
|
32
|
+
const kiloSecrets = secretPresence(kilo.configDir);
|
|
37
33
|
|
|
38
34
|
const report = {
|
|
39
35
|
repoDir,
|
|
40
|
-
configDir,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
entry: tui.entry,
|
|
45
|
-
sidebar: tui.sidebar,
|
|
46
|
-
statusline: tui.statusline,
|
|
47
|
-
...tuiLink,
|
|
48
|
-
},
|
|
36
|
+
configDir: opencode.configDir,
|
|
37
|
+
detected,
|
|
38
|
+
server: opencode.server,
|
|
39
|
+
tui: opencode.tui,
|
|
49
40
|
secrets: { envPresent: secrets.envPresent, filePresent: secrets.filePresent },
|
|
41
|
+
kilo: {
|
|
42
|
+
configDir: kilo.configDir,
|
|
43
|
+
server: kilo.server,
|
|
44
|
+
tui: kilo.tui,
|
|
45
|
+
secrets: { envPresent: kiloSecrets.envPresent, filePresent: kiloSecrets.filePresent },
|
|
46
|
+
},
|
|
50
47
|
};
|
|
51
48
|
|
|
49
|
+
function describeLinkLine(label, link, entry) {
|
|
50
|
+
return `${label}: ${link.state}${link.detail ? ` -> ${link.detail}` : ""} (entry: ${entry ? "present" : "missing"})`;
|
|
51
|
+
}
|
|
52
|
+
|
|
52
53
|
if (asJson) {
|
|
53
54
|
console.log(JSON.stringify(report, null, 2));
|
|
54
55
|
} else {
|
|
55
56
|
console.log(`repo: ${repoDir}`);
|
|
56
|
-
console.log(`
|
|
57
|
-
console.log(
|
|
58
|
-
console.log(
|
|
59
|
-
console.log(`toggles: sidebar=${tui.sidebar} statusline=${tui.statusline}`);
|
|
60
|
-
console.log(
|
|
57
|
+
console.log(`opencode: ${opencode.configDir} (detected: ${detected.opencode ? "yes" : "no"})`);
|
|
58
|
+
console.log(describeLinkLine(" server", opencode.server, opencode.server.entry));
|
|
59
|
+
console.log(describeLinkLine(" tui", opencode.tui, opencode.tui.entry));
|
|
60
|
+
console.log(` toggles: sidebar=${opencode.tui.sidebar} statusline=${opencode.tui.statusline}`);
|
|
61
|
+
console.log(
|
|
62
|
+
` secrets: env=${secrets.envPresent ? "set" : "unset"} file=${secrets.filePresent ? "present" : "absent"} (values never shown)`,
|
|
63
|
+
);
|
|
64
|
+
console.log(`kilo: ${kilo.configDir} (detected: ${detected.kilo ? "yes" : "no"})`);
|
|
65
|
+
console.log(describeLinkLine(" server", kilo.server, kilo.server.entry));
|
|
66
|
+
console.log(describeLinkLine(" tui", kilo.tui, kilo.tui.entry));
|
|
67
|
+
console.log(
|
|
68
|
+
` secrets: env=${kiloSecrets.envPresent ? "set" : "unset"} file=${kiloSecrets.filePresent ? "present" : "absent"} (values never shown)`,
|
|
69
|
+
);
|
|
61
70
|
}
|
|
62
71
|
} catch (error) {
|
|
63
|
-
|
|
64
|
-
throw error;
|
|
72
|
+
exitWithError(error);
|
|
65
73
|
}
|
|
@@ -1,64 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Check the installation. Exit 0 when healthy, 1 with reasons otherwise.
|
|
3
|
-
// Verifies:
|
|
3
|
+
// Verifies: bundled plugin files (dist/plugins/*) point at this repo
|
|
4
|
+
// (symlinks verified by target, dangling symlinks reported unhealthy,
|
|
5
|
+
// plain-file copy installs accepted with a note), config entries exist,
|
|
6
|
+
// toggles set (opencode only; Kilo's tui.json rejects them).
|
|
7
|
+
// Without an explicit target it checks the hosts that have an installation and
|
|
8
|
+
// falls back to opencode.
|
|
4
9
|
|
|
5
|
-
import * as path from "node:path";
|
|
6
10
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readJsonFile,
|
|
13
|
-
SERVER_PLUGIN_REL,
|
|
14
|
-
readTuiSelection,
|
|
11
|
+
HOSTS,
|
|
12
|
+
checkHostInstall,
|
|
13
|
+
describeHostInstall,
|
|
14
|
+
exitWithError,
|
|
15
|
+
hostDirFromArgv,
|
|
15
16
|
repoDirFromArgv,
|
|
17
|
+
resolveStatusTargets,
|
|
16
18
|
} from "./lib.js";
|
|
17
19
|
|
|
18
20
|
try {
|
|
19
21
|
const argv = process.argv.slice(2);
|
|
20
22
|
const repoDir = repoDirFromArgv(argv);
|
|
21
|
-
|
|
22
|
-
const problems = [];
|
|
23
|
-
|
|
24
|
-
const expectedServer = path.join(repoDir, "src", "index.ts");
|
|
25
|
-
const expectedTui = path.join(repoDir, "src", "tui.tsx");
|
|
26
|
-
const serverLink = describeLink(path.join(configDir, "plugins", SERVER_FILE_NAME));
|
|
27
|
-
const tuiLink = describeLink(path.join(configDir, "plugins", TUI_FILE_NAME));
|
|
23
|
+
let targets = resolveStatusTargets(argv);
|
|
28
24
|
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
if (targets === null) {
|
|
26
|
+
targets = HOSTS.filter((host) => {
|
|
27
|
+
const report = describeHostInstall(host, hostDirFromArgv(host, argv));
|
|
28
|
+
return (
|
|
29
|
+
report.server.state !== "missing" ||
|
|
30
|
+
report.tui.state !== "missing" ||
|
|
31
|
+
report.server.entry ||
|
|
32
|
+
report.tui.entry
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
if (targets.length === 0) targets = ["opencode"];
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
opencodeJson.value.plugin.includes(SERVER_PLUGIN_REL);
|
|
47
|
-
if (!serverEntry) problems.push("opencode.jsonc is missing the server plugin entry");
|
|
48
|
-
|
|
49
|
-
const tui = readTuiSelection(configDir);
|
|
50
|
-
if (!tui.entry) problems.push("tui.json is missing the tui plugin entry");
|
|
51
|
-
if (tui.sidebar === null || tui.statusline === null) {
|
|
52
|
-
problems.push(`tui toggles incomplete: sidebar=${tui.sidebar} statusline=${tui.statusline}`);
|
|
38
|
+
const problems = [];
|
|
39
|
+
const notes = [];
|
|
40
|
+
for (const host of targets) {
|
|
41
|
+
const report = checkHostInstall(host, hostDirFromArgv(host, argv), repoDir);
|
|
42
|
+
for (const problem of report.problems) problems.push(`${host}: ${problem}`);
|
|
43
|
+
for (const note of report.notes) notes.push(`${host}: ${note}`);
|
|
53
44
|
}
|
|
54
45
|
|
|
55
46
|
if (problems.length > 0) {
|
|
56
47
|
for (const problem of problems) console.error(`FAIL: ${problem}`);
|
|
57
48
|
process.exitCode = 1;
|
|
58
49
|
} else {
|
|
59
|
-
console.log(`
|
|
50
|
+
for (const note of notes) console.log(`NOTE: ${note}`);
|
|
51
|
+
console.log(`OK: installed from ${repoDir} (targets: ${targets.join(", ")})`);
|
|
60
52
|
}
|
|
61
53
|
} catch (error) {
|
|
62
|
-
|
|
63
|
-
throw error;
|
|
54
|
+
exitWithError(error);
|
|
64
55
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Update the installation: re-link plugin files, re-register config entries
|
|
3
|
-
// then fast-forward the repo (only when it has a
|
|
4
|
-
// the update).
|
|
2
|
+
// Update the installation: re-link plugin files, re-register config entries
|
|
3
|
+
// for the selected host(s), then fast-forward the repo (only when it has a
|
|
4
|
+
// remote; otherwise re-link is the update). Target selection matches init.
|
|
5
|
+
// Restart the host(s) afterwards to pick up changes.
|
|
5
6
|
|
|
6
7
|
import { execFileSync } from "node:child_process";
|
|
7
8
|
import * as fs from "node:fs";
|
|
@@ -9,12 +10,14 @@ import * as path from "node:path";
|
|
|
9
10
|
import {
|
|
10
11
|
ensureServerEntry,
|
|
11
12
|
ensureTuiEntry,
|
|
13
|
+
exitWithError,
|
|
12
14
|
fail,
|
|
15
|
+
hostDirFromArgv,
|
|
13
16
|
linkModeFromArgv,
|
|
14
17
|
linkPluginFiles,
|
|
15
|
-
openCodeDirFromArgv,
|
|
16
18
|
parseOptionalToggle,
|
|
17
19
|
repoDirFromArgv,
|
|
20
|
+
selectTargets,
|
|
18
21
|
} from "./lib.js";
|
|
19
22
|
|
|
20
23
|
function hasRemote(repoDir) {
|
|
@@ -38,10 +41,13 @@ function isClean(repoDir) {
|
|
|
38
41
|
try {
|
|
39
42
|
const argv = process.argv.slice(2);
|
|
40
43
|
const repoDir = repoDirFromArgv(argv);
|
|
41
|
-
const configDir = openCodeDirFromArgv(argv);
|
|
42
44
|
const mode = linkModeFromArgv(argv);
|
|
43
45
|
const sidebar = parseOptionalToggle(argv, "--sidebar");
|
|
44
46
|
const statusline = parseOptionalToggle(argv, "--statusline");
|
|
47
|
+
const targets = selectTargets(argv);
|
|
48
|
+
if (targets.includes("kilo") && (sidebar !== null || statusline !== null)) {
|
|
49
|
+
fail("--sidebar/--statusline do not apply to kilo (its tui.json rejects those options)");
|
|
50
|
+
}
|
|
45
51
|
|
|
46
52
|
if (!fs.existsSync(path.join(repoDir, ".git"))) fail(`not a git repo: ${repoDir}`);
|
|
47
53
|
|
|
@@ -52,15 +58,22 @@ try {
|
|
|
52
58
|
console.log("no remote configured; re-linking local files (no fetch)");
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
linkPluginFiles(repoDir, configDir, mode);
|
|
56
|
-
const server = ensureServerEntry(configDir);
|
|
57
|
-
const tui = ensureTuiEntry(configDir, { sidebar, statusline });
|
|
58
|
-
|
|
59
61
|
console.log(`updated from ${repoDir} (${mode})`);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
for (const host of targets) {
|
|
63
|
+
const configDir = hostDirFromArgv(host, argv);
|
|
64
|
+
linkPluginFiles(repoDir, configDir, mode, host);
|
|
65
|
+
const server = ensureServerEntry(configDir, { host });
|
|
66
|
+
const tui = ensureTuiEntry(configDir, { sidebar, statusline, host });
|
|
67
|
+
|
|
68
|
+
console.log(`${host}: ${configDir}`);
|
|
69
|
+
console.log(`${host} server entry: ${server.present ? "present" : "missing"}`);
|
|
70
|
+
if (host === "kilo") {
|
|
71
|
+
console.log(`kilo tui entry: ${tui.entry ? "present" : "missing"}`);
|
|
72
|
+
} else {
|
|
73
|
+
console.log(`tui toggles: sidebar=${tui.sidebar} statusline=${tui.statusline}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
console.log("restart the host(s) to pick up plugin changes");
|
|
63
77
|
} catch (error) {
|
|
64
|
-
|
|
65
|
-
throw error;
|
|
78
|
+
exitWithError(error);
|
|
66
79
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ModelUsage, UsageHost, UsageSnapshot, UsageTokens, UsageWindow } from "./shared.js";
|
|
2
|
+
export declare function formatServerLine(snapshot: UsageSnapshot): string;
|
|
3
|
+
export type FileConfig = {
|
|
4
|
+
workspaceId: string | null;
|
|
5
|
+
authCookie: string | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function fileConfigPath(host?: UsageHost): string;
|
|
8
|
+
export declare function readFileConfig(host?: UsageHost): FileConfig;
|
|
9
|
+
export declare function isMalformedAuthCookie(cookie: string): boolean;
|
|
10
|
+
export declare function hasMalformedAuthCookie(fileConfig?: FileConfig, host?: UsageHost): boolean;
|
|
11
|
+
export declare const MAX_REDIRECT_HOPS = 3;
|
|
12
|
+
export type RedirectDecision = {
|
|
13
|
+
follow: true;
|
|
14
|
+
url: string;
|
|
15
|
+
} | {
|
|
16
|
+
follow: false;
|
|
17
|
+
reason: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function isAllowedRedirect(fromUrl: string, location: string): boolean;
|
|
20
|
+
export declare function resolveAllowedRedirect(fromUrl: string, location: string | null, hopsFollowed: number): RedirectDecision;
|
|
21
|
+
export type DisplayMode = "sidebar" | "statusline" | "both";
|
|
22
|
+
export type SurfaceSelection = {
|
|
23
|
+
sidebar: boolean;
|
|
24
|
+
statusline: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type UsageRow = {
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function isDisplayMode(value: unknown): value is DisplayMode;
|
|
31
|
+
export type SidebarMode = "integrated" | "standalone";
|
|
32
|
+
export declare const DEFAULT_SIDEBAR_MODE: SidebarMode;
|
|
33
|
+
export declare function parseSidebarMode(value: unknown): SidebarMode | null;
|
|
34
|
+
export type ProviderSource = {
|
|
35
|
+
config?: {
|
|
36
|
+
model?: unknown;
|
|
37
|
+
} | undefined;
|
|
38
|
+
session?: {
|
|
39
|
+
get?: ((sessionID: string) => {
|
|
40
|
+
model?: {
|
|
41
|
+
providerID?: unknown;
|
|
42
|
+
} | undefined;
|
|
43
|
+
} | undefined) | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
};
|
|
46
|
+
export declare function providerIdFromModel(model: unknown): string | undefined;
|
|
47
|
+
export declare function resolveProviderId(state: ProviderSource | undefined, sessionId: string, fallback: string | undefined): string | undefined;
|
|
48
|
+
export declare function surfaceSelectionFromDisplayMode(mode: DisplayMode): SurfaceSelection;
|
|
49
|
+
export declare function parseBooleanFlag(value: unknown): boolean | null;
|
|
50
|
+
export declare function isSnapshotEmpty(snapshot: UsageSnapshot): boolean;
|
|
51
|
+
export type ResetCountdown = {
|
|
52
|
+
label: string;
|
|
53
|
+
text: string;
|
|
54
|
+
};
|
|
55
|
+
export declare function relevantReset(snapshot: UsageSnapshot): ResetCountdown | null;
|
|
56
|
+
export declare function formatStatusline(snapshot: UsageSnapshot): string;
|
|
57
|
+
export type UsageMeterSeverity = "muted" | "warning" | "error";
|
|
58
|
+
export declare function usageMeterSeverity(window: UsageWindow): UsageMeterSeverity;
|
|
59
|
+
export declare function meterSeverityForPercent(percent: number): UsageMeterSeverity;
|
|
60
|
+
export declare function meterFillPercent(percent: number): number;
|
|
61
|
+
export type PlanRow = {
|
|
62
|
+
label: string;
|
|
63
|
+
percent: number;
|
|
64
|
+
severity: UsageMeterSeverity;
|
|
65
|
+
reset: string | null;
|
|
66
|
+
};
|
|
67
|
+
export declare function buildPlanRows(snapshot: UsageSnapshot): PlanRow[];
|
|
68
|
+
export declare function formatUsageCount(value: unknown): string;
|
|
69
|
+
export declare function formatUsageCost(value: unknown): string;
|
|
70
|
+
export declare function usageTokenCount(tokens: UsageTokens): number;
|
|
71
|
+
export declare function cacheRatePercent(tokens: UsageTokens): string;
|
|
72
|
+
export declare function goSharePercent(modelTokens: unknown, totalGoTokens: unknown): number;
|
|
73
|
+
export declare function totalGoTokens(models: readonly ModelUsage[]): number;
|
|
74
|
+
export type ModelProviderGroup = {
|
|
75
|
+
providerID: string;
|
|
76
|
+
providerName: string;
|
|
77
|
+
models: ModelUsage[];
|
|
78
|
+
};
|
|
79
|
+
export declare function groupModelsByProvider(models: readonly ModelUsage[], providerNames?: ReadonlyMap<string, string>): ModelProviderGroup[];
|
|
80
|
+
export declare function truncateModelName(value: string, max?: number): string;
|
|
81
|
+
export declare function displayModelName(name: string): string;
|
|
82
|
+
export declare function modelDisplayName(catalogName: string | null, modelID: string, max?: number): string;
|
|
83
|
+
export declare function shortModelName(value: string, max?: number): string;
|
|
84
|
+
export declare const PLAN_LABEL_WIDTH = 3;
|
|
85
|
+
export declare function formatPercentCell(percent: number, width?: number): string;
|
|
86
|
+
export declare function formatTokenCount(value: unknown): string;
|
|
87
|
+
export type GoModelWeight = {
|
|
88
|
+
providerID: string;
|
|
89
|
+
modelID: string;
|
|
90
|
+
tokens: number;
|
|
91
|
+
share: number;
|
|
92
|
+
steps: number;
|
|
93
|
+
cost: number;
|
|
94
|
+
};
|
|
95
|
+
export type GoModelWeights = {
|
|
96
|
+
models: GoModelWeight[];
|
|
97
|
+
goModels: number;
|
|
98
|
+
goTokens: number;
|
|
99
|
+
listedTokens: number;
|
|
100
|
+
listedShare: number;
|
|
101
|
+
otherCount: number;
|
|
102
|
+
steps: number;
|
|
103
|
+
cost: number;
|
|
104
|
+
};
|
|
105
|
+
export declare function weightGoModels(models: readonly ModelUsage[], limit?: number): GoModelWeights;
|
|
106
|
+
export declare function buildModelMixSummary(entries: ReadonlyArray<{
|
|
107
|
+
name: string;
|
|
108
|
+
share: number;
|
|
109
|
+
}>, budget?: number): string;
|
|
110
|
+
export declare function buildGoModelFooters(weights: GoModelWeights): string[];
|
|
111
|
+
export declare function buildTokenUsageRows(totals: {
|
|
112
|
+
cost: number;
|
|
113
|
+
tokens: UsageTokens;
|
|
114
|
+
}): UsageRow[];
|
|
115
|
+
export declare function buildModelTokenRows(tokens: UsageTokens): UsageRow[];
|
|
116
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAWlG,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAchE;AAMD,MAAM,MAAM,UAAU,GAAG;IAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEnF,wBAAgB,cAAc,CAAC,IAAI,GAAE,SAAsB,GAAG,MAAM,CAEnE;AAED,wBAAgB,cAAc,CAAC,IAAI,GAAE,SAAsB,GAAG,UAAU,CAkBvE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,UAA6B,EACzC,IAAI,GAAE,SAA8B,GACnC,OAAO,CAIT;AAiBD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,MAAM,MAAM,gBAAgB,GACxB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA6CtC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5E;AAID,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,YAAY,EAAE,MAAM,GACn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