What does DropTerm's pinned build need to carry an AI capability end to end: HTTP transport with streaming, provider wire shapes, key storage on Linux and COSMIC, and a seam through which plugins can use the host's AI?
Question: What does DropTerm's pinned build need in order to carry an AI capability end to end — an HTTP transport with streaming, the provider wire shapes and the crates that speak them, a place to keep API keys on Linux and COSMIC, and a seam through which a plugin can use the host's AI — building on (not re-arguing) the ruled v1 shape in ai-completion-providers?
Date: 2026-11-26
TL;DR: Everything hard is already in the pinned graph — gpui-pre-http-client (a streaming-capable HttpClient trait) is an unconditional dependency of gpui-pre itself, gpui-pre-reqwest (reqwest 0.12.15, the whole rustls stack) is already resolved in the lock and the graph-pin test anticipates it, the multi-thread tokio sidecar runtime is running for D-Bus, and — the record-changing find — oo7 0.6.0, a pure-Rust Secret Service/keyring client Zed itself uses, is already compiled into every Linux build as a hard dependency of gpui-pre-linux, sharing DropTerm's own zbus 5.19.0. What remains is small and additive: two direct dependency lines, a thin ~200-line HttpClient adapter (Zed's reqwest_client is the worked example), a hand-rolled OpenAI-compatible chat/SSE client over the ruled {provider, model} pair, key handling that extends the ruled env-first order with oo7 second and COSMIC's gnome-keyring-backed org.freedesktop.secrets as the store it finds, and a token-matched request→HostEvent AI facility that reuses the Lua host's existing query pattern. No hard blockers; three spikes before commitment.
Findings
1. The transport trait is already in the build, ungated, and it streams
gpui-pre-http-client0.3.12 is the snapshot of Zed'shttp_clientcrate (manifest metadata:zed-crate = "http_client",zed-rev = d2a4fb6…) — theHttpClienttrait, request-extension surface, wrappers, and test fakes. It carries no HTTP implementation of its own (gpui-pre-http-client-0.3.12/Cargo.tomlhas no reqwest/hyper dependency at all).- It is not feature-gated.
gpui-pre0.3.12 declares it as a plain (non-optional) dependency (gpui-pre-0.3.12/Cargo.toml:359-361), and there is nohttp_client = […]feature in gpui-pre's feature list (lines 53-92) — the only feature touchpoint istest-supportenablinghttp_client/test-support(:82), which switches on theFakeHttpClienttest fakes. The ruled feature set (wayland+font-kit) is irrelevant to it: the trait crate is in every gpui-pre build, and the lock confirms it (Cargo.lock:2469under gpui-pre,:2652under gpui-pre-linux). DropTerm's dev-dependency on gpui withtest-support(dropterm/Cargo.toml:224) therefore already makesFakeHttpClientavailable in test builds. - Streaming is native to the trait's shape:
HttpClient::sendreturnsBoxFuture<anyhow::Result<Response<AsyncBody>>>(http_client.rs:123-126), andAsyncBodyimplementsfutures::AsyncRead— the response variant is anAsyncReader(Pin<Box<dyn AsyncRead + Send + Sync>>)(async_body.rs:14-41,poll_readat:114-131) plus anhttp_body::Bodyadapter that emits 8 KiB frames (:133-152). Incremental response reads — exactly what Server-Sent Events need — are supported at the trait level. The request side carriesAsyncBody::from_readerfor streaming uploads, aJsonnewtype (:93-103),RequestTimeout(whole-request deadline including body,http_client.rs:51-53),RedirectPolicy(:17-23), and pre-validatedCustomHeaders(:66-86) — the user-supplied-header surface Zed validates once at settings load. - Consequence: DropTerm can adopt the trait by adding one direct dependency line (
gpui-pre-http-client = "=0.3.12", needed because a crate must be a direct dependency to beuse-able) and naming an implementation — nothing new enters the graph.
2. gpui-pre-reqwest is reqwest 0.12.15, pinned in the family, waiting as the implementation
-
gpui-pre-reqwest0.12.15 is reqwest itself — manifest description "higher level HTTP client library zed-industries/request@c156624", repository seanmonstar/reqwest, license MIT OR Apache-2.0, lib renamedgpui_pre_reqwest. It is Zed's reqwest fork (zed-industries/reqwest) published under the snapshot family's namespace, riding "its own 0.12 line (its semver universe)" — language the graph-pin test already anticipates (dropterm/src/main.rs:569-573: "gpui-pre-reqwest rides its own 0.12 line … every other family crate is a 0.3.12 snapshot cut"). -
It is in the lock (
Cargo.lock:2755-2803) with the full stack resolved: hyper 1.12 / hyper-util 0.1.21 / http 1.5 / h2 0.4.20, rustls 0.23.46 + tokio-rustls 0.26.6 + hyper-rustls 0.27.10 + rustls-native-certs 0.8.5 (system CA store),ring0.17.14, tokio-socks, tokio-util. One caveat on "present": the only crate that declares it,gpui-kit-assets0.9.1, declares it under[target.'cfg(target_family = "wasm")'](gpui-kit-assets-0.9.1/Cargo.toml:105-117, featurescharset, http2, macos-system-configuration, multipart, rustls-tls-native-roots, socks, stream) — so it is lock-resolved and, per the build tree's fingerprints, not compiled on Linux today (settled; see Unverified). Adding it as a direct dependency compiles it for the first time; no new crates enter, only build time. Zed's own workspace pins the identical fork shape (zed-reqwest 0.12.15-zed, featureshttp2, macos-system-configuration, rustls-tls-native-roots, socks, stream,default-features = false— zed mainCargo.toml, fetched 2026-11-26), which is the feature set to declare. -
SSE needs the
streamfeature:Response::bytes_streamis#[cfg(feature = "stream")](src/async_impl/response.rs:357-359). Zed's adapter is the worked example of the whole seam — three lines of body plumbing:let bytes = response.bytes_stream().map_err(futures::io::Error::other).into_async_read();let body = http_client::AsyncBody::from_reader(bytes);(
crates/reqwest_client/src/reqwest_client.rsat zed main, fetched 2026-11-26; it also mapsRedirectPolicy→redirect policies,RequestTimeout→per-request timeout with a test proving it fires mid-body, and proxy env handling withno_proxy.) -
Execution context: reqwest 0.12's async client contains no internal
tokio::spawnfor requests (grep oversrc/async_impl/found spawns only in the h3 client and the blocking wrapper), so the caller's executor drives the futures — and those futures need a tokio reactor for hyper/TLS/timers. DropTerm already runs one: the D-Bus sidecar thread builds anew_multi_thread().enable_all()runtime and blocks on it for the process lifetime (dropterm/src/dbus.rs:92-107). AI requests should be built and awaited there, with results marshaled to the UI or Lua host threads overstd::sync::mpsc— the same discipline the Lua host already states ("no tokio channel crosses the bridge",lua_host.rs:8-11).
3. What one "OpenAI-compatible" client covers, and where the others diverge
- The compatible family (what the ruled v1
customprovider reaches):- OpenAI Chat Completions:
stream: trueyields SSEdata:chunks of object"chat.completion.chunk"withchoices[].delta(role,content,tool_calls),choices[].finish_reason("stop" | "length" | "tool_calls" | "content_filter"), and a final usage chunk (the SDK chunk type carries ausagefield gated on theinclude_usagestream option — openai-pythontypes/chat/chat_completion_chunk.py, fetched 2026-11-26; OpenRouter's docs confirm the convention from the consumer side: its final usage chunk "follows OpenAI's spec", see below). Tools: requesttools: [{type: "function", function: {name, description, parameters}}]; the assistant replies withtool_calls: [{id, type: "function", function: {name, arguments}}]whereargumentsis a JSON-encoded string the docs warn to "validate… before calling your function" (types/chat/chat_completion_message_function_tool_call.py); the follow-up is arole: "tool"message carryingtool_call_id. Streaming tool arguments arrive as fragments keyed bydelta.tool_calls[].index(chat_completion_chunk.py,ChoiceDeltaToolCallFunction). Models:GET /v1/modelsreturnsdata[].{id, object: "model", created, owned_by}(types/model.py; the API hub shows theAuthorization: Bearerrequest, developers.openai.com/api/reference, fetched 2026-11-26). - OpenAI Responses API exists in parallel — the hub steers "direct model requests, tool use…" to it, and its streaming vocabulary is far larger (
response.output_text.delta,response.output_item.added,response.function_call_arguments.delta,response.completed,response.failed,response.incomplete, MCP/image-gen/shell events —types/responses/response_stream_event.py). The OpenAI-compatible ecosystem below standardized on Chat Completions, not Responses; LM Studio is the one local server that also serves/v1/responses(its docs note "Codex is supported because LM Studio implements the OpenAI-compatiblePOST /v1/responsesendpoint"). - Ollama (
http://localhost:11434/v1): compatibility is "experimental and subject to major adjustments including breaking changes"; the API key is "required but ignored"./v1/chat/completionssupports streaming, JSON mode, vision,tools— but tool streaming is "coming soon" andtool_choiceis unsupported;/v1/completions,/v1/models(withcreated= last-modified,owned_bydefaulting to"library"),/v1/models/{model},/v1/embeddings(docs/openai.mdat main, fetched 2026-11-26). The native API diverges:/api/chatstreams NDJSON objects (message.contentdeltas, terminal line withdone: true+ eval stats), carriestoolswithrole: "tool"follow-ups keyed bytool_name;GET /api/tagslists local models (models[].{name, size, digest, details.parameter_size, …}),POST /api/showreportscapabilities(docs/api.md, fetched 2026-11-26). - llama.cpp
llama-server: serves/v1/chat/completions,/v1/completions,/v1/models("the returned list always has one single element" — one model per server instance,--aliasoverridable),/v1/embeddings; "OpenAI-style function calling is supported with the--jinjaflag"; grammar/--json-schemaconstrained outputs; native/completionis explicitly "not OAI-compatible"; SSE keep-alive pings via--sse-ping-interval; and the caveat is load-bearing: "While no strong claims of compatibility with OpenAI API spec is being made, in our experience it suffices to support many apps" (tools/server/README.mdat master, fetched 2026-11-26). - LM Studio (port 1234): "Supported endpoints" table lists
GET /v1/models,POST /v1/responses,POST /v1/chat/completions,POST /v1/embeddings,POST /v1/completions; a dedicated Tool Use page exists under OpenAI Compatibility; the native REST API v0 (/api/v0/…) adds loaded/unloaded state and TTFT stats (lmstudio.ai/docs/app/api/endpoints/openai, fetched 2026-11-26). - OpenRouter (
https://openrouter.ai/api/v1): SSEdata:chunks ending withdata: [DONE], keep-alive comment lines": OPENROUTER PROCESSING"— "If you parse the stream by hand, skip lines that start with:before callingJSON.parse" — mid-stream errors arrive as events while HTTP stays 200, and the final usage chunk "contains one choice with a content-freedeltathat repeats thefinish_reason" (deviation from OpenAI's spec, which it otherwise follows) (docs/api-reference/streaming, fetched 2026-11-26).GET /api/v1/modelsis a public catalog (no auth required) returningdata[].{id (routable slug, e.g.anthropic/claude-3.5-sonnet), name, canonical_slug, pricing}(docs/api-reference/list-available-models, fetched 2026-11-26). - Net: one hand-rolled Chat Completions + SSE client covers OpenAI, Ollama, LM Studio, llama.cpp, OpenRouter, vLLM-class servers, and corporate gateways;
GET /v1/modelsreaches all of them (llama.cpp degenerately; OpenRouter auth-free). The deltas are field-tolerance details (OpenRouter's comment lines and usage chunk; Ollama's ignored key; llama.cpp's single model), all handled by a tolerant client, not by per-vendor code.
- OpenAI Chat Completions:
- The named-vendor natives diverge structurally, which is the ground the v1 ruling already stood on ("named per-vendor adapters rejected"):
- Anthropic Messages: auth is
x-api-key+anthropic-versionheaders (not Bearer);stream: trueyields named SSE eventsmessage_start→content_block_start/content_block_delta/content_block_stop→message_delta→message_stop, withpingand in-streamerrorevents; deltas are typed (text_delta,input_json_deltawithpartial_jsonaccumulation,thinking_delta,signature_delta); tool use is atool_usecontent block whoseinputfills frompartial_jsonchunks and whose stream ends withstop_reason: "tool_use"; usage inmessage_deltais cumulative (platform.claude.com/docs/en/api/messages-streaming, fetched 2026-11-26). Nothing here matches the Chat Completions shape. - Google Gemini: native base is
POST /v1beta/models/{model}:generateContentand:streamGenerateContent; tools arefunctionDeclarations(JSON Schema), responses carryfunctionCallparts and follow-upsfunctionResponseparts; the models list isGET /v1beta/modelswith a different resource shape (name: "models/{id}",supportedGenerationMethods) (aistudio.google.com/api-reference/generate-content,/api-reference/models, fetched 2026-11-26). The docs also show a newer "interactions" endpoint with?alt=sse(aistudio.google.com/docs/text-generation, fetched 2026-11-26) — Google's reference surface is actively reorganizing (flagged under Unverified). Neither shape is reachable by a pure OpenAI-compatible client; Wave'sai:apitypeenum (openai-chat,openai-responses,google-gemini) is the peer evidence that Gemini needs its own adapter (see ai-completion-providers finding 4).
- Anthropic Messages: auth is
4. The crate field: the multi-provider SDKs all import a second HTTP family; the thin client imports none
All crates.io facts fetched 2026-11-26. GPL-3.0-compatibility first (MIT / MIT-OR-Apache-2.0 / Apache-2.0 all compatible), then weight against the ruled graph.
| Candidate | Verdict facts | Assessment |
|---|---|---|
async-openai 0.43.0 | MIT; 11.4M downloads; updated 2026-11-01; MSRV 1.75. OpenAI-only (Chat + Responses + Realtime). Required deps are just serde + getrandom; reqwest ^0.13 is its client (optional dep, feature names not pinned this session) | The best SDK if a full OpenAI SDK were wanted — but it speaks only OpenAI and pulls the crates.io reqwest 0.13 family alongside the pinned gpui-pre-reqwest 0.12.15: two HTTP stacks in one binary |
genai 0.7.5 | MIT OR Apache-2.0; 666k downloads; updated 2026-11-14; multi-provider (OpenAI, Anthropic, Gemini, Ollama, Bedrock, …) | Requires reqwest ^0.13 (json/stream/gzip/charset/http2) plus its own tokio feature set — the same second-HTTP-family cost, now for a provider matrix the v1 ruling deliberately excludes (one custom provider, named adapters rejected) |
rig-core 0.47.1 | MIT; 4.8M downloads; very active (updated 2026-11-25) | MSRV 1.97.1 exceeds DropTerm's rust-version = 1.93 (dropterm/Cargo.toml:12) — a hard blocker at pin; also an opinionated "LLM-powered applications" framework, far more surface than one provider trait |
llm 1.3.8 | MIT; 137k downloads; updated 2026-04-19; repo graniet/llm, "unifying multiple LLM backends" | The crates.io name today is not the historically known rustformers project (local inference; that project is a different lineage — see Unverified). Modest adoption; excluded by the same second-HTTP-family logic |
misanthropy 0.0.8 | MIT; 13k downloads; last updated 2025-06-08 (six months stale) | Anthropic-only — the native shape finding 3 shows is out of v1 scope; stale |
| Official vendor SDKs | OpenAI and Anthropic publish Python/TypeScript/Java/Go SDKs; no first-party Rust SDK (inference from the crates.io ecosystems: the Rust crates in this space are community projects — labeled inference, not a fetched statement of absence) | Nothing official to pin |
eventsource-stream 0.2.3 | MIT OR Apache-2.0; 38M downloads (the SSE parser under agent SDKs); last published 2022-02-17; deps: futures-core ^0.3, nom ^7.1, pin-project-lite ^0.2.8 — no HTTP client | The one SSE crate that fits the graph: pure parser over Stream<Item = Result<Bytes>>, no reqwest, tiny. Staleness is real but the API is a stable grammar parser |
reqwest-eventsource 0.6.0 | MIT OR Apache-2.0; 13M downloads; updated 2024-03-29 | "Helper to build an Eventsource using reqwest" — couples to the crates.io reqwest line; redundant when the transport is gpui-pre-reqwest |
async-sse 5.1.0 | MIT OR Apache-2.0; 5M downloads; last updated 2021-09-17; http-rs (async-std family) | Stale and ecosystem-tied to async-std; the async-io world is already in DropTerm's lock, but a 2021 parser has no edge over hand-rolling |
| No crate: a thin hand-rolled client | One OpenAI-compatible wire subset (chat completions request/response, chunk deltas, data: [DONE], comment-line tolerance, /v1/models list) is a few serde structs and one SSE line-splitter; Zed's reqwest_client adapter (finding 2) proves the transport glue is ~200 lines | Wins on weight (zero new crates beyond the two trait/client lines), on pin discipline (both crates already in the lock at exact versions), and on scope (exactly the ruled v1 shape). Cost: the wire subset is maintained by hand — real but small, and the tolerance rules are documented in finding 3 |
rmcp 3.11.0 | Apache-2.0; 55M downloads; active (2026-11-17); feature deps include reqwest, oauth2, sse-stream, schemars | Dependency weight noted only, per scope split: MCP/ACP/skills belong to agent-protocols-mcp-acp-skills |
5. Secret storage: peers converge on the OS store; COSMIC ships one; oo7 is already in the binary
- Peers:
- Zed: keys live in the system keychain with env-var override ("Keys saved through Zed are stored in the system keychain, not in
settings.json"; provider id →<PROVIDER>_API_KEY— quoted in ai-completion-providers finding 7). The Linux mechanism is now pinned from the workspace manifest:oo7 = { git = "https://github.com/zed-industries/oo7", rev = "731c1215edb6905876c6137ab300428c7b8d7c13", version = "0.6", default-features = false }in zed main'sCargo.toml— Zed forks oo7 0.6 and ships it. - Wave: "Instead of storing API keys directly in the configuration, you should use Wave's secret store to keep your credentials secure", set via
wsh secret set OPENAI_KEY=…, and "Secrets are stored encrypted using your system's native keychain" — with provider presets auto-deriving secret names (OPENAI_KEY,OPENROUTER_KEY,GOOGLE_AI_KEY, …) surfaced in config through a key whose doc description is "Name of secret containing API token (auto-set by provider)" (docs.waveterm.dev/waveai-modes, fetched 2026-11-26). Same rule as Zed, OS-keychain backing. - Warp: "Personal API keys are stored in your device's secure storage." and "Warp does not retain your personal API key." — and even BYOK prompts "pass through Warp's servers to that provider" (
docs.warp.dev/agents/inference/bring-your-own-api-key, fetched 2026-11-26). DropTerm has no server, so the honest analog is: keys stay on the machine, requests go provider-direct. - VS Code:
context.secretsis "A global storage for secrets (or any information that is sensitive) that will be encrypted"; "For VS Code desktop, this leverages Electron's safeStorage API" (code.visualstudio.com/api/extension-capabilities/common-capabilities, fetched 2026-11-26). Electron's safeStorage on Linux picks among "kwallet, kwallet5, kwallet6 and gnome-libsecret" and — the cautionary ladder — "If no secret store is available, items stored using the safeStorage API will be unprotected as they are encrypted via hardcoded plaintext password. You can detect when this happens when safeStorage.getSelectedStorageBackend() returnsbasic_text" (electronjs.org/docs/latest/api/safe-storage, fetched 2026-11-26). Copilot CLI'sproviders.jsonplaintext credentials remain the counter-example that documents its own flaw (ai-completion-providers finding 6).
- Zed: keys live in the system keychain with env-var override ("Keys saved through Zed are stored in the system keychain, not in
- The crates:
- oo7 0.7.3 upstream (MIT, MSRV 1.92, repo
linux-credentials/oo7, 4.3M downloads, updated 2026-11-21): "James Bond went on a new mission and this time as a Secret Service provider" — zbus-based Secret Service client, XDG portal Secret integration via ashpd, and a sandboxed local encrypted-file backend (keyfile) for when no service runs. Runtime selectable:tokio(zbus/tokio) orasync-std(zbus/async-io) features; crypto vianative_crypto(aes/cbc/hkdf/pbkdf2/sha2) or openssl. - The decisive fact: oo7 0.6.0 is already in DropTerm's lock.
gpui-pre-linux0.3.12 — compiled into every DropTerm Linux build throughgpui_platform'swaylandfeature, which is "the consumer-side switch into the Linux crate's wayland backend" (dropterm/Cargo.toml:36-38) — declaresoo7 = "0.6"non-optionally withfeatures = ["async-std", "native_crypto"],default-features = false(gpui-pre-linux-0.3.12/Cargo.toml:160-166), and the lock carriesoo7 0.6.0with aes/ashpd/pbkdf2/zeroize/zbus/zvariant (Cargo.lock:4886-4919). Because the lock holds exactly one zbus entry (5.19.0,Cargo.lock:8885), oo7 resolves against the same zbus DropTerm itself pins — no duplication, no new crates; adroptermdependency line onoo7 = "0.6"with the same features only names what is already compiled. - keyring 4.2.0 (MIT OR Apache-2.0, MSRV 1.88, now under the open-source-cooperative org, updated 2026-08-29): refactored into per-store crates; its
default/v1feature pickszbus-secret-service-keyring-storeas the Linux native store (docs.rs + crates.io features, fetched 2026-11-26). Whichever zbus major that store crate wants, it will not unify with 5.19 unless it is 5.x (Unverified) — so keyring likely duplicates the zbus graph that oo7 already fills. - secret-service 6.0.0 (MIT OR Apache-2.0, updated 2026-11-22): requires zbus ^6 (dependencies endpoint) — a second major of the D-Bus stack. Duplicates; and unnecessary given oo7.
- dbus-secret-service 4.2.0: mandatory dependency on the
dbus ^0.9crate — the libdbus C binding (dependencies endpoint). Rejected on the project's pure-Rust D-Bus discipline (the graph holds no libdbus today — nodbus/libdbus-sysentry in the lock).
- oo7 0.7.3 upstream (MIT, MSRV 1.92, repo
- COSMIC ships a Secret Service provider — verified at the source. COSMIC's session script starts it explicitly:
if [ -d "$XDG_RUNTIME_DIR/keyring" ]; then eval "$(gnome-keyring-daemon --start --components=pkcs11,secrets,ssh …)"— thesecretscomponent is gnome-keyring'sorg.freedesktop.secretsprovider (pop-os/cosmic-session,data/start-cosmicat master, fetched 2026-11-26). It is not COSMIC-native code — the desktop borrows gnome-keyring — and community reports note first-login default-keychain quirks (cosmic-epoch issue #1635, 2025-02; Fedora discussion "GNOME Keyring on COSMIC", 2025-07, both fetched 2026-11-26, secondary corroboration). Pop!_OS inherits the same session script. So a Secret Service store is the expected case on the primary desktop; the design must still answer "no service running" (sway without a keyring daemon, for instance) — that is what oo7's keyfile backend and the ruled env-var-first order are for. - The fallback ladder (extending the ruled "environment variable first, secret store second"): env var → Secret Service via oo7 (only when the user opts in by storing a key; never probed silently) → nothing automatic. A mode-0600 plaintext file is not proposed as an automatic fallback: Electron's
basic_text(hardcoded-password "encryption") is exactly the failure mode peers can at least detect, and DropTerm should do better by refusing rather than degrading — an explicit user action with a stated warning would be the only path to a file, and even that is better served by oo7's encrypted keyfile backend (Unverified: the keyfile backend's exact threat story — where its master key lives — was not read this session).
6. The plugin-facing async seam: the precedents all converge on ask-host → answer-as-event
- The physics: a Lua script cannot make a network round-trip under DropTerm's bounds. The host's debug hook counts VM instructions with a 100 ms soft bound and a 1 s hard cap, and "a script blocked inside a C call (
io.readon a pipe) … executes no main-thread VM instructions to trip the hook" — so a blocking HTTP call is both too slow to permit and structurally un-interruptible (lua_host.rs:29-41). A synchronousdropterm.ai(prompt)would either freeze the host thread for seconds or hang forever. - Precedents, all pointing the same direction:
- Neovim
vim.system(cmd, opts?, on_exit?): the async form takes anon_exitcallback — "Called with the result on process exit and output pipes closed" — and returns aSystemObj(wait,kill,write,close);wait()blocks but pumps events (vim.wait(…, 200, true)); the callback form is the sanctioned non-blocking shape (runtime/lua/vim/_core/system.luaat master, fetched 2026-11-26).plenary.nvim's curl shows the ecosystem's answer for HTTP specifically:opts.callback/opts.streamdeliver parsed responses or stream chunks, while the default synchronous call "blocks the Neovim main loop until completion" (lua/plenary/curl.luaat master, fetched 2026-11-26) — the blocking default is the anti-pattern to avoid. - WezTerm: DropTerm's Lua host exists precisely to diverge from WezTerm's "GUI-thread Lua" (
lua_host.rs:6-11); WezTerm's documented process APIs split the same way —wezterm.run_child_processreturns output (synchronous), whilewezterm.background_child_processis fire-and-forget: "it will attempt to spawn that command in the background. This function doesn't return any value." (docs/config/lua/wezterm/background_child_process.mdat main, fetched 2026-11-26). WezTerm's HTTP API story could not be pinned this session (docs paths 404; see Unverified). - kitty kittens: the async surface is a process boundary — kittens are separate Python programs; remote control is capability-scoped by generated passwords ("This will use a secure generated password to restrict remote control") and "by default, for security, child processes launched by your kitten cannot use remote control" (
sw.kovidgoyal.net/kitty/kittens/custom.html, fetched 2026-11-26). The lesson for DropTerm is capability-scoping, not mechanism (its scripts are in-process by the ruled tiering in terminal-plugin-systems). - VS Code
vscode.lm: the promise-based shape is the host-side template —lm.selectChatModels({vendor, id, family})returns an array (async),model.sendRequest(prompt, options, token)returns a streaming async-iterable consumed withfor await, takes aCancellationToken, and carries a consent gate: "selectChatModels should be called as part of a user-initiated action, such as a command" (code.visualstudio.com/api/extension-guides/language-model, fetched 2026-11-26). The lifecycle record already gated "a progress slot … only when the host grows asynchronous work" (vscode-extension-lifecycle-rea incorporation item 5) — an AI facility is exactly that growth.
- Neovim
- Design constraints a
dropterm.aiseam must satisfy in DropTerm's host-thread model (each from the pinned sources above):- Script calls are non-blocking asks; answers return as events. The vocabulary pattern already exists:
QuerySegments/QueryTabTitles/PanelAskcarry atoken, "the reply lands as a [HostEvent] arm matched by token: stale until it arrives, and the … keeps its prior" (lua_host.rs:105-142). An AI ask joins as new arms — "The vocabulary stays closed: new commands join as new arms with the module that needs them, never by widening these semantics" (lua_host.rs:108-109). - The request executes off the host thread, on the tokio sidecar, and the completion marshals back through the
LuaHostHandle(send/emit,lua_host.rs:394-413,:558-577) — never a direct call into mlua from a foreign thread (the interpreter lives and dies on its one thread; "no tokio channel crosses the bridge",lua_host.rs:8-11). - Stale answers are discarded at the drain, per the soft-bound contract — an AI answer arriving after its dispatch went stale is dropped, never replayed (
lua_host.rs:30-37). - Hot reload kills in-flight callbacks by design: a
Reloadrecreates the interpreter whole, and answers arriving for the old generation must be dropped, not delivered (the reload semantics,lua_host.rs:43-50). - No streaming into Lua at v1: SSE chunk-by-chunk delivery into script callbacks multiplies the stale/generation checks and gives scripts a long-lived session object the reload model cannot clean up; the host consumes streams internally (ghost text per ai-completion-providers) and hands scripts whole results.
- Consent and capability scoping: the feature is off by default (the ruled consent gate), the ask carries only what the script passes plus the configured
{provider, model}— never other tabs' content — and the answer is labeled as model output (untrusted) at the port.
- Script calls are non-blocking asks; answers return as events. The vocabulary pattern already exists:
7. Security checklist mapping (the named sections)
Against .agents/references/security-checklist.md:
- AI / LLM Security (
security-checklist.md:192-201): model output is untrusted data — it must never reach a command line, file path, or eval path without host-side validation; the OpenAI SDK's own docs warn tool arguments are model-generated and to "Validate the arguments in your code before calling your function" (finding 3), and DropTerm's port should treat anydropterm.airesult the way OSC payloads are treated: parsed, bounded, never executed. Prompt injection is assumed — permissions live in code (the host decides what an AI-assisted verb may do), not in a system prompt; secrets and cross-tab content stay out of prompts (LLM02/LLM07,:233-249). - Data Protection (
:134-143): what leaves the machine is the typed prompt plus declared context, over HTTPS (rustls with the system CA store — corporate proxies work), only when the user-enabled feature is invoked; nothing is logged — the failure-stays-silent contract already in the suggest model ("a failed or slow AI fetch degrades toNone") doubles as the no-secrets-in-logs rule; keys never enter the config store (whose RON files are watched, serialized, and docs-pinned — a secret there would leak into the docs gate) and are zeroized on drop (oo7 already pullszeroize,Cargo.lock:4917). - Dependency Security (
:145-190): the recommendation adds exactly two crates, both already in the lock at exact versions (gpui-pre-http-client 0.3.12,gpui-pre-reqwest 0.12.15— checksums recorded, registry-provenanced, same publishers as the rest of the ruled family), plus optionallyoo7 = "0.6"(same). No new transitive crates enter the graph; the graph-pin tests (main.rs:552-592) extend naturally (the family pin already special-cases gpui-pre-reqwest's 0.12 line). New crates rejected in finding 4 are rejected partly on this ground: every SDK candidate imports a second HTTP family whose provenance review burden duplicates the one already carried.
What DropTerm has today
Verified at HEAD a83fb8f (2026-11-26) unless noted:
- The Lua host (
dropterm/src/core/lua_host.rs, module doc lines 1-50): one dedicated host thread owning one mlua (Lua 5.4, vendored) interpreter for its life;std::sync::mpscboth ways; full stdlib, no sandbox, stated plainly; soft 100 ms / hard 1 s instruction-count bounds via a debug hook; C-call blocking un-interruptible; hot reload recreates the interpreter whole; the UI thread never executes Lua and never blocks on the host; no tokio channel crosses the bridge (:8-11). - The closed command vocabulary with token-matched answers:
HostCommand(:110, armsEmit,Reload,QuerySegments,QueryTabTitles,PanelAsk,RunCommand,SettingsSync,StartupMark); "new commands join as new arms with the module that needs them" (:105-109);LuaHostHandle::send(:394),try_event(:413),handle()(:446), and host-side event injection viaLuaHostHandle::emit→HostCommand::Emit(:573-577). - The tokio sidecar: the D-Bus service runs on its own thread with a
new_multi_thread().enable_all()runtime held for the process lifetime (dropterm/src/dbus.rs:92-107); tokio rides the manifest asrt-multi-thread+sync(dropterm/Cargo.toml:76); zbus 5.19 default-features off withtokio,p2p(:84). - The build graph (
Cargo.lock):gpui-pre-http-client 0.3.12present (unconditional under gpui-pre:2469and gpui-pre-linux:2652);gpui-pre-reqwest 0.12.15present (:2755) with hyper 1.12, hyper-util 0.1.21, http 1.5, h2 0.4.20, rustls 0.23.46, tokio-rustls 0.26.6, hyper-rustls 0.27.10, rustls-native-certs 0.8.5, ring 0.17.14; oo7 0.6.0 present (:4887, via gpui-pre-linux) sharing the singlezbus 5.19.0entry (:8885); ashpd 0.13.13, async-io 2.6.0, blocking 1.7.0 present;schemars1.2.3 present; nokeyring,secret-service,dbus(libdbus),reqwest(crates.io), or SSE crate in the lock; no direct HTTP client dependency indropterm/Cargo.toml. - The graph pins (
dropterm/src/main.rs:552-592): everygpui-pre*crate must resolve at 0.3.12 exceptgpui-pre-reqwest, explicitly carved out for "its own 0.12 line"; nogpui-kit/gpui-shellaggregates may enter. - The prior AI ruling (ai-completion-providers, Proposed 2026-11-23): an engine-side provider trait, v1 exactly one OpenAI-compatible custom provider over a
{provider, model}pair, keys never in config (env first, secret store second), feature off by default, no LLM on the ghost-text path, ranked last, failure stays silent. - The plugin tiering (terminal-plugin-systems, Complete 2026-11-23): tiered Lua-first — status segments, tab titles, script commands, hooks all ship on the host-thread pattern the AI seam would extend.
Recommendation
Proposed: finish the ruled AI capability with what the graph already carries — the gpui-pre-http-client trait over a thin gpui-pre-reqwest adapter on the existing tokio sidecar, a hand-rolled OpenAI-compatible Chat Completions + SSE client for the ruled v1 custom provider, keys via env-first with oo7 (already in the binary) as the opt-in Secret Service store on COSMIC's gnome-keyring, and a dropterm.ai plugin facility built as new arms of the existing token-matched HostCommand/HostEvent vocabulary.
- Transport: two dependency lines, one adapter module. Declare
gpui-pre-http-client = "=0.3.12"andgpui-pre-reqwest = { version = "=0.12.15", default-features = false, features = ["charset", "http2", "macos-system-configuration", "multipart", "rustls-tls-native-roots", "socks", "stream"] }(the exact feature set the lock already resolves and Zed ships), and write a ~200-250-lineHttpClientimpl modeled on Zed'sreqwest_client(bytes_stream → into_async_read → AsyncBody::from_reader; redirect policy, request timeout, proxy env,CustomHeaderspassthrough). Build the client and await its futures on the D-Bus sidecar's runtime (dbus.rs:92-107), never on the foreground executor. - Wire: exactly the ruled v1 shape, hand-rolled. One OpenAI-compatible client module: chat completions request/response serde types, SSE line parsing (
data:/:comment tolerance per OpenRouter /[DONE]sentinel / incrementaltool_calls[].indexaccumulation /stream_options.include_usage), andGET /v1/modelslisting. Named adapters (Anthropic Messages, Gemini, Responses) stay future additive impls of the same internal trait — the divergence evidence in finding 3 is the standing ground, not a to-do. - Keys: extend the ruled ladder with what is already compiled. Env var first (
<PROVIDER>_API_KEYderived-name convention per Zed). Second, an opt-in store write path viaoo7 = "0.6"(featuresasync-std,native_crypto— the exact set gpui-pre-linux already builds) againstorg.freedesktop.secrets, which COSMIC's session provides through gnome-keyring'ssecretscomponent (finding 5). No automatic plaintext fallback: no service → the env var remains the answer, and the settings surface says so. Never a key in the RON config. - Plugin seam:
dropterm.aias new arms of the closed vocabulary. AHostCommandarm carrying{token, request}(prompt/messages,{provider, model}, caps), executed on the tokio sidecar, the answer landing as a token-matchedHostEventarm (or anai:*event through the existingEmitpath); stale-discard at the drain; generation-checked after reload; whole-result (no streaming into Lua); cancellable via a matching cancel arm; every constraint in finding 6 restated in the module doc. - Model discovery rides
GET /v1/modelsper provider base URL (OpenAI, Ollama, LM Studio, llama.cpp's single entry, OpenRouter auth-free) — the settings picker's data source, mirroring Zed'sauto_discoverprecedent; until a picker exists, the model stays the config string the ruling chose. - Security posture per finding 7: untrusted output, no secrets in prompts or logs, off-by-default consent, bounded consumption (one in-flight request per source, request + token caps, the generator deadline pattern), and the graph-pin tests extended so the two new direct deps stay pinned at their exact family lines.
Rejected alternatives:
- A multi-provider SDK at v1 (
genai,async-openai,rig-core,llm).genairequires crates.ioreqwest ^0.13andasync-openai's client is that same 0.13 line — each imports a second HTTP family beside the pinnedgpui-pre-reqwest0.12.15;rig-core's MSRV 1.97.1 exceeds DropTerm's 1.93 outright; all four exceed the ruled scope (one custom provider, named adapters rejected). - Crates.io
reqwestdirectly. Same second-family duplication; gains nothing overgpui-pre-reqwest, which is the same code already pinned inside the ruled snapshot family and anticipated by the graph-pin test. ureq(sync) or rawhyper. ureq brings its own TLS stack and a blocking model needing a dedicated thread — a third HTTP design for a graph that already resolved the async one; raw hyper reimplements reqwest's conveniences (redirects, timeouts, proxy, TLS setup) for no pin benefit.dbus-secret-serviceorsecret-servicefor keys. The former links libdbus (a C dependency the graph does not carry); the latter demands zbus ^6 — a second D-Bus major — whenoo7 0.6already sits in the lock against the same zbus 5.19 and is the crate Zed itself ships.- Hand-rolling Secret Service D-Bus over zbus 5.19. The protocol includes session negotiation and AES-CBC secret transport; oo7 already implements and ships it. Only worth a spike if the owner rules the oo7 dependency line unacceptable.
- Streaming into Lua scripts at v1. No interruptible-C-call escape exists, and per-chunk callbacks multiply the stale/generation checks the drain would have to enforce; the host consumes streams (finding 6, constraint 5).
- A WezTerm-style GUI-thread synchronous HTTP call from scripts. It contradicts the host-thread model that is lua-host's reason to exist (
lua_host.rs:6-11), and the bounds make it un-shippable.
Feasibility
- What is needed (coarse work items, counted in items/files):
- Transport adapter: the two dependency lines + one
HttpClientimpl module (~1 file + tests) in a newdropterm/src/core/ai/(or beside the suggest engine). - Provider client: OpenAI-compatible shapes + SSE parser + models list (~2-3 files + tests).
- Key store: env-first resolver + oo7 opt-in store (~1-2 files + tests).
- Host AI seam: new
HostCommand/HostEventarms + aLuaHostHandlemethod + tokio-sidecar dispatch glue (~1 module + lua_host growth + tests). - Config + docs:
DropTermConfigkeys with the docs gate rows in../configuration.md, a settings row, and the plugins doc table row. - Graph-pin extension in
main.rs(the carve-out for gpui-pre-reqwest's 0.12 line already exists). Total ≈ 8-11 items across four seams, each spec-able independently; the engine-side cache consumption (theAisuggestion arm) is ruled already and lands per ai-completion-providers.
- Transport adapter: the two dependency lines + one
- Hard blockers: none found. (The nearest misses:
rig-core's MSRV exceeds the toolchain pin — avoided by not adopting it;secret-service6's zbus ^6 — avoided by adopting oo7 0.6 instead.) - Needs a spike before commitment:
- S1 — transport spike: build the gpui-pre-reqwest client on the sidecar runtime, stream an SSE response through
AsyncBodyend-to-end against a local server, and prove no foreign-thread waker reaches the foreground executor (the pty-test-gate class is the known hazard). - S2 — first compile: gpui-pre-reqwest has likely never compiled on Linux in this tree (its only current in-edge is wasm-gated); confirm the declared feature set builds cleanly and adds no new lock entries.
- S3 — secrets spike:
oo7 0.6(async-std flavor) create/read an item against live gnome-keyring on COSMIC, its error shape when no service runs, and its async-std-flavored futures awaited under the tokio sidecar (async-io's reactor thread makes this work, but it is unproven here).
- S1 — transport spike: build the gpui-pre-reqwest client on the sidecar runtime, stream an SSE response through
- Effort units: the six items above; S1-S3 are one session each. Items 1-4 are independent of the invoked-AI-surface record, terminal-ai-surfaces, which consumes this transport through the engine-side trait.
Sources
All web sources fetched 2026-11-26. Repos pinned by branch state at fetch date (main/master) unless a rev is quoted.
DropTerm (local, HEAD a83fb8f, branch ced):
dropterm/Cargo.toml— the ruled pins, tokio/zbus lines,rust-version = 1.93, devtest-support.Cargo.lock— gpui-pre-http-client:2469/:2652, gpui-pre-reqwest:2755-2803, oo7:4886-4919, zbus 5.19.0:8885, rustls/ring/hyper entries, absence of keyring/secret-service/dbus/reqwest.dropterm/src/core/lua_host.rs— module doc:1-50, command vocabulary:105-152, handle API:379-430,:558-577.dropterm/src/dbus.rs:92-107— the sidecar runtime.dropterm/src/main.rs:552-592— the graph-pin tests..agents/references/security-checklist.md— AI/LLM Security:192-201, Data Protection:134-143, Dependency Security:145-190, LLM Top 10:233-249.docs/architecture.md,docs/research/README.md— house grounding and format.
Pinned crate sources on disk (~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/):
gpui-pre-0.3.12/Cargo.toml— feature list:53-92(nohttp_clientfeature;test-support→http_client/test-support:82), dependency:359-361.gpui-pre-http-client-0.3.12/src/http_client.rs,src/async_body.rs,Cargo.toml— trait, streaming body, fakes, no HTTP impl.gpui-pre-reqwest-0.12.15/Cargo.toml(:24description, features:60-182,stream:172-176),src/async_impl/response.rs:357-359(bytes_stream).gpui-pre-linux-0.3.12/Cargo.toml:160-166— the oo7 0.6 hard dependency.gpui-kit-assets-0.9.1/Cargo.toml:105-117— the wasm-gated reqwest declaration.
Zed (zed-industries/zed, main):
- Workspace
Cargo.toml— oo7 fork pin (rev731c1215…),zed-reqwest 0.12.15-zedfeature set. crates/reqwest_client/src/reqwest_client.rs— the streaming adapter pattern.
Providers (official references and first-party SDK types):
- OpenAI:
developers.openai.com/api/reference(hub: auth headers,/v1/modelsrequest, Responses steer); openai-pythonsrc/openai/types/chat/chat_completion_chunk.py,chat_completion_message_function_tool_call.py,model.py,responses/response_stream_event.py. - Anthropic:
platform.claude.com/docs/en/api/messages-streaming. - Google:
aistudio.google.com/api-reference/generate-content,api-reference/models,docs/text-generation. - Ollama:
github.com/ollama/ollamadocs/openai.md,docs/api.md(main). - llama.cpp:
ggml-org/llama.cpptools/server/README.md(master). - LM Studio:
lmstudio.ai/docs/app/api/endpoints/openai. - OpenRouter:
openrouter.ai/docs/api-reference/streaming,docs/api-reference/list-available-models.
Secrets:
- VS Code:
code.visualstudio.com/api/extension-capabilities/common-capabilities(secrets section);electronjs.org/docs/latest/api/safe-storage(Linux backends,basic_textfallback). - Warp:
docs.warp.dev/agents/inference/bring-your-own-api-key. - Wave:
docs.waveterm.dev/waveai-modes. - COSMIC:
pop-os/cosmic-sessiondata/start-cosmic(master) — the gnome-keyring secrets start; corroboration: Fedora discussion thread (2025-07),pop-os/cosmic-epochissue #1635 (2025-02).
Crates (crates.io API + docs.rs): async-openai, genai, rig-core, llm, misanthropy, eventsource-stream, reqwest-eventsource, async-sse, keyring, secret-service, dbus-secret-service, oo7, rmcp (metadata + dependency/feature endpoints, fetched 2026-11-26).
Async-seam precedents:
- Neovim:
neovim/neovimruntime/lua/vim/_core/system.lua(master) —vim.systemAPI. - plenary.nvim:
nvim-lua/plenary.nvimlua/plenary/curl.lua(master). - WezTerm:
wezterm/weztermdocs/config/lua/wezterm/background_child_process.md(main). - kitty:
sw.kovidgoyal.net/kitty/kittens/custom.html. - VS Code:
code.visualstudio.com/api/extension-guides/language-model.
Unverified
- Whether gpui-pre-reqwest compiles into the Linux binary today. The brief's prior verification said "present and built"; my read of the only declaring crate (
gpui-kit-assets) shows a wasm-gated declaration, which would mean lock-resolved but not compiled on Linux. Both claims recorded. The factual half was settled the same day against the build tree:target/debug/.fingerprintholds nogpui-pre-reqwestentry whilegpui-pre-http-clientandoo7each hold entries, so the crate is lock-resolved and not compiled on Linux today. S2 remains the spike that the declared feature set builds cleanly and adds no new lock entries. Either way the recommendation is unchanged (a direct dependency makes it compile). - async-openai's default features: its
reqwest ^0.13dependency is optional in the manifest data, but whether the default feature set enables it (making the crate unusable without that second HTTP family) was not pinned from a feature list this session. - WezTerm's HTTP API: no
http_request/download_filedoc exists indocs/config/lua/wezterm/at main, and the wezterm.org URLs tried 404'd — the status of WezTerm's Lua HTTP API (and its GUI-thread blocking story) is unverified from a primary source this session. - zbus majors behind
keyring4.2.0'szbus-secret-service-keyring-storeand behindoo70.7.x upstream: not fetched. oo7 0.6.0 as in DropTerm's lock provably shares zbus 5.19.0 (single lock entry), which is all the recommendation relies on. - Anthropic's native
GET /v1/modelsshape was not fetched; "Anthropic diverges" rests on the Messages/auth evidence only. - Google's OpenAI-compatible endpoint (commonly cited as
…/v1beta/openai/): not fetched from a primary page this session; the record claims only that Gemini's native shapes diverge (fetched) and that Google's docs surface is reorganizing (theinteractionsendpoint appearing alongside:streamGenerateContent). - The crates.io
llmname change: today'sllm(graniet/llm, 1.3.8) is not the historically known rustformers local-inference project; the rustformers project's archived status was not fetched, so the lineage claim is labeled inference from the crates.io metadata. - oo7's keyfile backend threat story (where the master key lives, what protects the file): the backend's existence is pinned (crate description/keywords), its security model was not read this session — read before relying on it as the no-daemon fallback.
- GNOME Keyring's continued support of the
plainSS algorithm (relevant only if a hand-rolled SS client were ever spiked): not fetched. - quinn 0.11.12 under gpui-pre-reqwest's lock entry implies some target-feature combination enabled
http3; the enabling source was not identified (feature resolution is the union across targets). - kitty's "Async and streaming requests" remote-control doc page: seen only as a navigation link during the kittens fetch; not read.
- Wave's config key for the derived secret name: this session's fetch rendered it as
ai:apitokensecimal; ai-completion-providers (fetched 2026-11-23 from the same page) recordedai:apitokensecretname. The semantic is identical in both ("name of the secret containing the API token"); the exact spelling differs between the two fetches and was not reconciled. Both recorded; the record's claims do not depend on the spelling. - No fetched page contained instructions addressed to AI agents that would need flagging as embedded directives.