Skip to content

Feat/integration/ag UI - #40

Merged
gitsad merged 8 commits into
mainfrom
feat/integration/ag-ui
Jul 3, 2026
Merged

Feat/integration/ag UI#40
gitsad merged 8 commits into
mainfrom
feat/integration/ag-ui

Conversation

@gitsad

@gitsad gitsad commented Jul 3, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Adds the AG-UI protocol adapter (@mobile-reality/mdma-agui) and the runtime/renderer support needed to make MDMA documents fully interactive over an AG-UI agent, plus a backend-driven hydration path so re-opened conversations render pre-populated.

Highlights:

  • AG-UI bridge — streams MDMA documents from an AG-UI agent (reparsing in place so in-flight form edits/focus survive) and routes every user decision back into the agent run: form submit, button, tasklist completion, approve/deny, and webhook trigger. Ships a headless core (createMdmaAgentBridge) plus a React layer (useMdmaAgentStream, MdmaAgentView). AG-UI coupling is isolated to a minimal structural agent interface.
  • initialState hydration — new option on createDocumentStore to seed component values at store creation (e.g. restoring a persisted conversation fetched from a backend). Keyed by component id → its values map (symmetric with getState()), it overlays AST defaults without emitting audit events or marking fields touched, and applies only to freshly-created components so a streaming re-parse never clobbers in-flight edits. Threaded through parseMdma, the bridge, and MdmaAgentView.
  • Renderer support — tasklist now emits ACTION_TRIGGERED (its onComplete action) on the transition into all-items-checked; webhook renders a trigger button emitting INTEGRATION_CALLED.
  • Dead-code cleanup — removed the never-invoked onAction methods from the core attachable handlers (renderers dispatch store actions directly; the methods were unreachable).
  • Docs — new AG-UI integration page + a "Restoring State" section in the demo docs with an interactive conversation preview (fetch → 2s → form hydrates); root README corrections to the validator rules table, auto-fix pipeline, and form examples.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Refactor (no functional change)
  • Documentation
  • CI / tooling

Packages Affected

  • @mobile-reality/mdma-spec
  • @mobile-reality/mdma-parser
  • @mobile-reality/mdma-runtime
  • @mobile-reality/mdma-attachables-core
  • @mobile-reality/mdma-renderer-react
  • @mobile-reality/mdma-prompt-pack

Checklist

  • I have read the CONTRIBUTING guide.
  • My code follows the existing code style (pnpm format and pnpm lint pass).
  • I have added or updated tests that cover my changes.
  • All tests pass (pnpm test).
  • Type-checking passes (pnpm typecheck).
  • I have added a changeset (pnpm changeset) if this change affects published packages.
  • New or changed MDMA schemas are backwards-compatible (or marked as breaking).
  • Sensitive fields are marked with sensitive: true where appropriate.

How to Test

  1. pnpm install && pnpm build
  2. Unit testspnpm --filter @mobile-reality/mdma-runtime --filter @mobile-reality/mdma-agui --filter @mobile-reality/mdma-renderer-react --filter @mobile-reality/mdma-attachables-core test (all green). Covers initialState hydration (values seeded, bindings resolve, no forged audit events, survives updateAst) and bridge routing of tasklist completion / webhook INTEGRATION_CALLED.
  3. Hydration demopnpm --filter @mobile-reality/mdma-demo dev, open Docs → Usage → "Restoring State" → "Show live example →". In the right panel, click "Fetch saved state"; after ~2s the intake form in the agent message re-hydrates from the mock backend snapshot.
  4. AG-UI end-to-end — point <MdmaAgentView agent={httpAgent} /> at an AG-UI agent that streams MDMA. Confirm: form submit / button / completing a tasklist / approve-deny / firing a webhook each resume the agent run; and passing initialState={…} renders a re-opened conversation pre-populated.

Screenshots / Examples

Restore a persisted conversation with a backend snapshot:

// Persist — snapshot each component's values
const snapshot = Object.fromEntries(
  [...store.getState().components].map(([id, c]) => [id, c.values]),
); // → { 'intake-form': { 'patient-name': 'Jane Doe' }, 'approve-1': { status: 'approved' } }

// Restore — seed a fresh store on reload
const store = createDocumentStore(ast, { initialState: snapshot });
// or via the adapter:
<MdmaAgentView agent={agent} initialState={snapshot} />

@gitsad
gitsad merged commit 333df31 into main Jul 3, 2026
1 check passed
@gitsad
gitsad deleted the feat/integration/ag-ui branch July 3, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants