Skip to content

Plugin providers: TLS profiles, installation-owned profiles, retained page fix and market logos - #617

Merged
AAswordman merged 19 commits into
AAswordman:mainfrom
luojiaping:feat/plugin-provider-lifecycle-upstream
Dec 3, 2026
Merged

AAswordman merged 19 commits into
AAswordman:mainfrom
luojiaping:feat/plugin-provider-lifecycle-upstream

Conversation

@luojiaping

@luojiaping luojiaping commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Host-side changes for the ToolPkg provider work, split into three areas.

1. TLS profiles for packages (host + build)

  • feat(http): a ToolPkg HTTP call can present a TLS profile; the caller's Content-Type is no longer overridden by the body type's default.
  • feat(host): profiles are presented through a BoringSSL client (operit-host-native-http, feature tls-profiles), also on Android (generic NDK clang + --target, minSdk platform, perl for the BoringSSL assembly in the images).
  • build(windows): cargo_build.py provisions NASM and libclang for BoringSSL/bindgen; BUILDING.md lists the toolchain pieces.
  • feat(provider): signed-in account facts are handed to ToolPkg provider hooks; package logos show in the create-provider picker and currentColor SVGs take the theme's icon colour.

2. Provider lifecycle for ToolPkg providers

  • fix(provider): host-bridged native tool calls are collected per index and emitted as complete, contiguous blocks after the package hook returns; non-object parameters fail the whole batch. Contract documented in docs/model-catalog.md.
  • feat(models): provider profiles are owned by the package installation (runtime/extensions/{scope}/provider_profiles/..., profileOwnerId generation), so scope moves / snapshots / uninstalls carry or remove them. Legacy shared profiles migrate only on the authoring node (originDeviceId), the shared copies are retired and filtered from exported history (Kernel::export_retained). Device-scoped providers keep bindings, per-chat selection and quota/check-in preferences in the CoreNodeStateStore overlay; the chat composer renders unbound states instead of switching providers; deletePackage failures surface in the Flutter catalog.

3. Flutter fixes and market logos

  • fix(app): RetainedPage applies parent-provided configurations in the build phase instead of its layout callback (fixes A _RenderLayoutBuilder was mutated in _RenderRetainedPage.performLayout and the state loss that followed); page-internal updates keep the layout-callback timing.
  • feat(market): ArtifactPublishScreen uploads the package LOGO beside the plugin package in the same Release (<asset>.logo.<ext>, MIME normalized by Core) on both publish paths; package-builder docs describe the logo manifest field; docs/market-logo-assets.md records the contract and the server-side follow-up.

4. Listed model names

  • feat(models): ModelListedSpec.name / ProviderModelSummary.listedName carry the name the provider's own list gave a model (ToolPkg slots such as qmodel_38max read as Qwen3.8-Max); the composer label, model selector popup, available-model picker, settings panel and function mapping rows show and search it. Model ids remain the storage/sync keys. (Work in progress from the same tree; included on request.)

A chore(deps) commit reconciles the four lockfiles with main.

Platforms / boundaries

  • Rust: operit-host-contract, operit-http host (common), operit-store, operit-provider-services, operit-runtime-application, operit-tool-services.
  • Flutter: chat composer/model picker, extension catalog, publish screen, RetainedPage.
  • Host API surface grows by the TLS-profile presentation on HTTP (host-contract) and the sqlite host parameter on ExtensionStore::{moveScope, delete, deleteFailedPackageInstallations} (adapted to main's signatures). Dart proxy regenerated from unchanged Core commands.

Verification

  • Cherry-picks onto current main applied cleanly; the five textual conflicts in Task 2 files were resolved toward main's storage-injected managers (ModelConfigManager::withStorage / FunctionalConfigManager::withStorage) and the sqlite-host ExtensionStore signatures; test call sites were adapted.
  • cargo metadata --locked passes for apps/cli, the Flutter bridge, hosts/{apple,linux,windows} and operit-host-native-http.
  • Not run locally: cargo test for the touched crates and flutter test/flutter analyze (CI should cover; the author will also run them). The RetainedPage tests and provider-lifecycle tests are included in this PR.

Not included

  • The plugin packages themselves (qoder, zcode, workbuddy, zen-free, …) are published separately.
  • CNB-only pipeline commits (.cnb/*) and unrelated local staging stay on the fork.

…hooks

The usage and check-in hooks already received `auth` (method, account
label, plugin data) beside the token, but listModels, sendMessage,
testConnection and calculateInputTokens only got the access token, so a
plugin whose request signing needs the account it signed in as (Qoder's
machine id and device token, ZCode's device id and plan) could not
resolve it. Resolve the auth context through the runtime support trait
for every provider hook and declare it on the base event payload.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
Icon sets ship monochrome glyphs as `currentColor` so the host picks the
colour; flutter_svg paints them black, which disappears on a dark theme
(the Qoder provider logo is one). Substitute the icon colour into the SVG
text before rendering and leave logos that name their colours untouched.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
The provider type picker and the provider type field of the account form
rendered `ProviderBrandLogo` straight from the catalog asset, which plugin
providers do not have, so they fell back to their initial while every
other surface showed the package logo. Route entries that come from a
plugin package through `ProviderLogo` with the package name and clients.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
`prepareHttpRequest` always appended the body type's Content-Type, so a
request that named its own (a plugin serialising and signing a JSON body
sent as `text/plain`) went out with two headers and Qoder's token exchange
answered 415 Unsupported Media Type. The body type now only names a
default when the caller stated none.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
`http_request` takes a `tls_profile` object naming the cipher suites, key
exchange groups and signature algorithms (IANA ids), the ALPN list and the
OCSP-stapling, SCT and GREASE switches of the TLS client to present instead
of the host's own; `HttpRequestData` carries it to the host. The OkHttp
bridge gains `RequestBuilder.tlsProfile(profile)`. Only a package whose
manifest declares `network.tls_profiles` may name one, never the model: the
JS execution host admits the parameter against the package's declaration.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
`operit-host-native-http` gains the `tls-profiles` feature: a request that
names a TLS profile is sent over BoringSSL configured as the profile says
(cipher list, groups, signature algorithms, ALPN, OCSP stapling, SCT, GREASE)
with the system's trust store, HTTP/1.1 written with the caller's header
names and order, chunked and fixed bodies streamed to the same callbacks the
host's own client feeds. A profile naming BoringSSL's default suites gets the
default list, whose order is Bun's; an explicit list is ordered differently.
Desktop hosts, the Windows/Linux/macOS CLI and the Flutter desktop bridge
enable the feature; Android, iOS and OpenHarmony builds answer that the host
does not present profiles.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
BoringSSL's build script runs bindgen, which loads libclang at build time;
Windows has none. `tools/build_scripts/prepare_libclang.py` keeps one under
.ci-tools (the PyPI wheel), and the Flutter bridge's CMake build passes
`OPERIT_LIBCLANG_DIR` to cargo as `LIBCLANG_PATH`, the variable the Android
build already reads. BUILDING.md lists the pieces the `tls-profiles` feature
needs on each desktop platform.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
…ild.py

BoringSSL's build runs bindgen and NASM; Windows ships neither, so the
desktop build failed inside boring-sys with bindgen's "Unable to find
libclang". `tools/build_scripts/prepare_tls_toolchain.py` now installs both
under .ci-tools (NASM 2.16.03 pinned by SHA-256, the PyPI libclang wheel),
and `cargo_build.py`, which every Windows cargo build goes through, puts
`.ci-tools/nasm` on PATH and that libclang into `LIBCLANG_PATH` for the
manifests that build the `tls-profiles` feature, stopping with that
instruction when either is missing. The Flutter bridge CMake no longer
forwards a variable of its own.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
…n tools over the Bun profile

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
The Android bridge now builds operit-host-native-http with tls-profiles, so a
package that declares network.tls_profiles keeps its TLS client there. boring-sys
takes the toolchain Gradle already passes (ANDROID_NDK_HOME for the NDK's CMake
toolchain, LIBCLANG_PATH for bindgen); the client trusts Android's own CA store,
the PEM files under /system/etc/security/cacerts and the Conscrypt module, since
rustls-native-certs reads none there. iOS and OpenHarmony stay without it.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
cmake-rs builds MNN and BoringSSL through the NDK's android.toolchain.cmake, which
defaults to API 21 when ANDROID_PLATFORM is unset while the CC/CXX wrappers above
are the API-<minSdk> ones; BoringSSL's second configure, for the crypto target,
then failed its C++ feature checks against the mismatch.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
… target

The NDK's CMake toolchain rewrites whatever compiler it is given to its generic
clang with its own --target, and boring-sys (BoringSSL) configures once per library:
the second configure saw the API-level wrapper again, reset its cache against the
rewritten compiler and failed BoringSSL's C++ checks. Cargo now gets the generic
clang carrying the wrapper's target flag through CFLAGS_<target>/CXXFLAGS_<target>,
so the toolchain has nothing to rewrite; the linker keeps the wrapper.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
A ToolPkg AI provider that bridges to the host's native tool calling used to
stream a tool call's parameter chunks straight into the conversation as they
arrived. When the model interleaved several calls, the opening tags of one call
were emitted before the previous call was closed, and the Core-side parser saw
crossed <tool_*> tags and dropped the call or failed the turn.

Parameters are now collected per request index and nothing is emitted until the
package's hook returns. Core then writes each call as one complete, contiguous
block in the model's order. Any parameter that is not a JSON object fails the
whole batch with a precise error instead of producing a half-written call.

The Core-facing contract (per-index collection, toolCall/toolCallDone/
toolCallsDone, complete `toolCalls` arrays) is documented in docs/model-catalog.md.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
A provider profile created by a ToolPkg provider was stored like a built-in
provider's: in the Space-synced model preferences. Uninstalling the package on
one device left a profile whose dynamic provider no longer existed, and every
other device inherited the same orphan through Space sync. Device-only state
(function bindings, chat model selection, quota and check-in preferences) also
travelled through the shared store.

- Provider profiles now live under the package's installation
  (runtime/extensions/{scope}/provider_profiles/<sha256(pkgId)>/<owner>/...), so
  a scope move, snapshot, backup or uninstall carries or removes them with the
  package. `ExtensionStore::withPackageInstallation` serializes writes per
  package and refuses to touch an installation whose journal is unfinished.
- A profile keeps the `profileOwnerId` of the installation that created it, so a
  reinstall that reuses the package id cannot adopt stale profiles.
- Profiles written before this change are migrated into the scoped storage only
  on the node that authored them (by `originDeviceId`); the shared copies are
  retired from the synced snapshot, and `Kernel::export_retained` filters the
  stale legacy operations out of the history exported to new devices.
- Device-scoped providers keep their bindings, per-chat model selection and
  quota/check-in preferences in the CoreNodeStateStore overlay instead of the
  shared preferences; portable providers keep syncing as before. Deleting a
  chat clears its local selection.
- The chat composer and model picker render a device-scoped provider from its
  stored profile even when the package is not loaded, showing an unbound state
  instead of silently switching the user to another provider. Execution still
  validates the provider strictly.
- `ExtensionCatalogController.deletePackage` fails loudly when Core reports the
  package was not removed.

docs/model-catalog.md documents the lifecycle (ownership, scope moves, uninstall,
Space delivery and the device-only preference split).

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
RetainedPage applied every configuration change, including the parent's, inside
its own layout callback. When a parent rebuild moved a keyed subtree that held
an OverlayPortal (MenuAnchor, Autocomplete, Tooltip), the portal re-attached its
overlay children during layout and Flutter failed with
"A _RenderLayoutBuilder was mutated in _RenderRetainedPage.performLayout", then
silently dropped the moved subtree and its state.

Parent-provided configurations are now applied synchronously in mount/update like
any other element, so such moves happen in the build phase. Updates requested by
the page itself keep the layout-callback timing, so microtasks scheduled during
those builds still run only after the frame has laid out. A per-BuildOwner
scheduler hook keeps normal frame scheduling alive when only a dormant scope is
dirty.

Tests cover keyed MenuAnchor subtrees moving between parent revisions in the
build phase, the microtask timing of page-internal builds, and same-frame
ticker-driven updates.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
The market only ever saw the plugin package: `manifest.logo` lives inside the
.toolpkg, so logos showed up only after a package was installed locally.

ArtifactPublishScreen now uploads the package's LOGO next to the plugin package
in the same GitHub Release on both publish paths, as
`<asset-without-extension>.logo.<ext>` with the MIME type Core normalizes
(svg/png/jpg/webp). An existing asset with the same name is replaced first. A
package without a logo is reported before publishing, with the manifest snippet
to add one. Retrying a failed market registration does not upload again.

The package builder docs describe the `logo` manifest field and its resource
entry; docs/market-logo-assets.md records the investigation, the client
contract and the server-side work needed to expose the asset URL.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
ToolPkg providers expose slot ids such as `qmodel_38max` while their model list
carries the name users read (`Qwen3.8-Max`). The UI formatted the id, so every
picker showed the slot.

`ModelListedSpec.name` and `ProviderModelSummary.listedName` now carry that
name from the provider's list; the composer label, the model selector popup, the
available-model picker, the settings panel and the function mapping rows show it
in place of the formatted id and match on it when searching. Model ids stay the
storage and sync keys.

Signed-off-by: luojiaping <luojiaping@users.noreply.github.com>
@AAswordman
AAswordman merged commit fa10c5d into AAswordman:main Dec 3, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants