codex-copilot-dx 0.9.40 → 0.10.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 +25 -4
- package/bin/cli.mjs +37 -11
- package/docs/ARCHITECTURE.md +84 -13
- package/docs/REFERENCE.md +207 -16
- package/package.json +4 -1
- package/src/adapter.mjs +98 -152
- package/src/auto-review-model.mjs +4 -3
- package/src/claude-client-config.mjs +217 -0
- package/src/claude-gateway.mjs +163 -0
- package/src/cli-m365.mjs +133 -0
- package/src/cli-models.mjs +1 -1
- package/src/cli-options.mjs +20 -6
- package/src/cli-status.mjs +23 -7
- package/src/codex-model-catalog.mjs +7 -2
- package/src/copilot-client.mjs +4 -0
- package/src/copilot-responses-compat.mjs +1 -1
- package/src/copilot-responses-policy.mjs +11 -64
- package/src/dashboard/index.html +14 -4
- package/src/dashboard/language.js +40 -2
- package/src/dashboard/status.js +26 -4
- package/src/dashboard/ui.css +2 -2
- package/src/dashboard/ui.js +16 -7
- package/src/dashboard/usage.js +3 -1
- package/src/dashboard-api.mjs +10 -7
- package/src/doctor-repair.mjs +2 -0
- package/src/doctor.mjs +18 -2
- package/src/http-transport.mjs +6 -3
- package/src/m365-settings.mjs +89 -0
- package/src/management-routes.mjs +118 -0
- package/src/native-prediction-windows.mjs +2 -7
- package/src/optional-routes.mjs +33 -0
- package/src/profile-model-runtime.mjs +4 -2
- package/src/provider-management.mjs +28 -0
- package/src/provider-runtime.mjs +179 -0
- package/src/provider-settings.mjs +32 -0
- package/src/providers/github.mjs +62 -0
- package/src/providers/m365-auth-helper.mjs +72 -0
- package/src/providers/m365-auth.mjs +105 -0
- package/src/providers/m365-messages-policy.mjs +20 -0
- package/src/providers/m365-network.mjs +73 -0
- package/src/providers/m365.mjs +238 -0
- package/src/response-failures.mjs +66 -5
- package/src/response-history.mjs +20 -3
- package/src/responses-bridge.mjs +1 -1
- package/src/responses-handler.mjs +40 -103
- package/src/responses-image-tools.mjs +61 -0
- package/src/responses-proxy.mjs +5 -5
- package/src/responses-request.mjs +25 -0
- package/src/stream-performance.mjs +42 -10
- package/src/usage-analysis.mjs +3 -2
- package/src/usage-store.mjs +41 -12
- package/src/usage.mjs +8 -2
- package/src/windows-http-network.mjs +122 -0
- package/src/windows-prediction-network.cs +13 -6
- package/src/windows-prediction-network.mjs +4 -108
- package/src/windows-process.mjs +8 -0
package/src/cli-status.mjs
CHANGED
|
@@ -39,11 +39,14 @@ function mebibytes(value) {
|
|
|
39
39
|
return bytes === null ? "n/a" : `${(bytes / (1024 * 1024)).toFixed(1)}MiB`;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function
|
|
43
|
-
const average = finiteNumber(metric?.avg);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
function outputRate(metric) {
|
|
43
|
+
const average = metric?.avg === null ? null : finiteNumber(metric?.avg);
|
|
44
|
+
return metric?.samples > 0 && average !== null ? `${average.toFixed(1)}token/s` : "n/a";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function firstOutputLatency(metric) {
|
|
48
|
+
const average = metric?.avg === null ? null : finiteNumber(metric?.avg);
|
|
49
|
+
return metric?.samples > 0 && average !== null ? `${average.toFixed(1)}ms` : "n/a";
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
function cacheHitRate(cache = {}) {
|
|
@@ -68,6 +71,7 @@ function profileSummary(label, profile = {}) {
|
|
|
68
71
|
|
|
69
72
|
function routingTarget(value) {
|
|
70
73
|
if (value === "codex") return "Codex";
|
|
74
|
+
if (value === "m365") return "Codex (Microsoft 365 backup)";
|
|
71
75
|
return "unknown";
|
|
72
76
|
}
|
|
73
77
|
|
|
@@ -151,7 +155,7 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
|
|
|
151
155
|
`${commandName} status`,
|
|
152
156
|
adapterLine,
|
|
153
157
|
status("info", `Requests: ${count(requests.completed)}/${count(requests.total)} completed, ${count(requests.active)} active, ${count(requests.status_4xx)} 4xx, ${count(requests.status_5xx)} 5xx, ${count(requests.aborted)} aborted`),
|
|
154
|
-
status("info", `Responses stream: TTFT avg ${
|
|
158
|
+
status("info", `Responses stream: TTFT avg ${firstOutputLatency(performance.ttft_ms)} (${count(performance.ttft_ms?.samples)} samples), output avg ${outputRate(performance.output_tokens_per_second)} (${count(performance.output_tokens_per_second?.samples)} samples; gateway estimate)`),
|
|
155
159
|
...(terminalOutcomes ? [status("info", `Model outcomes: ${count(terminalOutcomes.completed)} completed, ${count(terminalOutcomes.incomplete)} incomplete, ${count(terminalOutcomes.failed)} failed, ${count(terminalOutcomes.cancelled)} cancelled, ${count(terminalOutcomes.unknown)} without terminal`)] : []),
|
|
156
160
|
status("info", `Admission: ${count(admission.activeRequests)} active, ${count(admission.queued)} queued, ${count(admission.rejected)} rejected, ${count(admission.timedOut)} timed out, wait avg ${latency(admission.waitMsAvg)}`),
|
|
157
161
|
status("info", `Memory: RSS ${mebibytes(processStats.rss_bytes)}, heap ${mebibytes(processStats.heap_used_bytes)}`),
|
|
@@ -188,7 +192,14 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
|
|
|
188
192
|
lines.push(status("warn", ` ${model} ${code}: ${message}${failure.retried ? ` [retried:${retryPolicy}]` : ""}`));
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
|
-
if (data.http_errors)
|
|
195
|
+
if (data.http_errors) {
|
|
196
|
+
lines.push(status("info", `HTTP failures: ${count(data.http_errors.total)} observed (separate from model terminal events)`));
|
|
197
|
+
const categories = data.http_errors.by_category;
|
|
198
|
+
if (categories) lines.push(status("info", `HTTP categories: ${count(categories.inference)} inference, ${count(categories.protocol)} unsupported MCP methods, ${count(categories.route)} unmatched routes, ${count(categories.other)} other`));
|
|
199
|
+
for (const failure of (data.http_errors.actionable_recent || []).slice(-3).reverse()) {
|
|
200
|
+
lines.push(status("warn", `HTTP ${count(failure.http_status)} ${terminalCell(failure.model)} ${terminalCell(failure.code)}${failure.parameter ? ` param=${terminalCell(failure.parameter)}` : ""}; ${terminalCell(failure.origin)}; ${count(failure.upstream_attempts)} attempts`));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
192
203
|
lines.push(status("info", `Models: ${count(models.models)} total; Copilot token ${copilot.token_cached ? `cached (${duration(copilot.token_expires_in_ms)} remaining)` : "not cached"}`));
|
|
193
204
|
const prediction = data.client_integrations?.prediction;
|
|
194
205
|
if (prediction) {
|
|
@@ -203,6 +214,11 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
|
|
|
203
214
|
if (data.routing?.responses) {
|
|
204
215
|
lines.push(status("info", `Routing: /v1/responses -> ${routingTarget(data.routing.responses)}`));
|
|
205
216
|
}
|
|
217
|
+
if (data.providers?.m365) {
|
|
218
|
+
const m365 = data.providers.m365;
|
|
219
|
+
lines.push(status("info", `Microsoft 365: ${terminalCell(m365.state)}; ${count(m365.models?.claude)} Claude, ${count(m365.models?.gpt)} GPT; gateway ${terminalCell(m365.claude?.gateway || "unavailable")}`));
|
|
220
|
+
if (m365.reason) lines.push(status("info", `Microsoft 365 detail: ${terminalCell(m365.reason)}`));
|
|
221
|
+
}
|
|
206
222
|
lines.push(status("info", `Limits: request body ${mebibytes(limits.max_body_bytes)}, decoded body ${mebibytes(limits.max_decoded_body_bytes)}`));
|
|
207
223
|
const recentContext = data.stream_performance?.recent_requests?.at(-1)?.context;
|
|
208
224
|
const contextValue = (value, format) => value === null || value === undefined ? "n/a" : format(value);
|
|
@@ -155,11 +155,16 @@ function insertByPriority(models, model) {
|
|
|
155
155
|
else models.splice(index, 0, model);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
export function buildCodexModelResponse({ copilotModels, codexCatalog } = {}) {
|
|
158
|
+
export function buildCodexModelResponse({ copilotModels, codexCatalog, restrictToUpstream = false } = {}) {
|
|
159
159
|
if (!copilotModelData(copilotModels) || !codexCatalogIsValid(codexCatalog)) return null;
|
|
160
160
|
|
|
161
161
|
const bundledSlugs = new Set(codexCatalog.models.map(({ slug }) => slug));
|
|
162
162
|
const models = codexCatalog.models.map((model) => {
|
|
163
|
+
if (restrictToUpstream) {
|
|
164
|
+
return isEligibleCopilotGpt6(copilotModels, model.slug)
|
|
165
|
+
? { ...catalogModelForCopilot(model, copilotModels, { filterReasoning: true }), upgrade: null }
|
|
166
|
+
: { ...model, visibility: "hide", upgrade: null };
|
|
167
|
+
}
|
|
163
168
|
if (!MANAGED_GPT6_MODELS.has(model.slug)) return model;
|
|
164
169
|
if (!isEligibleCopilotGpt6(copilotModels, model.slug)) return { ...model, visibility: "hide" };
|
|
165
170
|
return catalogModelForCopilot(model, copilotModels, { filterReasoning: model.slug === "gpt-6.1-sol" });
|
|
@@ -168,7 +173,7 @@ export function buildCodexModelResponse({ copilotModels, codexCatalog } = {}) {
|
|
|
168
173
|
if (bundledSlugs.has(slug) || !isEligibleCopilotGpt6(copilotModels, slug)) continue;
|
|
169
174
|
const model = compatibilityModel(codexCatalog, slug);
|
|
170
175
|
if (!model) continue;
|
|
171
|
-
insertByPriority(models, catalogModelForCopilot(model, copilotModels, { filterReasoning: true }));
|
|
176
|
+
insertByPriority(models, { ...catalogModelForCopilot(model, copilotModels, { filterReasoning: true }), ...(restrictToUpstream ? { upgrade: null } : {}) });
|
|
172
177
|
}
|
|
173
178
|
|
|
174
179
|
return { ...copilotModels, object: copilotModels.object || "list", models };
|
package/src/copilot-client.mjs
CHANGED
|
@@ -6,6 +6,8 @@ import { enforceResponsesPayloadByteBudget } from "./responses-byte-budget.mjs";
|
|
|
6
6
|
import { status } from "./status.mjs";
|
|
7
7
|
import { withChatStreamUsage } from "./stream-contract.mjs";
|
|
8
8
|
import { markRequestObservation, markUpstreamStarted } from "./stream-performance.mjs";
|
|
9
|
+
import { currentRequestContext } from "./request-context.mjs";
|
|
10
|
+
import { requestOptionsEvidence } from "./response-failures.mjs";
|
|
9
11
|
|
|
10
12
|
function abortError(signal) {
|
|
11
13
|
if (signal?.reason instanceof Error) return signal.reason;
|
|
@@ -185,6 +187,8 @@ export function createCopilotClientRuntime({
|
|
|
185
187
|
headers["Content-Length"] = String(bodyBytes);
|
|
186
188
|
headers.Accept = reqBody.stream ? "text/event-stream" : "application/json";
|
|
187
189
|
try {
|
|
190
|
+
const context = currentRequestContext();
|
|
191
|
+
if (context) context.requestOptions = requestOptionsEvidence(reqBody);
|
|
188
192
|
onUpstreamStart?.();
|
|
189
193
|
markUpstreamStarted(reqBody.stream === true);
|
|
190
194
|
return await fetchCopilotUpstream(`${tokenSession.getApiBase()}${responsesEndpointPath()}`, {
|
|
@@ -110,7 +110,7 @@ export async function openCopilotResponse(reqContext, upstream = copilotResponse
|
|
|
110
110
|
payloadPrepared,
|
|
111
111
|
});
|
|
112
112
|
} finally { releaseRecovery?.();releaseRecovery = null; }
|
|
113
|
-
markUpstreamHeaders();
|
|
113
|
+
markUpstreamHeaders(resp.status);
|
|
114
114
|
options.assertPrepareActive?.();
|
|
115
115
|
payloadPrepared = true;
|
|
116
116
|
if (resp.ok) {
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { errorEvidenceText } from "./operation-error.mjs";
|
|
2
|
+
import { removeNativeImageTools as applyCopilotResponsesRequestPolicies } from "./responses-image-tools.mjs";
|
|
3
|
+
export { removeNativeImageTools as applyCopilotResponsesRequestPolicies, isNativeImageTool as isCopilotImageNamespaceTool } from "./responses-image-tools.mjs";
|
|
2
4
|
|
|
3
5
|
function cloneJson(value) {
|
|
4
6
|
return value === undefined ? undefined : structuredClone(value);
|
|
5
7
|
}
|
|
6
8
|
|
|
9
|
+
export function stripUnsupportedGpt6ServiceTier(body, requestedModel, upstreamModel, priorityTierModel) {
|
|
10
|
+
if (requestedModel.startsWith("gpt-6-")
|
|
11
|
+
&& upstreamModel === requestedModel
|
|
12
|
+
&& !priorityTierModel
|
|
13
|
+
&& body.service_tier === "priority") {
|
|
14
|
+
delete body.service_tier;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export function isConnectionOwnedInputError(statusCode, text) {
|
|
8
19
|
if (statusCode !== 400 || !text) return false;
|
|
9
20
|
try {
|
|
@@ -34,70 +45,6 @@ export function isImageNamespaceCollisionError(statusCode, text) {
|
|
|
34
45
|
&& lower.includes("collid");
|
|
35
46
|
}
|
|
36
47
|
|
|
37
|
-
export function isCopilotImageNamespaceTool(tool, { collisionFallback = false } = {}) {
|
|
38
|
-
if (!tool || typeof tool !== "object") return false;
|
|
39
|
-
const type = String(tool.type || "").toLowerCase();
|
|
40
|
-
if (["image_gen", "image_generation"].includes(type)) return true;
|
|
41
|
-
if (!collisionFallback) return false;
|
|
42
|
-
const name = String(tool.name || tool.function?.name || "").toLowerCase();
|
|
43
|
-
const namespace = String(tool.namespace || "").toLowerCase();
|
|
44
|
-
if (["image_gen", "image_generation"].includes(name)) return true;
|
|
45
|
-
if (namespace === "image_gen" || namespace === "image_generation") return true;
|
|
46
|
-
return [type, name, namespace].some((value) => value.startsWith("image_gen"));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function toolName(tool) {
|
|
50
|
-
return String(tool?.name || tool?.function?.name || "").trim();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Copilot currently rejects the public image-generation tool. Keep this
|
|
54
|
-
// provider-owned policy paired with tool_choice so request invariants survive
|
|
55
|
-
// the removal. Revalidate against Copilot before deleting or broadening it.
|
|
56
|
-
// Reference: https://github.com/Menci/Floway/blob/ac2bbb04352033a7d9d74574a9d465d40395ef06/packages/provider-copilot/src/interceptors/openai-responses/strip-image-generation.ts
|
|
57
|
-
export function applyCopilotResponsesRequestPolicies(body, options = {}) {
|
|
58
|
-
if (!body || typeof body !== "object") return false;
|
|
59
|
-
const removedNames = new Set();
|
|
60
|
-
const survivingNames = new Set();
|
|
61
|
-
let survivingTools = 0;
|
|
62
|
-
let changed = false;
|
|
63
|
-
const filter = (container, topLevel = false) => {
|
|
64
|
-
if (!Array.isArray(container?.tools)) return;
|
|
65
|
-
const tools = container.tools;
|
|
66
|
-
const filtered = tools.filter((tool) => {
|
|
67
|
-
const removed = isCopilotImageNamespaceTool(tool, options);
|
|
68
|
-
const name = toolName(tool);
|
|
69
|
-
if (removed && name) removedNames.add(name);
|
|
70
|
-
if (!removed) {
|
|
71
|
-
survivingTools += 1;
|
|
72
|
-
if (name) survivingNames.add(name);
|
|
73
|
-
}
|
|
74
|
-
return !removed;
|
|
75
|
-
});
|
|
76
|
-
if (filtered.length === tools.length) return;
|
|
77
|
-
changed = true;
|
|
78
|
-
if (topLevel && !filtered.length) delete container.tools;
|
|
79
|
-
else container.tools = filtered;
|
|
80
|
-
};
|
|
81
|
-
filter(body, true);
|
|
82
|
-
for (const item of Array.isArray(body.input) ? body.input : []) {
|
|
83
|
-
if (["additional_tools", "tool_search_output"].includes(item?.type)) filter(item);
|
|
84
|
-
}
|
|
85
|
-
if (!changed) return false;
|
|
86
|
-
|
|
87
|
-
const removedChoice = (choice) => isCopilotImageNamespaceTool(choice, options)
|
|
88
|
-
|| (removedNames.has(toolName(choice)) && !survivingNames.has(toolName(choice)));
|
|
89
|
-
if (body.tool_choice?.type === "allowed_tools" && Array.isArray(body.tool_choice.tools)) {
|
|
90
|
-
const choices = body.tool_choice.tools.filter((choice) => !removedChoice(choice));
|
|
91
|
-
body.tool_choice = choices.length ? { ...body.tool_choice, tools: choices } : "none";
|
|
92
|
-
} else if (removedChoice(body.tool_choice)) {
|
|
93
|
-
if (survivingTools) body.tool_choice = "none";
|
|
94
|
-
else delete body.tool_choice;
|
|
95
|
-
} else if (body.tool_choice === "required" && !survivingTools) {
|
|
96
|
-
delete body.tool_choice;
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
48
|
export function sanitizeImageNamespaceCollisionRequest(reqContext) {
|
|
102
49
|
if (!Array.isArray(reqContext?.body?.tools)) return null;
|
|
103
50
|
const body = cloneJson(reqContext.body);
|
package/src/dashboard/index.html
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<article class="card"><h2 data-i18n>ADAPTER</h2><strong id="version">—</strong><p id="uptime">—</p></article>
|
|
32
32
|
<article class="card"><h2>Copilot</h2><strong id="copilot">—</strong><p id="token">—</p></article>
|
|
33
33
|
<article class="card"><h2 data-i18n>KNOWN MODELS</h2><strong id="models">—</strong><p id="model-source">—</p></article>
|
|
34
|
-
<article class="card"><h2 data-i18n>REQUESTS</h2><strong id="requests">—</strong><p id="request-errors">—</p><p><span data-i18n>Per-request limits (active)</span><br><span id="body-limits">—</span></p></article>
|
|
34
|
+
<article class="card"><h2 data-i18n>REQUESTS</h2><strong id="requests">—</strong><p id="request-errors">—</p><p id="http-error-breakdown">—</p><p><span data-i18n>Per-request limits (active)</span><br><span id="body-limits">—</span></p></article>
|
|
35
35
|
</section>
|
|
36
36
|
|
|
37
37
|
<section class="details" aria-label="Runtime details" data-i18n-label>
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
<div class="panel-heading"><h2 data-i18n>MODEL OUTCOMES</h2><span>RESPONSES</span></div>
|
|
40
40
|
<dl class="stats"><div><dt data-i18n>Completed</dt><dd id="completed">—</dd></div><div><dt data-i18n>Incomplete</dt><dd id="incomplete">—</dd></div><div><dt data-i18n>Failed</dt><dd id="failed">—</dd></div><div><dt data-i18n>Cancelled</dt><dd id="cancelled">—</dd></div></dl>
|
|
41
41
|
<p class="hint" data-i18n>HTTP 2xx != model completed.</p>
|
|
42
|
-
<dl class="stats timing-stats"><div><dt data-i18n>First output</dt><dd id="ttft">—</dd></div><div><dt data-i18n>
|
|
43
|
-
<p class="hint" data-i18n>Gateway timing.
|
|
42
|
+
<dl class="stats timing-stats"><div><dt data-i18n>First output</dt><dd id="ttft">—</dd></div><div><dt data-i18n>Output speed</dt><dd id="tpot">—</dd></div></dl>
|
|
43
|
+
<p class="hint" data-i18n>Gateway timing. Output speed is estimated.</p>
|
|
44
44
|
</article>
|
|
45
45
|
<article class="panel">
|
|
46
46
|
<div class="panel-heading"><h2 data-i18n>LOCAL HISTORY</h2><span data-i18n>ACTIVE LIMIT</span></div>
|
|
@@ -51,6 +51,16 @@
|
|
|
51
51
|
<div class="panel-heading"><h2 data-i18n>IMAGE GENERATION</h2><span data-i18n>OPTIONAL</span></div>
|
|
52
52
|
<strong id="image">—</strong><p id="image-detail" class="hint">—</p>
|
|
53
53
|
</article>
|
|
54
|
+
<article class="panel">
|
|
55
|
+
<div class="panel-heading"><h2>Microsoft 365</h2><span data-i18n>SEPARATE PROFILE</span></div>
|
|
56
|
+
<strong id="m365-state">—</strong>
|
|
57
|
+
<p id="m365-account" class="hint">—</p>
|
|
58
|
+
<p id="m365-models" class="hint">—</p>
|
|
59
|
+
<p id="m365-claude" class="hint">—</p>
|
|
60
|
+
<p id="m365-requests" class="hint">—</p>
|
|
61
|
+
<p id="m365-clients" class="hint">—</p>
|
|
62
|
+
<p id="m365-codex" class="hint">—</p>
|
|
63
|
+
</article>
|
|
54
64
|
</section>
|
|
55
65
|
|
|
56
66
|
<details class="panel dashboard-section" id="client-features" open>
|
|
@@ -77,7 +87,7 @@
|
|
|
77
87
|
|
|
78
88
|
<details class="panel dashboard-section" id="model-usage" open>
|
|
79
89
|
<summary class="panel-heading"><h2 data-i18n>USAGE</h2><span id="usage-state" data-i18n>READING LOG</span></summary>
|
|
80
|
-
<div class="section-actions"><button id="clear-usage-day" type="button" hidden data-i18n>All history</button><button id="refresh-usage" type="button" data-i18n>Refresh</button></div>
|
|
90
|
+
<div class="section-actions"><label><span data-i18n>Source</span> <select id="usage-provider"><option value="" data-i18n>All providers</option><option value="github">GitHub Copilot</option><option value="m365">Microsoft 365</option></select></label><button id="clear-usage-day" type="button" hidden data-i18n>All history</button><button id="refresh-usage" type="button" data-i18n>Refresh</button></div>
|
|
81
91
|
<p id="usage-note" class="table-note" data-i18n>Aggregating local usage metadata…</p>
|
|
82
92
|
<div class="table-wrap"><table class="usage-table"><thead><tr><th scope="col" data-i18n>MODEL</th><th scope="col" data-i18n>CALLS</th><th scope="col" data-i18n>INPUT</th><th scope="col" data-i18n>CACHE READ</th><th scope="col" data-i18n>OUTPUT</th><th scope="col" data-i18n>TOTAL</th><th scope="col" data-i18n>CACHE HIT</th></tr></thead><tbody id="usage-body"><tr><td colspan="7" data-i18n>Loading…</td></tr></tbody></table></div>
|
|
83
93
|
<p class="hint" data-i18n>Cache hit = recorded cached / input tokens. ~ = incomplete history. — = unavailable or invalid counts.</p>
|
|
@@ -15,8 +15,20 @@
|
|
|
15
15
|
"Unavailable": ["Unavailable", "不可用"],
|
|
16
16
|
"Observed": ["Observed", "已收到配置请求"],
|
|
17
17
|
"First output": ["First output", "首次输出"],
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"Output speed": ["Output speed", "输出速度"],
|
|
19
|
+
"Inference {inference} / method {protocol} / route {route} / other {other}": ["Inference {inference} / method {protocol} / route {route} / other {other}", "推理{inference}·方法{protocol}·路由{route}·其他{other}"],
|
|
20
|
+
"Upstream returned no error details.": ["The upstream returned no error details.", "上游未返回错误详情。"],
|
|
21
|
+
"error_type": ["Error type", "错误类型"],
|
|
22
|
+
"parameter": ["Parameter", "请求参数"],
|
|
23
|
+
"error_body": ["Error details", "错误详情"],
|
|
24
|
+
"diagnostic_message": ["Opt-in error detail", "诊断详情"],
|
|
25
|
+
"method": ["Method", "请求方法"],
|
|
26
|
+
"target": ["Endpoint", "请求入口"],
|
|
27
|
+
"request_options": ["Request options", "请求选项"],
|
|
28
|
+
"requested_model": ["Requested model", "指定模型"],
|
|
29
|
+
"request_kind": ["Request purpose", "请求用途"],
|
|
30
|
+
"attempt_timings": ["Upstream attempts", "上游尝试"],
|
|
31
|
+
"Gateway timing. Output speed is estimated.": ["Gateway estimates, not internal model timing or total throughput.", "网关估算值。\n非模型内部耗时或总吞吐量。"],
|
|
20
32
|
"{value} / {samples} samples": ["{value} / {samples} samples", "{value} / {samples}次样本"],
|
|
21
33
|
"CCDX · Local dashboard": ["CCDX · Dashboard", "CCDX · 运行看板"],
|
|
22
34
|
"/ LOCAL STATUS": ["/ DASHBOARD", "/ 运行看板"],
|
|
@@ -65,6 +77,32 @@
|
|
|
65
77
|
"History cache usage": ["Local history usage", "对话暂存"],
|
|
66
78
|
"IMAGE GENERATION": ["IMAGE GENERATION", "图片生成"],
|
|
67
79
|
"OPTIONAL": ["OPT-IN", "按需开启"],
|
|
80
|
+
"SEPARATE PROFILE": ["SEPARATE PROFILE", "独立授权"],
|
|
81
|
+
"Source": ["Source", "来源"],
|
|
82
|
+
"provider": ["Source", "来源"],
|
|
83
|
+
"CATALOG SNAPSHOT": ["SAVED CATALOG", "目录快照"],
|
|
84
|
+
"All providers": ["All providers", "全部来源"],
|
|
85
|
+
"M365 READY": ["AUTHORIZED", "已授权"],
|
|
86
|
+
"M365 CHECKING": ["CHECKING", "检查中"],
|
|
87
|
+
"M365 OFF": ["OFF", "已关闭"],
|
|
88
|
+
"M365 UNSUPPORTED": ["NOT SUPPORTED", "暂不支持"],
|
|
89
|
+
"M365 UNAVAILABLE": ["UNAVAILABLE", "未接入"],
|
|
90
|
+
"M365 UNKNOWN": ["UNKNOWN", "未知"],
|
|
91
|
+
"Account unavailable": ["Account unavailable", "暂无账号信息"],
|
|
92
|
+
"Claude {claude} / GPT {gpt}": ["Claude {claude} / GPT {gpt}", "Claude {claude}个 / GPT {gpt}个"],
|
|
93
|
+
"Claude gateway running": ["Claude gateway running", "Claude 网关已运行"],
|
|
94
|
+
"Claude gateway unavailable": ["Claude gateway unavailable", "Claude 网关未运行"],
|
|
95
|
+
"Claude: {done} done / {incomplete} incomplete / {failed} failed": ["Claude: {done} done / {incomplete} incomplete / {failed} failed", "完成 {done} / 未完成 {incomplete} / 失败 {failed}"],
|
|
96
|
+
"Claude requests unavailable": ["Claude requests unavailable", "暂无请求数据"],
|
|
97
|
+
"Code: {code} / App: {app}": ["Code: {code}\nApp: {app}", "Code:{code}\nApp:{app}"],
|
|
98
|
+
"Configured": ["Configured", "已配置"],
|
|
99
|
+
"Existing settings kept": ["Existing settings kept", "保留原配置"],
|
|
100
|
+
"Restored": ["Restored", "已恢复"],
|
|
101
|
+
"Not installed": ["Not installed", "未安装"],
|
|
102
|
+
"Setup unavailable": ["Setup unavailable", "配置失败"],
|
|
103
|
+
"Not configured": ["Not configured", "未配置"],
|
|
104
|
+
"Codex source: Microsoft 365": ["Codex source: Microsoft 365", "Codex:M365"],
|
|
105
|
+
"Codex source: GitHub Copilot": ["Codex source: GitHub Copilot", "Codex:GitHub Copilot"],
|
|
68
106
|
"Live upstream models": ["Online models", "在线模型"],
|
|
69
107
|
"UPSTREAM GPT MODELS": ["ONLINE MODELS", "在线模型"],
|
|
70
108
|
"CHECKING LIVE": ["CHECKING", "查询中"],
|
package/src/dashboard/status.js
CHANGED
|
@@ -74,7 +74,12 @@
|
|
|
74
74
|
recovery: failure.recovery ? JSON.stringify(failure.recovery) : undefined,
|
|
75
75
|
request_id: failure.request_id, outcome: timeline?.outcome, origin: failure.origin || timeline?.origin,
|
|
76
76
|
phase: timeline?.phase, http_status: failure.http_status ?? timeline?.http_status, route: failure.route,
|
|
77
|
-
upstream_attempts: timeline?.upstream_attempts,
|
|
77
|
+
upstream_attempts: failure.upstream_attempts ?? timeline?.upstream_attempts,
|
|
78
|
+
error_type: failure.error_type, parameter: failure.parameter, error_body: failure.error_body,
|
|
79
|
+
diagnostic_message: failure.diagnostic_message, method: failure.method, target: failure.target,
|
|
80
|
+
request_options: failure.request_options ? JSON.stringify(failure.request_options) : undefined,
|
|
81
|
+
requested_model: failure.requested_model, request_kind: failure.request_kind, provider: failure.provider || timeline?.provider,
|
|
82
|
+
attempt_timings: failure.attempt_timings || timeline?.attempts ? JSON.stringify(failure.attempt_timings || timeline.attempts) : undefined,
|
|
78
83
|
timings_ms: timingText };
|
|
79
84
|
const diagnostic = document.createElement("dl");
|
|
80
85
|
diagnostic.className = "failure-detail";
|
|
@@ -120,12 +125,15 @@
|
|
|
120
125
|
const requests = data.requests || {};
|
|
121
126
|
text("requests", number(requests.total));
|
|
122
127
|
text("request-errors", "4xx {client} / 5xx {server} / active {active}", { client: number(requests.status_4xx), server: number(requests.status_5xx), active: number(requests.active) });
|
|
128
|
+
const categories = data.http_errors?.by_category;
|
|
129
|
+
text("http-error-breakdown", categories ? "Inference {inference} / method {protocol} / route {route} / other {other}" : "—",
|
|
130
|
+
categories ? Object.fromEntries(Object.entries(categories).map(([key, value]) => [key, number(value)])) : {});
|
|
123
131
|
text("body-limits", "raw {raw} / decoded {decoded}", { raw: mib(data.limits?.max_body_bytes), decoded: mib(data.limits?.max_decoded_body_bytes) });
|
|
124
132
|
|
|
125
133
|
const outcomes = data.stream_performance?.by_route?.responses?.terminal_outcomes?.totals || {};
|
|
126
134
|
for (const key of ["completed", "incomplete", "failed", "cancelled"]) text(key, number(outcomes[key]));
|
|
127
135
|
const timing = data.stream_performance?.by_route?.responses || {};
|
|
128
|
-
for (const [id, metric, scale, unit] of [["ttft", timing.ttft_ms, 1, "ms"], ["tpot", timing.
|
|
136
|
+
for (const [id, metric, scale, unit] of [["ttft", timing.ttft_ms, 1, "ms"], ["tpot", timing.output_tokens_per_second, 1, "token/s"]]) {
|
|
129
137
|
const value = metric?.samples > 0 && finite(metric.avg) ? `${(Number(metric.avg) / scale).toFixed(1)} ${unit}` : "—";
|
|
130
138
|
text(id, "{value} / {samples} samples", { value, samples: number(metric?.samples) });
|
|
131
139
|
}
|
|
@@ -142,8 +150,22 @@
|
|
|
142
150
|
text("image-detail", image
|
|
143
151
|
? "active {active} / failed {failed} / delivery failures {delivery}"
|
|
144
152
|
: "Setup state unknown / ccdx image-status", { active: number(image?.active), failed: number(image?.failed), delivery: number(image?.delivery_failures) });
|
|
153
|
+
|
|
154
|
+
if (element("m365-state")) {
|
|
155
|
+
const providers = data.providers || {}, m365 = providers.m365 || {}, claude = m365.claude || {};
|
|
156
|
+
const state = { ready: "M365 READY", checking: "M365 CHECKING", disabled: "M365 OFF", unsupported: "M365 UNSUPPORTED", unavailable: "M365 UNAVAILABLE", idle: "M365 CHECKING" };
|
|
157
|
+
text("m365-state", state[m365.state] || "M365 UNKNOWN");
|
|
158
|
+
text("m365-account", m365.account?.login || "Account unavailable");
|
|
159
|
+
text("m365-models", "Claude {claude} / GPT {gpt}", { claude: number(m365.models?.claude), gpt: number(m365.models?.gpt) });
|
|
160
|
+
text("m365-claude", claude.gateway === "running" ? "Claude gateway running" : "Claude gateway unavailable");
|
|
161
|
+
if (element("m365-requests")) text("m365-requests", claude.requests ? "Claude: {done} done / {incomplete} incomplete / {failed} failed" : "Claude requests unavailable",
|
|
162
|
+
{ done: number(claude.requests?.completed), incomplete: number(claude.requests?.incomplete), failed: number(claude.requests?.failed) });
|
|
163
|
+
const labels = { configured: "Configured", preserved: "Existing settings kept", partially_preserved: "Existing settings kept", restored: "Restored", not_installed: "Not installed", configuration_unavailable: "Setup unavailable", not_configured: "Not configured" };
|
|
164
|
+
text("m365-clients", "Code: {code} / App: {app}", { code: phrase(labels[claude.clients?.code] || "Unknown"), app: phrase(labels[claude.clients?.app] || "Unknown") });
|
|
165
|
+
text("m365-codex", providers.codex_provider === "m365" ? "Codex source: Microsoft 365" : "Codex source: GitHub Copilot");
|
|
166
|
+
}
|
|
145
167
|
|
|
146
|
-
renderFailures([...(data.response_failures?.recent || []), ...(data.http_errors?.recent || [])]
|
|
168
|
+
renderFailures([...(data.response_failures?.recent || []), ...(data.http_errors?.actionable_recent || data.http_errors?.recent || [])]
|
|
147
169
|
.sort((a, b) => (Date.parse(a.at) || 0) - (Date.parse(b.at) || 0)), data.stream_performance?.recent_requests);
|
|
148
170
|
renderContext(data.stream_performance);
|
|
149
171
|
if (element("prediction-preference")) {
|
|
@@ -179,7 +201,7 @@
|
|
|
179
201
|
? request.outcome[0].toUpperCase() + request.outcome.slice(1) : "Unknown";
|
|
180
202
|
const ratio = finite(context.input_tokens) && finite(context.context_window_tokens) && Number(context.context_window_tokens) > 0
|
|
181
203
|
? `${(100 * Number(context.input_tokens) / Number(context.context_window_tokens)).toFixed(1)}%` : "—";
|
|
182
|
-
body.append(tableRow([String(request.model || "unknown").slice(0, 80),
|
|
204
|
+
body.append(tableRow([String(request.model || "unknown").slice(0, 80) + (request.provider === "m365" ? " / M365" : ""),
|
|
183
205
|
finite(context.payload_bytes) ? (Number(context.payload_bytes) / 1048576).toFixed(2) : "—",
|
|
184
206
|
number(context.images), number(context.input_tokens), number(context.context_window_tokens), ratio,
|
|
185
207
|
outcome], { labels: [6] }));
|
package/src/dashboard/ui.css
CHANGED
|
@@ -34,7 +34,7 @@ h1 { margin: 0; font-size: clamp(20px, 3vw, 27px); font-weight: 650; letter-spac
|
|
|
34
34
|
.card h2, .panel h2, .lower h2, .panel > summary, .analytics-section > summary { color: var(--heading); font-size: 11px; font-weight: 700; letter-spacing: .08em; line-height: 1.6; margin: 0; }
|
|
35
35
|
.card strong, .panel > strong { display: block; margin-top: 21px; color: var(--strong); font-size: 23px; font-weight: 650; line-height: 1.25; letter-spacing: -.035em; overflow-wrap: anywhere; }
|
|
36
36
|
.card p { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
|
|
37
|
-
.details { display: grid; grid-template-columns: repeat(
|
|
37
|
+
.details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; margin-top: 11px; }
|
|
38
38
|
.panel { min-height: 205px; padding: 18px; }
|
|
39
39
|
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
|
|
40
40
|
.panel-heading span { color: var(--quiet); font-size: 10px; white-space: nowrap; }
|
|
@@ -133,7 +133,7 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
|
|
|
133
133
|
#auto-refresh[aria-pressed="false"] { background: transparent; color: var(--muted); border-color: var(--border); }
|
|
134
134
|
.refresh-time { display: block; margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
|
|
135
135
|
@media (max-width: 1000px) { .animation-options { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
136
|
-
@media (max-width:
|
|
136
|
+
@media (max-width: 1000px) { .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); } .details { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
137
137
|
@media (max-width: 680px) { .animation-options { grid-template-columns: 1fr; } }
|
|
138
138
|
@media (max-width: 620px) { .snapshot-meta { justify-content: flex-start; margin-top: 9px; } }
|
|
139
139
|
@media (max-width: 620px) { .shell { padding: 0 16px; } .topbar { min-height: 60px; } .brand-detail { display: none; } .topbar-actions { gap: 11px; } .intro { display: block; padding: 29px 0 21px; } .intro p { margin-top: 9px; } .overview, .details { grid-template-columns: 1fr; } .details .panel:last-child { grid-column: auto; } .card { min-height: 122px; } .card strong { margin-top: 14px; } .lower li { display: block; } .lower li span { display: block; margin-top: 5px; } }
|
package/src/dashboard/ui.js
CHANGED
|
@@ -246,7 +246,7 @@ function applyModels(data, { changed }) {
|
|
|
246
246
|
}
|
|
247
247
|
if (!data.models.length) emptyTable("live-models-body", 4, "No selectable GPT models advertised.");
|
|
248
248
|
}
|
|
249
|
-
text("models-note", "{selectable} selectable / {advertised} advertised / {host} / {time}", { selectable: number(data.selectable), advertised: number(data.advertised), host: data.upstream_host, time: new Date(data.checked_at).toLocaleTimeString() });
|
|
249
|
+
text("models-note", "{selectable} selectable / {advertised} advertised / {host} / {time}", { selectable: number(data.selectable), advertised: number(data.advertised), host: data.upstream_host, time: data.checked_at ? new Date(data.checked_at).toLocaleTimeString() : phrase("Unknown") });
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
async function loadUsage() { return dashboardRefresh.refresh("usage", { force: true }); }
|
|
@@ -255,7 +255,7 @@ async function readDashboard(url, { signal, timeout = 15000, source } = {}) {
|
|
|
255
255
|
const response = await fetch(url, { cache: "no-store", headers: { "X-CCDX-Dashboard": "1", Accept: "application/json" },
|
|
256
256
|
signal: AbortSignal.any([signal, AbortSignal.timeout(timeout)]) });
|
|
257
257
|
const data = await response.json();
|
|
258
|
-
if (!response.ok || (source &&
|
|
258
|
+
if (!response.ok || (source && !(Array.isArray(source) ? source : [source]).includes(data.source))) throw new Error(data.error || `HTTP ${response.status}`);
|
|
259
259
|
return data;
|
|
260
260
|
}
|
|
261
261
|
|
|
@@ -312,7 +312,7 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
|
312
312
|
models: {
|
|
313
313
|
visible: () => element("upstream-models").open,
|
|
314
314
|
load: async ({ signal }) => {
|
|
315
|
-
const data = await readDashboard("/_ccdx/ui/models/live", { signal, source: "live" });
|
|
315
|
+
const data = await readDashboard("/_ccdx/ui/models/live", { signal, source: ["live", "catalog"] });
|
|
316
316
|
if (!Array.isArray(data.models) || data.models.some(model => !model || typeof model.id !== "string" || !Array.isArray(model.endpoints))) throw new Error("Invalid model snapshot");
|
|
317
317
|
return data;
|
|
318
318
|
},
|
|
@@ -320,7 +320,7 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
|
320
320
|
apply: applyModels,
|
|
321
321
|
state: state => {
|
|
322
322
|
element("refresh-models").disabled = Boolean(state.pending);
|
|
323
|
-
text("models-state", state.pending ? "CHECKING LIVE" : state.error ? "LIVE LOOKUP FAILED" : "LIVE SNAPSHOT");
|
|
323
|
+
text("models-state", state.pending ? "CHECKING LIVE" : state.error ? "LIVE LOOKUP FAILED" : state.value?.source === "catalog" ? "CATALOG SNAPSHOT" : "LIVE SNAPSHOT");
|
|
324
324
|
if (state.error) {
|
|
325
325
|
const message = String(state.error.message || state.error).slice(0, 240);
|
|
326
326
|
const httpError = /^Live model lookup failed \(HTTP (\d{3})\)\. Run ccdx models for details\.$/.exec(message);
|
|
@@ -333,15 +333,23 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
|
333
333
|
},
|
|
334
334
|
usage: {
|
|
335
335
|
visible: () => element("model-usage").open,
|
|
336
|
-
variant: () =>
|
|
336
|
+
variant: () => {
|
|
337
|
+
const mode = ((element("model-usage").open && element("usage-analytics").open) || Boolean(usageView.selectedDate)) ? "analytics" : "summary";
|
|
338
|
+
const provider = element("usage-provider")?.value || "";
|
|
339
|
+
return mode + (provider ? `:${provider}` : "");
|
|
340
|
+
},
|
|
337
341
|
load: async ({ variant, signal }) => {
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
342
|
+
const [mode, provider = ""] = variant.split(":"), query = new URLSearchParams();
|
|
343
|
+
if (mode === "analytics") { query.set("analytics", "1");query.set("time_zone", Intl.DateTimeFormat().resolvedOptions().timeZone); }
|
|
344
|
+
if (provider) query.set("provider", provider);
|
|
345
|
+
const data = await readDashboard(`/_ccdx/ui/usage${query.size ? `?${query}` : ""}`, { signal, source: "local_usage_log" });
|
|
346
|
+
if (!data.total || !Array.isArray(data.rows) || (mode === "analytics" && (!Array.isArray(data.analytics?.days) || !data.analytics.days.length))) throw new Error("Invalid usage snapshot");
|
|
340
347
|
return data;
|
|
341
348
|
},
|
|
342
349
|
apply: applyUsage,
|
|
343
350
|
state: state => {
|
|
344
351
|
element("refresh-usage").disabled = Boolean(state.pending);
|
|
352
|
+
if (element("usage-provider")) element("usage-provider").disabled = Boolean(state.pending);
|
|
345
353
|
if (state.pending) text("usage-state", "READING LOG");
|
|
346
354
|
else if (state.error) {
|
|
347
355
|
text("usage-state", "LOG UNAVAILABLE");
|
|
@@ -415,6 +423,7 @@ for (const id of ["analytics-model", "analytics-range", "analytics-metric"]) ele
|
|
|
415
423
|
if (usageView.data && usageView.selectedDate) renderUsageTable();
|
|
416
424
|
});
|
|
417
425
|
element("clear-usage-day").addEventListener("click", () => selectUsageDay(""));
|
|
426
|
+
element("usage-provider")?.addEventListener("change", () => { dashboardRefresh.invalidate("usage");dashboardRefresh.refresh("usage", { force: true }); });
|
|
418
427
|
element("refresh-models").addEventListener("click", loadModels);
|
|
419
428
|
element("refresh-usage").addEventListener("click", loadUsage);
|
|
420
429
|
loadAnimation();
|
package/src/dashboard/usage.js
CHANGED
|
@@ -145,7 +145,9 @@
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
function applyUsage(data, { changed }) {
|
|
148
|
-
|
|
148
|
+
const sameProvider = (data.provider || "all") === (usageData?.provider || "all");
|
|
149
|
+
if (!sameProvider) selectedUsageDate = "";
|
|
150
|
+
usageData = { ...data, ...(!data.analytics && sameProvider && usageData?.analytics ? { analytics: usageData.analytics } : {}) };
|
|
149
151
|
if (changed) {
|
|
150
152
|
if (data.analytics) updateAnalyticsModels();
|
|
151
153
|
renderUsageTable();
|
package/src/dashboard-api.mjs
CHANGED
|
@@ -114,6 +114,7 @@ export async function handleDashboardApi(req, res, pathname, {
|
|
|
114
114
|
liveModelsFn = options => fetchLiveCopilotModels({ home, ...options }),
|
|
115
115
|
usageSummaryFn,
|
|
116
116
|
authStatusFn = () => authStatus({ home }),
|
|
117
|
+
providerCatalogFn,
|
|
117
118
|
} = {}) {
|
|
118
119
|
if (!isLoopbackAddress(req.socket?.remoteAddress)
|
|
119
120
|
|| req.headers?.host === undefined
|
|
@@ -193,21 +194,21 @@ export async function handleDashboardApi(req, res, pathname, {
|
|
|
193
194
|
if (pathname === MODELS_PATH && req.method === "GET") {
|
|
194
195
|
const abort = createRequestAbort(req, res);
|
|
195
196
|
try {
|
|
196
|
-
const catalog = await liveModelsFn({ signal: abort.signal });
|
|
197
|
+
const catalog = providerCatalogFn?.() || await liveModelsFn({ signal: abort.signal });
|
|
197
198
|
if (!Array.isArray(catalog?.models) || !Number.isFinite(catalog?.advertised)) {
|
|
198
199
|
throw new Error("Invalid live model catalog");
|
|
199
200
|
}
|
|
200
201
|
const models = catalog.models;
|
|
201
202
|
sendJson(res, 200, {
|
|
202
|
-
source: "live",
|
|
203
|
-
checked_at: new Date().toISOString(),
|
|
203
|
+
source: catalog.source === "catalog" ? "catalog" : "live",
|
|
204
|
+
checked_at: catalog.source === "catalog" ? catalog.checkedAt : new Date().toISOString(),
|
|
204
205
|
upstream_host: safeText(catalog?.upstreamHost || "GitHub Copilot", 120),
|
|
205
206
|
advertised: finite(catalog?.advertised),
|
|
206
207
|
selectable: models.length,
|
|
207
208
|
models: models.slice(0, 500).map((model) => ({
|
|
208
209
|
id: safeText(model.id, 100),
|
|
209
210
|
vendor: safeText(model.vendor, 80),
|
|
210
|
-
endpoints: Array.isArray(model.endpoints) ? model.endpoints.filter((value) =>
|
|
211
|
+
endpoints: Array.isArray(model.endpoints) ? model.endpoints.filter((value) => ["responses", "chat", "messages"].includes(value)) : [],
|
|
211
212
|
preview: model.preview === true,
|
|
212
213
|
})),
|
|
213
214
|
});
|
|
@@ -219,6 +220,8 @@ export async function handleDashboardApi(req, res, pathname, {
|
|
|
219
220
|
|
|
220
221
|
if (pathname === USAGE_PATH && req.method === "GET") {
|
|
221
222
|
const query = new URL(req.url, "http://localhost").searchParams;
|
|
223
|
+
const provider = query.get("provider") || "";
|
|
224
|
+
if (provider && !["github", "m365"].includes(provider)) { sendJson(res, 400, { error: "Select GitHub or Microsoft 365" });return; }
|
|
222
225
|
let analytics = null;
|
|
223
226
|
if (query.get("analytics") === "1") {
|
|
224
227
|
try {
|
|
@@ -232,9 +235,9 @@ export async function handleDashboardApi(req, res, pathname, {
|
|
|
232
235
|
}
|
|
233
236
|
try {
|
|
234
237
|
const analysis = analytics && !usageSummaryFn
|
|
235
|
-
? await analyzeUsageLogs(undefined, { timeZone: query.get("time_zone") || "UTC" }) : null;
|
|
236
|
-
const summary = analysis?.summary || await (usageSummaryFn || (options => summarizeUsageLogs(undefined, options)))(analytics ? { onRecord: analytics.record } :
|
|
237
|
-
sendJson(res, 200, { source: "local_usage_log", ...usageTable(summary), ...(analytics ? { analytics: analysis?.analytics || analytics.snapshot() } : {}) });
|
|
238
|
+
? await analyzeUsageLogs(undefined, { timeZone: query.get("time_zone") || "UTC", provider }) : null;
|
|
239
|
+
const summary = analysis?.summary || await (usageSummaryFn || (options => summarizeUsageLogs(undefined, options)))({ provider, ...(analytics ? { onRecord: analytics.record } : {}) });
|
|
240
|
+
sendJson(res, 200, { source: "local_usage_log", provider: provider || "all", providers: summary.providers, ...usageTable(summary), ...(analytics ? { analytics: analysis?.analytics || analytics.snapshot() } : {}) });
|
|
238
241
|
} catch {
|
|
239
242
|
sendJson(res, 500, { error: "Could not read local usage summary" });
|
|
240
243
|
}
|
package/src/doctor-repair.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { readSavedGithubToken } from "./auth-credentials.mjs";
|
|
|
4
4
|
import { importDiscoveredGithubToken } from "./auth.mjs";
|
|
5
5
|
import { readPredictionSettings } from "./native-prediction-profile.mjs";
|
|
6
6
|
import { requestPredictionFix } from "./native-prediction-fix.mjs";
|
|
7
|
+
import { readProviderSettings } from "./provider-settings.mjs";
|
|
7
8
|
|
|
8
9
|
// Explicit invocation only. One repair and one affected recheck per operation.
|
|
9
10
|
export async function repairDoctor({ home, env = process.env, host, port, platform = process.platform, fetchImpl = fetch,
|
|
@@ -31,6 +32,7 @@ export async function repairDoctor({ home, env = process.env, host, port, platfo
|
|
|
31
32
|
: "Codex configuration preserved; review invalid or custom settings manually" };
|
|
32
33
|
});
|
|
33
34
|
await run("github-auth", async () => {
|
|
35
|
+
if (readProviderSettings({ home, env }).codex === "m365") return { kind: "info", result: "preserved_existing", message: "GitHub credentials preserved; Codex currently uses Microsoft 365" };
|
|
34
36
|
if (savedToken(home)) return { kind: "info", result: "preserved_existing", message: "Saved GitHub credential retained; use doctor --online to verify access" };
|
|
35
37
|
const imported = await importToken({ home, env, fetchImpl, log: () => {} });
|
|
36
38
|
const verified = imported?.ok && Boolean(savedToken(home));
|
package/src/doctor.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import { inspectPredictionEnvironment } from "./native-prediction-environment.mj
|
|
|
22
22
|
import { formatPredictionEnvironment } from "./native-prediction-state.mjs";
|
|
23
23
|
import { readImageProviderConfig } from "./image-provider-config.mjs";
|
|
24
24
|
import { inspectAdapterCompatibility } from "./doctor-compat.mjs";
|
|
25
|
+
import { readProviderSettings } from "./provider-settings.mjs";
|
|
25
26
|
export { selectCompatibilityModels, inspectAdapterCompatibility } from "./doctor-compat.mjs";
|
|
26
27
|
|
|
27
28
|
export { inspectCodexConfig };
|
|
@@ -196,14 +197,20 @@ export async function collectDoctorChecks({
|
|
|
196
197
|
readPredictionSettingsFn = readPredictionSettings,
|
|
197
198
|
inspectPredictionEnvironmentFn = inspectPredictionEnvironment,
|
|
198
199
|
readImageProviderConfigFn = readImageProviderConfig,
|
|
200
|
+
providerControlFn,
|
|
199
201
|
} = {}) {
|
|
200
202
|
if (configOnly) return inspectCodexConfig({ home, env, host, port });
|
|
201
203
|
checkedDoctorProfile(profile);
|
|
204
|
+
let source = "github", sourceError = null;
|
|
205
|
+
try { source = readProviderSettings({ home, env }).codex; } catch (error) { sourceError = error.message; }
|
|
202
206
|
const checks = [
|
|
203
|
-
...inspectAuthProfiles({ home }).map(check => ({ ...check, id: "github-auth"
|
|
207
|
+
...inspectAuthProfiles({ home }).map(check => ({ ...check, id: "github-auth",
|
|
208
|
+
...(source === "m365" ? { kind: "info", message: `Inactive GitHub provider: ${check.message}` } : {}) })),
|
|
204
209
|
...inspectCodexConfig({ home, env, host, port }).map(check => ({ ...check, id: "codex-config" })),
|
|
205
210
|
{ kind: "info", message: `Runtime: Node ${process.version}, ${platform}/${process.arch}` },
|
|
206
211
|
];
|
|
212
|
+
if (sourceError) checks.push({ kind: "err", id: "provider", message: sourceError });
|
|
213
|
+
else if (source === "m365") checks.push({ kind: "info", id: "provider", message: "Codex provider: Microsoft 365; GitHub credentials are retained independently" });
|
|
207
214
|
if (platform === "win32") {
|
|
208
215
|
const command = inspectWindowsCommandFn({ platform });
|
|
209
216
|
checks.push({ kind: command.status === "ready" ? "ok" : ["checkout", "not_applicable"].includes(command.status) ? "info" : "warn", id: "windows-command",
|
|
@@ -237,7 +244,16 @@ export async function collectDoctorChecks({
|
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
if (online) {
|
|
240
|
-
|
|
247
|
+
if (source === "m365") {
|
|
248
|
+
try {
|
|
249
|
+
const control = providerControlFn || (await import("./cli-m365.mjs")).providerControl;
|
|
250
|
+
const result = await control({ host, port, fetchImpl, action: { action: "models", family: "gpt" }, timeoutMs: onlineTimeoutMs });
|
|
251
|
+
const ready = result.state?.m365?.state === "ready" && result.models?.length > 0;
|
|
252
|
+
checks.push({ kind: ready ? "ok" : "warn", id: "provider", message: ready
|
|
253
|
+
? `Microsoft 365 is ready; ${result.models.length} GPT models available`
|
|
254
|
+
: "Microsoft 365 is not ready; inspect ccdx m365 status. No GitHub fallback was selected" });
|
|
255
|
+
} catch { checks.push({ kind: "warn", id: "provider", message: "Microsoft 365 could not be checked through the running adapter; start ccdx and inspect ccdx m365 status" }); }
|
|
256
|
+
} else if (!sourceError) checks.push(...await inspectAuthProfilesOnline({
|
|
241
257
|
home,
|
|
242
258
|
profile,
|
|
243
259
|
fetchImpl,
|