codex-copilot-dx 1.2.23 → 1.2.24
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 +4 -4
- package/docs/ARCHITECTURE.md +32 -0
- package/docs/REFERENCE.md +74 -7
- package/package.json +1 -1
- package/src/adapter.mjs +2 -1
- package/src/api-catalog-refresh.mjs +2 -2
- package/src/api-model-display.mjs +47 -0
- package/src/claude-gateway.mjs +18 -9
- package/src/cli-status.mjs +1 -1
- package/src/codex-memory-model.mjs +64 -0
- package/src/codex-memory-probe.mjs +25 -0
- package/src/connection-runtime.mjs +22 -8
- package/src/dashboard/connections.js +61 -7
- package/src/dashboard/flow.js +3 -8
- package/src/dashboard/index.html +5 -0
- package/src/dashboard/language.js +31 -2
- package/src/dashboard/status.js +14 -7
- package/src/dashboard/ui.css +29 -6
- package/src/dashboard/ui.js +5 -2
- package/src/provider-metadata.mjs +2 -2
- package/src/providers/api-token-count.mjs +52 -47
- package/src/providers/api.mjs +11 -5
- package/src/providers/m365.mjs +1 -1
- package/src/response-failures.mjs +13 -5
- package/src/responses-handler.mjs +2 -0
- package/src/stream-performance.mjs +7 -3
package/src/providers/m365.mjs
CHANGED
|
@@ -118,7 +118,7 @@ export function createM365Provider({ home, env = process.env, account: accountOv
|
|
|
118
118
|
const serialized = body ? options.bodyText ?? JSON.stringify(body) : undefined;
|
|
119
119
|
if (serialized !== undefined) requestHeaders["Content-Length"] = String(Buffer.byteLength(serialized));
|
|
120
120
|
options.onUpstreamStart?.();
|
|
121
|
-
if (body) markUpstreamStarted(body.stream === true);
|
|
121
|
+
if (body) { markUpstreamStarted(body.stream === true);if (!options.countTokens) markRequestObservation({ max_output_tokens_sent: endpoint.includes("messages") ? body.max_tokens : body.max_output_tokens }); }
|
|
122
122
|
try {
|
|
123
123
|
const send = fetchImpl || await transport(options.signal);
|
|
124
124
|
const response = await send(`${M365_API_BASE}${endpoint}`, { method: body ? "POST" : "GET", headers: requestHeaders,
|
|
@@ -2,6 +2,7 @@ import { terminalCell } from "./terminal-text.mjs";
|
|
|
2
2
|
import { redactDiagnosticText } from "./diagnostic-text.mjs";
|
|
3
3
|
import { currentRequestContext } from "./request-context.mjs";
|
|
4
4
|
import { isProviderId } from "./provider-metadata.mjs";
|
|
5
|
+
import { transportErrorDetails } from "./operation-error.mjs";
|
|
5
6
|
|
|
6
7
|
const DEFAULT_RECENT_FAILURES = 10;
|
|
7
8
|
|
|
@@ -129,6 +130,7 @@ export function requestOptionsEvidence(body) {
|
|
|
129
130
|
if (["auto", "default", "flex", "priority", "scale"].includes(body.service_tier)) result.service_tier = body.service_tier;
|
|
130
131
|
if (["text", "json_object", "json_schema"].includes(body.text?.format?.type)) result.output_format = body.text.format.type;
|
|
131
132
|
if (Number.isSafeInteger(body.max_output_tokens) && body.max_output_tokens >= 0) result.max_output_tokens = body.max_output_tokens;
|
|
133
|
+
if (Number.isSafeInteger(body.max_tokens) && body.max_tokens >= 0) result.max_tokens = body.max_tokens;
|
|
132
134
|
if (Array.isArray(body.tools)) result.tools = body.tools.length;
|
|
133
135
|
if (Array.isArray(body.input)) result.input_items = body.input.length;
|
|
134
136
|
return result;
|
|
@@ -144,15 +146,16 @@ export function createHttpFailureDiagnostics({ maxEntries = 20, now } = {}) {
|
|
|
144
146
|
return {
|
|
145
147
|
record(details) {
|
|
146
148
|
all.record(details);
|
|
147
|
-
const
|
|
149
|
+
const accessNotice = details.reason === "ccdx_model_not_selected" || details.reason === "ccdx_client_source_disabled";
|
|
150
|
+
const category = accessNotice || details.route === "messages_count_tokens" ? "capability"
|
|
148
151
|
: ["responses", "responses_compact", "messages"].includes(details.route) ? "inference"
|
|
149
152
|
: details.route === "image_mcp" && details.http_status === 405 ? "protocol"
|
|
150
153
|
: details.route === "not_found" ? "route" : "other";
|
|
151
154
|
counts[category]++;
|
|
152
|
-
if (category === "inference" || category === "other") actionable.record(details);
|
|
155
|
+
if ((category === "inference" || category === "other") && !accessNotice) actionable.record(details);
|
|
153
156
|
if (category === "capability") {
|
|
154
157
|
capability.record(details);
|
|
155
|
-
if (![404, 405, 501].includes(details.http_status)) actionable.record(details);
|
|
158
|
+
if (!accessNotice && ![404, 405, 501].includes(details.http_status)) actionable.record(details);
|
|
156
159
|
}
|
|
157
160
|
if (category === "protocol") protocol.record(details);
|
|
158
161
|
if (category === "route") routes.record(details);
|
|
@@ -165,13 +168,17 @@ export function createHttpFailureDiagnostics({ maxEntries = 20, now } = {}) {
|
|
|
165
168
|
|
|
166
169
|
export function buildHttpFailureDetails({ statusCode, route, requestId, model, code, origin, headers,
|
|
167
170
|
error_body, error_type, parameter, diagnostic_message, method, target, request_options, upstream_attempts, attempt_timings, requested_model, provider,
|
|
168
|
-
application, reason, capability_cached, shared_upstream }) {
|
|
171
|
+
application, reason, capability_cached, shared_upstream, transport }) {
|
|
172
|
+
if (!reason && code === "ccdx_client_source_disabled" && upstream_attempts === 0 && origin !== "upstream_http") {
|
|
173
|
+
reason = code;origin = "client_validation";
|
|
174
|
+
}
|
|
169
175
|
const reasons = { ccdx_model_not_selected: "This model is not selected for this app.",
|
|
170
176
|
ccdx_model_ambiguous: "This model name matches multiple sources. Select its source-specific entry.",
|
|
171
177
|
ccdx_model_catalog_unavailable: "The selected model is not currently available in its source catalog.",
|
|
172
178
|
ccdx_client_source_disabled: "This app or its model source is turned off." };
|
|
173
179
|
const message = (Object.hasOwn(reasons, reason) ? reasons[reason] : null) || (route === "messages_count_tokens" && statusCode === 404 ? "The source's token-count endpoint returned HTTP 404. Message generation is separate."
|
|
174
|
-
:
|
|
180
|
+
: code === "ccdx_api_network_unavailable" ? "Connection to the model source failed."
|
|
181
|
+
: origin === "client_validation" ? "The request was rejected locally before an upstream call."
|
|
175
182
|
: error_body === "empty" ? "Upstream returned no error details." : "HTTP request failed; original response was preserved.");
|
|
176
183
|
const details = responseFailureDetails({ model, error: { code: typeof code === "string" && /^[a-z\d_.:-]{1,80}$/i.test(code) ? code : `http_${statusCode}`,
|
|
177
184
|
message } }, "http.error", { headers, provider });
|
|
@@ -186,5 +193,6 @@ export function buildHttpFailureDetails({ statusCode, route, requestId, model, c
|
|
|
186
193
|
...(["codex_app", "codex_cli", "codex", "claude_app", "claude_code", "claude", "api"].includes(application) ? { application } : {}),
|
|
187
194
|
...(Object.hasOwn(reasons, reason) ? { reason } : {}),
|
|
188
195
|
...(capability_cached === true ? { capability_cached: true } : {}), ...(shared_upstream === true ? { shared_upstream: true } : {}),
|
|
196
|
+
...(transport ? { transport: transportErrorDetails({ transport }) } : {}),
|
|
189
197
|
...(Number.isSafeInteger(upstream_attempts) ? { upstream_attempts } : {}) };
|
|
190
198
|
}
|
|
@@ -208,6 +208,7 @@ export function createResponsesHandler(options) {
|
|
|
208
208
|
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
209
209
|
parsed = await measureRequestStageAsync("body", () => readJsonBody(req, { admission: releaseRequest, signal: abort.signal }));
|
|
210
210
|
observeRequestedModel(parsed);
|
|
211
|
+
markRequestObservation({ max_output_tokens_requested: parsed?.max_output_tokens });
|
|
211
212
|
const selectedProvider = options.resolveProvider?.(parsed, req);
|
|
212
213
|
if (selectedProvider) {
|
|
213
214
|
provider = selectedProvider;modelRegistry = provider.registry;
|
|
@@ -492,6 +493,7 @@ export function createResponsesCompactHandler(options) {
|
|
|
492
493
|
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
493
494
|
const parsed = await measureRequestStageAsync("body", () => readJsonBody(req, { admission: releaseRequest, signal: abort.signal }));
|
|
494
495
|
observeRequestedModel(parsed);
|
|
496
|
+
markRequestObservation({ max_output_tokens_requested: parsed?.max_output_tokens });
|
|
495
497
|
const selectedProvider = options.resolveProvider?.(parsed, req);
|
|
496
498
|
if (selectedProvider) {
|
|
497
499
|
provider = selectedProvider;modelRegistry = provider.registry;
|
|
@@ -249,7 +249,8 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
249
249
|
let headersAt = null;
|
|
250
250
|
let lastActivityAt = null;
|
|
251
251
|
let terminalAt = null;
|
|
252
|
-
const context = { payload_bytes: null, images: null, input_tokens: null, context_window_tokens: null };
|
|
252
|
+
const context = { payload_bytes: null, images: null, input_tokens: null, context_window_tokens: null, output_tokens: null, max_output_tokens_requested: null, max_output_tokens_sent: null };
|
|
253
|
+
let stopReason = null;
|
|
253
254
|
const elapsed = (time) => time === null ? null : Number(Math.max(0, time - requestStartedAt).toFixed(1));
|
|
254
255
|
if (activeRequests.size < MAX_ACTIVE_REQUESTS) activeRequests.set(activeId, () => ({
|
|
255
256
|
request_id: safeRequestId, application: client, route: routeName, provider, model, phase,
|
|
@@ -337,19 +338,20 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
337
338
|
setErrorOrigin(value) {
|
|
338
339
|
if (TERMINAL_ORIGINS.has(value)) errorOrigin = value;
|
|
339
340
|
},
|
|
340
|
-
terminal(outcome, { model: terminalModel, origin, reason } = {}) {
|
|
341
|
+
terminal(outcome, { model: terminalModel, origin, reason, stopReason: stopped } = {}) {
|
|
341
342
|
if (finished || terminalOutcome || !TERMINAL_OUTCOMES.includes(outcome)) return;
|
|
342
343
|
terminalOutcome = outcome;
|
|
343
344
|
terminalAt = now();
|
|
344
345
|
if (terminalModel !== undefined) model = modelLabel(terminalModel);
|
|
345
346
|
if (TERMINAL_ORIGINS.has(origin)) terminalOrigin = origin;
|
|
346
347
|
if (outcome === "incomplete") incompleteReason = INCOMPLETE_REASONS.has(reason) ? reason : "other";
|
|
348
|
+
if (["end_turn", "max_tokens", "tool_use", "stop_sequence", "pause_turn", "refusal", "model_context_window_exceeded"].includes(stopped)) stopReason = stopped;
|
|
347
349
|
if (outcome !== "completed") failed = true;
|
|
348
350
|
},
|
|
349
351
|
fail() {
|
|
350
352
|
failed = true;
|
|
351
353
|
},
|
|
352
|
-
finish({ failed: finishFailed = false, aborted = false, statusCode = 0 } = {}) {
|
|
354
|
+
finish({ failed: finishFailed = false, aborted = false, statusCode = 0, rejectionReason } = {}) {
|
|
353
355
|
if (finished) return;
|
|
354
356
|
if (!sourceStats) assignProvider("unknown");
|
|
355
357
|
finished = true;
|
|
@@ -381,6 +383,8 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
381
383
|
recentRequests.push({
|
|
382
384
|
request_id: safeRequestId, application: client,
|
|
383
385
|
at, route: routeName, model, outcome, origin, phase,
|
|
386
|
+
...(["ccdx_model_not_selected", "ccdx_client_source_disabled"].includes(rejectionReason) ? { rejection_reason: rejectionReason } : {}),
|
|
387
|
+
...(stopReason ? { stop_reason: stopReason } : {}),
|
|
384
388
|
...(provider ? { provider } : {}),
|
|
385
389
|
empty_stream_completion: emptyStreamCompletion,
|
|
386
390
|
failed: failed || aborted || (terminalOutcome !== null && terminalOutcome !== "completed"),
|