codex-copilot-dx 0.9.39 → 0.9.41
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/bin/cli.mjs +6 -1
- package/docs/ARCHITECTURE.md +36 -5
- package/docs/REFERENCE.md +80 -12
- package/package.json +1 -1
- package/src/adapter.mjs +26 -141
- package/src/auth.mjs +11 -2
- package/src/cli-status.mjs +17 -7
- package/src/copilot-client.mjs +4 -0
- package/src/copilot-responses-compat.mjs +1 -1
- package/src/copilot-responses-policy.mjs +9 -0
- package/src/copilot-token-session.mjs +19 -3
- package/src/dashboard/index.html +3 -3
- package/src/dashboard/language.js +14 -2
- package/src/dashboard/status.js +11 -3
- package/src/http-transport.mjs +6 -3
- package/src/launcher.mjs +4 -4
- package/src/management-routes.mjs +118 -0
- package/src/native-prediction-route.mjs +2 -2
- package/src/native-prediction-transport.mjs +4 -3
- package/src/native-prediction-windows.mjs +2 -2
- package/src/network-route.mjs +2 -1
- package/src/optional-routes.mjs +33 -0
- package/src/prediction-pac.mjs +17 -0
- package/src/response-failures.mjs +64 -5
- package/src/responses-bridge.mjs +1 -1
- package/src/responses-handler.mjs +4 -12
- package/src/stream-performance.mjs +35 -6
- package/src/windows-prediction-network.mjs +2 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ is needed. On Windows, open the App manually unless native prediction setup is
|
|
|
21
21
|
enabled. In restricted Windows PowerShell, use `npm.cmd` to install and `ccdx.cmd` for the first launch, or run `ccdx.cmd doctor --fix`. Startup, updates and explicit repair remove only CCDX's exact npm-generated `.ps1` launchers so later calls can use `ccdx`. No install script, alias or policy change is added; custom launchers are preserved. npm's own script is untouched. The configured `dummy` API key is a placeholder, not a credential.
|
|
22
22
|
|
|
23
23
|
Open [the local dashboard](http://127.0.0.1:2026/) for status, model discovery,
|
|
24
|
-
usage, cache/limits, recent failures, request context and animation settings.
|
|
24
|
+
usage, cache/limits, recent failures, request context and animation settings. First output uses **ms**; estimated output speed uses **token/s**. Inference HTTP failures are retained separately from route and MCP-method errors.
|
|
25
25
|
Auto refresh runs every 30 minutes while visible and can be switched off. Hidden pages pause; opening sections and manual refresh still work. The atom rotates once on page load and manual refresh, respecting reduced motion. Startup uses a compact six-line atom and aligned checks; `Ready` refers to the core service. Narrow/non-color terminals use a plain title.
|
|
26
26
|
|
|
27
27
|
## Commands
|
|
@@ -66,7 +66,7 @@ Auto refresh runs every 30 minutes while visible and can be switched off. Hidden
|
|
|
66
66
|
break continuations. Generated images and Codex transcripts are not deleted.
|
|
67
67
|
- Optional image setup/maintenance never blocks the primary service. Disabled
|
|
68
68
|
users get no CCDX image skill or MCP installation.
|
|
69
|
-
- Missing-token discovery includes legacy OpenCode Copilot OAuth and GitHub CLI. Reads are bounded and account-matched; incomplete/network-failed discovery does not start another login. Other apps' credentials stay read-only.
|
|
69
|
+
- Missing-token discovery includes legacy OpenCode Copilot OAuth and GitHub CLI. Reads are bounded and account-matched; incomplete/network-failed or HTTP-403-blocked discovery does not start another login. The default saved credential is preserved; Copilot 401/403 alone is not proof that it expired. Other apps' credentials stay read-only.
|
|
70
70
|
- `doctor --fix` does not start login, enable optional features, change company policy or force-restart Apps. It backs up changed config; missing-token repair can contact GitHub. Partial repairs exit 1. See the reference for exact scope.
|
|
71
71
|
- Native predictions are a separate, opt-in compatibility feature. Quit Codex,
|
|
72
72
|
run `ccdx prediction on`, then restart CCDX. This adds App-profile certificate
|
|
@@ -75,7 +75,7 @@ Auto refresh runs every 30 minutes while visible and can be switched off. Hidden
|
|
|
75
75
|
Other domains and the CCDX model endpoint stay on their existing routes.
|
|
76
76
|
No program files or OS trust are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are retained.
|
|
77
77
|
Windows supports company PAC/WPAD; macOS dynamic routing remains unsupported. Windows setup needs the official MSIX App, Windows PowerShell and .NET Framework 4.7.2+—not Git/OpenSSL. See the reference for limits.
|
|
78
|
-
Bridge checks allow three same-port recovery attempts per process,
|
|
78
|
+
Bridge checks allow three same-port recovery attempts per process. The revised PAC adds a loopback retry endpoint after the unchanged primary, preserving company fallback. Quit Codex once to load this route revision; later CCDX upgrades retain it. App prediction failures can remain cached for five minutes, so network recovery is not proof of an immediate suggestion. Only closed, initialized Apps in direct environments receive an owned persistent route; missing routes in running Apps are not hot-attached.
|
|
79
79
|
- CCDX adds experimental local history compression only when installed App
|
|
80
80
|
runtimes support it and report it off. Existing choices are preserved; an
|
|
81
81
|
already-enabled default, unavailable runtime or failed check is skipped.
|
|
@@ -88,7 +88,7 @@ Auto refresh runs every 30 minutes while visible and can be switched off. Hidden
|
|
|
88
88
|
Startup checks GitHub's latest-release web redirect, not npm or the anonymous REST quota, and suggests `ccdx update github`.
|
|
89
89
|
Updates install the exact stable tag; dependencies still use npm's configured registry. Lookup errors identify HTTP refusal, timeout, network failure or invalid redirects. For npm `EALLOWREMOTE`, only if policy permits and the update is trusted, use `ccdx update github --allow-remote`: explicit URL-download permission for that installation's whole dependency tree, not a hostname allowlist. Persistent npm settings stay unchanged.
|
|
90
90
|
Updates warn about mismatched npm targets without changing PATH/prefix and verify the installed target version (exact tag for GitHub). Restart the adapter separately. Full `ccdx doctor` reports this target and readonly credential permissions; it never changes ACLs.
|
|
91
|
-
Recent errors separate HTTP and model failures. HTTP metadata retains status, source and IDs, not error bodies or prompts; original errors still reach Codex unchanged.
|
|
91
|
+
Recent errors separate HTTP and model failures. By default HTTP metadata retains status, source and IDs, not error bodies or prompts; original errors still reach Codex unchanged. Explicit, bounded error-excerpt collection is described in the [reference](docs/REFERENCE.md#http-error-diagnostics).
|
|
92
92
|
|
|
93
93
|
The dashboard and CLI separate prediction preference, bridge state and observed config traffic; candidate visibility stays unknown. See [architecture boundaries](docs/ARCHITECTURE.md) for separate inference, integration, image and management ownership.
|
|
94
94
|
|
package/bin/cli.mjs
CHANGED
|
@@ -382,6 +382,11 @@ try {
|
|
|
382
382
|
process.exit(0);
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
+
// Restore the opted-in listener alongside authentication/model initialization;
|
|
386
|
+
// a slow company-proxy setup must not delay the core listener.
|
|
387
|
+
const earlyIntegration = await clientIntegrations();
|
|
388
|
+
const predictionSetup = runInBackground(() => earlyIntegration.start());
|
|
389
|
+
|
|
385
390
|
// Ensure GitHub login, using device flow if no token exists.
|
|
386
391
|
await ensureAuth({ log: startupLogger("Auth") });
|
|
387
392
|
|
|
@@ -430,7 +435,7 @@ try {
|
|
|
430
435
|
const { compressionSetup, imageEnabled, imageMcpSkipped } = await configureCodexClient();
|
|
431
436
|
|
|
432
437
|
// Optional native prediction setup must never prevent the core adapter from running.
|
|
433
|
-
nativePrediction = await
|
|
438
|
+
nativePrediction = await predictionSetup;
|
|
434
439
|
const persistentRoute = await nativePrediction?.prepareRoute();
|
|
435
440
|
|
|
436
441
|
// Launch Codex when available. A running App is never forcibly restarted.
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -17,6 +17,15 @@ The CLI composes the service. Client integration owns its `configure`, `start`,
|
|
|
17
17
|
`snapshot` and `close` operations. It does not forward inference requests or
|
|
18
18
|
render the dashboard. The adapter exposes integration snapshots and keeps
|
|
19
19
|
management/MCP routes separate from the Responses path.
|
|
20
|
+
`management-routes.mjs` owns status, health, cache control and prediction repair
|
|
21
|
+
HTTP checks. It receives a snapshot callback and the existing explicit repair
|
|
22
|
+
action, not a model client or a second recovery lifecycle.
|
|
23
|
+
`optional-routes.mjs` owns lazy WebUI/API and image-MCP dispatch and image stats.
|
|
24
|
+
The adapter remains the HTTP composition root; neither extracted route module
|
|
25
|
+
imports it. Native prediction belongs to client integration, WebUI to management,
|
|
26
|
+
and terminal animation to presentation. Input-image optimization remains core
|
|
27
|
+
multimodal inference, distinct from optional image generation. This is a module
|
|
28
|
+
boundary, not a plugin framework, daemon, IPC protocol or package split.
|
|
20
29
|
The HTTP dispatch boundary rejects browser Origin-bearing inference requests
|
|
21
30
|
before body admission, credential use or provider dispatch; native LAN opt-in is unchanged.
|
|
22
31
|
|
|
@@ -71,6 +80,10 @@ backup transactionally. Disabled optional features stay disabled. JSON reports
|
|
|
71
80
|
separate before checks from final repair evidence; HTTP 200 alone is not success.
|
|
72
81
|
|
|
73
82
|
Native prediction has a separate loopback transport and an isolated HTTPS agent.
|
|
83
|
+
The opted-in listener starts in parallel with auth/model initialization,
|
|
84
|
+
independently of Copilot credentials. A slow optional start cannot block core
|
|
85
|
+
listener setup, and fatal
|
|
86
|
+
startup cleanup closes any optional listener that was already started.
|
|
74
87
|
Only its two selected hosts use the App-specific route. Non-configuration requests
|
|
75
88
|
on those hosts are forwarded unchanged. The bridge does not replace Copilot or
|
|
76
89
|
image-provider networking, modify client program files, or install system trust.
|
|
@@ -117,6 +130,16 @@ of certificates, networking and the CLI. It accepts multiple named hashed chunks
|
|
|
117
130
|
without assuming the first general-settings chunk is the implementation. Signature
|
|
118
131
|
and profile checks remain in the existing platform boundary.
|
|
119
132
|
|
|
133
|
+
`prediction-pac.mjs` is the pure shared format boundary for direct, static and
|
|
134
|
+
Windows company-PAC composition. Its stable revision URL makes a one-time old-PAC
|
|
135
|
+
migration observable without coupling routes to package versions. The unchanged
|
|
136
|
+
primary endpoint comes first; a clock-bucketed `.localhost` secondary lets
|
|
137
|
+
Chromium retry the same restored listener despite its per-endpoint failure cache.
|
|
138
|
+
The original company/direct fallback remains afterward. This adds no Node DNS
|
|
139
|
+
lookup, timer, listener, process or inference-path work. Browser route recovery
|
|
140
|
+
and the client's independently cached prediction configuration remain distinct;
|
|
141
|
+
neither is a visibility guarantee.
|
|
142
|
+
|
|
120
143
|
Explicit `prediction fix` uses the optional integration's serialized lifecycle,
|
|
121
144
|
not a second adapter or detached predictor. Startup, repair and shutdown cannot
|
|
122
145
|
create overlapping owned listeners. Healthy/current bridges are retained; explicit
|
|
@@ -212,11 +235,19 @@ Prediction preference, bridge readiness and observed configuration responses are
|
|
|
212
235
|
different states. None proves that a candidate appeared in the App. The dashboard
|
|
213
236
|
keeps that result unknown. Integration diagnostics retain bounded, redacted
|
|
214
237
|
metadata, not conversation or image contents.
|
|
215
|
-
HTTP failures
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
238
|
+
HTTP failures retain the original 20-entry metadata ring (`http_errors.recent`)
|
|
239
|
+
plus independent 20-entry inference/other and eight-entry image-MCP method rings.
|
|
240
|
+
Fixed categories distinguish inference, image-MCP HTTP 405, unmatched routes and
|
|
241
|
+
other failures without treating every 404/405 as harmless. Status, safe technical
|
|
242
|
+
code/type/parameter, method, allowlisted target, request IDs and numeric/enum
|
|
243
|
+
request options survive; body/query/prompt/tool/schema values do not. Optional
|
|
244
|
+
error prose requires `CCDX_HTTP_ERROR_DETAILS=1` at service creation, is redacted
|
|
245
|
+
and capped at 500 characters, and still needs review before sharing.
|
|
246
|
+
Original error responses are preserved. Per-request attempt timings retain only
|
|
247
|
+
the first and last two provider calls, not unbounded stream events. All data is
|
|
248
|
+
process-local and cleared on restart. The dashboard uses the independently
|
|
249
|
+
retained actionable HTTP errors rather than letting route noise erase them.
|
|
250
|
+
Model terminal diagnostics and HTTP counters retain their original meanings.
|
|
220
251
|
|
|
221
252
|
Tests cover module dependency direction, default-off behavior, concurrent writers,
|
|
222
253
|
proxy handshakes, TLS validation, streaming, history isolation and release lookup.
|
package/docs/REFERENCE.md
CHANGED
|
@@ -31,6 +31,27 @@ feature uses the App's existing composer UI and the conversation's
|
|
|
31
31
|
selected model through CCDX. Suggestions are not sent automatically. Native
|
|
32
32
|
eligibility rules still apply; availability is not promised for every thread type.
|
|
33
33
|
|
|
34
|
+
The `0.9.40` routing revision uses the stable local PAC URL
|
|
35
|
+
`/proxy.pac?v=2`, independent of the package version. The primary proxy remains
|
|
36
|
+
`127.0.0.1` on the saved port. A secondary, time-bucketed `.localhost` name points
|
|
37
|
+
Chromium back to that same loopback listener after a cached proxy failure. Its
|
|
38
|
+
name changes every ten seconds when the PAC is evaluated, without a Node timer,
|
|
39
|
+
new listener, dependency, port, or background App watcher. Healthy traffic keeps
|
|
40
|
+
the original primary connection path. Direct/static/company-PAC fallbacks remain
|
|
41
|
+
after the two local entries, and unrelated hosts retain their original route.
|
|
42
|
+
The optional listener starts alongside GitHub auth and model initialization;
|
|
43
|
+
slow proxy setup does not delay the core adapter listener.
|
|
44
|
+
|
|
45
|
+
An App that loaded the old PAC must normally quit once to load this revision;
|
|
46
|
+
CCDX never force-restarts it or hot-writes an open profile. Subsequent upgrades
|
|
47
|
+
keep the revision URL, saved port and trust unchanged. An occupied saved port or
|
|
48
|
+
missing App route is not repaired by this retry mechanism. The installed App may
|
|
49
|
+
cache a failed prediction configuration for five minutes, and a subsequent
|
|
50
|
+
eligible turn may be needed to request another prediction. Returning configuration
|
|
51
|
+
traffic is not proof that native gray text is visible. Cross-platform browser
|
|
52
|
+
routing is tested separately from the user's native end-to-end acceptance;
|
|
53
|
+
the investigation report records these evidence levels without equating them.
|
|
54
|
+
|
|
34
55
|
Version `0.9.26` adds Windows platform adapters. Native gray suggestions,
|
|
35
56
|
adoption/sending and switching predictions off were verified on Windows with the
|
|
36
57
|
`.4` candidate. Windows setup
|
|
@@ -772,8 +793,16 @@ output is observed at the gateway from generated deltas, hidden-reasoning/tool
|
|
|
772
793
|
announcements or content snapshots; a runtime-only result is marked separately.
|
|
773
794
|
Empty message/envelope frames, client tool results and compaction are excluded.
|
|
774
795
|
`first_output_sources` and each recent request's `first_output_source` describe
|
|
775
|
-
that evidence, not internal model decode or prefill timing.
|
|
776
|
-
|
|
796
|
+
that evidence, not internal model decode or prefill timing. First output is
|
|
797
|
+
displayed in ms, and output speed in token/s. The additive
|
|
798
|
+
`output_tokens_per_second` metric divides the sum of reported output-token
|
|
799
|
+
intervals (`output_tokens - 1`) by their summed first-output-to-finish durations.
|
|
800
|
+
It is a time-weighted per-request estimate, not the inverse of average TPOT, an
|
|
801
|
+
unweighted average of request speeds, or concurrent system throughput. At least
|
|
802
|
+
two integral output tokens and a positive duration are required; missing usage
|
|
803
|
+
is unknown, not zero speed. The existing TPOT histogram remains unchanged for
|
|
804
|
+
API consumers, including its partial-failure samples. Both estimates can
|
|
805
|
+
include hosted-tool and downstream delays. The new
|
|
777
806
|
timing classifier does not change stream forwarding or the existing output
|
|
778
807
|
commitment that gates compatibility retries.
|
|
779
808
|
|
|
@@ -871,7 +900,7 @@ For the complete machine-readable status payload:
|
|
|
871
900
|
curl -s http://127.0.0.1:2026/_ccdx/status | jq
|
|
872
901
|
```
|
|
873
902
|
|
|
874
|
-
The status endpoint is restricted to the socket's real loopback address even when LAN binding is explicitly enabled. It reports fixed-size HTTP request counters separately from bounded `completed` / `incomplete` / `failed` / `cancelled` response outcomes by model and origin, plus bounded incomplete-reason counts, TTFT/TPOT histograms, admission pressure, memory use, response-history size/tree concentration/lookup misses, image queue/cache and adaptive-history state, model-cache counts, token expiry state, and the ten most recent upstream `response.failed` diagnostics retained by the running process. HTTP errors without a model terminal remain "without terminal" and retain their known origin; they are not counted as model failures. History eviction markers are not failed-request counts; `ccdx status` warns near the cache limit without deleting or compressing history. Failure diagnostics include the event type, model, error code/message, response/request IDs when supplied upstream, and retry outcome. Common credential forms, long opaque encrypted values, and explicitly labelled input/prompt/tool-content echoes are redacted. They are cleared when the adapter restarts.
|
|
903
|
+
The status endpoint is restricted to the socket's real loopback address even when LAN binding is explicitly enabled. It reports fixed-size HTTP request counters separately from bounded `completed` / `incomplete` / `failed` / `cancelled` response outcomes by model and origin, plus bounded incomplete-reason counts, TTFT/TPOT histograms, admission pressure, memory use, response-history size/tree concentration/lookup misses, image queue/cache and adaptive-history state, model-cache counts, token expiry state, and the ten most recent upstream `response.failed` diagnostics retained by the running process. HTTP errors without a model terminal remain "without terminal" and retain their known origin; they are not counted as model failures. History eviction markers are not failed-request counts; `ccdx status` warns near the cache limit without deleting or compressing history. Failure diagnostics include the event type, model, error code/message, response/request IDs when supplied upstream, and retry outcome. Common credential forms, long opaque encrypted values, and explicitly labelled input/prompt/tool-content echoes are redacted. They are cleared when the adapter restarts. Whole request/response bodies, credential fields, and account profiles are not archived in status. Explicit HTTP diagnostic mode can retain a bounded error excerpt; see HTTP error diagnostics below. Arbitrary upstream prose cannot be guaranteed free of sensitive content; review diagnostics before sharing them.
|
|
875
904
|
|
|
876
905
|
`stream_performance.by_route.*.empty_stream_completions` counts completed streams
|
|
877
906
|
with no observed output and an explicit zero output-token count. The recent request's
|
|
@@ -926,17 +955,55 @@ Directory/profile scans have explicit caps; hitting a cap or a network failure
|
|
|
926
955
|
reports incomplete discovery rather than silently selecting an account or
|
|
927
956
|
starting another login. Set an explicit source/account to resolve ambiguity.
|
|
928
957
|
An existing saved-token startup path performs no extra discovery/network calls.
|
|
958
|
+
Package reinstallation does not clear that user-owned credential. Copilot's short-lived
|
|
959
|
+
access token is obtained again when needed; it is not the saved GitHub credential.
|
|
960
|
+
For the default credential store, Copilot HTTP 403 preserves the credential and
|
|
961
|
+
reports access/network policy rather than recommending deletion. Copilot HTTP 401
|
|
962
|
+
performs a bounded GitHub identity check only if compatible local recovery did not
|
|
963
|
+
succeed. Only an identity HTTP 401 permits reauthorization guidance; an unavailable
|
|
964
|
+
check does not establish expiry. Neither case automatically deletes the credential
|
|
965
|
+
or starts Device Flow. Denials are not hidden by a cached Copilot token. A discovery
|
|
966
|
+
HTTP 403 also stops before Device Flow, preserving external sources and account
|
|
967
|
+
selection. Isolated/custom credential clients retain their own recovery contract.
|
|
929
968
|
|
|
930
969
|
After an account is selected, automatic `401`/`403` recovery and in-process token rotation accept only that same GitHub account. Concurrent callers share token refresh work without sharing cancellation, and a still-valid Copilot token may be used briefly after a transient refresh failure. Explicit token variables remain the intentional way to select another account.
|
|
931
970
|
|
|
932
|
-
If refresh still fails with `401` or `403`, the saved
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
971
|
+
If refresh still fails with Copilot `401` or `403`, preserve the saved credential.
|
|
972
|
+
Run `ccdx auth status --online` only when you explicitly want an online diagnosis;
|
|
973
|
+
check account entitlement and company routing policy separately. Reauthorization
|
|
974
|
+
is appropriate only after independent GitHub identity rejection or an explicit
|
|
975
|
+
account-change decision, not merely a Copilot denial, package update, or failed
|
|
976
|
+
network probe. Existing same-account recovery and explicit source selection are
|
|
977
|
+
unchanged.
|
|
978
|
+
|
|
979
|
+
## HTTP error diagnostics
|
|
980
|
+
|
|
981
|
+
`http_errors.recent` keeps its 20-record rolling view. Independent
|
|
982
|
+
`actionable_recent` (20 inference/other failures) and `protocol_recent` (eight
|
|
983
|
+
image-MCP HTTP 405 records) prevent route/method noise from erasing inference
|
|
984
|
+
evidence. `by_category` counts inference, protocol, route and other HTTP failures;
|
|
985
|
+
classification does not discard errors, grant access or retry requests.
|
|
986
|
+
The WebUI prioritizes actionable records; raw HTTP counters remain visible.
|
|
987
|
+
|
|
988
|
+
New records retain safe error code/type/parameter paths, method, an allowlisted
|
|
989
|
+
endpoint without a query, and upstream attempt count. Requested/served model
|
|
990
|
+
IDs are distinct; only the explicit Auto-review alias identifies that request
|
|
991
|
+
purpose. Other purposes remain unknown, not guessed from a model name.
|
|
992
|
+
Known enum/numeric options
|
|
993
|
+
include reasoning effort, service tier, output format, max output tokens and
|
|
994
|
+
input/tool counts; no prompt, schema or tool values are kept. `error_body` says
|
|
995
|
+
whether the upstream provided empty, structured or unstructured error details.
|
|
996
|
+
Recent request `attempts` and HTTP `attempt_timings` retain the first and last two
|
|
997
|
+
provider dispatch/header offsets and statuses; these are not TCP-retry counts.
|
|
998
|
+
|
|
999
|
+
By default arbitrary upstream error prose is not copied into HTTP diagnostics.
|
|
1000
|
+
For a specific investigation, start a **new** service with
|
|
1001
|
+
`CCDX_HTTP_ERROR_DETAILS=1` to retain a redacted error-message excerpt, capped at
|
|
1002
|
+
500 characters, in those bounded in-memory records. In Windows PowerShell set
|
|
1003
|
+
`$env:CCDX_HTTP_ERROR_DETAILS='1'` before `ccdx.cmd`. This does not reconfigure an
|
|
1004
|
+
already-running service, enable file logging, retain whole requests, or guarantee
|
|
1005
|
+
that arbitrary upstream prose contains no private context. Review before sharing;
|
|
1006
|
+
unset the variable after the investigation. Records disappear on service exit.
|
|
940
1007
|
|
|
941
1008
|
## Security
|
|
942
1009
|
|
|
@@ -945,7 +1012,7 @@ Recovery first tries compatible local credentials and starts Device Flow only wh
|
|
|
945
1012
|
- Inference POSTs reject any browser `Origin` header before reading the body or contacting upstream, including simple `text/plain` requests. Native Codex/Node requests without Origin and deliberately enabled native LAN clients keep their existing access. This is not authentication or protection against untrusted local native programs.
|
|
946
1013
|
- The GitHub OAuth credential is stored locally at `~/.local/share/copilot-api/github_token`. Short-lived Copilot service tokens remain in process memory and are refreshed as needed.
|
|
947
1014
|
- The optional image API credential is stored separately with mode `0600` only after `ccdx enable-image`; it is never placed in Codex configuration or diagnostic output.
|
|
948
|
-
- Runtime status and usage records retain metadata
|
|
1015
|
+
- Runtime status and usage records retain metadata by default; explicitly enabled HTTP error excerpts can contain private context. Diagnostic logging records status and error messages; it is not a general redaction layer for arbitrary error text. See Debug logging before sharing logs.
|
|
949
1016
|
- Request/response bodies, request-admission queues, retained history, image work, SSE buffers, log queues, retries, and shutdown have explicit limits. These component limits are not a single process-wide memory ceiling; completed image files are persistent user artifacts, not an automatically evicted cache.
|
|
950
1017
|
|
|
951
1018
|
## Configuration
|
|
@@ -973,6 +1040,7 @@ Recovery first tries compatible local credentials and starts Device Flow only wh
|
|
|
973
1040
|
| `CCDX_AUTO_REVIEW_MODEL` | saved selection or `gpt-6.1-sol` | Copilot Responses model used for Codex Auto-review; overrides the interactive selection |
|
|
974
1041
|
| `CCDX_LOG_PATH` | unset | Mirror terminal logs to a file; set to `1` for `~/.local/share/codex-copilot-dx/debug.log` |
|
|
975
1042
|
| `CCDX_LOG_LEVEL` | `info` | Set to `debug` for upstream attempts, status codes, retry causes, and timings |
|
|
1043
|
+
| `CCDX_HTTP_ERROR_DETAILS` | unset | Set to `1` on a new service to retain redacted HTTP error excerpts (500 characters) in bounded memory; review before sharing, no file logging is enabled |
|
|
976
1044
|
| `CCDX_LOG_MAX_BYTES` | `16777216` | Rotate the debug log at this size and retain one `.1` backup; set to `0` to disable rotation |
|
|
977
1045
|
| `CCDX_TERMINAL_ANIMATION` | auto | Show the selected transient animation while an interactive terminal has active requests and no output for 800 ms; set to `0`, `false`, `no`, or `off` to disable |
|
|
978
1046
|
| `CCDX_IMG_MAX_DIM` | `2048` | Maximum long edge in pixels for image downscaling |
|
package/package.json
CHANGED
package/src/adapter.mjs
CHANGED
|
@@ -12,26 +12,21 @@ import { createRequestId, runWithRequestContext } from "./request-context.mjs";
|
|
|
12
12
|
import { createStreamPerformanceMetrics } from "./stream-performance.mjs";
|
|
13
13
|
import { status } from "./status.mjs";
|
|
14
14
|
import { createTerminalActivityIndicator } from "./terminal-activity.mjs";
|
|
15
|
-
import { ADAPTER_HEALTH_PATH, ADAPTER_PREDICTION_FIX_PATH
|
|
15
|
+
import { ADAPTER_HEALTH_PATH, ADAPTER_PREDICTION_FIX_PATH } from "./running-adapter.mjs";
|
|
16
|
+
import { createManagementHandler, isManagementRoute } from "./management-routes.mjs";
|
|
17
|
+
import { createOptionalRoutes, isOptionalRoute, DASHBOARD_PATHS, DASHBOARD_API_PATHS } from "./optional-routes.mjs";
|
|
16
18
|
import { createResponsesCompactHandler, createResponsesHandler } from "./responses-handler.mjs";
|
|
17
19
|
import { createResponsesImagePressureController } from "./responses-image-pressure.mjs";
|
|
18
|
-
import { createResponseFailureDiagnostics, buildHttpFailureDetails } from "./response-failures.mjs";
|
|
19
|
-
import {
|
|
20
|
-
ADAPTER_CACHE_PATH,
|
|
21
|
-
cacheRuntimeSnapshot,
|
|
22
|
-
cleanRuntimeCaches,
|
|
23
|
-
setHistoryCacheLimit,
|
|
24
|
-
} from "./cache-control.mjs";
|
|
20
|
+
import { createResponseFailureDiagnostics, createHttpFailureDiagnostics, buildHttpFailureDetails } from "./response-failures.mjs";
|
|
21
|
+
import { ADAPTER_CACHE_PATH } from "./cache-control.mjs";
|
|
25
22
|
import { loadRuntimeConfig, parsePositiveInteger } from "./runtime-config.mjs";
|
|
26
23
|
import {
|
|
27
24
|
createRequestAbort,
|
|
28
25
|
logRequestFailure,
|
|
29
|
-
readJsonBody,
|
|
30
26
|
sendJsonError,
|
|
31
27
|
} from "./http-transport.mjs";
|
|
32
28
|
import { httpError } from "./http-errors.mjs";
|
|
33
29
|
import { createRequestAdmission } from "./request-admission.mjs";
|
|
34
|
-
import { isLoopbackAddress, isLoopbackHostHeader } from "./security.mjs";
|
|
35
30
|
|
|
36
31
|
export {
|
|
37
32
|
abortErrorStatusCode,
|
|
@@ -63,8 +58,6 @@ export {
|
|
|
63
58
|
} from "./responses-request.mjs";
|
|
64
59
|
|
|
65
60
|
const ADAPTER_RUNTIME_CONFIG = loadRuntimeConfig();
|
|
66
|
-
const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/status.js", "/usage.js", "/ui.js"]);
|
|
67
|
-
const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth"]);
|
|
68
61
|
|
|
69
62
|
export function requestPath(reqUrl) {
|
|
70
63
|
return new URL(reqUrl || "/", "http://localhost").pathname;
|
|
@@ -170,8 +163,17 @@ export function createAdapterHandler(options = {}) {
|
|
|
170
163
|
const streamPerformanceMetrics = options.streamPerformanceMetrics || createStreamPerformanceMetrics();
|
|
171
164
|
const imagePressure = options.imagePressure || createResponsesImagePressureController();
|
|
172
165
|
const responseFailures = options.responseFailures || createResponseFailureDiagnostics();
|
|
173
|
-
const httpErrors =
|
|
174
|
-
|
|
166
|
+
const httpErrors = createHttpFailureDiagnostics();
|
|
167
|
+
const optionalRoutes = createOptionalRoutes(options);
|
|
168
|
+
const managementHandler = createManagementHandler({
|
|
169
|
+
nativePredictionPac: options.nativePredictionPac, fixPrediction: options.fixPrediction, requestBodyTimeoutMs,
|
|
170
|
+
statusSnapshot: () => ({ ...runtimeStatusPayload({
|
|
171
|
+
metrics: requestMetrics, streamPerformance: streamPerformanceMetrics, admission: acquireRequest,
|
|
172
|
+
imagePressure, responseFailures, imageGeneration: optionalRoutes.imageStats(),
|
|
173
|
+
modelRegistry: codexModelRegistry, codexClient, codexModelRegistry, codexModelCatalog,
|
|
174
|
+
clientIntegrations: options.clientIntegrationSnapshot?.(),
|
|
175
|
+
}), http_errors: httpErrors.snapshot() }),
|
|
176
|
+
});
|
|
175
177
|
const responsesHandler = createResponsesHandler({
|
|
176
178
|
acquireRequest,
|
|
177
179
|
autoReviewModelResolver: options.autoReviewModelResolver,
|
|
@@ -211,132 +213,8 @@ export function createAdapterHandler(options = {}) {
|
|
|
211
213
|
sendJsonError(res, error, 403);
|
|
212
214
|
return;
|
|
213
215
|
}
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
return handleDashboardApi(req, res, pathname, options.dashboardOptions);
|
|
217
|
-
}
|
|
218
|
-
if ((req.method === "GET" || req.method === "HEAD") && DASHBOARD_PATHS.has(pathname)) {
|
|
219
|
-
const { serveDashboard } = await import("./dashboard.mjs");
|
|
220
|
-
return serveDashboard(req, res, pathname);
|
|
221
|
-
}
|
|
222
|
-
if (pathname === "/mcp/image") {
|
|
223
|
-
if (imageMcpHandler) return imageMcpHandler(req, res);
|
|
224
|
-
return import("./image-mcp.mjs").then(({ createImageMcpHandler }) => {
|
|
225
|
-
imageMcpHandler ||= createImageMcpHandler({ localHostname: options.imageMcpHostname });
|
|
226
|
-
return imageMcpHandler(req, res);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
if (req.method === "GET" && pathname === ADAPTER_STATUS_PATH) {
|
|
230
|
-
if (!isLoopbackAddress(req.socket?.remoteAddress) || !isLoopbackHostHeader(req.headers?.host)) {
|
|
231
|
-
res.writeHead(403, { "Content-Type": "application/json" });
|
|
232
|
-
res.end(JSON.stringify({ error: "Runtime status is available only from loopback" }));
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
236
|
-
res.end(JSON.stringify({ ...runtimeStatusPayload({
|
|
237
|
-
metrics: requestMetrics,
|
|
238
|
-
streamPerformance: streamPerformanceMetrics,
|
|
239
|
-
admission: acquireRequest,
|
|
240
|
-
imagePressure,
|
|
241
|
-
responseFailures,
|
|
242
|
-
imageGeneration: imageMcpHandler?.stats?.(),
|
|
243
|
-
modelRegistry: codexModelRegistry,
|
|
244
|
-
codexClient,
|
|
245
|
-
codexModelRegistry,
|
|
246
|
-
codexModelCatalog,
|
|
247
|
-
clientIntegrations: options.clientIntegrationSnapshot?.(),
|
|
248
|
-
}), http_errors: httpErrors.snapshot() }));
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (req.method === "GET" && pathname === ADAPTER_HEALTH_PATH) {
|
|
253
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
254
|
-
const predictionPac = isLoopbackAddress(req.socket?.remoteAddress) && isLoopbackHostHeader(req.headers?.host)
|
|
255
|
-
? options.nativePredictionPac?.() : null;
|
|
256
|
-
const health = adapterHealthPayload();
|
|
257
|
-
res.end(JSON.stringify({ ...health,
|
|
258
|
-
capabilities: [...health.capabilities, ...(typeof options.fixPrediction === "function" ? [PREDICTION_FIX_CAPABILITY] : [])],
|
|
259
|
-
...(predictionPac ? { native_prediction_pac: predictionPac } : {}) }));
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (pathname === ADAPTER_PREDICTION_FIX_PATH) {
|
|
264
|
-
if (!isLoopbackAddress(req.socket?.remoteAddress) || req.headers?.host === undefined
|
|
265
|
-
|| !isLoopbackHostHeader(req.headers.host) || Object.hasOwn(req.headers, "origin")) {
|
|
266
|
-
sendJsonError(res, httpError("Prediction repair is available only to native loopback clients", 403));return;
|
|
267
|
-
}
|
|
268
|
-
if (req.method !== "POST") {
|
|
269
|
-
res.setHeader?.("Allow", "POST");sendJsonError(res, httpError("Prediction repair requires POST", 405));return;
|
|
270
|
-
}
|
|
271
|
-
if (String(req.headers["content-type"] || "").split(";", 1)[0].trim().toLowerCase() !== "application/json") {
|
|
272
|
-
sendJsonError(res, httpError("Prediction repair requires application/json", 415));return;
|
|
273
|
-
}
|
|
274
|
-
if (typeof options.fixPrediction !== "function") {
|
|
275
|
-
sendJsonError(res, httpError("This adapter does not support prediction repair; upgrade and restart CCDX once", 503));return;
|
|
276
|
-
}
|
|
277
|
-
const abort = createRequestAbort(req, res);abort.setTimeout(2000);
|
|
278
|
-
try {
|
|
279
|
-
const body = await readJsonBody(req, { maxBodyBytes: 1024, maxDecodedBodyBytes: 1024, signal: abort.signal });
|
|
280
|
-
if (!body || Object.keys(body).length !== 1 || body.action !== "fix") throw httpError("Expected prediction repair action: fix", 400);
|
|
281
|
-
abort.clearTimeout();
|
|
282
|
-
const result = await options.fixPrediction();
|
|
283
|
-
if (!res.destroyed && !res.writableEnded) {
|
|
284
|
-
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });res.end(JSON.stringify(result));
|
|
285
|
-
}
|
|
286
|
-
} catch (error) { sendJsonError(res, error, 503); }
|
|
287
|
-
finally { abort.cleanup(); }
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (pathname === ADAPTER_CACHE_PATH) {
|
|
292
|
-
if (!isLoopbackAddress(req.socket?.remoteAddress) || !isLoopbackHostHeader(req.headers?.host)) {
|
|
293
|
-
res.writeHead(403, { "Content-Type": "application/json" });
|
|
294
|
-
res.end(JSON.stringify({ error: "Cache control is available only from loopback" }));
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
if (req.method === "GET") {
|
|
298
|
-
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
299
|
-
res.end(JSON.stringify(cacheRuntimeSnapshot()));
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (req.method !== "POST") {
|
|
303
|
-
res.writeHead(405, { "Content-Type": "application/json", Allow: "GET, POST" });
|
|
304
|
-
res.end(JSON.stringify({ error: "Only GET and POST are supported" }));
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
if (Object.hasOwn(req.headers || {}, "origin")) {
|
|
308
|
-
res.writeHead(403, { "Content-Type": "application/json" });
|
|
309
|
-
res.end(JSON.stringify({ error: "Browser origins are not allowed for cache control" }));
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
const mediaType = String(req.headers?.["content-type"] || "").split(";", 1)[0].trim().toLowerCase();
|
|
313
|
-
if (mediaType !== "application/json") {
|
|
314
|
-
res.writeHead(415, { "Content-Type": "application/json" });
|
|
315
|
-
res.end(JSON.stringify({ error: "Cache control requires application/json" }));
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const abort = createRequestAbort(req, res);
|
|
319
|
-
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
320
|
-
try {
|
|
321
|
-
const body = await readJsonBody(req, {
|
|
322
|
-
maxBodyBytes: 8 * 1024,
|
|
323
|
-
maxDecodedBodyBytes: 8 * 1024,
|
|
324
|
-
signal: abort.signal,
|
|
325
|
-
});
|
|
326
|
-
let result;
|
|
327
|
-
if (body?.action === "set_limit") result = setHistoryCacheLimit(body.max_bytes);
|
|
328
|
-
else if (body?.action === "clean") result = cleanRuntimeCaches({ history: body.history === true });
|
|
329
|
-
else throw httpError("Unknown cache action", 400);
|
|
330
|
-
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
331
|
-
res.end(JSON.stringify(result));
|
|
332
|
-
} catch (error) {
|
|
333
|
-
if (["ccdx_cache_busy", "ccdx_cache_limit_below_usage"].includes(error?.code)) error.statusCode = 409;
|
|
334
|
-
sendJsonError(res, error, 400);
|
|
335
|
-
} finally {
|
|
336
|
-
abort.cleanup();
|
|
337
|
-
}
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
216
|
+
if (isOptionalRoute(req.method, pathname)) return optionalRoutes.handle(req, res, pathname);
|
|
217
|
+
if (isManagementRoute(req.method, pathname)) return managementHandler(req, res, pathname);
|
|
340
218
|
|
|
341
219
|
if (req.method === "POST" && pathname === "/v1/responses") {
|
|
342
220
|
return responsesHandler(req, res);
|
|
@@ -447,7 +325,13 @@ export function createAdapterHandler(options = {}) {
|
|
|
447
325
|
if (requestFinished) return;
|
|
448
326
|
requestFinished = true;
|
|
449
327
|
if (trackRequest && statusCode >= 400) {
|
|
450
|
-
try { httpErrors.record(buildHttpFailureDetails({ ...httpEvidence, statusCode, route: routeName, requestId, model: context?.model
|
|
328
|
+
try { httpErrors.record(buildHttpFailureDetails({ ...httpEvidence, statusCode, route: routeName, requestId, model: context?.model,
|
|
329
|
+
method: ["GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"].includes(req.method) ? req.method : "OTHER",
|
|
330
|
+
target: ["/v1/responses", "/v1/responses/compact", "/mcp/image", "/.well-known/oauth-authorization-server", "/.well-known/oauth-protected-resource", "/.well-known/oauth-protected-resource/mcp/image"].includes(pathname) ? pathname : "unrecognized_path",
|
|
331
|
+
request_options: context?.requestOptions, upstream_attempts: streamPerformance?.attemptCount?.(),
|
|
332
|
+
attempt_timings: streamPerformance?.attemptTimings?.(),
|
|
333
|
+
requested_model: context?.requestedModel,
|
|
334
|
+
})); } catch {}
|
|
451
335
|
}
|
|
452
336
|
try { complete({ statusCode, aborted }); } catch {}
|
|
453
337
|
try { streamPerformance?.finish({ failed: aborted || statusCode >= 400, aborted, statusCode }); } catch {}
|
|
@@ -484,6 +368,7 @@ export function createAdapterHandler(options = {}) {
|
|
|
484
368
|
requestId,
|
|
485
369
|
pathname,
|
|
486
370
|
showRequestId: options.showRequestId === true,
|
|
371
|
+
includeHttpErrorDetails: options.includeHttpErrorDetails === true || process.env.CCDX_HTTP_ERROR_DETAILS === "1",
|
|
487
372
|
streamPerformance,
|
|
488
373
|
onHttpError: evidence => { httpEvidence = evidence; },
|
|
489
374
|
};
|
package/src/auth.mjs
CHANGED
|
@@ -55,7 +55,10 @@ export async function fetchGithubIdentity(token, {
|
|
|
55
55
|
headers: { Authorization: `token ${token.trim()}`, Accept: "application/json" },
|
|
56
56
|
signal: controller.signal,
|
|
57
57
|
}), controller.signal);
|
|
58
|
-
if (!resp.ok)
|
|
58
|
+
if (!resp.ok) {
|
|
59
|
+
cancelResponseBody(resp);
|
|
60
|
+
return { ok: false, status: resp.status, reason: "github_user_failed" };
|
|
61
|
+
}
|
|
59
62
|
const data = await awaitWithSignal(() => resp.json(), controller.signal);
|
|
60
63
|
const identity = normalizeGithubIdentity(data);
|
|
61
64
|
return identity ? { ok: true, ...identity } : { ok: false, reason: "github_identity_missing" };
|
|
@@ -120,8 +123,9 @@ async function validateGithubTokenRequest(token, { fetchImpl, signal }) {
|
|
|
120
123
|
return {
|
|
121
124
|
ok: false,
|
|
122
125
|
status: userResp.status,
|
|
126
|
+
accessDenied: userResp.status === 403,
|
|
123
127
|
transient: userResp.status === 429 || userResp.status >= 500 || userResp.headers?.get?.("x-ratelimit-remaining") === "0",
|
|
124
|
-
reason: userResp.status === 401
|
|
128
|
+
reason: userResp.status === 401 ? "github_token_invalid" : userResp.status === 403 ? "github_access_denied" : "github_user_failed",
|
|
125
129
|
};
|
|
126
130
|
}
|
|
127
131
|
|
|
@@ -145,6 +149,7 @@ async function validateGithubTokenRequest(token, { fetchImpl, signal }) {
|
|
|
145
149
|
return {
|
|
146
150
|
ok: false,
|
|
147
151
|
status: copilotResp.status,
|
|
152
|
+
accessDenied: copilotResp.status === 403,
|
|
148
153
|
transient: copilotResp.status === 429 || copilotResp.status >= 500,
|
|
149
154
|
reason: copilotResp.status === 401 || copilotResp.status === 403 ? "copilot_access_denied" : "copilot_token_failed",
|
|
150
155
|
login,
|
|
@@ -244,6 +249,9 @@ export async function discoverGithubToken({
|
|
|
244
249
|
};
|
|
245
250
|
}
|
|
246
251
|
|
|
252
|
+
if (failures.some(item => item.validation?.accessDenied)) {
|
|
253
|
+
return { ok: false, accessDenied: true, failures };
|
|
254
|
+
}
|
|
247
255
|
return { ok: false, failures };
|
|
248
256
|
}
|
|
249
257
|
|
|
@@ -287,6 +295,7 @@ export async function importDiscoveredGithubToken({
|
|
|
287
295
|
const logins = [...new Set(discovered.candidates.map((candidate) => candidate.login || candidate.id || "unknown"))];
|
|
288
296
|
throw new Error(`Multiple GitHub Copilot accounts were found (${logins.join(", ")}). Set CCDX_GITHUB_LOGIN or CCDX_GITHUB_TOKEN_PATH to select one explicitly.`);
|
|
289
297
|
}
|
|
298
|
+
if (discovered.accessDenied) throw new Error("GitHub or Copilot denied access to an existing credential. Check account access and network policy; credentials were preserved and no new login was started.");
|
|
290
299
|
if (discovered.transient) throw new Error("Local GitHub credentials could not be fully checked. Check network access and retry; no new login was started.");
|
|
291
300
|
if (!discovered.ok) return null;
|
|
292
301
|
writeToken(discovered.token, home, discovered.validation);
|
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 = {}) {
|
|
@@ -151,7 +154,7 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
|
|
|
151
154
|
`${commandName} status`,
|
|
152
155
|
adapterLine,
|
|
153
156
|
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 ${
|
|
157
|
+
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
158
|
...(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
159
|
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
160
|
status("info", `Memory: RSS ${mebibytes(processStats.rss_bytes)}, heap ${mebibytes(processStats.heap_used_bytes)}`),
|
|
@@ -188,7 +191,14 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
|
|
|
188
191
|
lines.push(status("warn", ` ${model} ${code}: ${message}${failure.retried ? ` [retried:${retryPolicy}]` : ""}`));
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
|
-
if (data.http_errors)
|
|
194
|
+
if (data.http_errors) {
|
|
195
|
+
lines.push(status("info", `HTTP failures: ${count(data.http_errors.total)} observed (separate from model terminal events)`));
|
|
196
|
+
const categories = data.http_errors.by_category;
|
|
197
|
+
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`));
|
|
198
|
+
for (const failure of (data.http_errors.actionable_recent || []).slice(-3).reverse()) {
|
|
199
|
+
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`));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
192
202
|
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
203
|
const prediction = data.client_integrations?.prediction;
|
|
194
204
|
if (prediction) {
|
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) {
|