codex-copilot-dx 1.2.9 → 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.
@@ -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) }),