aKode fase 2b-1 (WIP): rimossi cloud-config, apps MCP ChatGPT, upload file, connectors-extension, rate limits backend; plugin remoti in corso (test non ancora compilanti)
Some checks failed
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
Some checks failed
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
This commit is contained in:
@@ -1,16 +1,9 @@
|
||||
use super::RemotePluginCatalogError;
|
||||
use super::RemotePluginListResponse;
|
||||
use super::RemotePluginScope;
|
||||
use super::RemotePluginServiceConfig;
|
||||
use super::RemotePluginSummary;
|
||||
use super::authenticated_request;
|
||||
use super::build_remote_plugin_summary;
|
||||
use super::ensure_chatgpt_auth;
|
||||
use super::send_and_decode;
|
||||
use codex_login::CodexAuth;
|
||||
use http::Method;
|
||||
use tracing::instrument;
|
||||
use url::Url;
|
||||
|
||||
/// Search parameters forwarded directly to plugin-service.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -39,53 +32,7 @@ pub async fn search_remote_plugins(
|
||||
auth: Option<&CodexAuth>,
|
||||
search: RemotePluginSearchRequest<'_>,
|
||||
) -> Result<RemotePluginSearchPage, RemotePluginCatalogError> {
|
||||
let auth = ensure_chatgpt_auth(auth)?;
|
||||
let base_url = config.chatgpt_base_url.trim_end_matches('/');
|
||||
let mut url = Url::parse(&format!("{base_url}/ps/plugins/search"))
|
||||
.map_err(RemotePluginCatalogError::InvalidBaseUrl)?;
|
||||
// Search terms and page tokens can contain user data. Keep the queryless endpoint for
|
||||
// diagnostics so neither value is exposed through errors or telemetry.
|
||||
let url_for_error = url.to_string();
|
||||
|
||||
{
|
||||
let mut query_pairs = url.query_pairs_mut();
|
||||
query_pairs.append_pair("q", search.query);
|
||||
if let Some(scope) = search.scope {
|
||||
query_pairs.append_pair("scope", scope.api_value());
|
||||
}
|
||||
query_pairs.append_pair("limit", &search.limit.to_string());
|
||||
if let Some(page_token) = search.page_token {
|
||||
query_pairs.append_pair("pageToken", page_token);
|
||||
}
|
||||
}
|
||||
|
||||
let url = url.to_string();
|
||||
let request = authenticated_request(config, Method::GET, &url, auth).await?;
|
||||
let response: RemotePluginListResponse = send_and_decode(request, &url_for_error)
|
||||
.await
|
||||
.map_err(|error| match error {
|
||||
RemotePluginCatalogError::Request { url, source } => {
|
||||
RemotePluginCatalogError::Request {
|
||||
url,
|
||||
source: source.without_url(),
|
||||
}
|
||||
}
|
||||
other => other,
|
||||
})?;
|
||||
let plugins = response
|
||||
.plugins
|
||||
.iter()
|
||||
// Search intentionally does not join against `/ps/plugins/installed`, so these
|
||||
// summaries always report `installed: false`.
|
||||
.map(|plugin| build_remote_plugin_summary(plugin, /*installed_plugin*/ None))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
Ok(RemotePluginSearchPage {
|
||||
plugins,
|
||||
next_page_token: response.pagination.next_page_token,
|
||||
})
|
||||
let _ = (config, auth, search);
|
||||
Err(RemotePluginCatalogError::Unavailable)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "search_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user