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
34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package helps
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v8/internal/config"
|
|
translatorcommon "github.com/router-for-me/CLIProxyAPI/v8/internal/translator/common"
|
|
)
|
|
|
|
func TestCodexCommentaryPolicyDefaultsAndSnapshots(t *testing.T) {
|
|
t.Setenv("CPA_VISIBLE_CODEX_COMMENTARY", "")
|
|
if translatorcommon.VisibleCodexCommentary(WithCodexCommentaryPolicy(nil, nil)) {
|
|
t.Fatal("commentary must remain hidden by default")
|
|
}
|
|
cfg := &config.Config{}
|
|
cfg.Client.Claude.ShowCodexCommentary = true
|
|
inFlight := WithCodexCommentaryPolicy(context.Background(), cfg)
|
|
cfg.Client.Claude.ShowCodexCommentary = false
|
|
if !translatorcommon.VisibleCodexCommentary(inFlight) {
|
|
t.Fatal("config reload changed an in-flight stream")
|
|
}
|
|
if translatorcommon.VisibleCodexCommentary(WithCodexCommentaryPolicy(context.Background(), cfg)) {
|
|
t.Fatal("new request did not use the changed policy")
|
|
}
|
|
}
|
|
|
|
func TestCodexCommentaryPolicyEnvironmentCompatibility(t *testing.T) {
|
|
t.Setenv("CPA_VISIBLE_CODEX_COMMENTARY", "1")
|
|
if !translatorcommon.VisibleCodexCommentary(WithCodexCommentaryPolicy(context.Background(), &config.Config{})) {
|
|
t.Fatal("legacy opt-in environment variable was ignored")
|
|
}
|
|
}
|