Repository navigation
Add IBackendsTransport interface for provider packages - #526
Conversation
@workglow/cli
@workglow/ai
@workglow/browser-control
@workglow/indexeddb
@workglow/javascript
@workglow/job-queue
@workglow/knowledge-base
@workglow/mcp
@workglow/storage
@workglow/task-graph
@workglow/tasks
@workglow/util
workglow
@workglow/anthropic
@workglow/bun-webview
@workglow/cactus
@workglow/chrome-ai
@workglow/electron
@workglow/google-gemini
@workglow/huggingface-inference
@workglow/huggingface-transformers
@workglow/llamacpp-server
@workglow/mlx
@workglow/node-llama-cpp
@workglow/ollama
@workglow/openai
@workglow/playwright
@workglow/postgres
@workglow/sqlite
@workglow/stable-diffusion-server
@workglow/supabase
@workglow/tf-mediapipe
commit: |
…s, tighten JSDoc (PR #526 follow-up) (#527) * feat(ai): finalize IBackendsTransport — add list/uninstall, widen opts, tighten JSDoc Adds list() and uninstall(backend) to IBackendsTransport so the libs interface matches what builder's MessagePortBackendsTransport already implements and the renderer UI requires. Widens IEnsureRunningRequest.opts from { ctx: number } to Readonly<Record<string, unknown>> so non-llamacpp backends (sd-cpp, future MLX/whisper) don't have to lie with ctx: 0. Updates StableDiffusionCppProvider to pass opts: {} accordingly. Tightens JSDoc on release() (resolves on post, not broker-ack) and subscribeStatus() (idempotent unsubscribe, dedup of double-subscribe). * docs(IBackendsTransport): clarify opts JSDoc for sd-cpp * test(IBackendsTransport): move type test under packages/test for CI discovery The repo's test runner (scripts/test.ts) only collects Vitest files from packages/test/src/test, so this file was never executed in CI. Removing the old location; the file is recreated under packages/test/src/test/ai in the following commit (also strengthens the structural conformance assertion with explicit parameter signatures). * test(IBackendsTransport): strengthen conformance with explicit signatures Recreates the type-conformance test at packages/test/src/test/ai/ (the location scripts/test.ts discovers) and replaces the zero-arg dummy implementations with explicit parameter signatures drawn from the interface. TypeScript happily assigns `() => X` to `(arg) => X`, so the previous form did not catch parameter-list drift; the new form fails typecheck on any rename, type change, or return-type change to a method of `IBackendsTransport`. Imports come from `@workglow/ai/provider-utils` (the public subpath export) instead of the previous relative path into packages/ai/src.
Coverage Report
File CoverageNo changed files found. |
There was a problem hiding this comment.
Pull request overview
Introduces a renderer-side IBackendsTransport abstraction in @workglow/ai/provider-utils so provider packages can acquire/install local backends without depending on any desktop/builder/Electron implementation details. The PR also adds three new provider packages (llamacpp-server, stable-diffusion-cpp, and an mlx stub) that consume this transport interface.
Changes:
- Added
IBackendsTransport(+ related request/handle/status types) and exported it via@workglow/ai/provider-utils. - Added compile-time conformance tests for the
IBackendsTransportsurface. - Added new provider packages for local backends (llama-server, stable-diffusion.cpp HTTP) and an MLX stub, plus workspace lockfile updates.
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| providers/stable-diffusion-cpp/tsconfig.json | New TS project config for the stable-diffusion.cpp provider package. |
| providers/stable-diffusion-cpp/src/ai/StableDiffusionCppProvider.ts | Implements a text-to-image provider that uses IBackendsTransport.ensureRunning() or an external URL. |
| providers/stable-diffusion-cpp/src/ai/runtime.ts | Runtime entry re-export for registration. |
| providers/stable-diffusion-cpp/src/ai/registerStableDiffusionCpp.ts | Provider registration helper (injects transport/external URL). |
| providers/stable-diffusion-cpp/src/ai/index.ts | Public AI entry exports for the provider. |
| providers/stable-diffusion-cpp/src/ai/common/StableDiffusionCpp_Constants.ts | Defines the provider name constant. |
| providers/stable-diffusion-cpp/src/ai.ts | Package ./ai entrypoint barrel. |
| providers/stable-diffusion-cpp/src/ai-runtime.ts | Package ./ai-runtime entrypoint barrel. |
| providers/stable-diffusion-cpp/package.json | New provider package manifest/exports/scripts. |
| providers/mlx/tsconfig.json | New TS project config for the MLX provider stub package. |
| providers/mlx/src/ai/runtime.ts | Runtime entry re-export for registration. |
| providers/mlx/src/ai/registerMlx.ts | Provider registration helper for the stub provider. |
| providers/mlx/src/ai/MlxProvider.ts | Stub provider that registers but throws on inference (v1 limitation). |
| providers/mlx/src/ai/index.ts | Public AI entry exports for the provider. |
| providers/mlx/src/ai/common/Mlx_Constants.ts | Defines the provider name constant. |
| providers/mlx/src/ai.ts | Package ./ai entrypoint barrel. |
| providers/mlx/src/ai-runtime.ts | Package ./ai-runtime entrypoint barrel. |
| providers/mlx/package.json | New provider package manifest/exports/scripts. |
| providers/llamacpp-server/tsconfig.json | New TS project config for the llama-server provider package. |
| providers/llamacpp-server/src/ai/runtime.ts | Runtime entry re-export for registration. |
| providers/llamacpp-server/src/ai/registerLlamaCppServer.ts | Provider registration helper (injects transport/external URL). |
| providers/llamacpp-server/src/ai/LlamaCppServerProvider.ts | OpenAI-compatible streaming chat-completions client for llama-server using IBackendsTransport. |
| providers/llamacpp-server/src/ai/index.ts | Public AI entry exports for the provider. |
| providers/llamacpp-server/src/ai/common/LlamaCppServer_Constants.ts | Defines the provider name constant. |
| providers/llamacpp-server/src/ai.ts | Package ./ai entrypoint barrel. |
| providers/llamacpp-server/src/ai-runtime.ts | Package ./ai-runtime entrypoint barrel. |
| providers/llamacpp-server/package.json | New provider package manifest/exports/scripts. |
| packages/test/src/test/ai/IBackendsTransport.types.test.ts | Adds compile-time conformance checks for IBackendsTransport. |
| packages/ai/src/provider-utils/IBackendsTransport.ts | Defines the new transport interface/types for provider packages. |
| packages/ai/src/provider-utils.ts | Re-exports IBackendsTransport from the provider-utils entrypoint. |
| bun.lock | Adds the new provider workspaces and adjusts trustedDependencies ordering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "png" | ||
| ); | ||
|
|
||
| emit({ type: "finish", data: { image } }); |
| for (const line of lines) { | ||
| const trimmed = line.trim(); | ||
| if (!trimmed.startsWith("data:")) continue; | ||
| const data = trimmed.slice(5).trim(); | ||
| if (data === "[DONE]") break; | ||
| if (!data) continue; |
| * Mirrors `IBackendStatus` from `packages/electron/src/backends-util/types.ts` | ||
| * without importing from the builder package. |
| * The concrete implementation (`MessagePortBackendsTransport`, in builder) uses | ||
| * `window.desktop.backends.openChannel()` to obtain a `MessagePort` and speaks | ||
| * the protocol defined in `packages/electron/src/backends-util/protocol.ts`. |
| export * from "./provider-utils/BaseCloudProvider"; | ||
| export * from "./provider-utils/CloudProviderClient"; | ||
| export * from "./provider-utils/OpenAIShapedChat"; | ||
| export * from "./provider-utils/IBackendsTransport"; |
| "peerDependencies": { | ||
| "@workglow/ai": "workspace:*", | ||
| "@workglow/util": "workspace:*" | ||
| }, | ||
| "peerDependenciesMeta": { | ||
| "@workglow/ai": { | ||
| "optional": false | ||
| }, | ||
| "@workglow/util": { | ||
| "optional": false | ||
| } | ||
| }, |
| "peerDependencies": { | ||
| "@workglow/ai": "workspace:*", | ||
| "@workglow/util": "workspace:*" | ||
| }, | ||
| "peerDependenciesMeta": { | ||
| "@workglow/ai": { | ||
| "optional": false | ||
| }, | ||
| "@workglow/util": { | ||
| "optional": false | ||
| } | ||
| }, |
| "@workglow/ai": "workspace:*", | ||
| "@workglow/util": "workspace:*" | ||
| }, | ||
| "peerDependenciesMeta": { | ||
| "@workglow/ai": { | ||
| "optional": false | ||
| }, | ||
| "@workglow/util": { | ||
| "optional": false | ||
| } | ||
| }, | ||
| "devDependencies": { | ||
| "@workglow/ai": "workspace:*", |
…s, tighten JSDoc (PR #526 follow-up) (#527) * feat(ai): finalize IBackendsTransport — add list/uninstall, widen opts, tighten JSDoc Adds list() and uninstall(backend) to IBackendsTransport so the libs interface matches what builder's MessagePortBackendsTransport already implements and the renderer UI requires. Widens IEnsureRunningRequest.opts from { ctx: number } to Readonly<Record<string, unknown>> so non-llamacpp backends (sd-cpp, future MLX/whisper) don't have to lie with ctx: 0. Updates StableDiffusionCppProvider to pass opts: {} accordingly. Tightens JSDoc on release() (resolves on post, not broker-ack) and subscribeStatus() (idempotent unsubscribe, dedup of double-subscribe). * docs(IBackendsTransport): clarify opts JSDoc for sd-cpp * test(IBackendsTransport): move type test under packages/test for CI discovery The repo's test runner (scripts/test.ts) only collects Vitest files from packages/test/src/test, so this file was never executed in CI. Removing the old location; the file is recreated under packages/test/src/test/ai in the following commit (also strengthens the structural conformance assertion with explicit parameter signatures). * test(IBackendsTransport): strengthen conformance with explicit signatures Recreates the type-conformance test at packages/test/src/test/ai/ (the location scripts/test.ts discovers) and replaces the zero-arg dummy implementations with explicit parameter signatures drawn from the interface. TypeScript happily assigns `() => X` to `(arg) => X`, so the previous form did not catch parameter-list drift; the new form fails typecheck on any rename, type change, or return-type change to a method of `IBackendsTransport`. Imports come from `@workglow/ai/provider-utils` (the public subpath export) instead of the previous relative path into packages/ai/src.
54cbafd to
60723b7
Compare
Review notes (process, not blocking)Thanks for the work here! Two process-level suggestions before merge — both about keeping the historical record clean, not about the code itself. H1 — Unrelated deletion of
|
…s, tighten JSDoc (PR #526 follow-up) (#527) * feat(ai): finalize IBackendsTransport — add list/uninstall, widen opts, tighten JSDoc Adds list() and uninstall(backend) to IBackendsTransport so the libs interface matches what builder's MessagePortBackendsTransport already implements and the renderer UI requires. Widens IEnsureRunningRequest.opts from { ctx: number } to Readonly<Record<string, unknown>> so non-llamacpp backends (sd-cpp, future MLX/whisper) don't have to lie with ctx: 0. Updates StableDiffusionCppProvider to pass opts: {} accordingly. Tightens JSDoc on release() (resolves on post, not broker-ack) and subscribeStatus() (idempotent unsubscribe, dedup of double-subscribe). * docs(IBackendsTransport): clarify opts JSDoc for sd-cpp * test(IBackendsTransport): move type test under packages/test for CI discovery The repo's test runner (scripts/test.ts) only collects Vitest files from packages/test/src/test, so this file was never executed in CI. Removing the old location; the file is recreated under packages/test/src/test/ai in the following commit (also strengthens the structural conformance assertion with explicit parameter signatures). * test(IBackendsTransport): strengthen conformance with explicit signatures Recreates the type-conformance test at packages/test/src/test/ai/ (the location scripts/test.ts discovers) and replaces the zero-arg dummy implementations with explicit parameter signatures drawn from the interface. TypeScript happily assigns `() => X` to `(arg) => X`, so the previous form did not catch parameter-list drift; the new form fails typecheck on any rename, type change, or return-type change to a method of `IBackendsTransport`. Imports come from `@workglow/ai/provider-utils` (the public subpath export) instead of the previous relative path into packages/ai/src.
2cc8663 to
231f21f
Compare
…registration, and barrels
…, browser/worker constraints
…ider — run-fns, registration, and barrels
…ty table, browser note
723516d to
ec5cc74
Compare
Summary
Introduces
IBackendsTransport, a renderer-side abstraction interface for the backends broker that provider packages can consume without importing Electron or builder dependencies. This enables a clean separation of concerns where provider packages depend only on the abstract interface, while the concrete implementation lives in the builder package.Changes
New file:
packages/ai/src/transport/IBackendsTransport.tsIEnsureRunningRequest— request payload for acquiring a running backendIRunningHandle— handle returned byensureRunning()with refcount-based lifecycleIBackendStatus— status snapshot mirroring the electron-side typeIBackendsTransport— main interface with three methods:ensureRunning()— acquire or share a running backend processsubscribeStatus()— subscribe to backend status updates with unsubscribe callbackinstall()— install a backend with optional progress reportingUpdated:
packages/ai/package.json"./backends-transport"export path pointing to the new interface fileImplementation Details
stringfor backend identifiers (not a closed union) so provider packages don't need to know the full set of backend names; the transport implementation in builder coerces toBackendNameIRunningHandle.release()is fire-and-forget to avoid blocking on broker acksreadonlyproperties,Iprefix for public interfaces, no Electron imports in the interface definitionhttps://claude.ai/code/session_01Avr2i3ryqAUJUFRRZZ3Mf3