MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / load_builtins

Method load_builtins

crates/opencode-plugin/src/subprocess/loader.rs:156–175  ·  view source on GitHub ↗

Load bundled auth plugins shipped with the Rust runtime.

(&self, context: &PluginContext)

Source from the content-addressed store, hash-verified

154
155 /// Load bundled auth plugins shipped with the Rust runtime.
156 pub async fn load_builtins(&self, context: &PluginContext) -> Result<(), PluginLoaderError> {
157 let cache_dir = dirs::cache_dir()
158 .unwrap_or_else(|| PathBuf::from("/tmp"))
159 .join("opencode")
160 .join("plugins")
161 .join("builtin");
162 std::fs::create_dir_all(&cache_dir)?;
163
164 let codex_path = cache_dir.join("builtin-codex-auth.ts");
165 std::fs::write(&codex_path, BUILTIN_CODEX_AUTH)?;
166
167 let copilot_path = cache_dir.join("builtin-copilot-auth.ts");
168 std::fs::write(&copilot_path, BUILTIN_COPILOT_AUTH)?;
169
170 let specs = vec![
171 format!("file://{}", codex_path.display()),
172 format!("file://{}", copilot_path.display()),
173 ];
174 self.load_all(&specs, context).await
175 }
176
177 /// Get all loaded plugin clients.
178 pub async fn clients(&self) -> Vec<Arc<PluginSubprocess>> {

Callers 2

load_plugin_auth_storeFunction · 0.80
load_plugin_auth_storeFunction · 0.80

Calls 1

load_allMethod · 0.45

Tested by

no test coverage detected