- Updated all package.json name fields and dependency references - Updated all TypeScript/JavaScript imports - Updated .woodpecker/publish.yml filters and registry paths - Updated tools/install.sh scope default - Updated .npmrc registry paths (worktree + host) - Enhanced update-checker.ts with checkForAllUpdates() multi-package support - Updated CLI update command to show table of all packages - Added KNOWN_PACKAGES, formatAllPackagesTable, getInstallAllCommand - Marked checkForUpdate() with @deprecated JSDoc Closes #391
2.3 KiB
2.3 KiB
M3-001 Provider Adapter Pattern — Scratchpad
Objective
Refactor ProviderService into an IProviderAdapter pattern without breaking existing Ollama flow.
Plan
- Add
IProviderAdapterinterface and supporting types to@mosaicstack/typesprovider package - Create
apps/gateway/src/agent/adapters/directory with:provider-adapter.interface.ts— IProviderAdapter + ProviderHealth + CompletionParams + CompletionEventollama.adapter.ts— extract existing Ollama logic
- Refactor ProviderService:
- Accept
IProviderAdapter[](injected via DI token) registerAll()/listModels()aggregates from all adaptersgetAdapter(name)— lookup by namehealthCheckAll()— check all adapters- Keep Pi ModelRegistry wiring (required by AgentService)
- Accept
- Wire up in AgentModule
Key Findings
Pi SDK Compatibility
- Pi SDK uses
ModelRegistryas central registry; ProviderService wraps it ModelRegistry.registerProvider()is the integration point — adapters call this- Pi doesn't have a native "IProviderAdapter" concept — adapters are a Mosaic abstraction on top
- The
createAgentSession()call in AgentService usesmodelRegistry: this.providerService.getRegistry() - OllamaAdapter should call
registry.registerProvider('ollama', {...})same as today - CompletionParams/CompletionEvent: Pi SDK streams via
AgentSession.prompt(), not raw completion — IProviderAdapter.createCompletion() is for future direct use; for now stub or leave as interface-only — ASSUMPTION: createCompletion is reserved for future M3+ work; Pi SDK owns the actual streaming
Implementation Notes
- ESM: use
.jsextensions in all imports - NestJS: use
@Inject()explicitly - Keep RoutingService working — it only uses
providerService.listAvailableModels() - Keep AgentService working — it uses
providerService.getRegistry(),findModel(),getDefaultModel(),listAvailableModels()
Progress
- Add types to @mosaicstack/types
- Create adapters/ directory
- Create IProviderAdapter interface file
- Create OllamaAdapter
- Refactor ProviderService
- Update AgentModule
- Run tests
- Run quality gates
Risks
- Pi SDK doesn't natively support IProviderAdapter — adapters are a layer on top
- createCompletion() is architecturally sound but requires Pi session bypass (future work)