Skip to content

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

make voice catalog_lookup type enum follow the active type registry

[._.]/ Adam Eivy1928115f5b56
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 3b964484cd..9846ebca97 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -22,6 +22,8 @@
- **[catalog-user-defined-types] Define your own Catalog ingredient types in Settings → Catalog.** The catalog shipped six built-in types (character / place / object / idea / scene / concept); you can now add your own — wardrobe, vehicle, faction, magic-system, prompt-fragment, anything — without a code change. A new Settings → Catalog tab lists the built-ins read-only and lets you build custom types from a flat field list: each type is `{ id, label, primaryContentKey, fields: [{ key, label, kind: 'string' | 'longtext' | 'tags' | 'ref', maxLength? }] }`. User types persist in `data/settings.json` (`catalogUserTypes`) — not a new table — and merge into the active type registry at boot and on every save, so they show up immediately as filter chips, in the "New" dropdown, and as a fully editable detail page driven by a single generic field renderer (no per-type React file). A `ref` field links to another catalog ingredient via the existing picker; `tags` reuses the tag chip input. Validity is enforced at the app layer (the registry + a Zod refinement on the ingredient `type`), building on the already-dropped DB `CHECK`. User types federate: they ride a new additive `catalogTypes` block in the catalog sync envelope (LWW-merged into each peer's own settings slice, skipping built-in-id collisions), gated by `PORTOS_SCHEMA_VERSIONS.catalog` bumped to 8 — a peer on an older catalog schema rejects a forward-shaped push with a clean 412 rather than dropping the definitions and then choking on ingredients of an unknown type. Deleting a type that still has ingredients is refused unless you force it (the orphaned rows survive under a fallback editor). No DB migration — settings-only.
+- **[catalog-voice-tools-user-type-filter] Voice can now search your user-defined catalog types.** The voice `catalog_lookup` tool advertised only the six built-in kinds in its `type` filter, so "search my factions" couldn't narrow to a user-defined type (it silently fell back to an unfiltered search). The tool's `type` enum is now derived from the active type registry at spec-build time, and the filter accepts any active type (built-in or user-defined), so a custom type created in Settings → Catalog is voice-addressable the moment it exists. Unknown types still drop to an unfiltered search rather than erroring.
+
- **[catalog-scrap-chunking] Long scrap pastes are now chunked so extraction doesn't silently degrade.** Pasting (or ingesting via URL / file / voice) a very long scrap — a whole screenplay, a 50k-word manuscript — used to land as a single row and a single LLM extraction pass, quietly overflowing the model's context and dropping ingredients from the tail. Inputs over ~12k characters now split into a parent row plus N child chunks (preferring paragraph, then sentence, then word boundaries so nothing is cut mid-word and the text reassembles exactly); the extractor runs each chunk independently (two at a time) and unions the results, de-duplicating by name + type so the same character mentioned in three chunks appears once. Short pastes behave exactly as before — one row, one pass. The chunk parent/child structure federates to peers (the catalog sync wire version is bumped, so a peer on an older catalog schema declines a forward-shaped push cleanly rather than mis-applying it); existing scraps are left as-is.
- **[catalog-ask-retrieval] Ask now draws on your Creative Catalog.** Asking a question (`/api/ask`, the Ask page, voice) now retrieves matching catalog ingredients — characters, places, objects, ideas, scenes, concepts — alongside memory, brain notes, goals, autobiography, and calendar. Matches use a hybrid Reciprocal-Rank-Fusion search (full-text + vector embedding) sharing the same scoring/budget model as memory retrieval, capped at 4 catalog sources per answer and weighted between brain-notes and autobiography. Each surfaced ingredient is a clickable source chip that deep-links to its catalog detail page. Full-text matching works immediately; semantic (vector) matches appear once you've configured an embedding model and run the catalog embeddings backfill. A catalog hiccup never blocks an answer (the retriever is isolated in the parallel fan-out).
diff --git a/PLAN.md b/PLAN.md
index 4bd28476fb..9529f7a7d7 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -6,18 +6,20 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel
### Creative Ingredients Catalog — follow-up slices
-The catalog backend, schema, federation routes, ingest extraction service, and Catalog/Ingest/Detail UI all landed in one PR (see `docs/plans/2026-05-29-creative-ingredients-catalog.md` for the design record). Phase-7-onward slices remain:
+The catalog backend, schema, federation routes, ingest extraction service, and Catalog/Ingest/Detail UI all landed in one PR (see `docs/plans/2026-05-29-creative-ingredients-catalog.md` for the design record). **All follow-up slices and the extensibility roadmap are now shipped — no Catalog items remain.**
_Merged 2026-05-30 (7 PRs, claude+codex reviewed): 15 items shipped to main — #554 roundtrip-and-cast bug fixes (`catalog-export-bundle-import-refs`, `catalog-markdown-roundtrip-fences-scraps`, `catalog-cast-panel-multi-role-unlink`); #555 `catalog-universe-builder-picker`; #556 `catalog-writers-room-version-refs`; #557 `catalog-tests`; #558 the combined schema stack (`catalog-shared-type-registry`, `catalog-payload-schemaversion-per-type`, `catalog-ingredient-relations`, `catalog-tag-taxonomy`, `catalog-ingredient-revisions`, `catalog-ingredient-media-refs`, `catalog-federation-orchestrator`, `catalog-bundled-universe-push`); #559 `catalog-source-kinds-url-file-voice`. #560 `catalog-character-sheet-enrichment` shipped a SLICE — kept open below for its remaining deep-unification + array-editor scope._
-_Re-triaged then cleared 2026-05-30 (post-merge follow-up pass): the 6 review-surfaced follow-ups + the 4 previously-gated items were each verified against `main` and all shipped — `catalog-bulk-import-scrap-persistence`, `catalog-sync-apply-kind-helper`, `catalog-detail-batched-endpoint`, `browser-navigate-ssrf-guard`, `catalog-bulk-import-route-db-tests`, `catalog-friendlify-universe-tags-on-sync`, the character-sheet slice, `catalog-type-table-vs-check`, and `catalog-ask-retrieval`. Still open below (verified still-valid 2026-05-30): `catalog-character-sheet-enrichment` (deep durable-record unification + structured array-field editors remain), `catalog-user-defined-types` (precondition now resolved; deferred until deliberately picked up), and `catalog-scrap-chunking` (per its own "wait for user pain" note — confirmed still not triggered)._
+_Re-triaged then cleared 2026-05-30 (post-merge follow-up pass): the 6 review-surfaced follow-ups + the 4 previously-gated items were each verified against `main` and all shipped — `catalog-bulk-import-scrap-persistence`, `catalog-sync-apply-kind-helper`, `catalog-detail-batched-endpoint`, `browser-navigate-ssrf-guard`, `catalog-bulk-import-route-db-tests`, `catalog-friendlify-universe-tags-on-sync`, the character-sheet slice, `catalog-type-table-vs-check`, and `catalog-ask-retrieval`._
+
+_Final three cleared 2026-05-30 (see the "Creative Catalog — extensibility roadmap" clearance note below): `catalog-scrap-chunking` (#567), `catalog-user-defined-types` (#568), and `catalog-character-sheet-enrichment` deep-unification + array-editor remainder (#569), plus the `catalog-voice-tools-user-type-filter` follow-up. The Catalog feature is fully shipped._
### Creative Catalog — extensibility roadmap
The v1 catalog hardcodes six types (`character|place|object|idea|scene|concept`) in at least eight places: the Postgres CHECK constraint (`server/scripts/init-db.sql` + `server/lib/db.js:ensureSchema`), the Zod enum in `server/lib/catalogValidation.js`, the extraction prompt in `server/services/catalogExtraction.js`, the `TYPES` array + `PRIMARY_CONTENT_KEY` + `PRIMARY_CONTENT_LABEL` + `payloadSnippet` fallback chain in `client/src/pages/Catalog.jsx`, the type-specific editor branches in `client/src/pages/CatalogIngredient.jsx`, the `IngredientPicker.jsx` type filter, and the `search_tsv` generated column expression. Adding a seventh type today is an 8-file touch across server, client, and a Postgres migration. The items below collapse that surface so the catalog can grow into the long tail of creative shards (lore fragments, factions, magic systems, vehicles, wardrobe, dialogue snippets, beat cards, prompt fragments, voice-memo transcripts, mood references, etc.) without each new shard being a multi-PR effort.
-- [ ] [catalog-voice-tools-user-type-filter] **Surface user-defined catalog types to the voice `catalog_search` / `catalog_create` tools.** `server/services/voice/tools.js` still hardcodes `CATALOG_INGREDIENT_TYPES = ['character', 'place', 'object', 'idea', 'scene', 'concept']` (line ~454) for the `type` enum on the catalog voice tools. With `[catalog-user-defined-types]` shipped, a user-defined type is accepted by the create route but a voice "search my factions" can't filter on it — `catalog_search` silently drops an unknown `type` to `undefined` (no crash, just no filter). Make the tool's `type` enum (and the `catalog_create` type validation) derive from `getActiveCatalogTypes()` at `getToolSpecs()` time so user types are voice-addressable. Low priority — nothing throws today; this is a discoverability gap, not a bug.
+_Catalog roadmap fully cleared 2026-05-30 (3 PRs, claude+codex+gemini reviewed): #567 `catalog-scrap-chunking` (long pastes split into parent + child chunks; per-chunk extraction unioned + deduped); #568 `catalog-user-defined-types` (Settings → Catalog UI + generic field renderer + runtime registry merge, federated via a catalogTypes sync block with LWW + delete tombstones); #569 `catalog-character-sheet-enrichment` remaining slice (bidirectional catalog↔canon projection with a re-entrancy guard + boot reconcile making the catalog row the single store of record, plus inline color-palette/stats/aliases editors). The follow-up `catalog-voice-tools-user-type-filter` (voice `catalog_lookup` type enum derived from the active registry so user types are voice-addressable) shipped in the same pass. No Catalog items remain._
_Batch-cleared 2026-05-25: 23 Next Up items shipped together via parallel sub-agents (env-file helper, formatBytes migration, lazy voice UI text, voice long-term-memory routing, voice tool expansion + `ui_describe_visually`, three phosphene generate_ltx2.py hardenings, the peer-sync snapshot-coverage P1 refactor + ephemeralize-then-delete, per-record tombstone-ack clamp, MediaLightbox→MediaImage, global vitest peer mock, videoHistory sync category, reverse-sub UI broadcast, palette Health disambiguation, insertXxxWithId resurrection side-effects, importer tombstone detection, TUI finish-rejection note, mortalLoom errno widen, VideoGen stale-model toast, Universes sidebar grandchildren). See `git log` + `.changelog/NEXT.md`._
diff --git a/server/services/voice/tools.js b/server/services/voice/tools.js
index 619cfec943..0cee637798 100644
--- a/server/services/voice/tools.js
+++ b/server/services/voice/tools.js
@@ -17,6 +17,7 @@ import { getUserTimezone, todayInTimezone, getLocalParts, getUtcOffsetMs } from
import * as journal from '../brainJournal.js';
import { resolveNavCommand, normalizeLabel } from '../../lib/navManifest.js';
import { listIngredients as listCatalogIngredients, listRefsForIngredient } from '../catalogDB.js';
+import { getActiveCatalogTypes, isActiveType } from '../../lib/catalogTypes.js';
import { runAsk, VALID_MODES as ASK_VALID_MODES } from '../askService.js';
import * as imageGen from '../imageGen/index.js';
import { createImageGenWaiter } from '../imageGenWaiter.js';
@@ -449,9 +450,17 @@ const describeWeatherCode = (code) => WEATHER_CODES[code] ?? 'unknown conditions
const DEFAULT_LAT = 37.7749;
const DEFAULT_LON = -122.4194;
-// Catalog ingredient kinds. Hardcoded for now — the shared catalog type
-// registry (PLAN item `[catalog-shared-type-registry]`) will replace this.
+// Catalog ingredient kinds. The six built-ins are a STATIC fallback; the live
+// enum advertised to the LLM (and the filter-validity check) resolves through
+// the active type registry at `getToolSpecs()` / call time so user-defined
+// types (Settings → Catalog) are voice-addressable too. `activeCatalogTypeIds`
+// reads the registry fresh each call — it changes on a settings save / peer
+// sync without a process restart.
const CATALOG_INGREDIENT_TYPES = ['character', 'place', 'object', 'idea', 'scene', 'concept'];
+const activeCatalogTypeIds = () => {
+ const ids = getActiveCatalogTypes().map((t) => t.id);
+ return ids.length ? ids : CATALOG_INGREDIENT_TYPES;
+};
// Pull a short snippet from an ingredient's type-specific payload. Mirrors
// the fallback chain used by client/src/pages/Catalog.jsx so voice + UI agree
@@ -2073,6 +2082,9 @@ const TOOLS = [
type: 'object',
properties: {
query: { type: 'string', description: 'Free-text search across name + payload content. Use the user\'s most distinctive phrasing.' },
+ // enum is filled in at spec-build time (toSpec) from the active type
+ // registry so user-defined types are advertised; this static default
+ // is the fallback shape.
type: { type: 'string', enum: CATALOG_INGREDIENT_TYPES, description: 'Optional: restrict to one ingredient kind.' },
limit: { type: 'integer', description: 'Max results (default 5, max 20).' },
},
@@ -2082,7 +2094,9 @@ const TOOLS = [
if (typeof query !== 'string' || !query.trim()) throw new Error('query is required');
const q = query.trim();
const max = clampLimit(limit, 5, 20);
- const filterType = CATALOG_INGREDIENT_TYPES.includes(type) ? type : undefined;
+ // Accept any ACTIVE type (built-in or user-defined); an unknown type
+ // silently drops to an unfiltered search rather than erroring.
+ const filterType = type && isActiveType(type) ? type : undefined;
const { items } = await listCatalogIngredients({ query: q, type: filterType, limit: max });
const results = await Promise.all(items.map(async (ing) => {
const refs = await listRefsForIngredient(ing.id);
@@ -2102,9 +2116,25 @@ const TOOLS = [
},
];
+// Resolve a tool's parameter schema at spec-build time. `catalog_lookup`'s
+// `type` enum is widened to the active type registry (built-in + user-defined
+// catalog types) so a user's custom kind ("faction", "wardrobe") is advertised
+// to the LLM and voice "search my factions" can filter on it. Other tools pass
+// their static schema through untouched.
+const resolveParameters = (t) => {
+ if (t.name !== 'catalog_lookup') return t.parameters;
+ return {
+ ...t.parameters,
+ properties: {
+ ...t.parameters.properties,
+ type: { ...t.parameters.properties.type, enum: activeCatalogTypeIds() },
+ },
+ };
+};
+
const toSpec = (t) => ({
type: 'function',
- function: { name: t.name, description: t.description, parameters: t.parameters },
+ function: { name: t.name, description: t.description, parameters: resolveParameters(t) },
});
export const getToolSpecs = () => TOOLS.map(toSpec);
diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.js
index a858ce13ac..7c74ee040c 100644
--- a/server/services/voice/tools.test.js
+++ b/server/services/voice/tools.test.js
@@ -199,6 +199,19 @@ describe('getToolSpecs', () => {
expect(s.function.parameters?.type).toBe('object');
}
});
+
+ it('catalog_lookup advertises user-defined catalog types in its type enum', async () => {
+ const { setUserCatalogTypes } = await import('../../lib/catalogTypes.js');
+ try {
+ setUserCatalogTypes([{ id: 'faction', label: 'Faction', primaryContentKey: 'creed', fields: [] }]);
+ const lookup = getToolSpecs().find((s) => s.function.name === 'catalog_lookup');
+ const enumVals = lookup.function.parameters.properties.type.enum;
+ // Built-ins still present, plus the user type.
+ expect(enumVals).toEqual(expect.arrayContaining(['character', 'place', 'object', 'idea', 'scene', 'concept', 'faction']));
+ } finally {
+ setUserCatalogTypes([]); // restore the registry for other suites
+ }
+ });
});
describe('dispatchTool unknown tool', () => {