mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-11-16 22:57:53 +08:00
- Add `client.claude.show-codex-commentary` config and propagate the request-scoped display policy through HTTP and WebSocket Codex executors. - Mirror public Codex `commentary` messages into visible Claude text blocks alongside the `cpa:commentary:v1` thinking marker in streaming and non-streaming responses without altering genuine reasoning or token accounting. - Deduplicate only the exact adjacent mirrored commentary text block during Claude-to-Codex request replay when enabled. Closes: #7129
28 lines
739 B
Go
28 lines
739 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
)
|
|
|
|
type codexCommentaryKey struct{}
|
|
|
|
// WithVisibleCodexCommentary snapshots the display policy for one request.
|
|
func WithVisibleCodexCommentary(ctx context.Context, enabled bool) context.Context {
|
|
if ctx == nil {
|
|
ctx = context.Background()
|
|
}
|
|
return context.WithValue(ctx, codexCommentaryKey{}, enabled)
|
|
}
|
|
|
|
// VisibleCodexCommentary reports the per-request display policy. The environment
|
|
// fallback supports SDK-only users and existing deployments of the opt-in mode.
|
|
func VisibleCodexCommentary(ctx context.Context) bool {
|
|
if ctx != nil {
|
|
if enabled, ok := ctx.Value(codexCommentaryKey{}).(bool); ok {
|
|
return enabled
|
|
}
|
|
}
|
|
return os.Getenv("CPA_VISIBLE_CODEX_COMMENTARY") == "1"
|
|
}
|