Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
docs: Wave 4 + Wave 5 + Wave 6 sweep across ui_migration_plan / schema RFC / CLAUDE.md
trohitg217a5773ef47
diff --git a/CLAUDE.md b/CLAUDE.mdindex 67c1c2d5..d6841446 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -11,7 +11,7 @@ This is a React Flow-based workflow automation platform implementing n8n-inspire|----------|-------------|| **[Frontend Architecture](./docs-internal/frontend_architecture.md)** | Current frontend stack (React 19 + Vite + Tailwind v4 + shadcn/ui + Radix + RHF/zod + TanStack Query + Zustand). Tokens, primitives, forms, credentials exemplar, ownership boundary, `uiHints` catalogue. || **[UI Migration Plan](./docs-internal/ui_migration_plan.md)** | antd → shadcn/ui migration plan + completion log. Waves 1–3 done; Phase 6 (ParameterRenderer → widget registry) deferred pending backend `get_node_spec`. |-| **[Schema Source of Truth RFC](./docs-internal/schema_source_of_truth_rfc.md)** | Wave 3 decision: node output shapes live on the backend (Pydantic → JSON Schema) and the frontend fetches them lazy, n8n-style. Defines `GET /api/schemas/nodes/{type}.json` + `get_node_output_schema` WS handler. |+| **[Schema Source of Truth RFC](./docs-internal/schema_source_of_truth_rfc.md)** | Wave 3 + Wave 6: backend is SSOT for node output schemas AND input parameter schemas via Pydantic → JSON Schema. 110 NodeSpecs registered. Endpoints: `GET /api/schemas/nodes/{type}.json` (output), `/{type}/spec.json` (full NodeSpec), `/nodes/options/{method}` (loadOptions dispatcher), `/nodes/groups` (node-groups index). Frontend adapter + feature flag `VITE_NODESPEC_BACKEND` ready; Phase 3e flag flip + frontend nodeDefinitions/* deletion deferred pending snapshot tests. || **[Node Creation Guide](./docs-internal/node_creation.md)** | Complete guide for creating new nodes (frontend definitions, backend handlers, config nodes, triggers) || **[AI Tool Node Guide](./docs-internal/ai_tool_node_creation.md)** | Detailed guide for creating dedicated AI Agent tool nodes (schemas, handlers, toolkits) || **[Specialized Agent Guide](./docs-internal/specialized_agent_node_creation.md)** | Guide for creating specialized AI agents (Android, Coding, Web, Task, Social, Travel, Tool, Productivity, Payments, Consumer) with full AI configuration |diff --git a/docs-internal/schema_source_of_truth_rfc.md b/docs-internal/schema_source_of_truth_rfc.mdindex 0d84ed07..4595d156 100644--- a/docs-internal/schema_source_of_truth_rfc.md+++ b/docs-internal/schema_source_of_truth_rfc.md@@ -1,8 +1,8 @@# Schema source of truth — RFC-**Status:** ✅ **implemented** · **Owner:** frontend + backend platform · **Date:** 2026-04-14 · **Landed across:** commits `cd252c1` → `4a4a439` (8 commits on `feature/credentials-scaling-v2`)+**Status:** ✅ **implemented + extended to NodeSpec** · **Owner:** frontend + backend platform · **Original landing:** 2026-04-14 (output schemas) · **Wave 6 extension:** 2026-04-15+ (full NodeSpec contract)-## Landed outcome+## Landed outcome (Wave 3 — output schemas)- Backend registry seeded with **98 Pydantic models** in [server/services/node_output_schemas.py](../server/services/node_output_schemas.py) covering every node type the deleted `sampleSchemas` map covered, plus all 18 specialized agents and 9 chat models.- `GET /api/schemas/nodes/{node_type}.json` serves static JSON Schema (Cache-Control `public, max-age=86400`). 404 for unknown types.@@ -11,6 +11,43 @@- `outputSchema` field removed from `INodeTypeDescription` — the frontend type no longer has any shape-describing surface for runtime output.- Adding a new node type's output shape: one Pydantic model in `node_output_schemas.py`. Zero frontend change.+## Wave 6 extension (input schemas + full NodeSpec)++Wave 3 proved the pattern for output schemas. Wave 6 generalises it to the **full parameter contract** — the business-logic surface the frontend still owned via `nodeDefinitions/*.ts` `properties` arrays, `displayOptions`, validation rules, dynamic-option loaders, and credential mappings.++**Shipped contract:**++- **Input schemas** — [server/services/node_input_schemas.py](../server/services/node_input_schemas.py) registers **105 Pydantic input models** across every node type, auto-expanding `SpecializedAgentParams` (16 variants) and `AndroidServiceParams` (16 variants) via Literal union introspection.+- **NodeSpec envelope** — [server/services/node_spec.py](../server/services/node_spec.py) assembles `{type, displayName, icon, group, description, version, inputs (JSON Schema), outputs (JSON Schema, reuses Wave 3), credentials, uiHints}` fusing three sources of truth.+- **Display metadata** — [server/models/node_metadata.py](../server/models/node_metadata.py) carries **105 entries** (one per input-modeled type). The only new server-side data file.+- **Endpoints** — alongside the Wave 3 `/nodes/{type}.json` output endpoint: `GET /api/schemas/nodes/{type}/spec.json`, `/nodes/{type}/input.json`, `/nodes/specs` (list), all with 24h `Cache-Control`. WS mirrors: `get_node_spec`, `list_node_specs`.+- **loadOptionsMethod dispatch** — [server/services/node_option_loaders/](../server/services/node_option_loaders/) generalises the WhatsApp-only pattern to a registry. Adding a new dynamic-option loader = one-line registration. `POST /api/schemas/nodes/options/{method}` + WS `load_options`.+- **Node-groups index** — `GET /api/schemas/nodes/groups` returns `{group: [node_type, ...]}` derived from every NodeSpec's `group` array. **25 groups with 110 entries** replacing the **34 hand-rolled `*_NODE_TYPES` arrays** scattered across 6 frontend files.+- **Pydantic Field hints** — authors encode `displayOptions.show`/`.hide`, `loadOptionsMethod`, `placeholder`, `validation`, `typeOptions` via `Field(json_schema_extra={...})`. Currently ~36 rules encoded across TwitterSend/User, TelegramSend, HttpRequest, WhatsAppSend, SocialSend, Gmail, Calendar.++**Frontend consumer (feature-flagged):**++- `VITE_NODESPEC_BACKEND` flag at [client/src/lib/featureFlags.ts](../client/src/lib/featureFlags.ts). Defaults OFF — legacy `nodeDefinitions/*.ts` wins; ON routes rendering through backend NodeSpec via the adapter.+- [client/src/lib/nodeSpec.ts](../client/src/lib/nodeSpec.ts) — shared `fetchNodeSpec`/`prefetchAllNodeSpecs`/`resolveNodeDescription` helpers following the Wave 3 colocation pattern (no new hook file).+- [client/src/adapters/nodeSpecToDescription.ts](../client/src/adapters/nodeSpecToDescription.ts) — NodeSpec wire shape → legacy `INodeTypeDescription` bridge. Handles `required`, JSON Schema `format` (dateTime/file/binary), `displayOptions`, `validation`, typeOptions lift (`loadOptionsMethod`, `password`, `rows`, `editor`, `editorLanguage`, `accept`, …), and reads hints from both top-level and nested `uiHints` wrapper.+- Dashboard idle-time prefetch warms all 110 NodeSpecs after WebSocket connect (no-op when flag off).++**Adding a new node type's parameter surface:**++1. Define `XyzParams(BaseNodeParams)` in [server/models/nodes.py](../server/models/nodes.py) with `type: Literal["xyz"]` discriminator and Field constraints.+2. Register in `KnownNodeParams` discriminated union.+3. Register in `NODE_INPUT_MODELS` dict in `node_input_schemas.py`.+4. Add `NODE_METADATA["xyz"] = {displayName, icon, group, description, version}` in `node_metadata.py`.++Zero frontend change for parameter rendering. Icons that are SVG assets still need frontend import until SVG payload migration is its own follow-up.++**What's deferred (Wave 7):**++- Phase 3e flag flip + frontend `nodeDefinitions/*.ts` reductions (~3000 LOC deletion). Adapter is ready; snapshot Playwright tests are the remaining prerequisite.+- Phase 5.b per-component migration from `*_NODE_TYPES` arrays to backend groups.+- Gmail/Calendar/Telegram/Twitter loadOptions loaders (Phase 4 registry is ready for one-line registrations).+- ParameterRenderer → DIY widget registry (the capstone). Now unblocked on backend since NodeSpec's `uiHints` already carry widget routing.+## ProblemThe editor's Input panel (`client/src/components/parameterPanel/InputSection.tsx`) needs to show the runtime output shape of every connected source node so users can drag variables into downstream parameters. Today there are two places this shape is declared:diff --git a/docs-internal/ui_migration_plan.md b/docs-internal/ui_migration_plan.mdindex 9a3ca947..4b2d56e8 100644--- a/docs-internal/ui_migration_plan.md+++ b/docs-internal/ui_migration_plan.md@@ -104,6 +104,59 @@ Under that finding, the in-flight Wave 3 Phase 1 was reversed: the backend owns- `InputSection` is a pure consumer of backend-declared shapes. Schema precedence there is the n8n pattern: real execution data wins, declared schema fills in, empty state otherwise.- Phase 6 (ParameterRenderer → widget registry) remains blocked on backend `get_node_spec`, but the `jsonSchema` slice of that future contract is the handler shipped in Wave 3 Phase 1b — Phase 6 extends it with `uiSchema` + `_uiHints`, doesn't replace it.+## Wave 4 — finish deferred Wave 3 cleanup (April 2026)++Landed as 3 independent commits: MasterSkillEditor Query migration (`0be3cb8`, −49), MiddleSection shadcn primitives (`ada8bd1`, −320), ConsolePanel Tailwind + CSS var tokens (`9802a48`, −89). All tsc green. Zero new owned components — every UI rewrite used existing shadcn primitives (Accordion, Badge, AlertDialog, Input, Button). Full details in commit messages.++## Wave 5 — architectural cleanup of node components (April 2026)++Two-commit push focused on real architectural debt, not cosmetic inline-style churn:+- `f55b2c0`: GenericNode.tsx dead `type === 'aiAgent'` ternary removed (unreachable — Dashboard routes aiAgent exclusively to AIAgentNode); imperative `onMouseEnter/Leave` DOM mutations → Tailwind `hover:` classes; Dashboard.tsx `else → GenericNode` fallback swapped to `else → SquareNode` (fallback was never reached at runtime). −28 LOC.+- SquareNode.tsx `getStoredApiKey` useEffect + 2 useState → `useQuery(['storedApiKey', providerId])` with shared cache across all instances. −25 LOC.++Audit findings deferred with explicit reasons: BaseChatModelNode / SettingsPanel inline-style churn (prop/state-driven, no architectural debt, visual verification required), ParameterRenderer `apiKey`/`model` specials (audit recommended waiting for Phase 6 backend), ConsolePanel remaining CSSProperties (visual regression risk without screenshot diff).++## Wave 6 — backend as NodeSpec source of truth (April 2026)++Extends Wave 3's pattern from runtime output schemas to the full parameter contract. Backend becomes single source of truth for: parameter schemas, validation, defaults, dynamic option loaders, credential requirements, conditional display rules, and UI hints. Frontend `nodeDefinitions/*.ts` retained today for back-compat; flag-gated migration path ready.++Plan: [C:\\Users\\Tgroh\\.claude\\plans\\typed-splashing-crown.md].++| Phase | Status | Commits | Outcome |+|---|---|---|---|+| 1 — NodeSpec contract + Pydantic → JSON Schema | ✅ done | `1d8670b` | `server/services/node_input_schemas.py` mirrors Wave 3's output-schema module. `server/services/node_spec.py` assembles `{type, displayName, icon, group, inputs, outputs, credentials, uiHints}`. `server/models/node_metadata.py` carries display strings. `GET /api/schemas/nodes/{type}/spec.json` + `/input.json` + `/specs` list endpoints with 24h Cache-Control. |+| 2 — Frontend NodeSpec consumer + feature flag | ✅ done | `1d8670b` | `client/src/lib/featureFlags.ts` (`VITE_NODESPEC_BACKEND`, default off). `client/src/lib/nodeSpec.ts` (inline-colocated per design system, matches InputSection Wave 3 pattern). `client/src/adapters/nodeSpecToDescription.ts` (the bridge converting JSON Schema 7 → `INodeProperties[]`). Dashboard idle-time prefetch useEffect. Flag off ⇒ no frontend behavior change. |+| 3a — Backend parity: utility + code + process + workflow (12 types) | ✅ done | `1d8670b` | 4 new Pydantic models (TypeScriptExecutor, ProcessManager, Console, TeamMonitor). 12 metadata entries. |+| 3b — Backend parity: messaging (11 types) | ✅ done | `4b699cb` | 7 new Pydantic models (TelegramSend, TwitterSend/Search/User, SocialReceive/Send). 11 metadata entries. |+| 3c — Backend parity: agents + chat models (28 types) | ✅ done | `8a8a413` | SpecializedAgentParams promoted to mirror AIAgentParams full surface (temperature/max_tokens/thinking/reasoning). 28 metadata entries. |+| 3d.i — Backend parity: location + scheduler + chat + Android (26 types) | ✅ done | `f3664e7` | 26 metadata entries. `test_input_model_coverage_complete` invariant locks "every input model has metadata". |+| 3d.ii — Backend parity: long-tail integrations (28 output-only types) | ✅ done | `2b65a7f` | 28 new Pydantic models across search, browser/scraping, email, Google Workspace, document/RAG, filesystem, proxy. `TestWave6FullCoverage` invariants. |+| 4 — Generalized loadOptionsMethod dispatch | ✅ done | `a3c1ac2` | `server/services/node_option_loaders/` package with registry + `dispatch_load_options()` + 3 WhatsApp loaders (groups/channels/members). `POST /api/schemas/nodes/options/{method}` + WS `load_options`. One-line registration for future Gmail/Calendar/Telegram loaders. |+| 5.a — Backend node-groups index | ✅ done | `6ef271d` | `GET /api/schemas/nodes/groups` returns `{group: [node_type, ...]}` derived from every NodeSpec's group array. 25 groups with 110 entries (tool=34, agent=19, android=16, trigger=10, …). Replaces 34 frontend `*_NODE_TYPES` arrays once consumers migrate. |+| 5.b — Frontend consumer migrations | ⏸ deferred | — | Per-component migration from `*_NODE_TYPES` helpers to backend groups. Visual-regression-prone; needs browser verification. |+| Adapter coverage hardening | ✅ done | `b7b83b3` | `required` field, JSON Schema `format` (dateTime/file/binary), richer enum `options`, typeOptions lift for placeholder/validation/password/rows/editor/editorLanguage/accept/multipleValues/noDataExpression, displayOptions dual-location read (top-level + uiHints wrapper). |+| Pydantic displayOptions enrichment | ✅ done | `08126b6`, `aca8d1a` | `Field(json_schema_extra={"displayOptions": {...}})` encoded for TwitterSend (6 rules), TwitterUser (3), TelegramSend (9), HttpRequest (4), WhatsAppSend (4 + 2 loadOptionsMethod wirings), SocialSend (2), Gmail (3), Calendar (5). |+| 3e — Flag flip + delete frontend nodeDefinitions/* properties | ⏸ deferred | — | The biggest LOC win (~−3000 LOC). Adapter now handles most edge cases; remaining need: snapshot Playwright tests per node-type group. |+| 6 — Sunset `INodeTypeDescription.properties` shape | ⏸ deferred | — | Requires 3e + 5.b complete. |++**Wave 6 numbers (14 commits across this wave):**+- Backend: 105 Pydantic input models (started 67, +57%), 105 NODE_METADATA entries (started 0), 110 total NodeSpecs (every registered node type), 3 dynamic-option loaders wired, 25 node groups derived. 63/63 pytest cases pass.+- Frontend: 3 new files (featureFlags.ts, nodeSpec.ts, adapters/nodeSpecToDescription.ts) — all inline-colocated per the design-system "no speculative scaffolding" principle. Zero new hook files.+- Flag `VITE_NODESPEC_BACKEND` defaults OFF — production behavior unchanged. Flipping ON routes parameter rendering through backend NodeSpec via the adapter.+- `pnpm exec tsc --noEmit` green throughout all 14 commits.++**Architectural delta (permanent):**+- Every parameter schema lives on the backend via Pydantic. Adding a new node = one Pydantic class + one handler registry entry + one NODE_METADATA entry. Zero frontend change for parameter rendering.+- Business logic (validation rules, conditional visibility, dynamic options, credential mappings) is backend-owned. Frontend is a pure renderer of the emitted NodeSpec.+- `loadOptionsMethod` pattern is registry-driven; adding new dynamic-option loaders (Gmail labels, Calendar list, Telegram chats) is a one-line registration.+- NodeSpec emission follows the Wave 3 RFC template: Pydantic → JSON Schema → REST endpoint with `Cache-Control: public, max-age=86400` + WS mirror + TanStack Query consumer.++**What's still deferred for Wave 7:**+- Phase 3e (flag flip + frontend nodeDefinitions/* deletion). Adapter is ready; snapshot tests are the remaining prerequisite.+- Phase 5.b (per-component migration from `*_NODE_TYPES` arrays to `getCachedNodeGroups()`).+- Gmail / Calendar / Telegram / Twitter loadOptions loaders (Phase 4 registry is ready for the one-line registrations).+- ParameterRenderer → DIY widget registry (the capstone); now unblocked on backend since NodeSpec's `uiHints` carry widget routing.+## ContextThe MachinaOs frontend was coupled to Ant Design (40 files, 187-line theme file, `ConfigProvider` at root). Pre-migration audit + research docs (now deleted; see git history under commit `4cb3dd9` if needed) prescribed shadcn/ui (canonical components copied via CLI registry) + Radix primitives + Tailwind 4 + JSON Forms for a schema-driven inspector. Phase 0/1 commits (`2209dba`, `7ac69fe`) included hand-written primitives and a toast facade — those got deleted as part of corrected Phase 0 (`cdeebb4`).