Skip to content

Commit bda076a

Browse files
author
Neon Splash Agent
committed
Fix: Use Python to write lib.rs - avoids YAML heredoc syntax conflict
1 parent a6f58d0 commit bda076a

File tree

1 file changed

+57
-57
lines changed

1 file changed

+57
-57
lines changed

.github/workflows/build.yml

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -66,63 +66,63 @@ jobs:
6666
}1' crates/config/src/loader.rs > tmp.rs && mv tmp.rs crates/config/src/loader.rs
6767
6868
# ── Patch 2: Overwrite shared_http_client with IPv4-forced, cert-loading version ──
69-
cat > crates/agents/src/lib.rs << 'RUSTEOF'
70-
//! LLM agent runtime: model selection, prompt building, tool execution, streaming.
71-
72-
// FFI wrappers for llama-cpp-2 require unsafe Send/Sync impls when local-llm feature is enabled.
73-
#![cfg_attr(feature = "local-llm", allow(unsafe_code))]
74-
75-
pub mod auth_profiles;
76-
77-
/// Shared HTTP client for LLM providers.
78-
///
79-
/// All providers that don't need custom redirect/proxy settings should
80-
/// reuse this client to share connection pools, DNS cache, and TLS sessions.
81-
///
82-
/// On Termux/Android we:
83-
/// 1. Force IPv4 to avoid broken IPv6 routing on mobile networks
84-
/// 2. Explicitly load Termux CA certs since standard paths don't exist
85-
pub fn shared_http_client() -> &'static reqwest::Client {
86-
static CLIENT: std::sync::LazyLock<reqwest::Client> =
87-
std::sync::LazyLock::new(|| {
88-
let mut builder = reqwest::ClientBuilder::new()
89-
// Force IPv4: Android/Termux often has broken IPv6 routing
90-
// which causes 5-second TCP timeouts on Cloudflare-backed domains
91-
.local_address(std::net::IpAddr::V4(std::net::Ipv4Addr::UNSPECIFIED))
92-
.connect_timeout(std::time::Duration::from_secs(15));
93-
94-
// Try to load PEM certs from SSL_CERT_FILE or common Termux path.
95-
let cert_path = std::env::var("SSL_CERT_FILE")
96-
.ok()
97-
.unwrap_or_else(|| "/data/data/com.termux/files/usr/etc/tls/cert.pem".into());
98-
99-
if let Ok(pem_data) = std::fs::read(&cert_path) {
100-
for cert_result in reqwest::tls::Certificate::from_pem_bundle(&pem_data) {
101-
builder = builder.add_root_certificate(cert_result);
102-
}
103-
}
104-
105-
builder.build().unwrap_or_else(|_| reqwest::Client::new())
106-
});
107-
&CLIENT
108-
}
109-
pub mod memory_writer;
110-
pub mod model;
111-
pub mod multimodal;
112-
pub mod prompt;
113-
pub mod providers;
114-
pub mod runner;
115-
pub use {
116-
model::{ChatMessage, ContentPart, UserContent},
117-
runner::AgentRunError,
118-
};
119-
pub mod provider_chain;
120-
pub mod silent_turn;
121-
pub mod skills;
122-
pub mod tool_registry;
123-
RUSTEOF
124-
echo "Patched lib.rs with IPv4-forced shared_http_client"
125-
cat crates/agents/src/lib.rs | head -20
69+
python3 -c "
70+
import pathlib, textwrap
71+
pathlib.Path('crates/agents/src/lib.rs').write_text(textwrap.dedent('''
72+
//! LLM agent runtime: model selection, prompt building, tool execution, streaming.
73+
74+
// FFI wrappers for llama-cpp-2 require unsafe Send/Sync impls when local-llm feature is enabled.
75+
#![cfg_attr(feature = \"local-llm\", allow(unsafe_code))]
76+
77+
pub mod auth_profiles;
78+
79+
/// Shared HTTP client for LLM providers.
80+
///
81+
/// All providers that don't need custom redirect/proxy settings should
82+
/// reuse this client to share connection pools, DNS cache, and TLS sessions.
83+
///
84+
/// On Termux/Android we:
85+
/// 1. Force IPv4 to avoid broken IPv6 routing on mobile networks
86+
/// 2. Explicitly load Termux CA certs since standard paths don't exist
87+
pub fn shared_http_client() -> &'static reqwest::Client {
88+
static CLIENT: std::sync::LazyLock<reqwest::Client> =
89+
std::sync::LazyLock::new(|| {
90+
let mut builder = reqwest::ClientBuilder::new()
91+
.local_address(std::net::IpAddr::V4(std::net::Ipv4Addr::UNSPECIFIED))
92+
.connect_timeout(std::time::Duration::from_secs(15));
93+
94+
let cert_path = std::env::var(\"SSL_CERT_FILE\")
95+
.ok()
96+
.unwrap_or_else(|| \"/data/data/com.termux/files/usr/etc/tls/cert.pem\".into());
97+
98+
if let Ok(pem_data) = std::fs::read(&cert_path) {
99+
for cert_result in reqwest::tls::Certificate::from_pem_bundle(&pem_data) {
100+
builder = builder.add_root_certificate(cert_result);
101+
}
102+
}
103+
104+
builder.build().unwrap_or_else(|_| reqwest::Client::new())
105+
});
106+
&CLIENT
107+
}
108+
pub mod memory_writer;
109+
pub mod model;
110+
pub mod multimodal;
111+
pub mod prompt;
112+
pub mod providers;
113+
pub mod runner;
114+
pub use {
115+
model::{ChatMessage, ContentPart, UserContent},
116+
runner::AgentRunError,
117+
};
118+
pub mod provider_chain;
119+
pub mod silent_turn;
120+
pub mod skills;
121+
pub mod tool_registry;
122+
''').lstrip())
123+
print('Patched lib.rs')
124+
"
125+
head -20 crates/agents/src/lib.rs
126126
127127
- name: Install cross
128128
uses: taiki-e/install-action@cross

0 commit comments

Comments
 (0)