Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(importer): add AI Provider & Model selection to intake
Adam Eivy4fd8cd67d1d3
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex c99a0ad216..d8183b6985 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -14,6 +14,7 @@ TBD## Changed+- **Pick the AI provider & model for the Importer.** The Create → Importer intake form now has an "AI Provider & Model" picker (mirroring the Universe and Series builders), so the canon / arc / issue-split extraction can run on a specific provider and model instead of always using each stage's configured default. Leave it on "Default (stage provider)" to keep the prior behavior; the same selection also drives the content-type auto-detect pass.- **Pick any AI provider for the voice assistant.** The voice Chief-of-Staff's language model was hard-wired to LM Studio. Settings → Voice now has an "LLM provider" picker listing every API provider you've configured (LM Studio, Ollama, NVIDIA, or any OpenAI-compatible endpoint) plus a model dropdown with a refresh button that re-queries the provider's available models. Local-only setups are unchanged out of the box — LM Studio stays the default and the `LM_STUDIO_URL` override still applies — but you can now point voice at a hosted model. The voice service-health badge probes whichever provider you select.- **Pipeline Series pages are now cover-forward editorial workspaces.** The series detail view replaces the long all-volumes scroll with a compact volume selector, cover cards for issues, colorful theme tags, and an editorial roadmap panel for visually debugging plot, character, and future reader-emotion arcs. Missing or in-flight volume and issue covers now show placeholders instead of leaving dense text lists as the primary navigation.- **Consistent inline badge styling.** The peer relationship and connection-scheme labels on the Instances page and the length-target cards in the Writers Room Guide now render through one shared badge component, so their look stays consistent as more badges are added.diff --git a/PLAN.md b/PLAN.mdindex 3f8d7863ca..bb8aacf383 100644--- a/PLAN.md+++ b/PLAN.md@@ -165,6 +165,12 @@ Surfaced by the multi-reviewer release gate for v2.10.0. The CRITICAL/correctnes- [x] [test-codereview-local-route] _(DONE post-v2.10.0 patch)_ **`POST /api/code-review/local` has no route-level test.** Add a supertest-style test (mocking `runLocalCodeReview`/`getSettings`): empty `diff` → 400 (Zod), unknown `backend` → 400 (`z.enum`), `model` omitted falls back to the settings model, and `{ ok: false }` service result → 502. Also add `validation.test.js` assertions that `featureProviderConfigSchema.parse({ providerId:'', model:'' })` yields `undefined`s and `codeReviewSettingsSchema` rejects unknown keys (`.strict()`). (Batch-3 IMPROVEMENT/NIT.)- [ ] [test-route-suites-peer-fanout-mock-noise] **`pipeline.test.js` / `universeBuilder.test.js` log noisy `auto-subscribe after create failed: [vitest] error when mocking a module` warnings on every record-creating test (pre-existing on main — ~88 in pipeline.test.js alone, surfaced during the v2.10.0 patch code review).** Root cause: `createSeries`/`createUniverse` fire-and-forget `import('../sharing/peerSync.js').then(autoSubscribeRecordToAllPeers)`, and in these suites that dynamic import trips a hoisting-broken `vi.mock` factory elsewhere in the graph, so the `.catch` swallows it and logs. Tests still pass (non-fatal). The canonical fix is to mock `services/instances.js` (`mockNoPeers`) + `services/sharing/peerSync.js` (`mockNoPeerSync`) per the CLAUDE.md test contract — but the route graph statically imports a broad peerSync surface (`installPeerSyncListener`, `peerSyncEvents`, `listPeerSubscriptions`, `assetShaListForRecord`), so a full-replace mock drops needed exports and the `importActual`-spread form currently throws the same vitest mock-factory error. Needs a dedicated investigation into why `vi.importActual('../services/sharing/peerSync.js')` inside the factory errors here (likely a circular/hoist interaction with the other mocks) before the noise can be silenced. Out of scope for the v2.10.0 patch (pre-existing, non-fatal). Surfaced 2026-05-26.+### Importer provider/model picker — deferred follow-ups (2026-05-26)++Surfaced by the code-review pass on the Importer AI Provider/Model picker (`client/src/pages/Importer.jsx`). Correctness was clean; these are reuse/altitude cleanups deferred to keep the PR focused.++- [ ] [shared-optional-provider-picker] **Add an optional/"Default" mode to the shared provider/model picker and migrate the inline copies.** Three pages now hand-roll the same inline two-`<select>` "Default sentinel + provider + model" picker because the shared `client/src/components/ProviderModelSelector.jsx` + `client/src/hooks/useProviderModels.js` force a selection (no empty option; `useProviderModels` auto-selects the first provider via `hasSetInitialRef`). UniverseBuilder.jsx (~2968-2992) and now Importer.jsx (~437-470, plus its `getProviders`+enabled-filter effect ~93-106 and `llmModels` memo) duplicate the logic in `FeatureProviderPicker.jsx`/`useProviderModels`. Add an `emptyOption={{ value:'', label }}` (or `allowDefault`) prop to `ProviderModelSelector` and an `allowDefault`/`includeEmpty` flag to `useProviderModels` that skips the auto-select, then refactor both Importer and UniverseBuilder to consume them — removing ~30 lines of JSX from each and the six prop-drilled values into `IntakeForm`. Note the importer's default label must stay accurate to its *per-stage* resolution (`stage.provider` → active), so a single "active provider (name)" label like UniverseBuilder's would be misleading for the importer — keep a generic "Default" label unless the picker is taught the resolved-per-stage provider. Cleanup only; no behavior change. Surfaced 2026-05-26.+## Future Ideas- **Identity Context Injection** — per-task-type digital twin preamble toggle.diff --git a/client/src/pages/Importer.jsx b/client/src/pages/Importer.jsxindex 8a64cc8f61..52e628f1c5 100644--- a/client/src/pages/Importer.jsx+++ b/client/src/pages/Importer.jsx@@ -6,6 +6,8 @@ import { useAsyncAction } from '../hooks/useAsyncAction';import { STORY_SHAPES } from '../components/pipeline/StoryShapes';import EntryCard from '../components/universe/EntryCard';import { previewCanonFragments } from '../lib/canonPrompt';+import { getProviders } from '../services/api';+import { filterSelectableModels } from '../utils/providers';import {analyzeImport,classifyImport,@@ -82,6 +84,27 @@ export default function Importer() {return () => ac.abort();}, []);+ // AI provider/model override for the extraction LLM calls (classify ++ // analyze). Empty string = "use the stage/active provider default" — sent+ // as `''` and coerced to undefined server-side (see importer*Schema).+ const [providers, setProviders] = useState([]);+ const [llmProvider, setLlmProvider] = useState('');+ const [llmModel, setLlmModel] = useState('');+ useEffect(() => {+ let cancelled = false;+ getProviders({ silent: true }).then((data) => {+ if (cancelled) return;+ setProviders((data?.providers || []).filter((p) => p.enabled));+ }).catch((err) => {+ console.warn(`⚠️ Importer provider list fetch failed: ${err?.message || err}`);+ });+ return () => { cancelled = true; };+ }, []);+ const llmModels = useMemo(() => {+ const p = providers.find((x) => x.id === llmProvider);+ return p ? filterSelectableModels(p.models || [p.defaultModel]) : [];+ }, [providers, llmProvider]);+const [canonSelections, setCanonSelections] = useState({ characters: [], places: [], objects: [] });const [selectedCanon, setSelectedCanon] = useState({ characters: new Set(), places: new Set(), objects: new Set() });const [arcDraft, setArcDraft] = useState(null);@@ -100,7 +123,11 @@ export default function Importer() {const [runClassify, classifying] = useAsyncAction(async () => {if (!intake.source.trim()) return null;- const result = await classifyImport({ source: intake.source.slice(0, CLASSIFY_SOURCE_HEAD_CHARS) }, { silent: true });+ const result = await classifyImport({+ source: intake.source.slice(0, CLASSIFY_SOURCE_HEAD_CHARS),+ providerOverride: llmProvider,+ modelOverride: llmModel,+ }, { silent: true });if (!result) return null;if (result.contentType && IMPORTER_CONTENT_TYPES.includes(result.contentType)) {setIntake((prev) => ({ ...prev, contentType: result.contentType }));@@ -122,6 +149,8 @@ export default function Importer() {seriesName: intake.seriesName.trim(),contentType: intake.contentType,source: intake.source,+ providerOverride: llmProvider,+ modelOverride: llmModel,};const tic = intake.targetIssueCount === '' ? null : Number(intake.targetIssueCount);if (Number.isFinite(tic) && tic > 0) payload.targetIssueCount = tic;@@ -229,6 +258,12 @@ export default function Importer() {classifying={classifying}onClassify={runClassify}classifyHint={classifyHint}+ providers={providers}+ llmProvider={llmProvider}+ llmModel={llmModel}+ llmModels={llmModels}+ onProviderChange={(id) => { setLlmProvider(id); setLlmModel(''); }}+ onModelChange={setLlmModel}/>)}@@ -257,7 +292,10 @@ export default function Importer() {);}-function IntakeForm({ intake, setIntake, sourceCharLimit, analyzing, onAnalyze, classifying, onClassify, classifyHint }) {+function IntakeForm({+ intake, setIntake, sourceCharLimit, analyzing, onAnalyze, classifying, onClassify, classifyHint,+ providers, llmProvider, llmModel, llmModels, onProviderChange, onModelChange,+}) {const sourceLen = intake.source.length;const sourceOver = sourceLen > sourceCharLimit;const intakeValid = intake.universeName.trim() && intake.seriesName.trim() && intake.source.trim() && !sourceOver;@@ -396,6 +434,39 @@ function IntakeForm({ intake, setIntake, sourceCharLimit, analyzing, onAnalyze,/><p className="text-xs text-port-text-muted mt-1">Leave blank to let the LLM split based on natural chapter/issue/act boundaries.</p></div>+ <div>+ <label htmlFor="importer-llm-provider" className="block text-sm font-medium mb-1">+ AI Provider & Model (optional)+ </label>+ <div className="flex items-center gap-2">+ <select+ id="importer-llm-provider"+ value={llmProvider}+ onChange={(e) => onProviderChange(e.target.value)}+ className="flex-1 min-w-0 bg-port-bg border border-port-border rounded px-3 py-2 text-sm focus:outline-none focus:border-port-accent"+ >+ <option value="">Default (stage provider)</option>+ {providers.map((p) => (+ <option key={p.id} value={p.id}>{p.name}</option>+ ))}+ </select>+ {llmModels.length > 0 && (+ <select+ id="importer-llm-model"+ aria-label="Model"+ value={llmModel}+ onChange={(e) => onModelChange(e.target.value)}+ className="flex-1 min-w-0 bg-port-bg border border-port-border rounded px-3 py-2 text-sm focus:outline-none focus:border-port-accent"+ >+ <option value="">Default model</option>+ {llmModels.map((m) => (+ <option key={m} value={m}>{m}</option>+ ))}+ </select>+ )}+ </div>+ <p className="text-xs text-port-text-muted mt-1">Model used to extract canon, arc, and the issue split. Defaults to each stage's configured provider.</p>+ </div></div><div className="flex items-center justify-end gap-2 pt-2">diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 761ba9f290..d378a0b512 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -1621,10 +1621,11 @@ const importerSourceField = z.string().min(1).max(5_000_000);// LLM only consumes the head, so the schema is intentionally minimal.export const importerClassifySchema = z.object({source: importerSourceField,- providerOverride: z.preprocess(- (v) => (v === '' ? undefined : v),- z.string().trim().max(120).optional(),- ),+ providerOverride: z.preprocess(emptyToUndefined, z.string().trim().max(120).optional()),+ // Pinned model id for the chosen provider; '' from the UI ("Default model")+ // coerces to undefined so runStagedLLM falls back to the stage/provider+ // default model.+ modelOverride: z.preprocess(emptyToUndefined, z.string().trim().max(200).optional()),}).strict();export const importerAnalyzeSchema = z.object({@@ -1634,10 +1635,11 @@ export const importerAnalyzeSchema = z.object({source: importerSourceField,// UI sends `''` for "no override picked"; coerce to undefined so the// server's `await getProviderById(undefined)` short-circuit kicks in.- providerOverride: z.preprocess(- (v) => (v === '' ? undefined : v),- z.string().trim().max(120).optional(),- ),+ providerOverride: z.preprocess(emptyToUndefined, z.string().trim().max(120).optional()),+ // Pinned model id for the chosen provider; '' from the UI ("Default model")+ // coerces to undefined so runStagedLLM falls back to the stage/provider+ // default model.+ modelOverride: z.preprocess(emptyToUndefined, z.string().trim().max(200).optional()),targetIssueCount: z.number().int().min(1).max(50).optional(),}).strict();diff --git a/server/services/importer.js b/server/services/importer.jsindex e85f6b3fc6..3fd206b710 100644--- a/server/services/importer.js+++ b/server/services/importer.js@@ -344,7 +344,7 @@ export const CLASSIFY_SOURCE_HEAD_CHARS = 4_000;* gated similarly. The reasoning string is passed through verbatim so the* UI can show it in a tooltip beside the auto-pick.*/-export async function classifyImportContent({ source, providerOverride } = {}) {+export async function classifyImportContent({ source, providerOverride, modelOverride } = {}) {if (!isStr(source) || !source.trim()) {throw makeErr('source is required', ERR_VALIDATION);}@@ -357,6 +357,7 @@ export async function classifyImportContent({ source, providerOverride } = {}) {const sourceHead = source.slice(0, CLASSIFY_SOURCE_HEAD_CHARS);const run = await runStagedLLM('importer-classify', { sourceHead }, {providerOverride,+ modelOverride,source: 'importer-classify',returnsJson: true,});@@ -396,6 +397,7 @@ export async function analyzeImport({contentType,source,providerOverride,+ modelOverride,targetIssueCount,} = {}) {if (!isStr(universeName) || !universeName.trim()) {@@ -449,7 +451,7 @@ export async function analyzeImport({// option). Helper returns a FRESH object each call so a future runner// that decides to add bookkeeping (`opts.attempt`, `opts.startedAt`)// can't leak state across our parallel canon + arc invocations.- const buildLlmOpts = () => ({ providerOverride, source: 'importer-analyze', returnsJson: true });+ const buildLlmOpts = () => ({ providerOverride, modelOverride, source: 'importer-analyze', returnsJson: true });const userRequestedCount = Number.isFinite(targetIssueCount) && targetIssueCount > 0;const issueCountHint = userRequestedCountdiff --git a/server/services/importer.test.js b/server/services/importer.test.jsindex 56992a13f9..5a564d18e5 100644--- a/server/services/importer.test.js+++ b/server/services/importer.test.js@@ -289,6 +289,22 @@ describe('analyzeImport', () => {}});+ it('forwards providerOverride + modelOverride to every analyze stage call', async () => {+ // Regression-pin: the importer UI lets the user pin a specific provider ++ // model for extraction (mirrors universe/series). Both must reach every+ // staged LLM call (canon, arc, issues) — a one-sided drop would silently+ // ignore the user's model choice on one of the three extractions.+ wireDefaultLLMResponses();+ await importerSvc.analyzeImport({+ universeName: 'U', seriesName: 'S', contentType: 'short-story', source: 'x',+ providerOverride: 'anthropic', modelOverride: 'claude-opus-4-7',+ });+ expect(mockRunStagedLLM).toHaveBeenCalled();+ for (const call of mockRunStagedLLM.mock.calls) {+ expect(call[2]).toMatchObject({ providerOverride: 'anthropic', modelOverride: 'claude-opus-4-7' });+ }+ });+it('forwards Mustache section-guard flags so per-content-type prompt blocks render', async () => {// Regression-pin: PortOS's template engine is Mustache-only — the prompts// use `{{#isShortStory}}…{{/isShortStory}}` blocks, so the orchestrator@@ -382,6 +398,23 @@ describe('classifyImportContent', () => {expect(result.runId).toBe('run-classify-1');});+ it('forwards providerOverride + modelOverride to the classify stage call', async () => {+ mockRunStagedLLM.mockResolvedValueOnce({+ content: { contentType: 'novel', confidence: 'high', reasoning: 'chapters' },+ model: 'mock',+ providerId: 'mock',+ runId: 'run-classify-override',+ });+ await importerSvc.classifyImportContent({+ source: 'some prose', providerOverride: 'anthropic', modelOverride: 'claude-opus-4-7',+ });+ expect(mockRunStagedLLM).toHaveBeenCalledWith(+ 'importer-classify',+ expect.any(Object),+ expect.objectContaining({ providerOverride: 'anthropic', modelOverride: 'claude-opus-4-7' }),+ );+ });+it('drops a hallucinated contentType not in IMPORTER_CONTENT_TYPES to null', async () => {mockRunStagedLLM.mockResolvedValueOnce({content: { contentType: 'manga', confidence: 'high', reasoning: 'panels' },