Expand description
Predictive typing — the “brain” behind system-wide inline autocomplete.
This crate owns the completion engine: the config (model / per-app
allowlist / debounce), the privacy denylist for password & secure controls,
the prompt assembly, the cleanup of the raw model reply, and the
/api/predict/* HTTP surface (api). The native overlay (apps-store/predict)
stays deliberately dumb — it reads the caret context, POSTs it here, and
renders whatever string comes back. No Gateway URL, key, or model id ever
lives in the overlay process.
Placement (CLAUDE.md §1, Core vs Gateway): deciding what runs (assemble the
prompt, enforce the app allowlist, refuse secure fields) is Core. The
actual model call is handed to the Gateway via the host’s
PredictHost::call_side_model (the same path /btw, goal, and double-check
use), so model routing / firewall / budgets / audit all apply — nothing
hardcoded.
§What stayed in the kernel
The process-global “predictive typing is on” flag — predict::set_enabled /
predict::is_enabled, seeded at boot from the built-in Predict plugin’s
persisted state and flipped live from the plugin enable/disable path
(apply_policy) — stays in apps/core: it is the plugin’s on/off switch, part
of the AppGate/plugin wiring, not the completion engine. This crate reads it
through PredictHost::is_enabled. The plugin id const + the predict.manifest.json
fixture likewise stay in Core.
The shared in-editor copilot (PlateJS ghost text) routes through the Gateway directly from the desktop webview; this endpoint is the system-wide sibling for arbitrary native apps, but both speak the same predictive contract.
Re-exports§
pub use api::routes;pub use api::PredictCtx;
Modules§
- api
- HTTP API for predictive typing (
/api/predict/*): the system-wide inline autocomplete brain.
Structs§
- Predict
Config - Persisted predictive-typing configuration.
camelCaseso the desktop settings tab and the overlay can read/write the same JSON shape.
Constants§
- DEFAULT_
DEBOUNCE_ MS - Default debounce between caret changes and a prediction request (ms).
- DEFAULT_
MAX_ CHARS - Default cap on a suggestion’s length (characters). Keeps inline ghost text to a sentence-ish continuation rather than a runaway paragraph.
- PREDICT_
CONFIG_ PREF - Preference key holding the predictive-typing config blob (one JSON object,
mirroring how
editor-aiis stored). The desktop settings tab and theapps-store/predictoverlay both read/write this single key.
Traits§
- Predict
Host - The kernel couplings the moved predict engine needs, inverted so this crate
stays free of any
apps/coredependency. Core implements it (predict_host.rs) over theServerStateand installs it into thePredictCtx.
Functions§
- app_
allowed - True when
appis permitted byallowlist. An empty allowlist permits every app; otherwise the process name must match an entry (case-insensitive, trimmed).appmay be a full path or a bare exe name — we compare on the file name component soC:\\…\\chrome.exematcheschrome.exe. - build_
messages - The predictive system prompt + user message for a given caret context. Pure so the exact wording is testable and lives in one place.
- clean_
suggestion - Clean a raw model reply into an inline suggestion. Strips wrapping quotes /
code fences, collapses to a single line, trims, enforces
max_chars, and maps the0sentinel (and empties) to an empty string = “no suggestion”. - is_
secure_ control - True when a control type / field descriptor names a password or secure input. Pure + case-insensitive so it is unit-testable without UIA.