дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-29 22:02:59 +02:00
feat(plugins): read HTTP responses as they arrive with net.fetch-stream
Plugin API 1.19 adds net.fetch-stream, which returns a response-stream once the headers arrive; its body is read piece by piece with a timeout, so a plugin can consume server-sent events or a model's streamed reply and stop early. It uses the same grants, secrets and redirect checks as fetch, which now shares the request builder. The SDK gets host::fetch_stream, ResponseStream and an sse parser; components are rebuilt for the new WIT.
Цей коміт міститься в:
1 джерело
18860f5f98
коміт
71e089b0fa
128 files changed
+869
-129
No files matched your search
@@ -9,8 +9,9 @@ use ide_extension::Package;
|
||||
use ide_extension::ledger::{Ledger, Subject};
|
||||
use ide_language::ProgramPin;
|
||||
use ide_plugin::{
|
||||
CommitChange, CommitDraft, EventKind, HostApi, HostError, HttpRequest, HttpResponse, NotificationLevel,
|
||||
ProcessChunk, ProcessCommand, ProcessOptions, ProcessOutput, Prompt, RepositoryStatus, SettingsTarget, StatusItem,
|
||||
CommitChange, CommitDraft, EventKind, HostApi, HostError, HttpRequest, HttpResponse, HttpStreamHead,
|
||||
NotificationLevel, ProcessChunk, ProcessCommand, ProcessOptions, ProcessOutput, Prompt, RepositoryStatus,
|
||||
SettingsTarget, StatusItem,
|
||||
};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
@@ -327,6 +328,14 @@ fn network_error(error: reqwest::Error) -> HostError {
|
||||
HostError::Failed(ide_http::client::describe(&error))
|
||||
}
|
||||
|
||||
fn response_headers(response: &reqwest::Response) -> Vec<(String, String)> {
|
||||
response
|
||||
.headers()
|
||||
.iter()
|
||||
.map(|(k, v)| (k.as_str().to_owned(), String::from_utf8_lossy(v.as_bytes()).into_owned()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn redirect_capability(from: &reqwest::Url, to: &reqwest::Url) -> Result<Capability, String> {
|
||||
if from.scheme() == "https" && to.scheme() == "http" {
|
||||
ide_plugin::net_host(to.as_str()).map(Capability::NetHttp)
|
||||
@@ -737,6 +746,7 @@ pub(super) struct Shared {
|
||||
processes: Mutex<HashMap<(String, u64), Arc<Proc>>>,
|
||||
next_process: AtomicU64,
|
||||
connections: super::ipc::Connections,
|
||||
http_streams: super::http_stream::HttpStreams,
|
||||
pub loopbacks: RwLock<Arc<dyn super::auth::Service>>,
|
||||
process_shutdowns: Mutex<Vec<std::thread::JoinHandle<()>>>,
|
||||
pub(super) prompts: Mutex<HashMap<u64, PromptEntry>>,
|
||||
@@ -850,6 +860,7 @@ impl Shared {
|
||||
processes: Mutex::default(),
|
||||
next_process: AtomicU64::new(1),
|
||||
connections: super::ipc::Connections::default(),
|
||||
http_streams: super::http_stream::HttpStreams::default(),
|
||||
loopbacks: RwLock::new(Arc::new(super::auth::Loopbacks::default())),
|
||||
process_shutdowns: Mutex::default(),
|
||||
prompts: Mutex::default(),
|
||||
@@ -1078,6 +1089,7 @@ impl Shared {
|
||||
|
||||
self.kill_processes(plugin);
|
||||
self.connections.clear(plugin);
|
||||
self.http_streams.clear(plugin);
|
||||
self.websockets.disconnect_plugin(plugin);
|
||||
self.setting_snapshots.lock().retain(|(_, p), _| p != plugin);
|
||||
let channels: Vec<_> = {
|
||||
@@ -1365,6 +1377,47 @@ impl PluginApi {
|
||||
self.approved_program_in_project(program, None)
|
||||
}
|
||||
|
||||
/// `request` with its secrets filled in and a redirect policy that checks
|
||||
/// every hop against its grants; the caller sets the timeout.
|
||||
fn http_request(&self, request: HttpRequest) -> Result<reqwest::RequestBuilder, HostError> {
|
||||
let secrets = self.shared.secrets.read().clone();
|
||||
let id = self.id().to_owned();
|
||||
let mut headers = reqwest::header::HeaderMap::new();
|
||||
for (name, value) in &request.headers {
|
||||
let value = fill_secrets(value, |n| secrets.get(&id, n))?;
|
||||
let name = reqwest::header::HeaderName::from_bytes(name.as_bytes())
|
||||
.map_err(|e| HostError::Invalid(format!("header {name:?}: {e}")))?;
|
||||
let mut value = reqwest::header::HeaderValue::from_str(&value)
|
||||
.map_err(|e| HostError::Invalid(format!("header {name}: {e}")))?;
|
||||
value.set_sensitive(true);
|
||||
headers.append(name, value);
|
||||
}
|
||||
let method = reqwest::Method::from_bytes(request.method.to_ascii_uppercase().as_bytes())
|
||||
.map_err(|_| HostError::Invalid(format!("method {:?}", request.method)))?;
|
||||
let grants = request.grants.clone();
|
||||
let policy = reqwest::redirect::Policy::custom(move |attempt| {
|
||||
if attempt.previous().len() >= 10 {
|
||||
return attempt.error("too many redirects");
|
||||
}
|
||||
let wanted = attempt.previous().last().map_or_else(
|
||||
|| ide_plugin::net_capability(attempt.url().as_str()),
|
||||
|from| redirect_capability(from, attempt.url()),
|
||||
);
|
||||
match wanted {
|
||||
Ok(wanted) if grants.iter().any(|g| g.covers(&wanted)) => attempt.follow(),
|
||||
Ok(wanted) => attempt.error(RedirectDenied(wanted.to_string())),
|
||||
Err(error) => attempt.error(error),
|
||||
}
|
||||
});
|
||||
let client = ide_http::client::build_with_redirect(&ide_core::proxy_settings::proxy(), policy)
|
||||
.map_err(|e| HostError::Failed(e.message))?;
|
||||
let builder = client.request(method, &request.url).headers(headers);
|
||||
Ok(match request.body {
|
||||
Some(body) => builder.body(body),
|
||||
None => builder,
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn approved_program_in_project(&self, program: &str, root: Option<&Path>) -> Result<PathBuf, HostError> {
|
||||
if let Some(pin) = root.and_then(|root| {
|
||||
self.shared.project_pins.read().get(&(self.id().into(), format!("process:{program}"), root.into())).cloned()
|
||||
@@ -2838,52 +2891,14 @@ impl HostApi for PluginApi {
|
||||
}
|
||||
|
||||
fn fetch(&self, request: HttpRequest, cancel: &CancellationToken) -> Result<HttpResponse, HostError> {
|
||||
let secrets = self.shared.secrets.read().clone();
|
||||
let id = self.id().to_owned();
|
||||
let mut headers = reqwest::header::HeaderMap::new();
|
||||
for (name, value) in &request.headers {
|
||||
let value = fill_secrets(value, |n| secrets.get(&id, n))?;
|
||||
let name = reqwest::header::HeaderName::from_bytes(name.as_bytes())
|
||||
.map_err(|e| HostError::Invalid(format!("header {name:?}: {e}")))?;
|
||||
let mut value = reqwest::header::HeaderValue::from_str(&value)
|
||||
.map_err(|e| HostError::Invalid(format!("header {name}: {e}")))?;
|
||||
value.set_sensitive(true);
|
||||
headers.append(name, value);
|
||||
}
|
||||
let method = reqwest::Method::from_bytes(request.method.to_ascii_uppercase().as_bytes())
|
||||
.map_err(|_| HostError::Invalid(format!("method {:?}", request.method)))?;
|
||||
let grants = request.grants.clone();
|
||||
let policy = reqwest::redirect::Policy::custom(move |attempt| {
|
||||
if attempt.previous().len() >= 10 {
|
||||
return attempt.error("too many redirects");
|
||||
}
|
||||
let wanted = attempt.previous().last().map_or_else(
|
||||
|| ide_plugin::net_capability(attempt.url().as_str()),
|
||||
|from| redirect_capability(from, attempt.url()),
|
||||
);
|
||||
match wanted {
|
||||
Ok(wanted) if grants.iter().any(|g| g.covers(&wanted)) => attempt.follow(),
|
||||
Ok(wanted) => attempt.error(RedirectDenied(wanted.to_string())),
|
||||
Err(error) => attempt.error(error),
|
||||
}
|
||||
});
|
||||
let client = ide_http::client::build_with_redirect(&ide_core::proxy_settings::proxy(), policy)
|
||||
.map_err(|e| HostError::Failed(e.message))?;
|
||||
let builder = client.request(method, &request.url).headers(headers).timeout(request.timeout);
|
||||
let builder = match request.body {
|
||||
Some(body) => builder.body(body),
|
||||
None => builder,
|
||||
};
|
||||
let timeout = request.timeout;
|
||||
let builder = self.http_request(request)?.timeout(timeout);
|
||||
let cancel = cancel.clone();
|
||||
net_runtime().block_on(async move {
|
||||
let send = async {
|
||||
let response = builder.send().await.map_err(network_error)?;
|
||||
let status = response.status().as_u16();
|
||||
let headers = response
|
||||
.headers()
|
||||
.iter()
|
||||
.map(|(k, v)| (k.as_str().to_owned(), String::from_utf8_lossy(v.as_bytes()).into_owned()))
|
||||
.collect();
|
||||
let headers = response_headers(&response);
|
||||
let mut body = Vec::new();
|
||||
let mut response = response;
|
||||
while let Some(chunk) = response.chunk().await.map_err(|e| HostError::Failed(e.to_string()))? {
|
||||
@@ -2901,6 +2916,40 @@ impl HostApi for PluginApi {
|
||||
})
|
||||
}
|
||||
|
||||
fn fetch_stream(&self, request: HttpRequest, cancel: &CancellationToken) -> Result<HttpStreamHead, HostError> {
|
||||
self.shared.http_streams.check(self.id())?;
|
||||
// Only the wait for the headers is bounded: the body may keep coming.
|
||||
let timeout = request.timeout;
|
||||
let builder = self.http_request(request)?;
|
||||
let cancel = cancel.clone();
|
||||
let response = net_runtime().block_on(async move {
|
||||
tokio::select! {
|
||||
r = tokio::time::timeout(timeout, builder.send()) => r
|
||||
.map_err(|_| HostError::Failed("timed out waiting for the response headers".into()))?
|
||||
.map_err(network_error),
|
||||
() = cancel.cancelled() => Err(HostError::Cancelled),
|
||||
}
|
||||
})?;
|
||||
let status = response.status().as_u16();
|
||||
let headers = response_headers(&response);
|
||||
let id = self.shared.http_streams.insert(self.id(), response)?;
|
||||
Ok(HttpStreamHead { id, status, headers })
|
||||
}
|
||||
|
||||
fn http_stream_read(
|
||||
&self,
|
||||
id: u64,
|
||||
max: usize,
|
||||
timeout: Duration,
|
||||
cancel: &CancellationToken,
|
||||
) -> Result<(Vec<u8>, bool), HostError> {
|
||||
self.shared.http_streams.read(self.id(), id, max, timeout, cancel)
|
||||
}
|
||||
|
||||
fn http_stream_close(&self, id: u64) {
|
||||
self.shared.http_streams.close(self.id(), id);
|
||||
}
|
||||
|
||||
fn websocket_connect(
|
||||
&self,
|
||||
root: &Path,
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//! Plugin-owned HTTP response bodies read as they arrive (`net.fetch-stream`),
|
||||
//! closed on resource drop and plugin shutdown.
|
||||
use super::api::net_runtime;
|
||||
use ide_core::CancellationToken;
|
||||
use ide_plugin::HostError;
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
/// Most response streams one plugin keeps open at once.
|
||||
const MAX_STREAMS: usize = 8;
|
||||
|
||||
struct Body {
|
||||
response: reqwest::Response,
|
||||
/// The part of the last chunk the plugin hasn't read yet.
|
||||
pending: Vec<u8>,
|
||||
done: bool,
|
||||
}
|
||||
|
||||
struct Stream {
|
||||
body: tokio::sync::Mutex<Body>,
|
||||
closed: CancellationToken,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct HttpStreams {
|
||||
next: AtomicU64,
|
||||
entries: Mutex<HashMap<(String, u64), Arc<Stream>>>,
|
||||
}
|
||||
|
||||
impl HttpStreams {
|
||||
/// Fails when `plugin` already has the most streams open.
|
||||
pub fn check(&self, plugin: &str) -> Result<(), HostError> {
|
||||
if self.entries.lock().keys().filter(|(p, _)| p == plugin).count() >= MAX_STREAMS {
|
||||
Err(HostError::Invalid("at most eight response streams per plugin".into()))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert(&self, plugin: &str, response: reqwest::Response) -> Result<u64, HostError> {
|
||||
let mut entries = self.entries.lock();
|
||||
if entries.keys().filter(|(p, _)| p == plugin).count() >= MAX_STREAMS {
|
||||
return Err(HostError::Invalid("at most eight response streams per plugin".into()));
|
||||
}
|
||||
let id = self.next.fetch_add(1, Ordering::Relaxed);
|
||||
let body = Body { response, pending: Vec::new(), done: false };
|
||||
entries.insert(
|
||||
(plugin.into(), id),
|
||||
Arc::new(Stream { body: tokio::sync::Mutex::new(body), closed: CancellationToken::new() }),
|
||||
);
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
pub fn read(
|
||||
&self,
|
||||
plugin: &str,
|
||||
id: u64,
|
||||
max: usize,
|
||||
timeout: Duration,
|
||||
cancel: &CancellationToken,
|
||||
) -> Result<(Vec<u8>, bool), HostError> {
|
||||
let entry = self
|
||||
.entries
|
||||
.lock()
|
||||
.get(&(plugin.into(), id))
|
||||
.cloned()
|
||||
.ok_or_else(|| HostError::NotFound("response stream".into()))?;
|
||||
net_runtime().block_on(async {
|
||||
let read = async {
|
||||
let mut body = entry.body.lock().await;
|
||||
// `chunk` takes nothing until it is ready, so a timeout that drops
|
||||
// this future in the middle loses no bytes.
|
||||
if body.pending.is_empty() && !body.done {
|
||||
match body.response.chunk().await {
|
||||
Ok(Some(chunk)) => body.pending = chunk.to_vec(),
|
||||
Ok(None) => body.done = true,
|
||||
Err(e) => return Err(HostError::Failed(ide_http::client::describe(&e))),
|
||||
}
|
||||
}
|
||||
let count = body.pending.len().min(max);
|
||||
let bytes: Vec<u8> = body.pending.drain(..count).collect();
|
||||
Ok((bytes, body.done && body.pending.is_empty()))
|
||||
};
|
||||
tokio::select! {
|
||||
biased;
|
||||
() = cancel.cancelled() => Err(HostError::Cancelled),
|
||||
() = entry.closed.cancelled() => Err(HostError::Cancelled),
|
||||
r = read => r,
|
||||
() = tokio::time::sleep(timeout) => Ok((Vec::new(), false)),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn close(&self, plugin: &str, id: u64) {
|
||||
if let Some(entry) = self.entries.lock().remove(&(plugin.into(), id)) {
|
||||
entry.closed.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&self, plugin: &str) {
|
||||
self.entries.lock().retain(|(p, _), entry| {
|
||||
if p != plugin {
|
||||
return true;
|
||||
}
|
||||
entry.closed.cancel();
|
||||
false
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ mod execution;
|
||||
mod external_watch;
|
||||
mod files_changed;
|
||||
mod hover;
|
||||
mod http_stream;
|
||||
mod icon_extensions;
|
||||
mod icon_patterns;
|
||||
mod icon_settings;
|
||||
|
||||
@@ -6545,6 +6545,58 @@ fn api14_denies_new_privileges_and_requires_an_invoking_window() {
|
||||
assert_eq!(f.host.declared_secret("api14", "token"), None);
|
||||
}
|
||||
|
||||
/// `net.fetch-stream`: the body is read as it arrives, so a plugin gets the
|
||||
/// first server-sent event while the server is still sending (here it never
|
||||
/// finishes), and a short body ends with `done`. The same grants as `fetch`.
|
||||
#[test]
|
||||
fn fetch_stream_reads_events_before_the_body_ends() {
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
let f = fixture(Limits::default());
|
||||
f.host.install_from_dir(&sample("api14"), &Consent::default()).unwrap();
|
||||
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
std::thread::spawn(move || {
|
||||
for (n, stream) in listener.incoming().flatten().enumerate() {
|
||||
std::thread::spawn(move || {
|
||||
let mut reader = BufReader::new(stream.try_clone().unwrap());
|
||||
let mut line = String::new();
|
||||
while reader.read_line(&mut line).unwrap_or(0) > 0 && line != "\r\n" {
|
||||
line.clear();
|
||||
}
|
||||
let mut stream = stream;
|
||||
let chunk = |stream: &mut std::net::TcpStream, s: &str| {
|
||||
write!(stream, "{:x}\r\n{s}\r\n", s.len()).and_then(|()| stream.flush())
|
||||
};
|
||||
let _ = write!(
|
||||
stream,
|
||||
"HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nTransfer-Encoding: chunked\r\n\r\n"
|
||||
);
|
||||
let _ = chunk(&mut stream, "data: one\n\nevent: delta\ndata: t");
|
||||
if n == 0 {
|
||||
// Never ends: only streaming lets the plugin see "one" in time.
|
||||
std::thread::sleep(Duration::from_secs(30));
|
||||
return;
|
||||
}
|
||||
let _ = chunk(&mut stream, "wo\n\n");
|
||||
let _ = write!(stream, "0\r\n\r\n");
|
||||
});
|
||||
}
|
||||
});
|
||||
let url = format!("http://localhost:{port}/events");
|
||||
|
||||
let err = f.run("api14", "fetch-stream", Some(&format!("1 {url}"))).unwrap_err();
|
||||
assert!(err.contains("net:localhost") && err.contains("not granted"), "{err}");
|
||||
f.host.set_capability("api14", "net:localhost", true).unwrap();
|
||||
|
||||
let started = std::time::Instant::now();
|
||||
let out = f.run("api14", "fetch-stream", Some(&format!("1 {url}"))).unwrap();
|
||||
assert_eq!(out.as_deref(), Some("200|message:one"));
|
||||
assert!(started.elapsed() < Duration::from_secs(10), "{:?}", started.elapsed());
|
||||
|
||||
let out = f.run("api14", "fetch-stream", Some(&format!("3 {url}"))).unwrap();
|
||||
assert_eq!(out.as_deref(), Some("200|message:one|delta:two|done"));
|
||||
}
|
||||
|
||||
/// `net:ask`: a first request to a host outside the manifest asks the user
|
||||
/// from an invoking window ("once" allows this request, "always" remembers
|
||||
/// the host, refusal and dismissal deny). Background calls are denied without
|
||||
|
||||
@@ -8,9 +8,9 @@ use crate::types::{
|
||||
PluginHover, PluginInlayHint, ProviderDocument, SemanticToken,
|
||||
};
|
||||
use crate::types::{
|
||||
EventKind, HostError, HttpRequest, HttpResponse, Invocation, Limits, NotificationLevel, ProcessChunk,
|
||||
ProcessCommand, ProcessOutput, Prompt, RepositoryStatus, StatusItem, SyntaxFold, SyntaxSymbol, SyntaxToken,
|
||||
WorkbenchEvent,
|
||||
EventKind, HostError, HttpRequest, HttpResponse, HttpStreamHead, Invocation, Limits, NotificationLevel,
|
||||
ProcessChunk, ProcessCommand, ProcessOutput, Prompt, RepositoryStatus, StatusItem, SyntaxFold, SyntaxSymbol,
|
||||
SyntaxToken, WorkbenchEvent,
|
||||
};
|
||||
use crate::types::{
|
||||
FieldValue, ServiceLog, ServiceLogToggle, ServicePane, ServiceTab, TableSort, View, ViewBody, ViewButton,
|
||||
@@ -365,6 +365,20 @@ pub trait HostApi: Send + Sync {
|
||||
fn publish_diagnostics(&self, path: &Path, items: Vec<ide_core::Diagnostic>) -> Result<(), HostError>;
|
||||
/// Performs `request` (its host is granted), filling in secret placeholders.
|
||||
fn fetch(&self, request: HttpRequest, cancel: &CancellationToken) -> Result<HttpResponse, HostError>;
|
||||
/// As [`HostApi::fetch`], returning once the headers arrive (`request.timeout`
|
||||
/// bounds only that wait); the body is read with [`HostApi::http_stream_read`].
|
||||
fn fetch_stream(&self, request: HttpRequest, cancel: &CancellationToken) -> Result<HttpStreamHead, HostError>;
|
||||
/// The next body bytes of an owned stream, at most `max`: empty and not done
|
||||
/// when nothing arrived within `timeout`; `true` once the body has ended.
|
||||
fn http_stream_read(
|
||||
&self,
|
||||
id: u64,
|
||||
max: usize,
|
||||
timeout: Duration,
|
||||
cancel: &CancellationToken,
|
||||
) -> Result<(Vec<u8>, bool), HostError>;
|
||||
/// Closes an owned stream, including when its resource is dropped.
|
||||
fn http_stream_close(&self, id: u64);
|
||||
|
||||
fn websocket_connect(
|
||||
&self,
|
||||
|
||||
@@ -574,6 +574,15 @@ pub struct HttpResponse {
|
||||
pub body: Vec<u8>,
|
||||
}
|
||||
|
||||
/// A response whose body is still arriving (WIT `net.response-stream`).
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct HttpStreamHead {
|
||||
/// Owned by this plugin instance; read with [`crate::HostApi::http_stream_read`].
|
||||
pub id: u64,
|
||||
pub status: u16,
|
||||
pub headers: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
/// What a one-off process printed (WIT `process.output`).
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct ProcessOutput {
|
||||
|
||||
@@ -27,6 +27,7 @@ pub(crate) mod bindings {
|
||||
"openidea:plugin/process.child": super::ChildRes,
|
||||
"openidea:plugin/ipc.connection": super::ConnectionRes,
|
||||
"openidea:plugin/net.websocket": super::WebSocketRes,
|
||||
"openidea:plugin/net.response-stream": super::ResponseStreamRes,
|
||||
"openidea:plugin/auth.loopback": super::LoopbackRes,
|
||||
},
|
||||
});
|
||||
@@ -263,6 +264,21 @@ impl Drop for WebSocketRes {
|
||||
}
|
||||
}
|
||||
|
||||
/// A response body still arriving, owned by this plugin instance. Releasing
|
||||
/// the component resource closes the connection.
|
||||
pub struct ResponseStreamRes {
|
||||
id: u64,
|
||||
status: u16,
|
||||
headers: Vec<(String, String)>,
|
||||
host: std::sync::Arc<dyn crate::HostApi>,
|
||||
}
|
||||
|
||||
impl Drop for ResponseStreamRes {
|
||||
fn drop(&mut self) {
|
||||
self.host.http_stream_close(self.id);
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ChildRes {
|
||||
fn drop(&mut self) {
|
||||
self.host.release_process(self.id);
|
||||
@@ -1866,12 +1882,11 @@ impl diagnostics::Host for StoreData {
|
||||
}
|
||||
}
|
||||
|
||||
impl net::Host for StoreData {
|
||||
fn fetch(&mut self, req: net::Request) -> Fallible<net::Response> {
|
||||
let capability = match net_capability(&req.url) {
|
||||
Ok(h) => h,
|
||||
Err(e) => return Ok(Err(wit::Error::Invalid(e))),
|
||||
};
|
||||
impl StoreData {
|
||||
/// The host request for `req` once its grants (asking under `net:ask`),
|
||||
/// secrets and body size are checked: shared by `fetch` and `fetch-stream`.
|
||||
fn net_request(&mut self, req: net::Request) -> Result<HttpRequest, wit::Error> {
|
||||
let capability = net_capability(&req.url).map_err(wit::Error::Invalid)?;
|
||||
let mut grants = self.granted.clone();
|
||||
if let Err(e) = self.require(capability.clone()) {
|
||||
// `net:ask`: an HTTPS (or loopback) host the manifest does not list
|
||||
@@ -1880,35 +1895,38 @@ impl net::Host for StoreData {
|
||||
let askable =
|
||||
matches!(&capability, Capability::Net(_)) && self.granted.iter().any(|g| g.covers(&Capability::NetAsk));
|
||||
let allowed = match &capability {
|
||||
Capability::Net(host) if askable => match self.ask_net(host) {
|
||||
Ok(Some(_)) => true,
|
||||
Ok(None) => false,
|
||||
// A cancelled or failed question is not a refusal.
|
||||
Err(e) => return Ok(Err(e)),
|
||||
},
|
||||
// A cancelled or failed question is not a refusal.
|
||||
Capability::Net(host) if askable => self.ask_net(host)?.is_some(),
|
||||
_ => false,
|
||||
};
|
||||
if !allowed {
|
||||
return Ok(Err(e));
|
||||
return Err(e);
|
||||
}
|
||||
grants.push(capability.clone());
|
||||
}
|
||||
if req.headers.iter().any(|h| h.value.contains("{{secret:"))
|
||||
&& let Err(e) = self.require(Capability::Secrets)
|
||||
{
|
||||
return Ok(Err(e));
|
||||
if req.headers.iter().any(|h| h.value.contains("{{secret:")) {
|
||||
self.require(Capability::Secrets)?;
|
||||
}
|
||||
if req.body.as_ref().is_some_and(|b| b.len() > MAX_REQUEST_BODY) {
|
||||
return Ok(Err(wit::Error::Invalid("request body larger than 8 MiB".into())));
|
||||
return Err(wit::Error::Invalid("request body larger than 8 MiB".into()));
|
||||
}
|
||||
let wanted = Duration::from_millis(u64::from(req.timeout_ms.unwrap_or(30_000)));
|
||||
let request = HttpRequest {
|
||||
Ok(HttpRequest {
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
headers: req.headers.into_iter().map(|h| (h.name, h.value)).collect(),
|
||||
body: req.body,
|
||||
timeout: wanted.min(self.io_timeout()),
|
||||
grants,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl net::Host for StoreData {
|
||||
fn fetch(&mut self, req: net::Request) -> Fallible<net::Response> {
|
||||
let request = match self.net_request(req) {
|
||||
Ok(request) => request,
|
||||
Err(e) => return Ok(Err(e)),
|
||||
};
|
||||
let token = self.cancel.token();
|
||||
let outcome = self.host.fetch(request, &token);
|
||||
@@ -1924,6 +1942,28 @@ impl net::Host for StoreData {
|
||||
.map_err(to_wit))
|
||||
}
|
||||
|
||||
fn fetch_stream(&mut self, req: net::Request) -> Fallible<Resource<ResponseStreamRes>> {
|
||||
let request = match self.net_request(req) {
|
||||
Ok(request) => request,
|
||||
Err(e) => return Ok(Err(e)),
|
||||
};
|
||||
let token = self.cancel.token();
|
||||
match self.host.fetch_stream(request, &token) {
|
||||
Ok(head) => self
|
||||
.push(ResponseStreamRes {
|
||||
id: head.id,
|
||||
status: head.status,
|
||||
headers: head.headers,
|
||||
host: self.host.clone(),
|
||||
})
|
||||
.map(Ok),
|
||||
Err(e) => {
|
||||
self.grant_io_error_grace();
|
||||
Ok(Err(to_wit(e)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn websocket_connect(
|
||||
&mut self,
|
||||
project: Resource<ProjectRes>,
|
||||
@@ -1989,6 +2029,43 @@ impl net::HostWebsocket for StoreData {
|
||||
}
|
||||
}
|
||||
|
||||
impl net::HostResponseStream for StoreData {
|
||||
fn status(&mut self, this: Resource<ResponseStreamRes>) -> wasmtime::Result<u16> {
|
||||
Ok(self.table.get(&this)?.status)
|
||||
}
|
||||
|
||||
fn headers(&mut self, this: Resource<ResponseStreamRes>) -> wasmtime::Result<Vec<net::Header>> {
|
||||
let stream = self.table.get(&this)?;
|
||||
Ok(stream
|
||||
.headers
|
||||
.iter()
|
||||
.map(|(name, value)| net::Header { name: name.clone(), value: value.clone() })
|
||||
.collect())
|
||||
}
|
||||
|
||||
fn read(&mut self, this: Resource<ResponseStreamRes>, max_bytes: u32, timeout_ms: u32) -> Fallible<net::BodyChunk> {
|
||||
let id = self.table.get(&this)?.id;
|
||||
let timeout = Duration::from_millis(u64::from(timeout_ms)).min(self.io_timeout());
|
||||
let max = (max_bytes as usize).min(1 << 20);
|
||||
let outcome = self.host.http_stream_read(id, max, timeout, &self.cancel.token());
|
||||
if outcome.is_err() {
|
||||
self.grant_io_error_grace();
|
||||
}
|
||||
Ok(outcome.map(|(bytes, done)| net::BodyChunk { bytes, done }).map_err(to_wit))
|
||||
}
|
||||
|
||||
fn close(&mut self, this: Resource<ResponseStreamRes>) -> wasmtime::Result<()> {
|
||||
let id = self.table.get(&this)?.id;
|
||||
self.host.http_stream_close(id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn drop(&mut self, this: Resource<ResponseStreamRes>) -> wasmtime::Result<()> {
|
||||
self.table.delete(this)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl secrets::Host for StoreData {
|
||||
fn set(&mut self, name: String, value: String) -> Fallible<()> {
|
||||
if let Err(e) = self.require(Capability::Secrets) {
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
1e6a4ba99409620e9bf3ceb51387704018737f186a89037b05bcbcee1e38a967
|
||||
8a08e92c30faaa683e531fd91c8a69392d75165cff62153e216008f7abbcb1ea
|
||||
@@ -24,6 +24,10 @@ title = "ipc"
|
||||
id = "fetch"
|
||||
title = "fetch"
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "fetch-stream"
|
||||
title = "fetch-stream"
|
||||
|
||||
[[contributes.commands]]
|
||||
id = "window-status"
|
||||
title = "window-status"
|
||||
|
||||
@@ -73,6 +73,21 @@ impl Plugin for Api14 {
|
||||
let response = host::fetch(&openidea_plugin::HttpRequest::get(arg))?;
|
||||
Ok(Some(String::from_utf8_lossy(&response.body).into()))
|
||||
}
|
||||
"fetch-stream" => {
|
||||
// `<count> <url>`: the first `count` events, then the stream is dropped.
|
||||
let (count, url) = arg.split_once(' ').unwrap_or(("1", arg));
|
||||
let stream = host::fetch_stream(&openidea_plugin::HttpRequest::get(url))?;
|
||||
let mut out = vec![stream.status().to_string()];
|
||||
let mut events = stream.events();
|
||||
for _ in 0..count.parse::<usize>().unwrap_or(1) {
|
||||
out.push(match events.next(5_000)? {
|
||||
Some(event) => format!("{}:{}", event.event, event.data),
|
||||
None if events.is_done() => "done".into(),
|
||||
None => "timeout".into(),
|
||||
});
|
||||
}
|
||||
Ok(Some(out.join("|")))
|
||||
}
|
||||
"global-status" | "window-status" => {
|
||||
let item = StatusItem { text: arg.into(), tooltip: None, command: Some("events".into()) };
|
||||
if id == "global-status" {
|
||||
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
667622767aa8c75a44c1348f6d07979ecb7a2db7ede9613999b61658a58557f5
|
||||
de08e41d78da65ee3de2c709112e8d8905b50432bd59af1701dd633f674fa121
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
689a9f36b9d13e0b57bd1540321a06da65837510fd9a37225776abd8baccfd7c
|
||||
455c833fc7d02c083a1ae67d1df507f29581f77d7f8624ff562f1ce982efc730
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
0316df8c6f5fd4523f077c1a12d2d8af9592729a66a5a99a155dde42bb331e96
|
||||
a891db4b18f175648ec47a6c1e20edde0ff266d38b37a1fd2acc8f95ddf0d5b4
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
6732e125bfefcfad1c5712516e05bdaff7ceea4e71994de45109086e252e5f72
|
||||
30f99018d1c6e518fbc179b2090a7f65856e10b9bed4bb76e605d88acec86393
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
bb6c942f198534adf96354dd670c175f73954782f516762c564d157f5004b744
|
||||
39e361f892aa0944bc3eac5a2a9f5a7133deced54ca28193f8d789eaccc1a326
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
fa0957c9041bc31f7dc5b58aa912fa83851e6f0058d055e9582950195a1015b4
|
||||
f36cf494eb56ebb9d6459a0b84b854ce413eed79e563074bc850de3ee4a4bb2d
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
00ac40b08a5a39d4e011e9391732f19c20eb439a6f980b8d96334a5547c28666
|
||||
ea314de1d7cdf468b69603bda1766c7361497c9a50fc3e43ab508592d1861fe7
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
82473da5332e96dc9ef3a82947cde59b0a5d6acd49f8baad7c4fcc46ed4284dc
|
||||
218dbcd47abeb8ef4b06e13cbbfdd7e24790c11f27c352ce95cfbb6cba61a062
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
8532a968b8522e9b1b6f0df3aed073191e2a441ab960f96af79d7132fda4090a
|
||||
78bad0a6062a0131527a700e0b75ca24fd96162e8fe326b45b5a96c8da8723b4
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
ee0f3be61a8684275dc15acfdfe374b6d1751078d15c92608ba39ccbc6e10c67
|
||||
f90db44c3df10b60fca9e337eba1d3269d8299ca06f5e60cbd9ab7dd65d32fba
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
4a3602e6024dcbeccb59ef9b324bab3e3254c908a7513c4f08bcbd212e368f9f
|
||||
72aac6f440205694028e52df9932340131f6f30d89fbe3e9363a97110c912336
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
bd6aa162f07d96a580a8891433fd042e08a976f0f3ce4aee7694957ad394057c
|
||||
366172ef7c2d4d2d218d3a653763852983b0af21e7e79ee644c4c216b64b2665
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
edac72326d401c873394ff0de9a659d5f3642259df136b87fb9b6cfe632e60c5
|
||||
3eac3cab007df8f12e89b044f02348f564a5ec53376743ffccaacc6df383fd37
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
7454788469a0c0662987a4a774d8fc59b20b0dfec9bbac754e8e4aa0a46a1b43
|
||||
3dab8c8f0177ab0de22a6daccc374c7aaa7e37f6959815edee5641d45bffa3ab
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
268b18f9303602b00f5c0d7254967aeb95c377b5a85011ead539b4ccab5811e2
|
||||
834b90f241c89b7f24217f4ea579810de703da23806b7e21113df5a43ea20dbb
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
9e8809f276ef27561fe337f8268b3cf4f06be7ac1707a61e6e41407ec932bbb1
|
||||
dbff03557f56e4483e8770c1dcca455c78f4331265613a93475ee28a8c581d79
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
c4594d365423395722e7f8e14f6d9c32ad4ff579b2eb42f5e2c5650e7cfa6bdc
|
||||
e674c90857e859a6a7684f9d7899dbdf05f9fe5d310ed809def6bf5403877bda
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
91b267d3845bbd199662c0857ee23634a1d1b287204ce81fa148f1ce43eace3b
|
||||
0e856198f5839dc675afcc883b43aa9c950c4f73807fe0b1145d976e00bbf2f4
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
8e5c91ab272fa1678fbef9607f12513f7a589ef3fd293cfd7a52497cf637de3d
|
||||
b693136d64688418665ef010b5cb83b86fc4b0adc052b7783530cc53d863085e
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
a2e19194ba5f42e9d02d996c77444e8a5267fecc99bb02933f35aabb22fddadd
|
||||
cb07913a6a7a1f61521818ffada5b59b8b30e08bc5ef3ed21a9d3a1924ac4445
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
78a9be879f2a07417c26a0818d2896ba6d93ea60bed69f3ebaf963ea1842147b
|
||||
47642c0e293829c19528d85d6058b0ea08d68d3380032c4e04937322c88178a2
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
2cc25b5de5003300b686ecc47a9f2379dcb61ed954c0b41db6b5945c865fffb7
|
||||
61cc8a30b6db4a50502b014e4849365cd25b86cc197305d570241186bb1bdbaf
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
a1167c3620a2fd143d94cbb235139f7f428f5360dcab65730f5abf0c5944b061
|
||||
72c8ce5f05dd3425fad3e9d8928a06f79f258beaaabcde7f14d5c1c65d3c2d97
|
||||
@@ -1 +1 @@
|
||||
57062a5c91e85524e22d61ef7cdda9f5241f760ccb47b3fd7a53c7bbd86ce58a
|
||||
667102db97617a5149e1a4fb1f81bb57a25cf0265cf08b37f76a976b42bd54a8
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
4ede6078038216c3c81de9732c32d653669a06c55b3482f7640cae3a2eab6b8c
|
||||
70b2bd11475b9cafb21ebe8cd2dfc888e442c9de0220d93c85fb3a25b45e96da
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
1f1b4a5aa2913ab087224d152df4c308e7b572c746ffabee18786fce78c50f9d
|
||||
1f633882937a9b8fa9d73466cd96dd6f6e3ff620148fd831fdced35fc2d79517
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
37ace7bb2fece14d1178166c3b81c938bebdf3938399384dff319eaa6dbc964f
|
||||
6e9a028bd06f3d79f05462a82bcc250a589f938c029633a73d28750a8ae72dbe
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
679aa7de740ef9c777fee6c72ed586ce9a8dc1b1f2d553214c080c0003626971
|
||||
c5f5ca68fac368b962ce152be508927ed42c60d1796adb9eadfc9c903766cc4c
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
7a7eb7e96053b06c75b4881619370b2faeca9da042fb6b54a75b38a98a1b8ad8
|
||||
cba28a450b12be242a5e0e4285ea61af01b055eced9d28c0c102383186596a1c
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
fee91a25750bc82ef5f44e85891466229da3884bbeca737331e72bd6f533c082
|
||||
baf3b27249b7cf07ffc62f1d5a6989ac17738d19074bb5d927ada85e202eac94
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
3f7c0bd15b37966fb6dd400ce32f6310c19aedfcdc8adfd90d6af4d1a409c96a
|
||||
a47ab3aaf7b2858899bee1999a6cb031a27436132c202081085da92b7c352321
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
54e09f6d2ae0bb4772661ec7d77f3b92e30da19f115847e456615af1d99ee608
|
||||
8f6e6b21759f7feeac98aac63d916d470ea1321d8023110b27fe4d4ae383a9e7
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
993bc87ead9037693e1f33a1d6ff20f08fb09ed5b0bb9a03641a6785f2a90f1c
|
||||
3d783bec5d19f49de0dd736030eaf693d0b8a5f71799617e7a21d5c939809d17
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
7b3456731392cca0aae6243689f7beab47d775a3f6adbadc0dd4bf1f23db8f5d
|
||||
06b50aaaddd87cd8d412db5d94375c703e205991e5de2db517d6342578fed332
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
5b2c9bb2a80ab7c7b777ce35bd5e86bd16c90085b6cfa5639eaa28850a7b828a
|
||||
a0eb78229020e413e63fa93df7cbd631b1b5f02336eb6453bc75de39d41aafd9
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
6a40da7abf14285fb3274a6e2ace582373e5f96689360428c6db1287c62da043
|
||||
60aee3fc7660b9f2fe53c7baf446b4a3c12e7f25ae092ed3a05331e2919221b4
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
5b86ed9e234d07d2c824719ec30e3705cfed1ae873e38be1c417c0a2623c95e2
|
||||
77db8099d8a68aafffc6eda2b1388b587a30f4fa83bfd611b968e5d4a680ad38
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
a0170f44828c31babcdae54fcaefb1546d7f7dfecb8145c21ad293a90acfaac7
|
||||
eb5277d6c1856122e1f7dc999d8d55067a6327fb3cb89c870661d280c63946fd
|
||||
@@ -40,7 +40,7 @@ The plugin calls these. Most are gated by a [capability](/en/plugins/capabilitie
|
||||
| `events` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | Subscribing to workbench events, optionally filtered by path |
|
||||
| `tasks` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | Long-running work with a progress indicator and a longer time budget |
|
||||
| `diagnostics` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Publishing problems for files and reading the Problems view |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) requests (`net:` / `net.http:` / `net:ask`) |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) requests (`net:` / `net.http:` / `net:ask`), streamed responses (`fetch-stream`, 1.19) |
|
||||
| `secrets` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Secrets in the OS keychain, used only through `{{secret:<name>}}` in requests |
|
||||
| `process` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Running approved programs once, with an environment, or behind a handle |
|
||||
| `ipc` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | Local sockets and named pipes on the project machine (API 1.4) |
|
||||
|
||||
@@ -65,7 +65,7 @@ Later:
|
||||
| `clipboard.read` | Medium | `host::read_clipboard`: the clipboard's text and image, only in commands and view actions the user ran (event handlers and other unattended calls are denied) | 1.11 |
|
||||
| `agents` | Medium | `host::fork_agent_session`: fork a recorded native agent session (`claude` or `codex`) into a new task in the invoking window's project; trusted projects only | 1.18 |
|
||||
| `secrets` | Medium | `{{secret:<name>}}` in request headers, `secret_is_set`, `secret_set`, `secret_delete` | 1.0 |
|
||||
| `net:<host>` | Medium | `host::fetch` over HTTPS (and loopback HTTP) to that host; `*.example.com` matches subdomains | 1.0 |
|
||||
| `net:<host>` | Medium | `host::fetch` / `host::fetch_stream` over HTTPS (and loopback HTTP) to that host; `*.example.com` matches subdomains | 1.0 |
|
||||
| `net:ask` | Medium | Ask the user at the first request to an HTTPS host that isn't declared | 1.5 |
|
||||
| `net.http:<host>` | Medium | Unencrypted HTTP to that host | 1.4 |
|
||||
| `database.sources` | Medium | Manage only the plugin's own project database sources and write their credentials; trusted projects only | 1.4 |
|
||||
|
||||
@@ -33,7 +33,7 @@ The plugin API has one version number: the version of the WIT package in [`wit/`
|
||||
| 1.16.0 | OpenIDEA 0.1.52 | Optional `completion-list-provider` export: completion marked incomplete is asked again while typing on, without re-asking the language server or other plugins; `decorations.set-markdown`: line-end decorations whose hover is a Markdown card |
|
||||
| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette |
|
||||
| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`: a package web page floating over the workbench that never takes the keyboard focus, placed and resized through `openidea.overlay`; `[[contributes.dialogs]]`: a package web page in a modal, resizable IDE dialog opened with `views.reveal`, with a `closed` view event and `openidea.dialog.close()`; `events.subscribe-paths-with-options` (`debounce-ms`), `workspace.project.generation` and `FilesChanged` project/generation fields, stale run target/configuration rejection, and the `project-closed` lifecycle event; `execution-configurations`, `run.start-with-options` and `runDetectors.outputMode`: `pipes` or `pty` console output for plugin run configurations; `[[contributes.runAnything]]` with the `run-anything-provider` export: Run Anything lines starting with the plugin's prefix; `views.open-terminal-session-in`: a keyed terminal in a project directory; `workspace.invoking-project`: the project of the window a call serves, also in `gutter-actions` and `hover-actions`; `events.watch-paths` and the `watched-files-changed` event: files and directories outside the project, within `fs.read` grants; the `run-configuration-completion` export: completion in the Arguments field of the plugin's own run configurations; `services.context` and `services.toolbar` menus on the IDE's own Services nodes, with the selected services as the command argument; `executor` on `[[contributes.javaAgents]]`: "Run/Debug '<name>' with <title>" beside Run and Debug, the only launches that get that agent, also startable from the plugin's own commands with a configuration id; grant-scoped `agents.fork-session`: fork a recorded native agent session (`claude` or `codex`) into a new task in the invoking window's project (`agents` capability), with the host validating the session and building the fork invocation itself |
|
||||
| 1.19.0 | In development on `main` | `[capabilities.reasons]`: the plugin's own sentence on why it asks for a capability, shown below the host's description in the permission dialog and Settings › Plugins; `settings.open` / `settings.open-permissions`: open Settings at one of the plugin's own pages or at its permissions |
|
||||
| 1.19.0 | In development on `main` | `[capabilities.reasons]`: the plugin's own sentence on why it asks for a capability, shown below the host's description in the permission dialog and Settings › Plugins; `settings.open` / `settings.open-permissions`: open Settings at one of the plugin's own pages or at its permissions; `net.fetch-stream`: a response whose body is read as it arrives (server-sent events, streamed model replies), with the SDK's `host::fetch_stream` and `sse` parser |
|
||||
|
||||
The full list of what each version added is in [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md).
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ description: "openidea:plugin WIT 包中的每个 interface:一句话说明及
|
||||
| `events` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | 订阅工作台事件,可按路径过滤 |
|
||||
| `tasks` | [events.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/events.wit) | 带进度指示、时间预算更长的后台工作 |
|
||||
| `diagnostics` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 为文件发布问题,读取 问题 视图 |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) 请求(`net:` / `net.http:` / `net:ask`) |
|
||||
| `net` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | HTTP(S) 请求(`net:` / `net.http:` / `net:ask`)、流式响应(`fetch-stream`,1.19) |
|
||||
| `secrets` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 系统钥匙串中的密钥,只能通过请求中的 `{{secret:<name>}}` 使用 |
|
||||
| `process` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 运行已批准的程序:一次性运行、带环境变量运行,或通过句柄保持运行 |
|
||||
| `ipc` | [io.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/io.wit) | 项目所在机器上的本地套接字和命名管道(API 1.4) |
|
||||
|
||||
@@ -65,7 +65,7 @@ optional = ["net:127.0.0.1", "clipboard.read"]
|
||||
| `clipboard.read` | 中 | `host::read_clipboard`:读取剪贴板的文本和图片,仅限用户运行的命令和视图操作(事件处理器等无人值守的调用会被拒绝) | 1.11 |
|
||||
| `agents` | 中 | `host::fork_agent_session`:把录制的原生 agent 会话(`claude` 或 `codex`)派生为当前窗口项目中的新任务;仅限受信任项目 | 1.18 |
|
||||
| `secrets` | 中 | 请求头中的 `{{secret:<name>}}`、`secret_is_set`、`secret_set`、`secret_delete` | 1.0 |
|
||||
| `net:<host>` | 中 | `host::fetch` 通过 HTTPS(以及回环地址的 HTTP)访问该主机;`*.example.com` 匹配子域名 | 1.0 |
|
||||
| `net:<host>` | 中 | `host::fetch` / `host::fetch_stream` 通过 HTTPS(以及回环地址的 HTTP)访问该主机;`*.example.com` 匹配子域名 | 1.0 |
|
||||
| `net:ask` | 中 | 第一次请求未声明的 HTTPS 主机时询问用户 | 1.5 |
|
||||
| `net.http:<host>` | 中 | 通过未加密的 HTTP 访问该主机 | 1.4 |
|
||||
| `database.sources` | 中 | 只管理插件自己的项目数据源并写入其凭据;仅限受信任项目 | 1.4 |
|
||||
|
||||
@@ -30,7 +30,7 @@ description: "engines.openidea、插件 API 从 1.0 到 1.19 的各个版本,
|
||||
| 1.16.0 | OpenIDEA 0.1.52 | 可选 `completion-list-provider` 导出:标记为不完整的补全在继续输入时再次询问,不会重新询问语言服务器和其他插件;`decorations.set-markdown`:悬停显示 Markdown 卡片的行尾装饰 |
|
||||
| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`:自带 `#rrggbb` / `#rrggbbaa` 前景色和背景色的编辑器装饰,用于主题调色板之外的颜色 |
|
||||
| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`:悬浮在工作台上方、从不抢占键盘焦点的插件网页,可通过 `openidea.overlay` 移动和调整大小;`[[contributes.dialogs]]`:插件网页显示在可调整大小的模态对话框中,用 `views.reveal` 打开,关闭时发 `closed` 视图事件,页面可调用 `openidea.dialog.close()`;`events.subscribe-paths-with-options`(`debounce-ms`)、`workspace.project.generation` 与 `FilesChanged` 的 `project`/`generation` 字段、过期运行目标/配置拒绝以及 `project-closed` 生命周期事件;`execution-configurations`、`run.start-with-options` 与 `runDetectors.outputMode`:插件运行配置的控制台输出方式(`pipes` 或 `pty`);`[[contributes.runAnything]]` 与 `run-anything-provider` 导出:以插件前缀开头的 Run Anything 行;`views.open-terminal-session-in`:在项目子目录中打开带 key 的终端;`workspace.invoking-project`:本次调用所服务窗口的项目,`gutter-actions` 和 `hover-actions` 中也可用;`events.watch-paths` 与 `watched-files-changed` 事件:监听项目之外、`fs.read` 授权范围内的文件和目录;`run-configuration-completion` 导出:补全插件自己运行配置的“实参”字段;`services.context` 和 `services.toolbar` 菜单:作用于 IDE 自带的 Services 节点,命令参数是选中的服务;`[[contributes.javaAgents]]` 的 `executor`:运行和调试旁边的“使用 <title> 运行/调试 '<name>'”,只有经它启动时才加载该代理,插件自己的命令也可用配置 id 经它启动;需授权的 `agents.fork-session`:把录制的原生 agent 会话(`claude` 或 `codex`)派生为调用窗口项目中的新任务(`agents` 能力),宿主自行校验会话并构造 fork 调用 |
|
||||
| 1.19.0 | `main` 上开发中 | `[capabilities.reasons]`:插件用一句话说明为什么需要某个能力,显示在授权对话框和 设置 › 插件 中宿主说明的下方;`settings.open` / `settings.open-permissions`:打开设置并定位到插件自己的页面或它的权限 |
|
||||
| 1.19.0 | `main` 上开发中 | `[capabilities.reasons]`:插件用一句话说明为什么需要某个能力,显示在授权对话框和 设置 › 插件 中宿主说明的下方;`settings.open` / `settings.open-permissions`:打开设置并定位到插件自己的页面或它的权限;`net.fetch-stream`:边到达边读取响应体(服务器推送事件 SSE、模型的流式回复),SDK 提供 `host::fetch_stream` 和 `sse` 解析器 |
|
||||
|
||||
每个版本新增内容的完整列表见 [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md)。
|
||||
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
ec3d63216f12488f1da4dec9925df931ee01bcbd310fe4c63310635040644e77
|
||||
7669b056e8fdfac23cf680bce156f9e5458102f5606d972c46563b75af96e90c
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
59f291af42ebf3c995cc2dbc1af884ee6907379a2b2dbce5a111ebce5751ad92
|
||||
0482fcab4ffa4ec70dbe1e27d6498cf6a6511cdac2c2effe2547f50b5fc051fe
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
f398b771ebb770eafc8b29257f7a8b3f169c17bcde272139df3ad36560d8f7b6
|
||||
079e6faf15706581715b1916319f2e86c368dd728a78abc62269845a0e8f287b
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
8e726e190c66dc9fa045efa6941848f5a8b5f60f63f03bdd13bfd1722899ae16
|
||||
44218a9f34c15352af7351bda6a0e4530fdee0f5a22662452e7425fcc696671f
|
||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача