codex-copilot-dx 0.10.1 → 1.1.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 +18 -17
- package/bin/cli.mjs +24 -3
- package/docs/ARCHITECTURE.md +60 -14
- package/docs/README.md +3 -0
- package/docs/REFERENCE.md +186 -45
- package/package.json +2 -2
- package/src/adapter.mjs +19 -4
- package/src/browser-launch.mjs +22 -0
- package/src/claude-client-config.mjs +22 -5
- package/src/claude-gateway.mjs +30 -8
- package/src/claude-models.mjs +26 -0
- package/src/cli-animation.mjs +1 -1
- package/src/cli-image.mjs +3 -0
- package/src/cli-m365.mjs +1 -1
- package/src/cli-options.mjs +11 -6
- package/src/cli-table.mjs +1 -1
- package/src/client-integration.mjs +5 -1
- package/src/dashboard/console.js +141 -0
- package/src/dashboard/index.html +105 -52
- package/src/dashboard/language.js +103 -0
- package/src/dashboard/refresh.js +2 -1
- package/src/dashboard/status.js +60 -29
- package/src/dashboard/ui.css +49 -0
- package/src/dashboard/ui.js +113 -26
- package/src/dashboard-api.mjs +72 -7
- package/src/dashboard.mjs +1 -0
- package/src/image-mcp.mjs +9 -6
- package/src/live-models.mjs +11 -3
- package/src/log.mjs +13 -11
- package/src/m365-settings.mjs +0 -2
- package/src/native-prediction-recovery.mjs +1 -0
- package/src/native-prediction.mjs +6 -2
- package/src/observability.mjs +8 -1
- package/src/optional-routes.mjs +2 -2
- package/src/provider-metadata.mjs +21 -0
- package/src/provider-runtime.mjs +80 -26
- package/src/providers/m365-auth.mjs +4 -4
- package/src/providers/m365.mjs +10 -2
- package/src/response-failures.mjs +1 -1
- package/src/service-control.mjs +60 -0
- package/src/startup-ui.mjs +4 -3
- package/src/terminal-console.mjs +87 -0
- package/src/usage-analysis.mjs +1 -1
- package/src/usage-analytics.mjs +3 -3
- package/src/usage-store.mjs +40 -17
- package/src/usage.mjs +14 -7
- package/src/user-settings.mjs +21 -0
package/src/usage.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { cliOutputFormat, cliOutputWidth, formatResponsiveCliTable, terminalCell } from "./cli-table.mjs";
|
|
2
|
-
import { cacheReadTokens, summarizeUsageLogs, usageCacheHitRate, usageLogPath } from "./usage-store.mjs";
|
|
2
|
+
import { cacheReadTokens, summarizeUsageLogs, usageCacheHitRate, usageLogPath, usageModelGroups } from "./usage-store.mjs";
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
5
|
usageSummaryVersion,
|
|
6
6
|
usageLoggingStats,
|
|
7
|
+
runtimeUsageSnapshot,
|
|
7
8
|
usageLogPath,
|
|
8
9
|
usageLogMaxBytes,
|
|
9
10
|
buildResponsesUsageRecord,
|
|
10
11
|
buildMessagesUsageRecord,
|
|
11
12
|
usageProvider,
|
|
13
|
+
usageModelGroups,
|
|
12
14
|
recordUsage,
|
|
13
15
|
recordResponsesUsage,
|
|
14
16
|
flushUsageWritesForTests,
|
|
@@ -33,10 +35,16 @@ function cacheHitPercent(usage) {
|
|
|
33
35
|
return rate === null ? "—" : `${usage.cache_hit_unknown_requests > 0 ? "~" : ""}${(rate * 100).toFixed(1)}%`;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
function providerSummaryLines(summary) {
|
|
39
|
+
if (summary.provider_filter) return [`Provider: ${summary.provider_filter}`];
|
|
40
|
+
const sources = Object.entries(summary.providers || {}).filter(([, count]) => count > 0);
|
|
41
|
+
return sources.some(([id]) => id !== "github")
|
|
42
|
+
? [`Providers: ${sources.map(([id, count]) => `${id} ${fmt(count)}`).join(" / ")} (combined totals; use --provider to separate)`] : [];
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
function formatPlainUsageSummary(summary, filePath, { sanitize = false } = {}) {
|
|
37
46
|
const lines = [`Usage log: ${filePath}`];
|
|
38
|
-
|
|
39
|
-
else if (summary.providers?.m365) lines.push(`Providers: GitHub ${fmt(summary.providers.github)} / M365 ${fmt(summary.providers.m365)} (combined totals; use --provider to separate)`);
|
|
47
|
+
lines.push(...providerSummaryLines(summary));
|
|
40
48
|
if (summary.requests === 0) {
|
|
41
49
|
lines.push("No usage records yet.");
|
|
42
50
|
return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
|
|
@@ -48,7 +56,7 @@ function formatPlainUsageSummary(summary, filePath, { sanitize = false } = {}) {
|
|
|
48
56
|
"",
|
|
49
57
|
"By model:",
|
|
50
58
|
);
|
|
51
|
-
for (const [model, row] of Object.entries(summary
|
|
59
|
+
for (const [model, row] of Object.entries(usageModelGroups(summary))) {
|
|
52
60
|
lines.push(` ${model}: requests=${fmt(row.requests)} input=${fmt(row.input_tokens)} cache_read=${fmt(cacheReadTokens(row))} output=${fmt(row.output_tokens)} total=${fmt(row.total_tokens)} cache_hit=${cacheHitPercent(row)}`);
|
|
53
61
|
}
|
|
54
62
|
return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
|
|
@@ -89,7 +97,7 @@ function formatTableUsageSummary(summary, filePath, output) {
|
|
|
89
97
|
{ key: "total", label: "TOTAL", align: "right" },
|
|
90
98
|
];
|
|
91
99
|
const compactColumns = [columns[0], columns[1], columns[5]];
|
|
92
|
-
const modelUsage = Object.entries(summary
|
|
100
|
+
const modelUsage = Object.entries(usageModelGroups(summary))
|
|
93
101
|
.map(([model, row]) => ({ model, row }))
|
|
94
102
|
.sort(compareModelUsage);
|
|
95
103
|
const totalUsage = { requests: summary.requests, ...summary.totals };
|
|
@@ -107,8 +115,7 @@ function formatTableUsageSummary(summary, filePath, output) {
|
|
|
107
115
|
} else {
|
|
108
116
|
table.compact = false;
|
|
109
117
|
}
|
|
110
|
-
const lines = [`Usage log: ${safePath}`, ...(summary
|
|
111
|
-
: summary.providers?.m365 ? [`Providers: GitHub ${fmt(summary.providers.github)} / M365 ${fmt(summary.providers.m365)} (combined totals; use --provider to separate)`] : []), "", table.output];
|
|
118
|
+
const lines = [`Usage log: ${safePath}`, ...providerSummaryLines(summary), "", table.output];
|
|
112
119
|
if (table.compact) {
|
|
113
120
|
lines.push(
|
|
114
121
|
"",
|
package/src/user-settings.mjs
CHANGED
|
@@ -22,6 +22,7 @@ const AUTO_REVIEW_REASONING_KEY = "auto_review_reasoning";
|
|
|
22
22
|
const TERMINAL_ANIMATION_KEY = "terminal_animation";
|
|
23
23
|
const RESPONSE_HISTORY_MAX_MIB_KEY = "response_history_max_mib";
|
|
24
24
|
const DECODED_BODY_LIMIT_MIB_KEY = "decoded_body_limit_mib";
|
|
25
|
+
const SERVICE_FLAGS = ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"];
|
|
25
26
|
export const DECODED_BODY_LIMIT_MIN_MIB = RUNTIME_DEFAULTS.maxDecodedBodyBytes / MIB;
|
|
26
27
|
export const DECODED_BODY_LIMIT_MAX_MIB = 512;
|
|
27
28
|
export { RESPONSE_HISTORY_MAX_MIB, RESPONSE_HISTORY_MIN_MIB };
|
|
@@ -43,6 +44,12 @@ export function readUserSettings({ env = process.env, home = os.homedir(), stric
|
|
|
43
44
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
44
45
|
throw invalidSettings(filePath, "expected a JSON object");
|
|
45
46
|
}
|
|
47
|
+
for (const key of SERVICE_FLAGS) {
|
|
48
|
+
if (Object.hasOwn(parsed, key) && typeof parsed[key] !== "boolean") {
|
|
49
|
+
if (strict) throw invalidSettings(filePath, `${key} must be a boolean`);
|
|
50
|
+
delete parsed[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
46
53
|
if (Object.hasOwn(parsed, AUTO_REVIEW_MODEL_KEY)) {
|
|
47
54
|
const value = parsed[AUTO_REVIEW_MODEL_KEY];
|
|
48
55
|
if (typeof value !== "string" || !value.trim()) {
|
|
@@ -107,6 +114,20 @@ export function savedAutoReviewModel(options = {}) {
|
|
|
107
114
|
return String(settings[AUTO_REVIEW_MODEL_KEY] || "").trim();
|
|
108
115
|
}
|
|
109
116
|
|
|
117
|
+
export function servicePreferences(options = {}) {
|
|
118
|
+
const settings = readUserSettings({ ...options, strict: true });
|
|
119
|
+
return Object.fromEntries(SERVICE_FLAGS.map(key => [key, settings[key] !== false]));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function writeServicePreference(key, value, options = {}) {
|
|
123
|
+
if (!SERVICE_FLAGS.includes(key) || typeof value !== "boolean") throw new Error("Unknown service setting or invalid boolean");
|
|
124
|
+
return withFileLockSync(`${userSettingsPath(options)}.lock`, () => {
|
|
125
|
+
const settings = readUserSettings({ ...options, strict: true });
|
|
126
|
+
const changed = atomicWriteFileIfChangedSync(userSettingsPath(options), `${JSON.stringify({ ...settings, [key]: value }, null, 2)}\n`, { mode: 0o600 });
|
|
127
|
+
return { changed, ...servicePreferences(options) };
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
110
131
|
export function autoReviewModelPreference({ env = process.env, home = os.homedir() } = {}) {
|
|
111
132
|
const { model, source } = autoReviewPreference({ env, home });
|
|
112
133
|
return { model, source };
|