MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / new_with_storage_for_url

Method new_with_storage_for_url

crates/opencode-server/src/server.rs:138–171  ·  view source on GitHub ↗
(server_url: String)

Source from the content-addressed store, hash-verified

136 }
137
138 pub async fn new_with_storage_for_url(server_url: String) -> anyhow::Result<Self> {
139 let mut state = Self::new();
140 let auth_manager = Arc::new(AuthManager::load_from_file(&auth_data_dir()).await);
141 state.auth_manager = auth_manager.clone();
142 load_plugin_auth_store(&server_url, auth_manager.clone()).await;
143 let auth_store = auth_manager.list().await;
144
145 // Load config and convert providers to bootstrap format
146 let cwd = std::env::current_dir().unwrap_or_default();
147 let bootstrap_config = match load_config(&cwd) {
148 Ok(config) => {
149 let providers = convert_config_providers_for_bootstrap(&config);
150 bootstrap_config_from_raw(
151 providers,
152 config.disabled_providers.clone(),
153 config.enabled_providers.clone(),
154 config.model.clone(),
155 config.small_model.clone(),
156 )
157 }
158 Err(error) => {
159 tracing::warn!(%error, "failed to load config for provider bootstrap, using defaults");
160 opencode_provider::BootstrapConfig::default()
161 }
162 };
163
164 state.providers = create_registry_from_bootstrap_config(&bootstrap_config, &auth_store);
165 let db = Database::new().await?;
166 let pool = db.pool().clone();
167 state.session_repo = Some(SessionRepository::new(pool.clone()));
168 state.message_repo = Some(MessageRepository::new(pool));
169 state.load_sessions_from_storage().await?;
170 Ok(state)
171 }
172
173 pub fn broadcast(&self, event: &str) {
174 let _ = self.event_bus.send(event.to_string());

Callers

nothing calls this directly

Calls 11

newFunction · 0.85
auth_data_dirFunction · 0.85
load_configFunction · 0.85
poolMethod · 0.80
load_plugin_auth_storeFunction · 0.70
cloneMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected