codex-copilot-dx 0.9.13 → 0.9.15
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 +61 -433
- package/docs/README.md +55 -0
- package/docs/REFERENCE.md +481 -0
- package/package.json +4 -3
- package/src/adapter.mjs +2 -0
- package/src/cli-options.mjs +1 -1
- package/src/cli-status.mjs +3 -0
- package/src/codex-client-doctor.mjs +67 -0
- package/src/codex-model-catalog.mjs +16 -2
- package/src/copilot-client.mjs +2 -1
- package/src/copilot-responses-policy.mjs +35 -18
- package/src/dashboard/index.html +7 -0
- package/src/dashboard/language.js +11 -0
- package/src/dashboard/ui.css +7 -6
- package/src/dashboard/ui.js +30 -0
- package/src/doctor.mjs +3 -0
- package/src/image-optimization.mjs +1 -1
- package/src/models.mjs +6 -0
- package/src/observability.mjs +17 -0
- package/src/responses-bridge.mjs +1 -1
- package/src/responses-chat-payload.mjs +2 -1
- package/src/responses-handler.mjs +12 -2
- package/src/responses-proxy.mjs +10 -0
- package/src/sse-keepalive.mjs +42 -0
- package/src/stream-performance.mjs +14 -1
- package/src/usage.mjs +3 -0
|
@@ -159,6 +159,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
159
159
|
let headersAt = null;
|
|
160
160
|
let lastActivityAt = null;
|
|
161
161
|
let terminalAt = null;
|
|
162
|
+
const context = { payload_bytes: null, images: null, input_tokens: null, context_window_tokens: null };
|
|
162
163
|
const elapsed = (time) => time === null ? null : Number(Math.max(0, time - requestStartedAt).toFixed(1));
|
|
163
164
|
|
|
164
165
|
return {
|
|
@@ -205,6 +206,13 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
205
206
|
setModel(value) {
|
|
206
207
|
model = modelLabel(value);
|
|
207
208
|
},
|
|
209
|
+
observeContext(values) {
|
|
210
|
+
if (finished || !values || typeof values !== "object") return;
|
|
211
|
+
for (const key of Object.keys(context)) {
|
|
212
|
+
const value = values[key];
|
|
213
|
+
if (Number.isSafeInteger(value) && value >= 0 && (key !== "context_window_tokens" || value > 0)) context[key] = value;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
208
216
|
setErrorOrigin(value) {
|
|
209
217
|
if (TERMINAL_ORIGINS.has(value)) errorOrigin = value;
|
|
210
218
|
},
|
|
@@ -242,6 +250,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
242
250
|
failed: failed || aborted || (terminalOutcome !== null && terminalOutcome !== "completed"),
|
|
243
251
|
http_status: Number.isInteger(statusCode) && statusCode >= 100 && statusCode <= 599 ? statusCode : null,
|
|
244
252
|
upstream_attempts: attempts,
|
|
253
|
+
context: { ...context },
|
|
245
254
|
timings_ms: {
|
|
246
255
|
...Object.fromEntries(PREPARATION_STAGES.map((stage) => [stage, Number(preparationMs[stage].toFixed(1))])),
|
|
247
256
|
upstream_start: elapsed(firstAttemptAt), upstream_headers: elapsed(headersAt),
|
|
@@ -272,7 +281,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
272
281
|
snapshot() {
|
|
273
282
|
return {
|
|
274
283
|
by_route: Object.fromEntries(PERFORMANCE_ROUTES.map((name) => [name, routeSnapshot(routes[name])])),
|
|
275
|
-
recent_requests: recentRequests.map((entry) => ({ ...entry, timings_ms: { ...entry.timings_ms } })),
|
|
284
|
+
recent_requests: recentRequests.map((entry) => ({ ...entry, context: { ...entry.context }, timings_ms: { ...entry.timings_ms } })),
|
|
276
285
|
};
|
|
277
286
|
},
|
|
278
287
|
};
|
|
@@ -320,6 +329,10 @@ export function markOutputTokens(value) {
|
|
|
320
329
|
tracker()?.setOutputTokens(value);
|
|
321
330
|
}
|
|
322
331
|
|
|
332
|
+
export function markRequestObservation(values) {
|
|
333
|
+
tracker()?.observeContext?.(values);
|
|
334
|
+
}
|
|
335
|
+
|
|
323
336
|
export function markStreamFailure() {
|
|
324
337
|
tracker()?.fail();
|
|
325
338
|
}
|
package/src/usage.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { markRequestObservation } from "./stream-performance.mjs";
|
|
2
3
|
import os from "node:os";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import readline from "node:readline";
|
|
@@ -180,6 +181,8 @@ export function recordUsage(record) {
|
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
export function recordResponsesUsage(args) {
|
|
184
|
+
const response = args.response || args.event?.response || args.event;
|
|
185
|
+
markRequestObservation({ input_tokens: response?.usage?.input_tokens });
|
|
183
186
|
return recordUsage(buildResponsesUsageRecord(args));
|
|
184
187
|
}
|
|
185
188
|
|