Skip to main content

Module api

Module api 

Source
Expand description

HTTP API for predictive typing (/api/predict/*): the system-wide inline autocomplete brain.

  • GET /api/predict/config → the normalized PredictConfig (defaults applied) so the desktop settings tab and the apps-store/predict overlay both read one shape in a single call.
  • PUT /api/predict/config → persist the config blob.
  • POST /api/predict/complete → given the caret context, return a single inline suggestion. Enforces the app allowlist + the secure-field denylist here (Core decides what runs), then hands the model call to the Gateway via PredictHost::call_side_model (the same path /btw uses).

Pure logic (prompt assembly, denylist, cleanup) lives in the crate root.

The router is built with its own state (PredictCtx) inside this crate so it returns a state-less, mergeable Router<()>. Routes are declared relative to /api/predict (Core nests this service at that prefix behind the Predict-App gate), while the OpenAPI annotations keep the full external paths.

Structs§

CompleteBody
POST /api/predict/complete request body. context is the text immediately before the caret (the model context). app is the focused process name (for the allowlist). control is the focused control’s localized type (for the secure-field denylist). agent_id optionally overrides the model.
CompleteResponse
POST /api/predict/complete response. suggestion is empty when there is nothing to suggest OR the request was refused (disabled / app not allowed / secure field / no context) — reason says which, for diagnostics.
PredictCtx
Router state for the predict HTTP surface: the PredictHost that inverts the kernel couplings (enabled flag, preferences, agent-bound model, default model, Gateway side-model call). Cloneable so the router bakes a concrete state and returns Router<()>.

Functions§

complete
POST /api/predict/complete — return one inline suggestion for the caret context. Always 200 with a (possibly empty) suggestion; refusals carry a reason rather than an error status, so the dumb overlay never has to branch on HTTP codes.
get_config
GET /api/predict/config — the normalized predictive-typing config.
openapi
The OpenAPI sub-document for the predict surface, merged into Core’s spec.
put_config
PUT /api/predict/config — persist the predictive-typing config.
routes
Build the /api/predict/* router with its own state baked in, returning a state-less Router<()> the host nests at /api/predict behind the App gate.