-
Notifications
You must be signed in to change notification settings - Fork 0
[codex] add Codex WebSocket transport and compat fixes #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # OPENCODE + OPENAI-CODEX LIVE TEST | ||
| # Routes OpenCode (Responses API) to the ChatGPT Codex backend using the Codex CLI auth file. | ||
| # Credentials: auto-discovered from ~/.codex/auth.json (tokens.access_token / refresh_token / account_id). | ||
| # Override with OPENAI_CODEX_ACCESS_TOKEN env var or config.access_token if needed. | ||
| # | ||
| # Start: go run ./cmd/lipstd serve --config ./config/examples/opencode-codex.yaml | ||
| # Point OpenCode at: http://127.0.0.1:8080/v1 (Responses API, @ai-sdk/openai), model gpt-5.5 | ||
| server: | ||
| address: "127.0.0.1:8080" | ||
|
|
||
| routing: | ||
| max_attempts: 3 | ||
| default_route: "openai-codex:gpt-5.5" | ||
|
|
||
| continuity: | ||
| in_memory: true | ||
| store: memory | ||
|
|
||
| logging: | ||
| level: info | ||
| format: text | ||
|
|
||
| diagnostics: | ||
| enabled: true | ||
| health_path: "/healthz" | ||
| attempts_path: "/admin/attempts" | ||
| inventory_path: "/debug/inventory" | ||
| route_trace_path: "/debug/route_trace" | ||
|
|
||
| hooks: | ||
| tool_reactor_error_policy: fail_open | ||
|
|
||
| plugins: | ||
| frontends: | ||
| - id: openai-responses | ||
| enabled: true | ||
| config: {} | ||
| - id: openai-legacy | ||
| enabled: true | ||
| config: {} | ||
| - id: anthropic | ||
| enabled: true | ||
| config: {} | ||
| - id: gemini | ||
| enabled: true | ||
| config: {} | ||
| backends: | ||
| - id: openai-responses | ||
| enabled: false | ||
| config: {} | ||
| - id: openai-legacy | ||
| enabled: false | ||
| config: {} | ||
| - id: anthropic | ||
| enabled: false | ||
| config: {} | ||
| - id: gemini | ||
| enabled: false | ||
| config: {} | ||
| - id: bedrock | ||
| enabled: false | ||
| config: {} | ||
| - id: acp | ||
| enabled: false | ||
| config: {} | ||
| - id: openrouter | ||
| enabled: false | ||
| config: {} | ||
| - id: nvidia | ||
| enabled: false | ||
| config: {} | ||
| - id: opencode-go | ||
| enabled: false | ||
| config: {} | ||
| - id: opencode-zen | ||
| enabled: false | ||
| config: {} | ||
| - id: ollama | ||
| enabled: false | ||
| config: {} | ||
| - id: ollama-cloud | ||
| enabled: false | ||
| config: {} | ||
| - id: llamacpp | ||
| enabled: false | ||
| config: {} | ||
| - id: lmstudio | ||
| enabled: false | ||
| config: {} | ||
| - id: vllm | ||
| enabled: false | ||
| config: {} | ||
| - id: openai-codex | ||
| enabled: true | ||
| config: | ||
| # base_url defaults to https://chatgpt.com/backend-api/codex — leave unset for live ChatGPT. | ||
| # access_token left empty so the connector auto-discovers ~/.codex/auth.json. | ||
| # account_id is read from auth.json tokens.account_id; override here only if needed. | ||
| default_reasoning_effort: "medium" | ||
| features: | ||
| - id: submit-noop | ||
| enabled: true | ||
| config: {} | ||
| - id: parts-noop | ||
| enabled: true | ||
| config: {} | ||
| - id: tool-reactor-noop | ||
| enabled: true | ||
| config: {} | ||
| - id: codex-client-compat | ||
| enabled: true | ||
| config: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package diag | ||
|
|
||
| import ( | ||
| "log/slog" | ||
| "os" | ||
| "sort" | ||
| "strconv" | ||
| "strings" | ||
| "sync" | ||
| ) | ||
|
|
||
| const envDebugTurns = "LIP_CODEX_DEBUG_TURNS" | ||
|
|
||
| var debugTurnsEnabled = sync.OnceValue(func() bool { | ||
| return strings.TrimSpace(os.Getenv(envDebugTurns)) != "" | ||
| }) | ||
|
|
||
| // DebugTurnsEnabled reports whether verbose per-turn diagnostics are enabled for | ||
| // this process. The environment is read once so debug wrappers agree on a single | ||
| // process-lifetime gate. | ||
| func DebugTurnsEnabled() bool { | ||
| return debugTurnsEnabled() | ||
| } | ||
|
|
||
| // LoggerOrDefault returns log when present, otherwise slog.Default(). | ||
| func LoggerOrDefault(log *slog.Logger) *slog.Logger { | ||
| if log != nil { | ||
| return log | ||
| } | ||
| return slog.Default() | ||
| } | ||
|
|
||
| // StableCounts formats count maps as sorted "key=value" strings for stable logs. | ||
| func StableCounts(counts map[string]int) []string { | ||
| keys := make([]string, 0, len(counts)) | ||
| for k := range counts { | ||
| keys = append(keys, k) | ||
| } | ||
| sort.Strings(keys) | ||
| out := make([]string, 0, len(keys)) | ||
| for _, k := range keys { | ||
| out = append(out, k+"="+strconv.Itoa(counts[k])) | ||
| } | ||
| return out | ||
| } | ||
|
|
||
| // AppendLimited appends a trimmed non-empty value until max entries are present. | ||
| func AppendLimited(values []string, value string, max int) []string { | ||
| value = strings.TrimSpace(value) | ||
| if value == "" || len(values) >= max { | ||
| return values | ||
| } | ||
| return append(values, value) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package routing | ||
|
|
||
| import ( | ||
| "slices" | ||
| "strings" | ||
| ) | ||
|
|
||
| // FilterRoutePrefixes trims, drops invalid (empty, colon- or slash-bearing), | ||
| // dedups, and sorts backend route-selector prefixes. Shared by runtime bundle | ||
| // composition and frontend PrefixSet construction so the validation rule lives | ||
| // in one place. A prefix is the "<prefix>:" segment of a route selector; it must | ||
| // not itself contain ":" (which would make it a full selector) or "/" (which | ||
| // collides with provider-namespace model syntax). | ||
| func FilterRoutePrefixes(prefixes []string) []string { | ||
| seen := make(map[string]struct{}, len(prefixes)) | ||
| out := make([]string, 0, len(prefixes)) | ||
| for _, prefix := range prefixes { | ||
| prefix = strings.TrimSpace(prefix) | ||
| if prefix == "" || strings.Contains(prefix, ":") || strings.Contains(prefix, "/") { | ||
| continue | ||
| } | ||
| if _, dup := seen[prefix]; dup { | ||
| continue | ||
| } | ||
| seen[prefix] = struct{}{} | ||
| out = append(out, prefix) | ||
| } | ||
| slices.Sort(out) | ||
| return out | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.