-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Add remote thread config loader protos #18892
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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
34889d6
Add protos for session config
rasmusrygaard 02ad45b
rebase
rasmusrygaard c739ccc
fix enum default
rasmusrygaard 5a05aff
Fix thread config argument comments
rasmusrygaard 26894c0
Use platform absolute paths in thread config tests
rasmusrygaard 77a8e29
set timeout
rasmusrygaard 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
| use std::path::PathBuf; | ||
|
|
||
| fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let Some(proto_dir_arg) = std::env::args().nth(1) else { | ||
| eprintln!("Usage: generate-proto <proto-dir>"); | ||
| std::process::exit(1); | ||
| }; | ||
|
|
||
| let proto_dir = PathBuf::from(proto_dir_arg); | ||
| let proto_file = proto_dir.join("codex.thread_config.v1.proto"); | ||
|
|
||
| tonic_prost_build::configure() | ||
| .build_client(true) | ||
| .build_server(true) | ||
| .out_dir(&proto_dir) | ||
| .compile_protos(&[proto_file], &[proto_dir])?; | ||
|
|
||
| Ok(()) | ||
| } | ||
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,38 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| repo_root="$(cd "$script_dir/../../.." && pwd)" | ||
| proto_dir="$repo_root/codex-rs/config/src/thread_config/proto" | ||
| generated="$proto_dir/codex.thread_config.v1.rs" | ||
| tmpdir="$(mktemp -d)" | ||
|
|
||
| cleanup() { | ||
| rm -rf "$tmpdir" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| ( | ||
| cd "$repo_root/codex-rs" | ||
| CARGO_TARGET_DIR="$tmpdir/target" cargo run \ | ||
| -p codex-config \ | ||
| --example generate-proto \ | ||
| -- "$proto_dir" | ||
| ) | ||
|
|
||
| if ! sed -n '2p' "$generated" | grep -q 'clippy::trivially_copy_pass_by_ref'; then | ||
| { | ||
| sed -n '1p' "$generated" | ||
| printf '#![allow(clippy::trivially_copy_pass_by_ref)]\n' | ||
| sed '1d' "$generated" | ||
| } > "$tmpdir/generated.rs" | ||
| mv "$tmpdir/generated.rs" "$generated" | ||
| fi | ||
|
|
||
| rustfmt --edition 2024 "$generated" | ||
|
|
||
| awk ' | ||
| NR == 3 && previous ~ /clippy::trivially_copy_pass_by_ref/ && $0 != "" { print "" } | ||
| { print; previous = $0 } | ||
| ' "$generated" > "$tmpdir/formatted.rs" | ||
| mv "$tmpdir/formatted.rs" "$generated" |
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
68 changes: 68 additions & 0 deletions
68
codex-rs/config/src/thread_config/proto/codex.thread_config.v1.proto
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,68 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package codex.thread_config.v1; | ||
|
|
||
| service ThreadConfigLoader { | ||
| rpc Load(LoadThreadConfigRequest) returns (LoadThreadConfigResponse); | ||
| } | ||
|
|
||
| message LoadThreadConfigRequest { | ||
| optional string thread_id = 1; | ||
| optional string cwd = 2; | ||
| } | ||
|
|
||
| message LoadThreadConfigResponse { | ||
| repeated ThreadConfigSource sources = 1; | ||
| } | ||
|
|
||
| message ThreadConfigSource { | ||
| oneof source { | ||
| SessionThreadConfig session = 1; | ||
| UserThreadConfig user = 2; | ||
| } | ||
| } | ||
|
|
||
| message SessionThreadConfig { | ||
| optional string model_provider = 1; | ||
| repeated ModelProvider model_providers = 2; | ||
| map<string, bool> features = 3; | ||
| } | ||
|
|
||
| message UserThreadConfig {} | ||
|
|
||
| message ModelProvider { | ||
| string id = 1; | ||
| string name = 2; | ||
| optional string base_url = 3; | ||
| optional string env_key = 4; | ||
| optional string env_key_instructions = 5; | ||
| optional string experimental_bearer_token = 6; | ||
| optional ModelProviderAuthInfo auth = 7; | ||
| WireApi wire_api = 8; | ||
| optional StringMap query_params = 9; | ||
| optional StringMap http_headers = 10; | ||
| optional StringMap env_http_headers = 11; | ||
| optional uint64 request_max_retries = 12; | ||
| optional uint64 stream_max_retries = 13; | ||
| optional uint64 stream_idle_timeout_ms = 14; | ||
| optional uint64 websocket_connect_timeout_ms = 15; | ||
| bool requires_openai_auth = 16; | ||
| bool supports_websockets = 17; | ||
| } | ||
|
|
||
| message StringMap { | ||
| map<string, string> values = 1; | ||
| } | ||
|
|
||
| message ModelProviderAuthInfo { | ||
| string command = 1; | ||
| repeated string args = 2; | ||
| uint64 timeout_ms = 3; | ||
| uint64 refresh_interval_ms = 4; | ||
| string cwd = 5; | ||
| } | ||
|
|
||
| enum WireApi { | ||
| WIRE_API_UNSPECIFIED = 0; | ||
| WIRE_API_RESPONSES = 1; | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would love a better place to put the proto generation than
examplesbut I couldn't figure out a better way to do it with the repo build rules