codex-copilot-dx 1.2.6 → 1.2.8
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 +5 -5
- package/bin/cli.mjs +42 -2
- package/docs/ARCHITECTURE.md +13 -1
- package/docs/README.md +5 -0
- package/docs/REFERENCE.md +31 -7
- package/package.json +1 -1
- package/src/account-tools.mjs +121 -0
- package/src/adapter.mjs +2 -0
- package/src/auth-credentials.mjs +18 -8
- package/src/auth-status.mjs +21 -7
- package/src/auth.mjs +1 -0
- package/src/claude-gateway.mjs +2 -2
- package/src/cli-auth.mjs +38 -1
- package/src/cli-options.mjs +46 -13
- package/src/cli-tools.mjs +25 -0
- package/src/cli-web.mjs +37 -0
- package/src/codex-config-doctor.mjs +4 -0
- package/src/copilot-client.mjs +1 -0
- package/src/copilot-token-session.mjs +9 -0
- package/src/dashboard/activity.js +27 -0
- package/src/dashboard/console.js +2 -1
- package/src/dashboard/icons.js +24 -0
- package/src/dashboard/index.html +63 -17
- package/src/dashboard/language.js +90 -0
- package/src/dashboard/status.js +10 -0
- package/src/dashboard/theme.js +3 -2
- package/src/dashboard/tools.js +151 -0
- package/src/dashboard/ui.css +73 -0
- package/src/dashboard/ui.js +5 -1
- package/src/dashboard-api.mjs +5 -0
- package/src/dashboard-tools.mjs +43 -0
- package/src/dashboard.mjs +3 -0
- package/src/doctor.mjs +3 -2
- package/src/local-tools.mjs +53 -0
- package/src/native-prediction-environment.mjs +1 -1
- package/src/observability.mjs +7 -1
- package/src/optional-routes.mjs +9 -3
- package/src/provider-runtime.mjs +2 -2
- package/src/stream-performance.mjs +7 -0
- package/src/terminal-colors.mjs +8 -3
- package/src/terminal-console.mjs +5 -3
- package/src/user-settings.mjs +2 -2
package/src/optional-routes.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/status.js", "/usage.js", "/ui.js", "/console.js", "/updates.js"]);
|
|
2
|
-
export const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth", "/_ccdx/ui/providers", "/_ccdx/ui/settings", "/_ccdx/ui/m365/accounts", "/_ccdx/ui/updates"]);
|
|
1
|
+
export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/status.js", "/activity.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/icons.js", "/tools.js"]);
|
|
2
|
+
export const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth", "/_ccdx/ui/providers", "/_ccdx/ui/settings", "/_ccdx/ui/m365/accounts", "/_ccdx/ui/updates", "/_ccdx/ui/account", "/_ccdx/ui/checks"]);
|
|
3
3
|
|
|
4
4
|
export function isOptionalRoute(method, pathname) {
|
|
5
5
|
return DASHBOARD_API_PATHS.has(pathname) || pathname === "/mcp/image"
|
|
@@ -10,12 +10,18 @@ export function isOptionalRoute(method, pathname) {
|
|
|
10
10
|
// shared HTTP dispatcher and cannot initialize or change core inference.
|
|
11
11
|
export function createOptionalRoutes(options = {}) {
|
|
12
12
|
let imageMcpHandler = options.imageMcpHandler || null;
|
|
13
|
+
let tools = null;
|
|
13
14
|
return {
|
|
15
|
+
dispose() { tools?.dispose(); },
|
|
14
16
|
imageStats() { return imageMcpHandler?.stats?.(); },
|
|
15
17
|
async handle(req, res, pathname) {
|
|
16
18
|
if (DASHBOARD_API_PATHS.has(pathname)) {
|
|
17
19
|
const { handleDashboardApi } = await import("./dashboard-api.mjs");
|
|
18
|
-
|
|
20
|
+
if (["/_ccdx/ui/account", "/_ccdx/ui/checks"].includes(pathname)) {
|
|
21
|
+
const { createDashboardTools } = await import("./dashboard-tools.mjs");
|
|
22
|
+
tools ||= createDashboardTools(options.dashboardOptions);
|
|
23
|
+
}
|
|
24
|
+
return handleDashboardApi(req, res, pathname, { ...options.dashboardOptions, tools });
|
|
19
25
|
}
|
|
20
26
|
if ((req.method === "GET" || req.method === "HEAD") && DASHBOARD_PATHS.has(pathname)) {
|
|
21
27
|
const { serveDashboard } = await import("./dashboard.mjs");
|
package/src/provider-runtime.mjs
CHANGED
|
@@ -16,7 +16,7 @@ const unavailable = reason => Object.assign(new Error(`Microsoft 365 is unavaila
|
|
|
16
16
|
|
|
17
17
|
// Composition owns source selection. Providers never modify Codex, prediction,
|
|
18
18
|
// image configuration or each other's credentials.
|
|
19
|
-
export function createProviderRuntime({ githubClient, githubRegistry, githubCredentialFingerprint = "", home, env = process.env, platform = process.platform,
|
|
19
|
+
export function createProviderRuntime({ githubClient, githubRegistry, githubCredentialFingerprint = "", githubClientConfigured = true, home, env = process.env, platform = process.platform,
|
|
20
20
|
corePort = Number(env.ADAPTER_PORT || 2026), log = () => {}, createM365, startGateway, configureClients, restoreClients,
|
|
21
21
|
discoverM365 = requestM365Accounts } = {}) {
|
|
22
22
|
const options = { home, env, platform }, github = { ...createGithubProvider({ client: githubClient,
|
|
@@ -206,7 +206,7 @@ export function createProviderRuntime({ githubClient, githubRegistry, githubCred
|
|
|
206
206
|
{ id: "github", name: "GitHub Copilot", generation: dashboardGeneration(github), enabled: true, state: service.token_cached ? "ready" : "unknown",
|
|
207
207
|
auth: { state: "unknown", token_cached: service.token_cached === true, expires_in_ms: service.token_expires_in_ms ?? null },
|
|
208
208
|
models: { count: githubRegistry?.models?.data?.length ?? null, source: githubRegistry?.source || "unknown" },
|
|
209
|
-
clients: [{ id: "codex", name: "Codex App", selected: selection.codex === "github", state: "configured" }] },
|
|
209
|
+
clients: [{ id: "codex", name: "Codex App", selected: selection.codex === "github", state: githubClientConfigured ? "configured" : "unknown" }] },
|
|
210
210
|
{ id: "m365", name: "Microsoft 365", generation: m365 ? dashboardGeneration(m365) : 0, enabled, state: ms.state, reason: ms.reason, network_diagnostic: ms.network_diagnostic,
|
|
211
211
|
auth: { state: ms.token_cached ? "authorized" : !enabled ? "disabled" : ms.reason ? "unavailable" : "unknown",
|
|
212
212
|
account: ms.account?.login || "", token_cached: ms.token_cached === true,
|
|
@@ -84,6 +84,13 @@ export function isChatOutputDelta(delta) {
|
|
|
84
84
|
|| nonEmptyString(delta.reasoning_text);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
export function isMessagesOutputDelta(delta) {
|
|
88
|
+
if (!delta || typeof delta !== "object") return false;
|
|
89
|
+
return delta.type === "text_delta" && nonEmptyString(delta.text)
|
|
90
|
+
|| delta.type === "thinking_delta" && nonEmptyString(delta.thinking)
|
|
91
|
+
|| delta.type === "input_json_delta" && nonEmptyString(delta.partial_json);
|
|
92
|
+
}
|
|
93
|
+
|
|
87
94
|
function createHistogram(edges) {
|
|
88
95
|
return {
|
|
89
96
|
edges,
|
package/src/terminal-colors.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
export const isColorTheme = value => value === "green" || value === "klein";
|
|
1
|
+
export const isColorTheme = value => value === "green" || value === "klein" || value === "pink";
|
|
2
2
|
|
|
3
3
|
export function terminalColorCode(theme, { output = process.stdout, env = process.env } = {}) {
|
|
4
4
|
if (output.isTTY !== true || Object.hasOwn(env, "NO_COLOR") || env.TERM === "dumb") return "";
|
|
5
5
|
// Preserve the original green exactly. Blue also supports ordinary ANSI terminals.
|
|
6
|
-
if (theme !== "klein") return "\x1b[38;2;166;245;168m";
|
|
6
|
+
if (theme !== "klein" && theme !== "pink") return "\x1b[38;2;166;245;168m";
|
|
7
7
|
const depth = output.getColorDepth?.(env) || (/truecolor|24bit/i.test(env.COLORTERM || "") ? 24 : 4);
|
|
8
|
+
if (theme === "pink") {
|
|
9
|
+
const light = /^(7|15)$/.test(String(env.COLORFGBG || "").split(";").at(-1));
|
|
10
|
+
return depth >= 24 ? light ? "\x1b[38;2;168;62;104m" : "\x1b[38;2;243;168;200m"
|
|
11
|
+
: depth >= 8 ? light ? "\x1b[38;5;132m" : "\x1b[38;5;218m" : "\x1b[95m";
|
|
12
|
+
}
|
|
8
13
|
return depth >= 24 ? "\x1b[38;2;76;159;255m" : depth >= 8 ? "\x1b[38;5;75m" : "\x1b[94m";
|
|
9
14
|
}
|
|
10
15
|
|
|
@@ -14,7 +19,7 @@ export function colorTerminalText(text, theme, options) {
|
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export function colorTerminalMotion(frame, theme, options) {
|
|
17
|
-
if (theme !== "klein") return frame;
|
|
22
|
+
if (theme !== "klein" && theme !== "pink") return frame;
|
|
18
23
|
const code = terminalColorCode(theme, options);
|
|
19
24
|
return frame.replace(/\x1b\[(?:38;5;\d+|97)m/g, code);
|
|
20
25
|
}
|
package/src/terminal-console.mjs
CHANGED
|
@@ -44,14 +44,16 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
|
|
|
44
44
|
function table(width, usage, requests, inferenceActive, sum, compactTitle = false) {
|
|
45
45
|
const left = Math.floor((width - 3) / 2), right = width - 3 - left;
|
|
46
46
|
const cell = (label, value, size) => {
|
|
47
|
-
const number = value === undefined ? "" : updatedAt === null && readFailed ? "—" : compact(value), inner = size - 2;
|
|
47
|
+
const number = value === undefined ? "" : updatedAt === null && readFailed ? "—" : typeof value === "string" ? value : compact(value), inner = size - 2;
|
|
48
48
|
const text = clip(label, Math.max(0, inner - displayWidth(number) - (number ? 1 : 0)));
|
|
49
49
|
return ` ${text}${" ".repeat(Math.max(0, inner - displayWidth(text) - displayWidth(number)))}${number} `;
|
|
50
50
|
};
|
|
51
51
|
const row = (a, b) => `│${a}│${b}│`;
|
|
52
52
|
const rule = (a, b, c) => `${a}${"─".repeat(left)}${b}${"─".repeat(right)}${c}`;
|
|
53
|
+
const rate = usage.cache_hit_rate;
|
|
54
|
+
const cacheHit = Number.isFinite(rate) && rate >= 0 && rate <= 1 ? `${usage.cache_hit_rate_partial ? "~" : ""}${(rate * 100).toFixed(1)}%` : "—";
|
|
53
55
|
const usageRows = [[left < 23 ? "Records" : "Usage records", usage.records || 0], ["Input", usage.input_tokens], [left < 23 ? "Reused" : "Reused input", usage.cached_input_tokens],
|
|
54
|
-
["Output", usage.output_tokens], ["Partial usage", usage.partial_records || 0], ["",
|
|
56
|
+
["Output", usage.output_tokens], ["Partial usage", usage.partial_records || 0], ["Cache hit", cacheHit]];
|
|
55
57
|
const requestRows = [["Requests", requests], ["Active", inferenceActive], ["Completed", sum("completed")], ["Incomplete", sum("incomplete")], ["Failed", sum("failed")], ["Cancelled", sum("cancelled")]];
|
|
56
58
|
const title = compactTitle ? [`┌─ Usage ${"─".repeat(left - 8)}┬─ Inference ${"─".repeat(right - 12)}┐`]
|
|
57
59
|
: [rule("┌", "┬", "┐"), row(cell("Usage / this run", undefined, left), cell("Inference", undefined, right)), rule("├", "┼", "┤")];
|
|
@@ -95,7 +97,7 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
|
|
|
95
97
|
dirty = false;
|
|
96
98
|
}
|
|
97
99
|
// Apply color after clipping/layout so escape sequences never consume columns.
|
|
98
|
-
const body = [...content.map(line => current.color_theme
|
|
100
|
+
const body = [...content.map(line => ["klein", "pink"].includes(current.color_theme) && /^[┌│├└]/.test(line)
|
|
99
101
|
? colorTerminalText(line, current.color_theme, { output, env }) : line), `${motion} ${active ? "Working" : "Idle"}`];
|
|
100
102
|
fits = body.length < (Number(output.rows) || 24);
|
|
101
103
|
if (!fits) { frameDelay = 1000;return; }
|
package/src/user-settings.mjs
CHANGED
|
@@ -52,7 +52,7 @@ export function readUserSettings({ env = process.env, home = os.homedir(), stric
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
if (Object.hasOwn(parsed, "terminal_color_theme") && !isColorTheme(parsed.terminal_color_theme)) {
|
|
55
|
-
if (strict) throw invalidSettings(filePath, "terminal_color_theme must be green or
|
|
55
|
+
if (strict) throw invalidSettings(filePath, "terminal_color_theme must be green, klein or pink");
|
|
56
56
|
delete parsed.terminal_color_theme;
|
|
57
57
|
}
|
|
58
58
|
if (Object.hasOwn(parsed, AUTO_REVIEW_MODEL_KEY)) {
|
|
@@ -137,7 +137,7 @@ export function terminalColorPreference(options = {}) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export function writeTerminalColorTheme(theme, options = {}) {
|
|
140
|
-
if (!isColorTheme(theme)) throw new Error("Choose green or
|
|
140
|
+
if (!isColorTheme(theme)) throw new Error("Choose green, klein or pink for the terminal color theme");
|
|
141
141
|
return withFileLockSync(`${userSettingsPath(options)}.lock`, () => {
|
|
142
142
|
const settings = readUserSettings({ ...options, strict: true });
|
|
143
143
|
const next = { ...settings };
|