codex-copilot-dx 1.2.8 → 1.2.10
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 +3 -3
- package/docs/ARCHITECTURE.md +31 -3
- package/docs/REFERENCE.md +36 -10
- package/package.json +1 -1
- package/src/cli-m365.mjs +5 -0
- package/src/dashboard/animation.js +186 -0
- package/src/dashboard/console.js +50 -19
- package/src/dashboard/index.html +106 -84
- package/src/dashboard/language.js +56 -5
- package/src/dashboard/status.js +60 -25
- package/src/dashboard/time.js +16 -0
- package/src/dashboard/tools.js +7 -3
- package/src/dashboard/ui.css +56 -14
- package/src/dashboard/ui.js +78 -211
- package/src/dashboard/updates.js +3 -3
- package/src/dashboard/usage.js +2 -2
- package/src/dashboard-api.mjs +4 -2
- package/src/dashboard.mjs +2 -0
- package/src/optional-routes.mjs +1 -1
- package/src/provider-descriptors.mjs +24 -0
- package/src/provider-runtime.mjs +10 -22
- package/src/providers/m365-catalog-diagnostic.mjs +38 -0
- package/src/providers/m365.mjs +8 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The server body is inspected once. Only fixed causes and bounded IDs survive.
|
|
2
|
+
const causes = Object.freeze({
|
|
3
|
+
sign_in_rejected: "Microsoft 365 rejected the sign-in. Check account access.",
|
|
4
|
+
entra_access_disabled: "Copilot CLI Entra access is not enabled for this account.",
|
|
5
|
+
access_denied: "Microsoft 365 denied access to the model list.",
|
|
6
|
+
rate_limited: "Microsoft 365 limited model-list checks. Try again later.",
|
|
7
|
+
service_unavailable: "Microsoft 365 could not serve the model list.",
|
|
8
|
+
catalog_rejected: "Microsoft 365 rejected the model-list request.",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const date = value => typeof value === "string" && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(value)
|
|
12
|
+
&& Number.isFinite(Date.parse(value)) ? value : null;
|
|
13
|
+
|
|
14
|
+
export function m365CatalogDiagnostic(value) {
|
|
15
|
+
if (!value || value.stage !== "catalog" || !Object.hasOwn(causes, value.cause_code)
|
|
16
|
+
|| !Number.isInteger(value.http_status) || value.http_status < 400 || value.http_status > 599) return null;
|
|
17
|
+
return { stage: "catalog", cause_code: value.cause_code, http_status: value.http_status,
|
|
18
|
+
checked_at: date(value.checked_at), last_success_at: date(value.last_success_at),
|
|
19
|
+
request_id: typeof value.request_id === "string" && /^[a-zA-Z0-9_-]{1,80}$/.test(value.request_id)
|
|
20
|
+
&& !/^(?:github_pat_|gh[pousr]_|sk-|eyJ)/.test(value.request_id) ? value.request_id : null };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function m365CatalogMessage(value) {
|
|
24
|
+
const diagnostic = m365CatalogDiagnostic(value);
|
|
25
|
+
return diagnostic ? causes[diagnostic.cause_code] : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function catalogFailure(response, body, { checkedAt, lastSuccessAt } = {}) {
|
|
29
|
+
let message;
|
|
30
|
+
try { const value = JSON.parse(body);message = value?.error?.message ?? value?.message; } catch { /* Unrecognized bodies get the HTTP category only. */ }
|
|
31
|
+
const code = response.status;
|
|
32
|
+
const cause_code = code === 401 ? "sign_in_rejected"
|
|
33
|
+
: code === 403 ? typeof message === "string" && /^Copilot CLI Entra access is not enabled for this user\.?$/i.test(message.trim())
|
|
34
|
+
? "entra_access_disabled" : "access_denied"
|
|
35
|
+
: code === 429 ? "rate_limited" : code >= 500 ? "service_unavailable" : "catalog_rejected";
|
|
36
|
+
return m365CatalogDiagnostic({ stage: "catalog", cause_code, http_status: code, checked_at: checkedAt,
|
|
37
|
+
last_success_at: lastSuccessAt, request_id: response.headers.get("request-id") || response.headers.get("x-ms-request-id") });
|
|
38
|
+
}
|
package/src/providers/m365.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { resolveClaudeModel } from "../claude-models.mjs";
|
|
|
16
16
|
import { modelReasoningEfforts } from "../provider-metadata.mjs";
|
|
17
17
|
import { limitM365CacheTtl } from "./m365-messages-policy.mjs";
|
|
18
18
|
import { createM365ConversationGuard } from "./m365-conversation-accounts.mjs";
|
|
19
|
+
import { catalogFailure, m365CatalogDiagnostic } from "./m365-catalog-diagnostic.mjs";
|
|
19
20
|
import { m365NetworkDiagnostic } from "./m365-network-diagnostic.mjs";
|
|
20
21
|
|
|
21
22
|
export const M365_API_BASE = "https://df.loki.delve.office.com/api/v1/llmapi";
|
|
@@ -75,7 +76,7 @@ export function createM365Provider({ home, env = process.env, account: accountOv
|
|
|
75
76
|
const guardConversation = createM365ConversationGuard({ home });
|
|
76
77
|
let catalog = null, account = null, catalogAt = 0, state = "idle", reason = null, flight = null, controller = null, generation = 0;
|
|
77
78
|
let network = null, networkFlight = null, cacheTtlAdjustments = 0;
|
|
78
|
-
let networkDiagnostic = null;
|
|
79
|
+
let networkDiagnostic = null, catalogDiagnostic = null;
|
|
79
80
|
const registry = { models: null, source: "unavailable", cacheState: "none", cacheSavedAtMs: null,
|
|
80
81
|
refreshInFlight: false, generation: 0, lastError: null, lastErrorAtMs: null };
|
|
81
82
|
const profile = () => account ? `m365:${m365AccountKey(account)}` : "m365:unavailable";
|
|
@@ -146,20 +147,23 @@ export function createM365Provider({ home, env = process.env, account: accountOv
|
|
|
146
147
|
const credential = await auth.getToken({ signal });
|
|
147
148
|
const response = await request("/models", null, { signal });
|
|
148
149
|
const raw = await readBoundedResponseText(response, { maxBytes: MAX_UPSTREAM_MODEL_CATALOG_BYTES, label: "M365 model catalog", signal });
|
|
149
|
-
if (!response.ok) throw m365Error(`m365_catalog_http_${response.status}`)
|
|
150
|
+
if (!response.ok) throw Object.assign(m365Error(`m365_catalog_http_${response.status}`), {
|
|
151
|
+
catalog_diagnostic: catalogFailure(response, raw, { checkedAt: new Date(now()).toISOString(),
|
|
152
|
+
lastSuccessAt: catalogAt ? new Date(catalogAt).toISOString() : null }) });
|
|
150
153
|
let value;try { value = m365Catalog(JSON.parse(raw)); } catch { throw m365Error("m365_catalog_invalid"); }
|
|
151
154
|
if (current !== generation || signal.aborted) throw m365Error("m365_refresh_cancelled");
|
|
152
155
|
const savedAt = now();
|
|
153
156
|
const nextAccount = { ...credential.account, ...(account?.history_isolation ? { history_isolation: true } : {}) };
|
|
154
157
|
if (persist) writeM365Binding(nextAccount, { account_key: m365AccountKey(nextAccount), saved_at: savedAt, models: value }, { home, expectedAccount: account });
|
|
155
158
|
account = nextAccount;
|
|
156
|
-
applyCatalog(value, "live", savedAt);state = "ready";reason = null;registry.lastError = null;registry.lastErrorAtMs = null;
|
|
159
|
+
applyCatalog(value, "live", savedAt);catalogDiagnostic = null;state = "ready";reason = null;registry.lastError = null;registry.lastErrorAtMs = null;
|
|
157
160
|
try { await onCatalog(value); } catch { log("warn", "M365 models are ready; optional client configuration could not be updated"); }
|
|
158
161
|
return value;
|
|
159
162
|
})().catch(error => {
|
|
160
163
|
if (current === generation) {
|
|
161
164
|
state = "unavailable";reason = /^m365_[a-z0-9_]+$/.test(error.code || "") ? error.code : "m365_unavailable";
|
|
162
165
|
networkDiagnostic = m365NetworkDiagnostic(error.network_diagnostic);
|
|
166
|
+
catalogDiagnostic = m365CatalogDiagnostic(error.catalog_diagnostic);
|
|
163
167
|
registry.lastError = reason;registry.lastErrorAtMs = now();
|
|
164
168
|
}
|
|
165
169
|
throw error;
|
|
@@ -254,6 +258,7 @@ export function createM365Provider({ home, env = process.env, account: accountOv
|
|
|
254
258
|
snapshot: () => ({ ...auth.snapshot(), state, reason: reason || auth.snapshot().reason, account: account ? { login: account.login, tenant: account.tenant, selection_source: account.selection_source || "legacy" } : null,
|
|
255
259
|
network: network?.snapshot() || null,
|
|
256
260
|
network_diagnostic: networkDiagnostic ? { ...networkDiagnostic } : null,
|
|
261
|
+
catalog_diagnostic: m365CatalogDiagnostic(catalogDiagnostic),
|
|
257
262
|
cache_ttl_adjustments: cacheTtlAdjustments,
|
|
258
263
|
models: { total: catalog?.data.length || 0, claude: m365Models(catalog, "claude").length, gpt: m365Models(catalog, "gpt").length,
|
|
259
264
|
source: registry.source, refreshed_at: catalogAt ? new Date(catalogAt).toISOString() : null }, refresh_in_flight: Boolean(flight) }),
|