oneie 2.0.2 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +245 -0
- package/CLAUDE.md +725 -0
- package/LICENSE.md +84 -0
- package/README.md +489 -931
- package/folders.yaml +78 -17
- package/one/.obsidian/app.json +1 -0
- package/one/.obsidian/appearance.json +1 -0
- package/one/.obsidian/core-plugins.json +33 -0
- package/one/.obsidian/workspace.json +211 -0
- package/one/connections/a2a.md +551 -0
- package/one/connections/acp.md +761 -0
- package/one/connections/acps.md +731 -0
- package/one/connections/agentkit.md +349 -0
- package/one/connections/agui.md +767 -0
- package/one/connections/any-backend.md +1702 -0
- package/one/connections/ap2.md +998 -0
- package/one/connections/api-docs.md +1891 -0
- package/one/connections/api.md +2190 -0
- package/one/connections/architecture-diagram.md +94 -0
- package/one/connections/communications.md +449 -0
- package/one/connections/connections.md +339 -0
- package/one/connections/copilotkit.md +1559 -0
- package/one/connections/cryptonetworks.md +781 -0
- package/one/connections/documentation.md +1120 -0
- package/one/connections/effect.md +279 -0
- package/one/connections/elizaos.md +1290 -0
- package/one/connections/inference.md +58 -0
- package/one/connections/kyc.md +632 -0
- package/one/connections/mcp.md +842 -0
- package/one/connections/membership.md +1152 -0
- package/one/connections/middleware.md +1067 -0
- package/one/connections/multitenant.md +1341 -0
- package/one/connections/n8n.md +1015 -0
- package/one/connections/patterns.md +89 -0
- package/one/connections/protocols.md +279 -0
- package/one/connections/relationships.md +107 -0
- package/one/connections/schema.md +587 -0
- package/one/connections/service-layer.md +550 -0
- package/one/connections/structure.md +0 -0
- package/one/connections/vectors.md +207 -0
- package/one/connections/wordpress.md +1302 -0
- package/one/connections/workflow-copy.md +905 -0
- package/one/connections/workflow-examples.md +741 -0
- package/one/connections/workflow.md +905 -0
- package/one/connections/workflows/delegation.md +885 -0
- package/one/connections/workflows/frontend.md +1037 -0
- package/one/connections/workflows/strategy.md +903 -0
- package/one/connections/workflows/tasks.md +698 -0
- package/one/connections/x402.md +1249 -0
- package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +412 -0
- package/one/events/FEATURE-2-4-COMPLETE.md +302 -0
- package/one/events/FEATURE_2_3_COMPLETE.md +575 -0
- package/one/events/GROUPS-MIGRATION.md +625 -0
- package/one/events/INSTALL-TESTS.md +293 -0
- package/one/events/INTEGRATION-ARCHITECTURE.md +561 -0
- package/one/events/INTEGRATION-CHECKLIST.md +1234 -0
- package/one/events/INTEGRATION-ORCHESTRATION.md +2623 -0
- package/one/events/INTEGRATION-SUMMARY.md +653 -0
- package/one/events/MIGRATION-REPORT.md +435 -0
- package/one/events/MIGRATION.md +69 -0
- package/one/events/README-archived.md +519 -0
- package/one/events/TEST-SUMMARY.md +393 -0
- package/one/events/TESTS-QUICK-REF.md +262 -0
- package/one/events/events.md +545 -0
- package/one/groups/groups.md +543 -0
- package/one/groups/one.md +599 -0
- package/one/groups/revenue.md +673 -0
- package/one/groups/strategy.md +869 -0
- package/one/groups/vision.md +98 -0
- package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +49 -0
- package/one/knowledge/ai-platform.md +305 -0
- package/one/knowledge/architecture-any-backend.md +1366 -0
- package/one/knowledge/architecture-diagram.md +94 -0
- package/one/knowledge/architecture-frontend.md +930 -0
- package/one/knowledge/architecture.md +2077 -0
- package/one/knowledge/crypto.md +960 -0
- package/one/knowledge/docs/flow.md +0 -0
- package/one/knowledge/dsl.md +1660 -0
- package/one/knowledge/files.md +2471 -0
- package/one/knowledge/frontend.md +1038 -0
- package/one/knowledge/hono.md +2109 -0
- package/one/knowledge/implementation-examples.md +2536 -0
- package/one/knowledge/inference-score.md +159 -0
- package/one/knowledge/knowledge.md +642 -0
- package/one/knowledge/language.md +980 -0
- package/one/knowledge/lessons-learned.md +70 -0
- package/one/knowledge/ontology-6-dimensions.md +0 -0
- package/one/knowledge/ontology-documentation.md +356 -0
- package/one/knowledge/ontology-engineering-specification.md +1292 -0
- package/one/knowledge/ontology-engineering.md +1652 -0
- package/one/knowledge/ontology-frontend-copy-2.md +1492 -0
- package/one/knowledge/ontology-frontend-copy.md +753 -0
- package/one/knowledge/ontology-frontend-specifications.md +2188 -0
- package/one/knowledge/ontology-frontend.md +2427 -0
- package/one/knowledge/ontology-minimal.yaml +299 -0
- package/one/knowledge/ontology.md +2830 -0
- package/one/knowledge/ontology.md.backup +2822 -0
- package/one/knowledge/ontology.yaml +1165 -0
- package/one/knowledge/patterns/backend/convex-mutation-pattern.md +100 -0
- package/one/knowledge/patterns/backend/convex-query-pattern.md +88 -0
- package/one/knowledge/patterns/backend/mutation-template.md +231 -0
- package/one/knowledge/patterns/backend/query-template.md +267 -0
- package/one/knowledge/patterns/backend/service-template.md +237 -0
- package/one/knowledge/patterns/design/component-architecture.md +399 -0
- package/one/knowledge/patterns/design/test-driven-design-pattern.md +162 -0
- package/one/knowledge/patterns/design/wireframe-template.md +216 -0
- package/one/knowledge/patterns/frontend/component-template.md +195 -0
- package/one/knowledge/patterns/frontend/form-template.md +276 -0
- package/one/knowledge/patterns/frontend/page-template.md +178 -0
- package/one/knowledge/patterns/frontend/react-component-pattern.md +128 -0
- package/one/knowledge/patterns/test/acceptance-criteria-template.md +378 -0
- package/one/knowledge/patterns/test/technical-test-template.md +544 -0
- package/one/knowledge/patterns/test/test-driven-pattern.md +140 -0
- package/one/knowledge/patterns/test/user-flow-template.md +254 -0
- package/one/knowledge/provider-creation-guide.md +1064 -0
- package/one/knowledge/quality-loop.md +401 -0
- package/one/knowledge/readme.md +131 -0
- package/one/knowledge/rules.md +626 -0
- package/one/knowledge/score.md +67 -0
- package/one/knowledge/specifications.md +855 -0
- package/one/knowledge/tags.md +130 -0
- package/one/knowledge/todo.md +251 -0
- package/one/license.md +84 -0
- package/one/people/anthony-o-connell.md +440 -0
- package/one/people/people.md +567 -0
- package/one/things/CHECKLIST.md +356 -0
- package/one/things/ONE.md +510 -0
- package/one/things/agents/agent-backend.md +1401 -0
- package/one/things/agents/agent-builder.md +955 -0
- package/one/things/agents/agent-clean.md +709 -0
- package/one/things/agents/agent-clone.md +1341 -0
- package/one/things/agents/agent-designer.md +2177 -0
- package/one/things/agents/agent-director.md +1508 -0
- package/one/things/agents/agent-documenter.md +1049 -0
- package/one/things/agents/agent-frontend.md +1119 -0
- package/one/things/agents/agent-integrator.md +1192 -0
- package/one/things/agents/agent-problem-solver.md +1379 -0
- package/one/things/agents/agent-quality.md +1353 -0
- package/one/things/agents/agent-sales.md +986 -0
- package/one/things/cascade/cascade.yaml +464 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +470 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +264 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts.md +486 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +516 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +544 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +223 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination.md +508 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +609 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +195 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management.md +577 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +797 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +212 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops.md +641 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +610 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +213 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure.md +575 -0
- package/one/things/cascade/docs/examples/readme.md +222 -0
- package/one/things/cascade/docs/getting-started.md +515 -0
- package/one/things/cascade/docs/workflow.md +1372 -0
- package/one/things/cascade/readme.md +336 -0
- package/one/things/cascade/templates/feature-template.md +267 -0
- package/one/things/claude/agents/advocacy-activation-manager.md +685 -0
- package/one/things/claude/agents/advocacy-campaign-designer.md +663 -0
- package/one/things/claude/agents/analyst.md +483 -0
- package/one/things/claude/agents/architect.md +480 -0
- package/one/things/claude/agents/brand-identity-specialist.md +513 -0
- package/one/things/claude/agents/bstp-token-strategist.md +667 -0
- package/one/things/claude/agents/builder-repo.md +489 -0
- package/one/things/claude/agents/bullstamp-community-builder.md +574 -0
- package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +506 -0
- package/one/things/claude/agents/bulltilt-platform-growth.md +567 -0
- package/one/things/claude/agents/company-bullstamp-character.md +587 -0
- package/one/things/claude/agents/company-bullstamp-community.md +292 -0
- package/one/things/claude/agents/company-bullstamp-marketing.md +292 -0
- package/one/things/claude/agents/company-bullstamp-token.md +292 -0
- package/one/things/claude/agents/company-bulltilt-growth.md +292 -0
- package/one/things/claude/agents/content-bibliography-formatter.md +381 -0
- package/one/things/claude/agents/content-calendar-planner.md +448 -0
- package/one/things/claude/agents/content-chapter-formatter.md +488 -0
- package/one/things/claude/agents/content-formatter.md +546 -0
- package/one/things/claude/agents/content-hook-specialist.md +462 -0
- package/one/things/claude/agents/content-image-formatter.md +535 -0
- package/one/things/claude/agents/content-introduction-formatter.md +485 -0
- package/one/things/claude/agents/content-multiplication-engine.md +556 -0
- package/one/things/claude/agents/content-playbook-writer.md +448 -0
- package/one/things/claude/agents/content-team-manager.md +622 -0
- package/one/things/claude/agents/content-toc-formatter.md +522 -0
- package/one/things/claude/agents/convex-backend-specialist.md +2561 -0
- package/one/things/claude/agents/core-manager.md +582 -0
- package/one/things/claude/agents/core-master.md +403 -0
- package/one/things/claude/agents/cross-functional-manager.md +471 -0
- package/one/things/claude/agents/crypto-airdrop-strategist.md +602 -0
- package/one/things/claude/agents/crypto-analytics-educator.md +553 -0
- package/one/things/claude/agents/crypto-architecture-specialist.md +466 -0
- package/one/things/claude/agents/crypto-community-analyst.md +298 -0
- package/one/things/claude/agents/crypto-community-psychologist.md +509 -0
- package/one/things/claude/agents/crypto-dex-optimization-expert.md +538 -0
- package/one/things/claude/agents/crypto-dex-optimizer.md +292 -0
- package/one/things/claude/agents/crypto-diamond-formation-specialist.md +513 -0
- package/one/things/claude/agents/crypto-diamond-hands.md +292 -0
- package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +554 -0
- package/one/things/claude/agents/crypto-engagement-specialist.md +540 -0
- package/one/things/claude/agents/crypto-market-researcher.md +292 -0
- package/one/things/claude/agents/crypto-marketing-orchestrator.md +523 -0
- package/one/things/claude/agents/crypto-network-effect-amplifier.md +569 -0
- package/one/things/claude/agents/crypto-optimization-analyst.md +554 -0
- package/one/things/claude/agents/crypto-strategic-synthesizer.md +517 -0
- package/one/things/claude/agents/crypto-team-manager.md +387 -0
- package/one/things/claude/agents/crypto-token-analyst.md +278 -0
- package/one/things/claude/agents/crypto-viral-content-creator.md +546 -0
- package/one/things/claude/agents/crypto-wallet-identification-expert.md +517 -0
- package/one/things/claude/agents/crypto-wallet-identifier.md +292 -0
- package/one/things/claude/agents/customer-journey-designer.md +481 -0
- package/one/things/claude/agents/customer-success-manager.md +581 -0
- package/one/things/claude/agents/dev.md +413 -0
- package/one/things/claude/agents/documenter.md +546 -0
- package/one/things/claude/agents/elevate-marketing-orchestrator.md +410 -0
- package/one/things/claude/agents/engagement-specialist.md +509 -0
- package/one/things/claude/agents/engineering-architect.md +387 -0
- package/one/things/claude/agents/engineering-business-analyst.md +537 -0
- package/one/things/claude/agents/engineering-developer.md +387 -0
- package/one/things/claude/agents/engineering-director.md +282 -0
- package/one/things/claude/agents/engineering-ingestor.md +649 -0
- package/one/things/claude/agents/engineering-product-manager.md +537 -0
- package/one/things/claude/agents/engineering-product-owner.md +537 -0
- package/one/things/claude/agents/engineering-project-coordinator.md +537 -0
- package/one/things/claude/agents/engineering-quality-assurance.md +393 -0
- package/one/things/claude/agents/engineering-team-manager.md +512 -0
- package/one/things/claude/agents/engineering-user-experience.md +387 -0
- package/one/things/claude/agents/framework-elevate-manager.md +294 -0
- package/one/things/claude/agents/improver.md +763 -0
- package/one/things/claude/agents/intelligence-team-manager.md +385 -0
- package/one/things/claude/agents/lead-capture-expert.md +466 -0
- package/one/things/claude/agents/lead-magnet-creator.md +453 -0
- package/one/things/claude/agents/market-research-analyst.md +412 -0
- package/one/things/claude/agents/marketing-brand-identity.md +314 -0
- package/one/things/claude/agents/marketing-content-hooks.md +450 -0
- package/one/things/claude/agents/marketing-content-multiplier.md +326 -0
- package/one/things/claude/agents/marketing-content-poster.md +361 -0
- package/one/things/claude/agents/marketing-customer-journey.md +326 -0
- package/one/things/claude/agents/marketing-director.md +397 -0
- package/one/things/claude/agents/marketing-engagement.md +326 -0
- package/one/things/claude/agents/marketing-lead-capture.md +326 -0
- package/one/things/claude/agents/marketing-lead-magnet.md +326 -0
- package/one/things/claude/agents/marketing-network-effects.md +326 -0
- package/one/things/claude/agents/marketing-nurture-campaigns.md +326 -0
- package/one/things/claude/agents/marketing-share-optimizer.md +326 -0
- package/one/things/claude/agents/marketing-team-manager.md +446 -0
- package/one/things/claude/agents/marketing-viral-growth.md +201 -0
- package/one/things/claude/agents/mission-commander.md +373 -0
- package/one/things/claude/agents/network-effect-analyst.md +587 -0
- package/one/things/claude/agents/nextjs-15-specialist.md +1547 -0
- package/one/things/claude/agents/npx.md +890 -0
- package/one/things/claude/agents/nurture-campaign-manager.md +531 -0
- package/one/things/claude/agents/one-master.md +355 -0
- package/one/things/claude/agents/one-orchestrator.md +315 -0
- package/one/things/claude/agents/one.md +601 -0
- package/one/things/claude/agents/playbook-generator.md +503 -0
- package/one/things/claude/agents/pm.md +326 -0
- package/one/things/claude/agents/po.md +345 -0
- package/one/things/claude/agents/qa.md +336 -0
- package/one/things/claude/agents/research-foundation-analyst.md +307 -0
- package/one/things/claude/agents/research-intelligence-gatherer.md +408 -0
- package/one/things/claude/agents/research-market-analyst.md +307 -0
- package/one/things/claude/agents/research-team-manager.md +482 -0
- package/one/things/claude/agents/sales-environment-optimizer.md +494 -0
- package/one/things/claude/agents/sales-team-manager.md +400 -0
- package/one/things/claude/agents/sales-upsell-strategist.md +307 -0
- package/one/things/claude/agents/service-advocacy-campaigns.md +307 -0
- package/one/things/claude/agents/service-advocacy-manager.md +307 -0
- package/one/things/claude/agents/service-success-manager.md +307 -0
- package/one/things/claude/agents/service-team-manager.md +400 -0
- package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +2302 -0
- package/one/things/claude/agents/share-optimization-specialist.md +551 -0
- package/one/things/claude/agents/sm.md +327 -0
- package/one/things/claude/agents/story-teller.md +473 -0
- package/one/things/claude/agents/task-master.md +596 -0
- package/one/things/claude/agents/tauri-cross-platform-specialist.md +1827 -0
- package/one/things/claude/agents/tester.md +556 -0
- package/one/things/claude/agents/the-bull-character-manager.md +580 -0
- package/one/things/claude/agents/tools-playbook-generator.md +489 -0
- package/one/things/claude/agents/turbo-repo-builder.md +316 -0
- package/one/things/claude/agents/upsell-strategist.md +480 -0
- package/one/things/claude/agents/ux-expert.md +335 -0
- package/one/things/claude/agents/viral-growth-orchestrator.md +497 -0
- package/one/things/claude/claude-code-hooks-development.json +21 -0
- package/one/things/claude/claude-code-hooks-production.json +21 -0
- package/one/things/claude/claude-code-hooks.json +25 -0
- package/one/things/claude/commands/agent.md +104 -0
- package/one/things/claude/commands/cascade-status.md +128 -0
- package/one/things/claude/commands/ingest.md +290 -0
- package/one/things/claude/commands/ingestor.md +136 -0
- package/one/things/claude/commands/mission.md +83 -0
- package/one/things/claude/commands/npx.md +133 -0
- package/one/things/claude/commands/one.md +440 -0
- package/one/things/claude/commands/quality-check.md +204 -0
- package/one/things/claude/commands/smart-route.md +220 -0
- package/one/things/claude/commands/start.md +121 -0
- package/one/things/claude/commands/story.md +83 -0
- package/one/things/claude/commands/task.md +173 -0
- package/one/things/claude/hook-bypass.json +32 -0
- package/one/things/claude/hooks/agent-hook-config.json +427 -0
- package/one/things/claude/hooks/agent-hook-manager.js +525 -0
- package/one/things/claude/hooks/agent-load-balancer.js +271 -0
- package/one/things/claude/hooks/agent-request-interceptor.js +70 -0
- package/one/things/claude/hooks/build-hook.sh +156 -0
- package/one/things/claude/hooks/cascade-feedback.js +297 -0
- package/one/things/claude/hooks/cascade-integration-hooks.js +648 -0
- package/one/things/claude/hooks/cleanup-hook.sh +201 -0
- package/one/things/claude/hooks/continuous-improvement-monitor.js +510 -0
- package/one/things/claude/hooks/file-organization-engine.js +427 -0
- package/one/things/claude/hooks/file-organization-hook.sh +80 -0
- package/one/things/claude/hooks/file-organization-monitor.js +269 -0
- package/one/things/claude/hooks/format-hook.sh +43 -0
- package/one/things/claude/hooks/hook-bypass.sh +293 -0
- package/one/things/claude/hooks/hook-config-manager.js +202 -0
- package/one/things/claude/hooks/hook-debouncer.sh +62 -0
- package/one/things/claude/hooks/hook-logger.sh +89 -0
- package/one/things/claude/hooks/hook-orchestrator.js +662 -0
- package/one/things/claude/hooks/hook-performance-report.js +120 -0
- package/one/things/claude/hooks/lint-hook.sh +140 -0
- package/one/things/claude/hooks/mcp-cascade-integration.js +816 -0
- package/one/things/claude/hooks/memory-optimizer.js +510 -0
- package/one/things/claude/hooks/notification-hook.sh +204 -0
- package/one/things/claude/hooks/ontology-compliance.js +394 -0
- package/one/things/claude/hooks/ontology-hook-manager.js +316 -0
- package/one/things/claude/hooks/ontology-validation-engine.js +317 -0
- package/one/things/claude/hooks/ontology-validation-hook.sh +86 -0
- package/one/things/claude/hooks/performance-metrics.json +25 -0
- package/one/things/claude/hooks/performance-monitoring-hook.js +422 -0
- package/one/things/claude/hooks/quality-scoring-engine.js +834 -0
- package/one/things/claude/hooks/security-hook.sh +256 -0
- package/one/things/claude/hooks/simple-load-balancer.js +238 -0
- package/one/things/claude/hooks/startup-optimizer.js +625 -0
- package/one/things/claude/hooks/story-scoring-system.js +445 -0
- package/one/things/claude/hooks/story-validation-engine.js +473 -0
- package/one/things/claude/hooks/story-validation-hook-enhanced.sh +210 -0
- package/one/things/claude/hooks/story-validation-hook.sh +145 -0
- package/one/things/claude/hooks/structure-synchronizer.js +194 -0
- package/one/things/claude/hooks/sub-agent-output-validator.js +647 -0
- package/one/things/claude/hooks/sub-agent-validation-hook.js +343 -0
- package/one/things/claude/hooks/test-hook.sh +145 -0
- package/one/things/claude/hooks/test-story-validation.sh +170 -0
- package/one/things/claude/hooks/trinity-validation-system.js +392 -0
- package/one/things/claude/settings-local.json +86 -0
- package/one/things/cli/cli-code.md +652 -0
- package/one/things/cli/cli-compiler-code.md +652 -0
- package/one/things/cli/cli.md +1068 -0
- package/one/things/components/card-shadcn.md +929 -0
- package/one/things/components/card.md +1050 -0
- package/one/things/components.md +1669 -0
- package/one/things/componets.md +4 -0
- package/one/things/creator-diagram.md +166 -0
- package/one/things/examples/children/lemonade-stand.md +366 -0
- package/one/things/examples/enterprise/crm-saas.md +1429 -0
- package/one/things/features/1-1-agent-prompts/design.md +470 -0
- package/one/things/features/1-1-agent-prompts/tests.md +264 -0
- package/one/things/features/1-1-agent-prompts.md +486 -0
- package/one/things/features/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/features/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/features/1-2-yaml-orchestrator.md +516 -0
- package/one/things/features/1-3-event-coordination/design.md +544 -0
- package/one/things/features/1-3-event-coordination/tests.md +223 -0
- package/one/things/features/1-3-event-coordination.md +508 -0
- package/one/things/features/1-4-knowledge-management/design.md +609 -0
- package/one/things/features/1-4-knowledge-management/tests.md +195 -0
- package/one/things/features/1-4-knowledge-management.md +577 -0
- package/one/things/features/1-5-quality-loops/design.md +797 -0
- package/one/things/features/1-5-quality-loops/tests.md +212 -0
- package/one/things/features/1-5-quality-loops.md +641 -0
- package/one/things/features/1-6-numbering-structure/design.md +610 -0
- package/one/things/features/1-6-numbering-structure/tests.md +213 -0
- package/one/things/features/1-6-numbering-structure.md +575 -0
- package/one/things/features/2-1-dataprovider-interface.md +2358 -0
- package/one/things/features/2-2-config-system.md +3075 -0
- package/one/things/features/2-3-effectts-services.md +1498 -0
- package/one/things/features/2-4-react-hooks.md +2120 -0
- package/one/things/features/2-5-auth-migration.md +2046 -0
- package/one/things/features/2-6-dashboard-migration.md +1985 -0
- package/one/things/features/2-7-alternative-providers.md +2505 -0
- package/one/things/features/2-7-implementation-report.md +680 -0
- package/one/things/features/2-cli.md +1235 -0
- package/one/things/features/2-design.md +1738 -0
- package/one/things/features/2-tests.md +520 -0
- package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +521 -0
- package/one/things/features/DECOUPLING.md +272 -0
- package/one/things/features/DEPLOYMENT.md +452 -0
- package/one/things/features/IMPLEMENTATION_SUMMARY.md +316 -0
- package/one/things/features/dataprovider-interface/1-tests.md +1522 -0
- package/one/things/features/improve.md +843 -0
- package/one/things/features/remove-convex-deps.md +45 -0
- package/one/things/features/top-features.md +79 -0
- package/one/things/features/use-one-backend.md +1180 -0
- package/one/things/ideas/1-create-workflow.md +189 -0
- package/one/things/ideas/2-backend-agnostic-frontend.md +384 -0
- package/one/things/plans/1-create-workflow-status.md +555 -0
- package/one/things/plans/1-create-workflow.md +713 -0
- package/one/things/plans/2-backend-agnostic-frontend.md +543 -0
- package/one/things/plans/3-groups.md +502 -0
- package/one/things/plans/app.md +761 -0
- package/one/things/plans/backend-agnostic-frontend.md +323 -0
- package/one/things/plans/better-auth-any-backend-revised.md +1065 -0
- package/one/things/plans/better-auth-any-backend.md +1852 -0
- package/one/things/plans/better-auth-available-features.md +235 -0
- package/one/things/plans/big-plan.md +38 -0
- package/one/things/plans/convex-better-auth.md +1109 -0
- package/one/things/plans/convex-on-off.md +389 -0
- package/one/things/plans/deploy-to-cloudflare.md +581 -0
- package/one/things/plans/desktop.md +1121 -0
- package/one/things/plans/effect-components.md +1669 -0
- package/one/things/plans/effect.md +973 -0
- package/one/things/plans/email.md +953 -0
- package/one/things/plans/enhance-auth.md +1669 -0
- package/one/things/plans/install-components.md +198 -0
- package/one/things/plans/landing.md +728 -0
- package/one/things/plans/layout.md +205 -0
- package/one/things/plans/mail-backend.md +1308 -0
- package/one/things/plans/mail.md +2624 -0
- package/one/things/plans/next-features.md +83 -0
- package/one/things/plans/one.md +658 -0
- package/one/things/plans/ontology-6-dimensions.md +2216 -0
- package/one/things/plans/ontology-driven-strategy.md +866 -0
- package/one/things/plans/ontology-ui-approach.md +357 -0
- package/one/things/plans/open-agent.md +785 -0
- package/one/things/plans/organizations-to-groups.md +705 -0
- package/one/things/plans/performace.md +90 -0
- package/one/things/plans/release.md +432 -0
- package/one/things/plans/releases.md +809 -0
- package/one/things/plans/repos.md +76 -0
- package/one/things/plans/separate-copy-2.md +1293 -0
- package/one/things/plans/separate-copy-3.md +2458 -0
- package/one/things/plans/separate-copy.md +1293 -0
- package/one/things/plans/separate.md +1983 -0
- package/one/things/plans/shadcn-integration-summary.md +450 -0
- package/one/things/plans/sidebar.md +172 -0
- package/one/things/plans/small-fixes.md +5 -0
- package/one/things/plans/test-backend-connection.md +476 -0
- package/one/things/plans/workflow-files.md +1196 -0
- package/one/things/plans/workflow.md +1372 -0
- package/one/things/products/cascade-landing-page.md +737 -0
- package/one/things/products/cascade.md +1518 -0
- package/one/things/products/context-engineering.md +1427 -0
- package/one/things/products/onthology.md +0 -0
- package/one/things/products/ontology-ui-shadcn.md +1280 -0
- package/one/things/products/ontology-ui.md +1387 -0
- package/one/things/products/ontology.md +717 -0
- package/one/things/products/sdk.md +557 -0
- package/one/things/promptkit.md +903 -0
- package/one/things/service-providers-new.md +982 -0
- package/one/things/service-providers.md +1092 -0
- package/one/things/system.md +600 -0
- package/one/things/tests/2-1-dataprovider-interface.md +1144 -0
- package/one/things/tests/2-1-test-analysis.md +496 -0
- package/one/things/things.md +349 -0
- package/one/things/todo.md +1248 -0
- package/one/things/vision/elegant-interface.md +214 -0
- package/package.json +5 -2
|
@@ -0,0 +1,1559 @@
|
|
|
1
|
+
# Generative UI and AG-UI Protocol - Building on PromptKit
|
|
2
|
+
|
|
3
|
+
**Version:** 2.0.0
|
|
4
|
+
**Purpose:** Extract generative UI and AG-UI protocol patterns from CopilotKit to build advanced AI agent interfaces on top of PromptKit + Effect.ts + Convex
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
This document extracts the key architectural patterns from **CopilotKit** (an MIT-licensed AI copilot framework) and shows how to implement them using our existing stack:
|
|
11
|
+
|
|
12
|
+
- **UI Layer:** PromptKit (shadcn-based components)
|
|
13
|
+
- **AI Layer:** Vercel AI SDK 5
|
|
14
|
+
- **Backend:** Convex + Effect.ts
|
|
15
|
+
- **Patterns:** CopilotKit-inspired AG-UI protocol and generative UI
|
|
16
|
+
|
|
17
|
+
**What We Learn from CopilotKit:**
|
|
18
|
+
1. ✅ **AG-UI Protocol** - Agent-to-frontend communication protocol
|
|
19
|
+
2. ✅ **Generative UI** - Agents dynamically rendering UI components
|
|
20
|
+
3. ✅ **Context Sharing** - Bidirectional state between app and agents
|
|
21
|
+
4. ✅ **Action Patterns** - Human-in-the-loop agent actions
|
|
22
|
+
5. ✅ **Multi-Agent Orchestration** - Coordinating multiple agents
|
|
23
|
+
|
|
24
|
+
**What We Build Ourselves:**
|
|
25
|
+
- AG-UI protocol implementation (Effect.ts services)
|
|
26
|
+
- Generative UI renderer (PromptKit + shadcn components)
|
|
27
|
+
- Context management (Convex real-time queries)
|
|
28
|
+
- Action system (Convex mutations)
|
|
29
|
+
- Agent coordination (Effect.ts composition)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Architecture: PromptKit + AG-UI Protocol
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
37
|
+
│ FRONTEND (React + Astro) │
|
|
38
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
39
|
+
│ PromptKit Components (shadcn/ui based) │
|
|
40
|
+
│ ├─ <Message> - Chat messages with markdown │
|
|
41
|
+
│ ├─ <PromptInput> - Auto-resize textarea │
|
|
42
|
+
│ ├─ <ChatContainer> - Auto-scroll │
|
|
43
|
+
│ ├─ <Reasoning> - Show agent thinking │
|
|
44
|
+
│ ├─ <Tool> - Display function calls │
|
|
45
|
+
│ └─ <ResponseStream> - Streaming responses │
|
|
46
|
+
│ │
|
|
47
|
+
│ Generative UI Renderer (Our Implementation) │
|
|
48
|
+
│ ├─ <GenerativeUIRenderer> - Render agent UI messages │
|
|
49
|
+
│ ├─ <DynamicChart> - Agent-generated charts │
|
|
50
|
+
│ ├─ <DynamicTable> - Agent-generated tables │
|
|
51
|
+
│ ├─ <DynamicForm> - Agent-generated forms │
|
|
52
|
+
│ └─ <ActionButtons> - Agent-suggested actions │
|
|
53
|
+
└──────────────────┬──────────────────────────────────────────────┘
|
|
54
|
+
│
|
|
55
|
+
↓ AG-UI Protocol Messages
|
|
56
|
+
┌──────────────────┐
|
|
57
|
+
│ Convex Backend │
|
|
58
|
+
│ (Real-time DB) │
|
|
59
|
+
└────────┬─────────┘
|
|
60
|
+
│
|
|
61
|
+
↓
|
|
62
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
63
|
+
│ Effect.ts Service Layer (100% Ours) │
|
|
64
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
65
|
+
│ AgentUIService - Implements AG-UI protocol │
|
|
66
|
+
│ ├─ sendTextMessage(conversationId, text) │
|
|
67
|
+
│ ├─ sendUIComponent(conversationId, component) │
|
|
68
|
+
│ ├─ sendActionSuggestion(conversationId, actions) │
|
|
69
|
+
│ └─ requestContext(conversationId, fields) │
|
|
70
|
+
│ │
|
|
71
|
+
│ Agent Services - Use AG-UI to communicate │
|
|
72
|
+
│ ├─ IntelligenceAgent - Sends charts, tables, insights │
|
|
73
|
+
│ ├─ StrategyAgent - Sends plans, timelines, actions │
|
|
74
|
+
│ ├─ MarketingAgent - Sends content previews, campaigns │
|
|
75
|
+
│ └─ Any agent can send structured UI via AG-UI protocol │
|
|
76
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Key Principle:** Agents return structured UI data (not HTML), frontend renders it with PromptKit components.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Part 1: AG-UI Protocol Implementation
|
|
84
|
+
|
|
85
|
+
### What is AG-UI Protocol?
|
|
86
|
+
|
|
87
|
+
**AG-UI (Agent-Generated User Interface)** is a communication protocol that allows AI agents to:
|
|
88
|
+
- Send structured UI data to the frontend
|
|
89
|
+
- Request context from the application
|
|
90
|
+
- Suggest actions for user approval
|
|
91
|
+
- Stream thinking/reasoning process
|
|
92
|
+
|
|
93
|
+
**CopilotKit's AG-UI Concept:**
|
|
94
|
+
```typescript
|
|
95
|
+
// Agent sends structured UI messages
|
|
96
|
+
{
|
|
97
|
+
type: 'ui',
|
|
98
|
+
component: 'Chart',
|
|
99
|
+
data: { /* chart configuration */ }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Agent requests context
|
|
103
|
+
{
|
|
104
|
+
type: 'context_request',
|
|
105
|
+
fields: ['user.cart', 'user.preferences']
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Agent suggests actions
|
|
109
|
+
{
|
|
110
|
+
type: 'action',
|
|
111
|
+
actions: [{ id: 'update_cart', params: {...} }]
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Our AG-UI Protocol Schema
|
|
116
|
+
|
|
117
|
+
**File:** `convex/protocols/agent-ui.ts`
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { v } from 'convex/values';
|
|
121
|
+
import type { Id } from '../_generated/dataModel';
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* AG-UI Protocol Message Types
|
|
125
|
+
* Based on CopilotKit's AG-UI concept, implemented for our stack
|
|
126
|
+
*/
|
|
127
|
+
export const AgentUIMessageType = {
|
|
128
|
+
TEXT: 'text', // Plain text message
|
|
129
|
+
UI: 'ui', // Structured UI component
|
|
130
|
+
ACTION: 'action', // Action suggestions
|
|
131
|
+
CONTEXT_REQUEST: 'context_request', // Request app context
|
|
132
|
+
REASONING: 'reasoning', // Agent thinking process
|
|
133
|
+
TOOL_CALL: 'tool_call', // Function/tool execution
|
|
134
|
+
ERROR: 'error', // Error message
|
|
135
|
+
} as const;
|
|
136
|
+
|
|
137
|
+
export type AgentUIMessageType =
|
|
138
|
+
(typeof AgentUIMessageType)[keyof typeof AgentUIMessageType];
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Base AG-UI Message
|
|
142
|
+
*/
|
|
143
|
+
export interface AgentUIMessage {
|
|
144
|
+
type: AgentUIMessageType;
|
|
145
|
+
agentId: Id<'entities'>;
|
|
146
|
+
conversationId: Id<'entities'>;
|
|
147
|
+
timestamp: number;
|
|
148
|
+
payload: AgentUIPayload;
|
|
149
|
+
metadata?: {
|
|
150
|
+
correlationId?: string; // Link related messages
|
|
151
|
+
replyTo?: Id<'entities'>; // Reply to specific message
|
|
152
|
+
[key: string]: any;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* AG-UI Payload Types
|
|
158
|
+
*/
|
|
159
|
+
export type AgentUIPayload =
|
|
160
|
+
| TextPayload
|
|
161
|
+
| UIPayload
|
|
162
|
+
| ActionPayload
|
|
163
|
+
| ContextRequestPayload
|
|
164
|
+
| ReasoningPayload
|
|
165
|
+
| ToolCallPayload
|
|
166
|
+
| ErrorPayload;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Text Message Payload
|
|
170
|
+
*/
|
|
171
|
+
export interface TextPayload {
|
|
172
|
+
type: 'text';
|
|
173
|
+
text: string;
|
|
174
|
+
sentiment?: 'positive' | 'neutral' | 'negative';
|
|
175
|
+
formatting?: {
|
|
176
|
+
bold?: boolean;
|
|
177
|
+
italic?: boolean;
|
|
178
|
+
code?: boolean;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* UI Component Payload
|
|
184
|
+
* Agents send structured component data, frontend renders it
|
|
185
|
+
*/
|
|
186
|
+
export interface UIPayload {
|
|
187
|
+
type: 'ui';
|
|
188
|
+
component: UIComponentType;
|
|
189
|
+
data: any;
|
|
190
|
+
layout?: {
|
|
191
|
+
width?: 'full' | 'half' | 'third';
|
|
192
|
+
height?: string;
|
|
193
|
+
position?: 'inline' | 'modal' | 'sidebar';
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export type UIComponentType =
|
|
198
|
+
| 'chart'
|
|
199
|
+
| 'table'
|
|
200
|
+
| 'card'
|
|
201
|
+
| 'form'
|
|
202
|
+
| 'list'
|
|
203
|
+
| 'timeline'
|
|
204
|
+
| 'calendar'
|
|
205
|
+
| 'kanban'
|
|
206
|
+
| 'map'
|
|
207
|
+
| 'custom';
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Chart Component Data
|
|
211
|
+
*/
|
|
212
|
+
export interface ChartComponentData {
|
|
213
|
+
component: 'chart';
|
|
214
|
+
data: {
|
|
215
|
+
title: string;
|
|
216
|
+
description?: string;
|
|
217
|
+
chartType: 'line' | 'bar' | 'pie' | 'area' | 'scatter' | 'radar';
|
|
218
|
+
labels: string[];
|
|
219
|
+
datasets: Array<{
|
|
220
|
+
label: string;
|
|
221
|
+
data: number[];
|
|
222
|
+
color?: string;
|
|
223
|
+
fill?: boolean;
|
|
224
|
+
}>;
|
|
225
|
+
options?: any; // Recharts options
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Table Component Data
|
|
231
|
+
*/
|
|
232
|
+
export interface TableComponentData {
|
|
233
|
+
component: 'table';
|
|
234
|
+
data: {
|
|
235
|
+
title: string;
|
|
236
|
+
description?: string;
|
|
237
|
+
headers: string[];
|
|
238
|
+
rows: Array<Array<string | number | boolean>>;
|
|
239
|
+
sortable?: boolean;
|
|
240
|
+
filterable?: boolean;
|
|
241
|
+
pagination?: {
|
|
242
|
+
pageSize: number;
|
|
243
|
+
currentPage: number;
|
|
244
|
+
totalPages: number;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Card Component Data
|
|
251
|
+
*/
|
|
252
|
+
export interface CardComponentData {
|
|
253
|
+
component: 'card';
|
|
254
|
+
data: {
|
|
255
|
+
title: string;
|
|
256
|
+
description?: string;
|
|
257
|
+
content: string | any;
|
|
258
|
+
footer?: string;
|
|
259
|
+
actions?: Array<{
|
|
260
|
+
label: string;
|
|
261
|
+
actionId: string;
|
|
262
|
+
variant?: 'default' | 'destructive' | 'outline';
|
|
263
|
+
}>;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Form Component Data
|
|
269
|
+
*/
|
|
270
|
+
export interface FormComponentData {
|
|
271
|
+
component: 'form';
|
|
272
|
+
data: {
|
|
273
|
+
title: string;
|
|
274
|
+
description?: string;
|
|
275
|
+
fields: Array<{
|
|
276
|
+
name: string;
|
|
277
|
+
label: string;
|
|
278
|
+
type: 'text' | 'email' | 'number' | 'select' | 'checkbox' | 'date';
|
|
279
|
+
required?: boolean;
|
|
280
|
+
options?: string[]; // For select fields
|
|
281
|
+
defaultValue?: any;
|
|
282
|
+
validation?: any;
|
|
283
|
+
}>;
|
|
284
|
+
submitLabel?: string;
|
|
285
|
+
onSubmitActionId: string;
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Action Suggestion Payload
|
|
291
|
+
*/
|
|
292
|
+
export interface ActionPayload {
|
|
293
|
+
type: 'action';
|
|
294
|
+
actions: Array<{
|
|
295
|
+
id: string;
|
|
296
|
+
label: string;
|
|
297
|
+
description?: string;
|
|
298
|
+
icon?: string;
|
|
299
|
+
params?: Record<string, any>;
|
|
300
|
+
confirmationRequired?: boolean;
|
|
301
|
+
confirmationMessage?: string;
|
|
302
|
+
}>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Context Request Payload
|
|
307
|
+
*/
|
|
308
|
+
export interface ContextRequestPayload {
|
|
309
|
+
type: 'context_request';
|
|
310
|
+
fields: string[]; // e.g., ['user.cart', 'user.preferences', 'app.currentPage']
|
|
311
|
+
reason: string; // Why agent needs this context
|
|
312
|
+
optional?: boolean;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Reasoning/Thinking Payload
|
|
317
|
+
*/
|
|
318
|
+
export interface ReasoningPayload {
|
|
319
|
+
type: 'reasoning';
|
|
320
|
+
steps: Array<{
|
|
321
|
+
step: number;
|
|
322
|
+
title: string;
|
|
323
|
+
description: string;
|
|
324
|
+
completed: boolean;
|
|
325
|
+
result?: any;
|
|
326
|
+
}>;
|
|
327
|
+
currentStep?: number;
|
|
328
|
+
streaming?: boolean;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Tool Call Payload
|
|
333
|
+
*/
|
|
334
|
+
export interface ToolCallPayload {
|
|
335
|
+
type: 'tool_call';
|
|
336
|
+
toolName: string;
|
|
337
|
+
arguments: Record<string, any>;
|
|
338
|
+
result?: any;
|
|
339
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
340
|
+
error?: string;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Error Payload
|
|
345
|
+
*/
|
|
346
|
+
export interface ErrorPayload {
|
|
347
|
+
type: 'error';
|
|
348
|
+
message: string;
|
|
349
|
+
code?: string;
|
|
350
|
+
recoverable?: boolean;
|
|
351
|
+
retryable?: boolean;
|
|
352
|
+
details?: any;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Convex validators for AG-UI messages
|
|
357
|
+
*/
|
|
358
|
+
export const agentUIMessageValidator = {
|
|
359
|
+
type: v.union(
|
|
360
|
+
v.literal('text'),
|
|
361
|
+
v.literal('ui'),
|
|
362
|
+
v.literal('action'),
|
|
363
|
+
v.literal('context_request'),
|
|
364
|
+
v.literal('reasoning'),
|
|
365
|
+
v.literal('tool_call'),
|
|
366
|
+
v.literal('error')
|
|
367
|
+
),
|
|
368
|
+
agentId: v.id('entities'),
|
|
369
|
+
conversationId: v.id('entities'),
|
|
370
|
+
timestamp: v.number(),
|
|
371
|
+
payload: v.any(), // Typed in TypeScript, flexible in Convex
|
|
372
|
+
metadata: v.optional(v.any()),
|
|
373
|
+
};
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### AgentUIService - Effect.ts Implementation
|
|
377
|
+
|
|
378
|
+
**File:** `convex/services/agent-ui.ts`
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
import { Effect } from 'effect';
|
|
382
|
+
import { ConvexDatabase } from './convex-database';
|
|
383
|
+
import type { Id } from '../_generated/dataModel';
|
|
384
|
+
import type {
|
|
385
|
+
AgentUIMessage,
|
|
386
|
+
TextPayload,
|
|
387
|
+
UIPayload,
|
|
388
|
+
ActionPayload,
|
|
389
|
+
ContextRequestPayload,
|
|
390
|
+
ReasoningPayload,
|
|
391
|
+
ToolCallPayload,
|
|
392
|
+
ErrorPayload,
|
|
393
|
+
} from '../protocols/agent-ui';
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* AgentUIService - Implements AG-UI Protocol
|
|
397
|
+
* Allows agents to send structured UI updates to the frontend
|
|
398
|
+
*/
|
|
399
|
+
export class AgentUIService extends Effect.Service<AgentUIService>()(
|
|
400
|
+
'AgentUIService',
|
|
401
|
+
{
|
|
402
|
+
effect: Effect.gen(function* () {
|
|
403
|
+
const db = yield* ConvexDatabase;
|
|
404
|
+
|
|
405
|
+
return {
|
|
406
|
+
/**
|
|
407
|
+
* Send text message
|
|
408
|
+
*/
|
|
409
|
+
sendText: (args: {
|
|
410
|
+
agentId: Id<'entities'>;
|
|
411
|
+
conversationId: Id<'entities'>;
|
|
412
|
+
text: string;
|
|
413
|
+
sentiment?: 'positive' | 'neutral' | 'negative';
|
|
414
|
+
}) =>
|
|
415
|
+
Effect.gen(function* () {
|
|
416
|
+
const message: AgentUIMessage = {
|
|
417
|
+
type: 'text',
|
|
418
|
+
agentId: args.agentId,
|
|
419
|
+
conversationId: args.conversationId,
|
|
420
|
+
timestamp: Date.now(),
|
|
421
|
+
payload: {
|
|
422
|
+
type: 'text',
|
|
423
|
+
text: args.text,
|
|
424
|
+
sentiment: args.sentiment,
|
|
425
|
+
} as TextPayload,
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
return yield* storeMessage(db, message);
|
|
429
|
+
}),
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Send UI component
|
|
433
|
+
*/
|
|
434
|
+
sendUI: (args: {
|
|
435
|
+
agentId: Id<'entities'>;
|
|
436
|
+
conversationId: Id<'entities'>;
|
|
437
|
+
component: any; // ChartComponentData | TableComponentData | etc.
|
|
438
|
+
}) =>
|
|
439
|
+
Effect.gen(function* () {
|
|
440
|
+
const message: AgentUIMessage = {
|
|
441
|
+
type: 'ui',
|
|
442
|
+
agentId: args.agentId,
|
|
443
|
+
conversationId: args.conversationId,
|
|
444
|
+
timestamp: Date.now(),
|
|
445
|
+
payload: {
|
|
446
|
+
type: 'ui',
|
|
447
|
+
component: args.component.component,
|
|
448
|
+
data: args.component.data,
|
|
449
|
+
layout: args.component.layout,
|
|
450
|
+
} as UIPayload,
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
return yield* storeMessage(db, message);
|
|
454
|
+
}),
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Send action suggestions
|
|
458
|
+
*/
|
|
459
|
+
sendActions: (args: {
|
|
460
|
+
agentId: Id<'entities'>;
|
|
461
|
+
conversationId: Id<'entities'>;
|
|
462
|
+
actions: Array<{
|
|
463
|
+
id: string;
|
|
464
|
+
label: string;
|
|
465
|
+
description?: string;
|
|
466
|
+
params?: any;
|
|
467
|
+
}>;
|
|
468
|
+
}) =>
|
|
469
|
+
Effect.gen(function* () {
|
|
470
|
+
const message: AgentUIMessage = {
|
|
471
|
+
type: 'action',
|
|
472
|
+
agentId: args.agentId,
|
|
473
|
+
conversationId: args.conversationId,
|
|
474
|
+
timestamp: Date.now(),
|
|
475
|
+
payload: {
|
|
476
|
+
type: 'action',
|
|
477
|
+
actions: args.actions,
|
|
478
|
+
} as ActionPayload,
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
return yield* storeMessage(db, message);
|
|
482
|
+
}),
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Request context from frontend
|
|
486
|
+
*/
|
|
487
|
+
requestContext: (args: {
|
|
488
|
+
agentId: Id<'entities'>;
|
|
489
|
+
conversationId: Id<'entities'>;
|
|
490
|
+
fields: string[];
|
|
491
|
+
reason: string;
|
|
492
|
+
}) =>
|
|
493
|
+
Effect.gen(function* () {
|
|
494
|
+
const message: AgentUIMessage = {
|
|
495
|
+
type: 'context_request',
|
|
496
|
+
agentId: args.agentId,
|
|
497
|
+
conversationId: args.conversationId,
|
|
498
|
+
timestamp: Date.now(),
|
|
499
|
+
payload: {
|
|
500
|
+
type: 'context_request',
|
|
501
|
+
fields: args.fields,
|
|
502
|
+
reason: args.reason,
|
|
503
|
+
} as ContextRequestPayload,
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
return yield* storeMessage(db, message);
|
|
507
|
+
}),
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Send reasoning/thinking steps
|
|
511
|
+
*/
|
|
512
|
+
sendReasoning: (args: {
|
|
513
|
+
agentId: Id<'entities'>;
|
|
514
|
+
conversationId: Id<'entities'>;
|
|
515
|
+
steps: Array<{
|
|
516
|
+
step: number;
|
|
517
|
+
title: string;
|
|
518
|
+
description: string;
|
|
519
|
+
completed: boolean;
|
|
520
|
+
}>;
|
|
521
|
+
}) =>
|
|
522
|
+
Effect.gen(function* () {
|
|
523
|
+
const message: AgentUIMessage = {
|
|
524
|
+
type: 'reasoning',
|
|
525
|
+
agentId: args.agentId,
|
|
526
|
+
conversationId: args.conversationId,
|
|
527
|
+
timestamp: Date.now(),
|
|
528
|
+
payload: {
|
|
529
|
+
type: 'reasoning',
|
|
530
|
+
steps: args.steps,
|
|
531
|
+
} as ReasoningPayload,
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
return yield* storeMessage(db, message);
|
|
535
|
+
}),
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Send tool call update
|
|
539
|
+
*/
|
|
540
|
+
sendToolCall: (args: {
|
|
541
|
+
agentId: Id<'entities'>;
|
|
542
|
+
conversationId: Id<'entities'>;
|
|
543
|
+
toolName: string;
|
|
544
|
+
arguments: any;
|
|
545
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
546
|
+
result?: any;
|
|
547
|
+
}) =>
|
|
548
|
+
Effect.gen(function* () {
|
|
549
|
+
const message: AgentUIMessage = {
|
|
550
|
+
type: 'tool_call',
|
|
551
|
+
agentId: args.agentId,
|
|
552
|
+
conversationId: args.conversationId,
|
|
553
|
+
timestamp: Date.now(),
|
|
554
|
+
payload: {
|
|
555
|
+
type: 'tool_call',
|
|
556
|
+
toolName: args.toolName,
|
|
557
|
+
arguments: args.arguments,
|
|
558
|
+
status: args.status,
|
|
559
|
+
result: args.result,
|
|
560
|
+
} as ToolCallPayload,
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
return yield* storeMessage(db, message);
|
|
564
|
+
}),
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Send error message
|
|
568
|
+
*/
|
|
569
|
+
sendError: (args: {
|
|
570
|
+
agentId: Id<'entities'>;
|
|
571
|
+
conversationId: Id<'entities'>;
|
|
572
|
+
message: string;
|
|
573
|
+
code?: string;
|
|
574
|
+
recoverable?: boolean;
|
|
575
|
+
}) =>
|
|
576
|
+
Effect.gen(function* () {
|
|
577
|
+
const message: AgentUIMessage = {
|
|
578
|
+
type: 'error',
|
|
579
|
+
agentId: args.agentId,
|
|
580
|
+
conversationId: args.conversationId,
|
|
581
|
+
timestamp: Date.now(),
|
|
582
|
+
payload: {
|
|
583
|
+
type: 'error',
|
|
584
|
+
message: args.message,
|
|
585
|
+
code: args.code,
|
|
586
|
+
recoverable: args.recoverable,
|
|
587
|
+
} as ErrorPayload,
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
return yield* storeMessage(db, message);
|
|
591
|
+
}),
|
|
592
|
+
};
|
|
593
|
+
}),
|
|
594
|
+
dependencies: [ConvexDatabase.Default],
|
|
595
|
+
}
|
|
596
|
+
) {}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Helper: Store AG-UI message in database
|
|
600
|
+
*/
|
|
601
|
+
const storeMessage = (
|
|
602
|
+
db: ConvexDatabase,
|
|
603
|
+
message: AgentUIMessage
|
|
604
|
+
) =>
|
|
605
|
+
Effect.gen(function* () {
|
|
606
|
+
// Store message entity
|
|
607
|
+
const messageId = yield* db.insert('entities', {
|
|
608
|
+
type: 'message',
|
|
609
|
+
name: `AG-UI ${message.type}`,
|
|
610
|
+
properties: {
|
|
611
|
+
conversationId: message.conversationId,
|
|
612
|
+
senderId: message.agentId,
|
|
613
|
+
senderType: 'one_agent',
|
|
614
|
+
content: {
|
|
615
|
+
protocol: 'ag-ui',
|
|
616
|
+
version: '1.0.0',
|
|
617
|
+
message: message,
|
|
618
|
+
},
|
|
619
|
+
timestamp: message.timestamp,
|
|
620
|
+
},
|
|
621
|
+
status: 'active',
|
|
622
|
+
createdAt: Date.now(),
|
|
623
|
+
updatedAt: Date.now(),
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
// Log event
|
|
627
|
+
yield* db.insert('events', {
|
|
628
|
+
type: 'agent_executed',
|
|
629
|
+
actorId: message.agentId,
|
|
630
|
+
targetId: message.conversationId,
|
|
631
|
+
timestamp: Date.now(),
|
|
632
|
+
metadata: {
|
|
633
|
+
action: 'ag_ui_message_sent',
|
|
634
|
+
messageType: message.type,
|
|
635
|
+
messageId: messageId,
|
|
636
|
+
},
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
return messageId;
|
|
640
|
+
});
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
---
|
|
644
|
+
|
|
645
|
+
## Part 2: Generative UI Implementation
|
|
646
|
+
|
|
647
|
+
### Generative UI Concept
|
|
648
|
+
|
|
649
|
+
**Generative UI** allows AI agents to dynamically create UI components based on data. Instead of returning HTML strings, agents return structured component specifications that the frontend renders.
|
|
650
|
+
|
|
651
|
+
**Traditional Approach (Bad):**
|
|
652
|
+
```typescript
|
|
653
|
+
// Agent returns HTML string (security risk, no type safety)
|
|
654
|
+
return "<div class='chart'>...</div>";
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
**Generative UI Approach (Good):**
|
|
658
|
+
```typescript
|
|
659
|
+
// Agent returns structured component data
|
|
660
|
+
return {
|
|
661
|
+
component: 'chart',
|
|
662
|
+
data: {
|
|
663
|
+
chartType: 'line',
|
|
664
|
+
labels: ['Jan', 'Feb', 'Mar'],
|
|
665
|
+
datasets: [{ label: 'Revenue', data: [10, 20, 30] }],
|
|
666
|
+
},
|
|
667
|
+
};
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### GenerativeUIRenderer Component
|
|
671
|
+
|
|
672
|
+
**File:** `src/components/agent-ui/GenerativeUIRenderer.tsx`
|
|
673
|
+
|
|
674
|
+
```tsx
|
|
675
|
+
import React from 'react';
|
|
676
|
+
import type { UIPayload, ChartComponentData, TableComponentData, CardComponentData, FormComponentData } from '@/convex/protocols/agent-ui';
|
|
677
|
+
|
|
678
|
+
// PromptKit components
|
|
679
|
+
import { Message, MessageContent } from '@/components/ui/message';
|
|
680
|
+
|
|
681
|
+
// shadcn/ui components
|
|
682
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card';
|
|
683
|
+
import { Button } from '@/components/ui/button';
|
|
684
|
+
|
|
685
|
+
// Recharts for data visualization
|
|
686
|
+
import { LineChart, BarChart, PieChart, Line, Bar, Pie, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts';
|
|
687
|
+
|
|
688
|
+
// Data table
|
|
689
|
+
import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from '@/components/ui/table';
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* GenerativeUIRenderer
|
|
693
|
+
* Renders agent-generated UI components from AG-UI protocol messages
|
|
694
|
+
*/
|
|
695
|
+
export function GenerativeUIRenderer({ payload }: { payload: UIPayload }) {
|
|
696
|
+
const { component, data, layout } = payload;
|
|
697
|
+
|
|
698
|
+
switch (component) {
|
|
699
|
+
case 'chart':
|
|
700
|
+
return <DynamicChart data={data} layout={layout} />;
|
|
701
|
+
case 'table':
|
|
702
|
+
return <DynamicTable data={data} layout={layout} />;
|
|
703
|
+
case 'card':
|
|
704
|
+
return <DynamicCard data={data} layout={layout} />;
|
|
705
|
+
case 'form':
|
|
706
|
+
return <DynamicForm data={data} layout={layout} />;
|
|
707
|
+
case 'list':
|
|
708
|
+
return <DynamicList data={data} layout={layout} />;
|
|
709
|
+
case 'timeline':
|
|
710
|
+
return <DynamicTimeline data={data} layout={layout} />;
|
|
711
|
+
default:
|
|
712
|
+
return (
|
|
713
|
+
<div className="rounded-lg border border-destructive bg-destructive/10 p-4">
|
|
714
|
+
<p className="text-sm text-destructive">
|
|
715
|
+
Unknown component type: {component}
|
|
716
|
+
</p>
|
|
717
|
+
</div>
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* DynamicChart - Render agent-generated charts
|
|
724
|
+
*/
|
|
725
|
+
function DynamicChart({ data, layout }: { data: ChartComponentData['data']; layout?: any }) {
|
|
726
|
+
const chartData = data.labels.map((label, i) => ({
|
|
727
|
+
name: label,
|
|
728
|
+
...data.datasets.reduce((acc, dataset) => ({
|
|
729
|
+
...acc,
|
|
730
|
+
[dataset.label]: dataset.data[i],
|
|
731
|
+
}), {}),
|
|
732
|
+
}));
|
|
733
|
+
|
|
734
|
+
const renderChart = () => {
|
|
735
|
+
switch (data.chartType) {
|
|
736
|
+
case 'line':
|
|
737
|
+
return (
|
|
738
|
+
<LineChart data={chartData} width={600} height={300}>
|
|
739
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
740
|
+
<XAxis dataKey="name" />
|
|
741
|
+
<YAxis />
|
|
742
|
+
<Tooltip />
|
|
743
|
+
<Legend />
|
|
744
|
+
{data.datasets.map((dataset, i) => (
|
|
745
|
+
<Line
|
|
746
|
+
key={i}
|
|
747
|
+
type="monotone"
|
|
748
|
+
dataKey={dataset.label}
|
|
749
|
+
stroke={dataset.color || `hsl(var(--chart-${i + 1}))`}
|
|
750
|
+
fill={dataset.fill ? dataset.color : undefined}
|
|
751
|
+
/>
|
|
752
|
+
))}
|
|
753
|
+
</LineChart>
|
|
754
|
+
);
|
|
755
|
+
case 'bar':
|
|
756
|
+
return (
|
|
757
|
+
<BarChart data={chartData} width={600} height={300}>
|
|
758
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
759
|
+
<XAxis dataKey="name" />
|
|
760
|
+
<YAxis />
|
|
761
|
+
<Tooltip />
|
|
762
|
+
<Legend />
|
|
763
|
+
{data.datasets.map((dataset, i) => (
|
|
764
|
+
<Bar
|
|
765
|
+
key={i}
|
|
766
|
+
dataKey={dataset.label}
|
|
767
|
+
fill={dataset.color || `hsl(var(--chart-${i + 1}))`}
|
|
768
|
+
/>
|
|
769
|
+
))}
|
|
770
|
+
</BarChart>
|
|
771
|
+
);
|
|
772
|
+
default:
|
|
773
|
+
return <p>Unsupported chart type: {data.chartType}</p>;
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
return (
|
|
778
|
+
<Card className={layout?.width === 'full' ? 'w-full' : ''}>
|
|
779
|
+
<CardHeader>
|
|
780
|
+
<CardTitle>{data.title}</CardTitle>
|
|
781
|
+
{data.description && <CardDescription>{data.description}</CardDescription>}
|
|
782
|
+
</CardHeader>
|
|
783
|
+
<CardContent>
|
|
784
|
+
{renderChart()}
|
|
785
|
+
</CardContent>
|
|
786
|
+
</Card>
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* DynamicTable - Render agent-generated tables
|
|
792
|
+
*/
|
|
793
|
+
function DynamicTable({ data, layout }: { data: TableComponentData['data']; layout?: any }) {
|
|
794
|
+
return (
|
|
795
|
+
<Card className={layout?.width === 'full' ? 'w-full' : ''}>
|
|
796
|
+
<CardHeader>
|
|
797
|
+
<CardTitle>{data.title}</CardTitle>
|
|
798
|
+
{data.description && <CardDescription>{data.description}</CardDescription>}
|
|
799
|
+
</CardHeader>
|
|
800
|
+
<CardContent>
|
|
801
|
+
<Table>
|
|
802
|
+
<TableHeader>
|
|
803
|
+
<TableRow>
|
|
804
|
+
{data.headers.map((header, i) => (
|
|
805
|
+
<TableHead key={i}>{header}</TableHead>
|
|
806
|
+
))}
|
|
807
|
+
</TableRow>
|
|
808
|
+
</TableHeader>
|
|
809
|
+
<TableBody>
|
|
810
|
+
{data.rows.map((row, rowIndex) => (
|
|
811
|
+
<TableRow key={rowIndex}>
|
|
812
|
+
{row.map((cell, cellIndex) => (
|
|
813
|
+
<TableCell key={cellIndex}>{String(cell)}</TableCell>
|
|
814
|
+
))}
|
|
815
|
+
</TableRow>
|
|
816
|
+
))}
|
|
817
|
+
</TableBody>
|
|
818
|
+
</Table>
|
|
819
|
+
</CardContent>
|
|
820
|
+
</Card>
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* DynamicCard - Render agent-generated cards
|
|
826
|
+
*/
|
|
827
|
+
function DynamicCard({ data, layout }: { data: CardComponentData['data']; layout?: any }) {
|
|
828
|
+
return (
|
|
829
|
+
<Card className={layout?.width === 'full' ? 'w-full' : ''}>
|
|
830
|
+
<CardHeader>
|
|
831
|
+
<CardTitle>{data.title}</CardTitle>
|
|
832
|
+
{data.description && <CardDescription>{data.description}</CardDescription>}
|
|
833
|
+
</CardHeader>
|
|
834
|
+
<CardContent>
|
|
835
|
+
{typeof data.content === 'string' ? (
|
|
836
|
+
<p className="text-sm">{data.content}</p>
|
|
837
|
+
) : (
|
|
838
|
+
<pre className="text-xs">{JSON.stringify(data.content, null, 2)}</pre>
|
|
839
|
+
)}
|
|
840
|
+
</CardContent>
|
|
841
|
+
{(data.footer || data.actions) && (
|
|
842
|
+
<CardFooter className="flex justify-between">
|
|
843
|
+
{data.footer && <p className="text-sm text-muted-foreground">{data.footer}</p>}
|
|
844
|
+
{data.actions && (
|
|
845
|
+
<div className="flex gap-2">
|
|
846
|
+
{data.actions.map((action, i) => (
|
|
847
|
+
<Button key={i} variant={action.variant || 'default'} size="sm">
|
|
848
|
+
{action.label}
|
|
849
|
+
</Button>
|
|
850
|
+
))}
|
|
851
|
+
</div>
|
|
852
|
+
)}
|
|
853
|
+
</CardFooter>
|
|
854
|
+
)}
|
|
855
|
+
</Card>
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* DynamicForm - Render agent-generated forms
|
|
861
|
+
*/
|
|
862
|
+
function DynamicForm({ data, layout }: { data: FormComponentData['data']; layout?: any }) {
|
|
863
|
+
return (
|
|
864
|
+
<Card className={layout?.width === 'full' ? 'w-full' : ''}>
|
|
865
|
+
<CardHeader>
|
|
866
|
+
<CardTitle>{data.title}</CardTitle>
|
|
867
|
+
{data.description && <CardDescription>{data.description}</CardDescription>}
|
|
868
|
+
</CardHeader>
|
|
869
|
+
<CardContent>
|
|
870
|
+
<form className="space-y-4">
|
|
871
|
+
{data.fields.map((field, i) => (
|
|
872
|
+
<div key={i} className="space-y-2">
|
|
873
|
+
<label className="text-sm font-medium">
|
|
874
|
+
{field.label}
|
|
875
|
+
{field.required && <span className="text-destructive">*</span>}
|
|
876
|
+
</label>
|
|
877
|
+
{/* Render input based on field type */}
|
|
878
|
+
{field.type === 'text' && (
|
|
879
|
+
<input
|
|
880
|
+
type="text"
|
|
881
|
+
name={field.name}
|
|
882
|
+
defaultValue={field.defaultValue}
|
|
883
|
+
required={field.required}
|
|
884
|
+
className="w-full rounded-md border px-3 py-2"
|
|
885
|
+
/>
|
|
886
|
+
)}
|
|
887
|
+
{/* Add other field types... */}
|
|
888
|
+
</div>
|
|
889
|
+
))}
|
|
890
|
+
<Button type="submit">{data.submitLabel || 'Submit'}</Button>
|
|
891
|
+
</form>
|
|
892
|
+
</CardContent>
|
|
893
|
+
</Card>
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* DynamicList - Render agent-generated lists
|
|
899
|
+
*/
|
|
900
|
+
function DynamicList({ data, layout }: { data: any; layout?: any }) {
|
|
901
|
+
return (
|
|
902
|
+
<Card className={layout?.width === 'full' ? 'w-full' : ''}>
|
|
903
|
+
<CardHeader>
|
|
904
|
+
<CardTitle>{data.title}</CardTitle>
|
|
905
|
+
</CardHeader>
|
|
906
|
+
<CardContent>
|
|
907
|
+
<ul className="space-y-2">
|
|
908
|
+
{data.items.map((item: any, i: number) => (
|
|
909
|
+
<li key={i} className="flex items-center gap-2">
|
|
910
|
+
{item.icon && <span>{item.icon}</span>}
|
|
911
|
+
<span>{item.label}</span>
|
|
912
|
+
</li>
|
|
913
|
+
))}
|
|
914
|
+
</ul>
|
|
915
|
+
</CardContent>
|
|
916
|
+
</Card>
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* DynamicTimeline - Render agent-generated timelines
|
|
922
|
+
*/
|
|
923
|
+
function DynamicTimeline({ data, layout }: { data: any; layout?: any }) {
|
|
924
|
+
return (
|
|
925
|
+
<Card className={layout?.width === 'full' ? 'w-full' : ''}>
|
|
926
|
+
<CardHeader>
|
|
927
|
+
<CardTitle>{data.title}</CardTitle>
|
|
928
|
+
</CardHeader>
|
|
929
|
+
<CardContent>
|
|
930
|
+
<div className="space-y-4">
|
|
931
|
+
{data.events.map((event: any, i: number) => (
|
|
932
|
+
<div key={i} className="flex gap-4">
|
|
933
|
+
<div className="flex flex-col items-center">
|
|
934
|
+
<div className="h-3 w-3 rounded-full bg-primary" />
|
|
935
|
+
{i < data.events.length - 1 && <div className="h-full w-px bg-border" />}
|
|
936
|
+
</div>
|
|
937
|
+
<div className="flex-1 pb-4">
|
|
938
|
+
<p className="font-medium">{event.title}</p>
|
|
939
|
+
<p className="text-sm text-muted-foreground">{event.timestamp}</p>
|
|
940
|
+
{event.description && <p className="mt-1 text-sm">{event.description}</p>}
|
|
941
|
+
</div>
|
|
942
|
+
</div>
|
|
943
|
+
))}
|
|
944
|
+
</div>
|
|
945
|
+
</CardContent>
|
|
946
|
+
</Card>
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
### AgentMessage Component with AG-UI Support
|
|
952
|
+
|
|
953
|
+
**File:** `src/components/agent-ui/AgentMessage.tsx`
|
|
954
|
+
|
|
955
|
+
```tsx
|
|
956
|
+
import React from 'react';
|
|
957
|
+
import type { Id } from '@/convex/_generated/dataModel';
|
|
958
|
+
import type { AgentUIMessage } from '@/convex/protocols/agent-ui';
|
|
959
|
+
|
|
960
|
+
// PromptKit components
|
|
961
|
+
import {
|
|
962
|
+
Message,
|
|
963
|
+
MessageAvatar,
|
|
964
|
+
MessageContent,
|
|
965
|
+
MessageActions,
|
|
966
|
+
MessageAction,
|
|
967
|
+
} from '@/components/ui/message';
|
|
968
|
+
import { Reasoning } from '@/components/ui/reasoning';
|
|
969
|
+
import { Tool } from '@/components/ui/tool';
|
|
970
|
+
import { ResponseStream } from '@/components/ui/response-stream';
|
|
971
|
+
|
|
972
|
+
// Our generative UI renderer
|
|
973
|
+
import { GenerativeUIRenderer } from './GenerativeUIRenderer';
|
|
974
|
+
|
|
975
|
+
// shadcn/ui components
|
|
976
|
+
import { Button } from '@/components/ui/button';
|
|
977
|
+
import { AlertCircle, Copy, ThumbsUp, ThumbsDown } from 'lucide-react';
|
|
978
|
+
|
|
979
|
+
interface AgentMessageProps {
|
|
980
|
+
message: {
|
|
981
|
+
_id: Id<'entities'>;
|
|
982
|
+
properties: {
|
|
983
|
+
content: {
|
|
984
|
+
protocol: 'ag-ui';
|
|
985
|
+
version: string;
|
|
986
|
+
message: AgentUIMessage;
|
|
987
|
+
};
|
|
988
|
+
senderId: Id<'entities'>;
|
|
989
|
+
timestamp: number;
|
|
990
|
+
};
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* AgentMessage - Render AG-UI protocol messages with PromptKit components
|
|
996
|
+
*/
|
|
997
|
+
export function AgentMessage({ message }: AgentMessageProps) {
|
|
998
|
+
const agMessage = message.properties.content.message;
|
|
999
|
+
|
|
1000
|
+
const renderMessageContent = () => {
|
|
1001
|
+
switch (agMessage.type) {
|
|
1002
|
+
case 'text':
|
|
1003
|
+
return (
|
|
1004
|
+
<MessageContent markdown>
|
|
1005
|
+
{agMessage.payload.text}
|
|
1006
|
+
</MessageContent>
|
|
1007
|
+
);
|
|
1008
|
+
|
|
1009
|
+
case 'ui':
|
|
1010
|
+
return <GenerativeUIRenderer payload={agMessage.payload} />;
|
|
1011
|
+
|
|
1012
|
+
case 'action':
|
|
1013
|
+
return (
|
|
1014
|
+
<div className="space-y-2">
|
|
1015
|
+
<p className="text-sm font-medium">Suggested actions:</p>
|
|
1016
|
+
<div className="flex flex-wrap gap-2">
|
|
1017
|
+
{agMessage.payload.actions.map((action) => (
|
|
1018
|
+
<Button
|
|
1019
|
+
key={action.id}
|
|
1020
|
+
variant="outline"
|
|
1021
|
+
size="sm"
|
|
1022
|
+
onClick={() => handleActionClick(action.id, action.params)}
|
|
1023
|
+
>
|
|
1024
|
+
{action.label}
|
|
1025
|
+
</Button>
|
|
1026
|
+
))}
|
|
1027
|
+
</div>
|
|
1028
|
+
</div>
|
|
1029
|
+
);
|
|
1030
|
+
|
|
1031
|
+
case 'reasoning':
|
|
1032
|
+
return (
|
|
1033
|
+
<Reasoning>
|
|
1034
|
+
<div className="space-y-2">
|
|
1035
|
+
{agMessage.payload.steps.map((step) => (
|
|
1036
|
+
<div key={step.step} className="flex items-start gap-2">
|
|
1037
|
+
<div
|
|
1038
|
+
className={`mt-1 h-4 w-4 rounded-full ${
|
|
1039
|
+
step.completed ? 'bg-green-500' : 'bg-gray-300'
|
|
1040
|
+
}`}
|
|
1041
|
+
/>
|
|
1042
|
+
<div className="flex-1">
|
|
1043
|
+
<p className="font-medium">{step.title}</p>
|
|
1044
|
+
<p className="text-sm text-muted-foreground">{step.description}</p>
|
|
1045
|
+
</div>
|
|
1046
|
+
</div>
|
|
1047
|
+
))}
|
|
1048
|
+
</div>
|
|
1049
|
+
</Reasoning>
|
|
1050
|
+
);
|
|
1051
|
+
|
|
1052
|
+
case 'tool_call':
|
|
1053
|
+
return (
|
|
1054
|
+
<Tool
|
|
1055
|
+
name={agMessage.payload.toolName}
|
|
1056
|
+
arguments={agMessage.payload.arguments}
|
|
1057
|
+
result={agMessage.payload.result}
|
|
1058
|
+
/>
|
|
1059
|
+
);
|
|
1060
|
+
|
|
1061
|
+
case 'context_request':
|
|
1062
|
+
return (
|
|
1063
|
+
<div className="rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950">
|
|
1064
|
+
<p className="text-sm font-medium">Context request:</p>
|
|
1065
|
+
<p className="mt-1 text-sm text-muted-foreground">{agMessage.payload.reason}</p>
|
|
1066
|
+
<ul className="mt-2 list-inside list-disc text-sm">
|
|
1067
|
+
{agMessage.payload.fields.map((field, i) => (
|
|
1068
|
+
<li key={i}>{field}</li>
|
|
1069
|
+
))}
|
|
1070
|
+
</ul>
|
|
1071
|
+
</div>
|
|
1072
|
+
);
|
|
1073
|
+
|
|
1074
|
+
case 'error':
|
|
1075
|
+
return (
|
|
1076
|
+
<div className="flex items-start gap-2 rounded-lg border border-destructive bg-destructive/10 p-4">
|
|
1077
|
+
<AlertCircle className="mt-0.5 h-4 w-4 text-destructive" />
|
|
1078
|
+
<div className="flex-1">
|
|
1079
|
+
<p className="font-medium text-destructive">Error</p>
|
|
1080
|
+
<p className="mt-1 text-sm">{agMessage.payload.message}</p>
|
|
1081
|
+
{agMessage.payload.recoverable && (
|
|
1082
|
+
<Button variant="outline" size="sm" className="mt-2">
|
|
1083
|
+
Retry
|
|
1084
|
+
</Button>
|
|
1085
|
+
)}
|
|
1086
|
+
</div>
|
|
1087
|
+
</div>
|
|
1088
|
+
);
|
|
1089
|
+
|
|
1090
|
+
default:
|
|
1091
|
+
return <MessageContent>Unknown message type</MessageContent>;
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
return (
|
|
1096
|
+
<Message>
|
|
1097
|
+
<MessageAvatar
|
|
1098
|
+
src="/ai-avatar.png"
|
|
1099
|
+
alt="AI Agent"
|
|
1100
|
+
fallback="AI"
|
|
1101
|
+
/>
|
|
1102
|
+
{renderMessageContent()}
|
|
1103
|
+
<MessageActions>
|
|
1104
|
+
<MessageAction tooltip="Copy message">
|
|
1105
|
+
<Button variant="ghost" size="icon" onClick={() => handleCopy()}>
|
|
1106
|
+
<Copy className="h-4 w-4" />
|
|
1107
|
+
</Button>
|
|
1108
|
+
</MessageAction>
|
|
1109
|
+
<MessageAction tooltip="Good response">
|
|
1110
|
+
<Button variant="ghost" size="icon" onClick={() => handleFeedback('positive')}>
|
|
1111
|
+
<ThumbsUp className="h-4 w-4" />
|
|
1112
|
+
</Button>
|
|
1113
|
+
</MessageAction>
|
|
1114
|
+
<MessageAction tooltip="Bad response">
|
|
1115
|
+
<Button variant="ghost" size="icon" onClick={() => handleFeedback('negative')}>
|
|
1116
|
+
<ThumbsDown className="h-4 w-4" />
|
|
1117
|
+
</Button>
|
|
1118
|
+
</MessageAction>
|
|
1119
|
+
</MessageActions>
|
|
1120
|
+
</Message>
|
|
1121
|
+
);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
function handleActionClick(actionId: string, params?: any) {
|
|
1125
|
+
// Execute action via Convex mutation
|
|
1126
|
+
console.log('Execute action:', actionId, params);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
function handleCopy() {
|
|
1130
|
+
// Copy message content
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
function handleFeedback(sentiment: 'positive' | 'negative') {
|
|
1134
|
+
// Send feedback to agent
|
|
1135
|
+
}
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
---
|
|
1139
|
+
|
|
1140
|
+
## Part 3: Example Agent Using AG-UI
|
|
1141
|
+
|
|
1142
|
+
### IntelligenceAgent with Generative UI
|
|
1143
|
+
|
|
1144
|
+
**File:** `convex/services/intelligence-agent.ts`
|
|
1145
|
+
|
|
1146
|
+
```typescript
|
|
1147
|
+
import { Effect } from 'effect';
|
|
1148
|
+
import { ConvexDatabase } from './convex-database';
|
|
1149
|
+
import { AgentUIService } from './agent-ui';
|
|
1150
|
+
import type { Id } from '../_generated/dataModel';
|
|
1151
|
+
import type { ChartComponentData, TableComponentData } from '../protocols/agent-ui';
|
|
1152
|
+
|
|
1153
|
+
export class IntelligenceAgent extends Effect.Service<IntelligenceAgent>()(
|
|
1154
|
+
'IntelligenceAgent',
|
|
1155
|
+
{
|
|
1156
|
+
effect: Effect.gen(function* () {
|
|
1157
|
+
const db = yield* ConvexDatabase;
|
|
1158
|
+
const agentUI = yield* AgentUIService;
|
|
1159
|
+
|
|
1160
|
+
const AGENT_ID = 'agent-intelligence' as Id<'entities'>;
|
|
1161
|
+
|
|
1162
|
+
return {
|
|
1163
|
+
/**
|
|
1164
|
+
* Analyze user performance and send generative UI dashboard
|
|
1165
|
+
*/
|
|
1166
|
+
analyzePerformance: (args: {
|
|
1167
|
+
userId: Id<'entities'>;
|
|
1168
|
+
conversationId: Id<'entities'>;
|
|
1169
|
+
}) =>
|
|
1170
|
+
Effect.gen(function* () {
|
|
1171
|
+
// 1. Send reasoning steps
|
|
1172
|
+
yield* agentUI.sendReasoning({
|
|
1173
|
+
agentId: AGENT_ID,
|
|
1174
|
+
conversationId: args.conversationId,
|
|
1175
|
+
steps: [
|
|
1176
|
+
{
|
|
1177
|
+
step: 1,
|
|
1178
|
+
title: 'Fetching user metrics',
|
|
1179
|
+
description: 'Retrieving performance data from database',
|
|
1180
|
+
completed: true,
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
step: 2,
|
|
1184
|
+
title: 'Analyzing trends',
|
|
1185
|
+
description: 'Identifying patterns and insights',
|
|
1186
|
+
completed: true,
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
step: 3,
|
|
1190
|
+
title: 'Generating visualizations',
|
|
1191
|
+
description: 'Creating charts and tables',
|
|
1192
|
+
completed: false,
|
|
1193
|
+
},
|
|
1194
|
+
],
|
|
1195
|
+
});
|
|
1196
|
+
|
|
1197
|
+
// 2. Get metrics (simulated)
|
|
1198
|
+
const metrics = {
|
|
1199
|
+
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
|
|
1200
|
+
revenue: [10000, 12000, 15000, 13000, 18000, 20000],
|
|
1201
|
+
users: [100, 120, 150, 140, 180, 200],
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
// 3. Send text intro
|
|
1205
|
+
yield* agentUI.sendText({
|
|
1206
|
+
agentId: AGENT_ID,
|
|
1207
|
+
conversationId: args.conversationId,
|
|
1208
|
+
text: "I've analyzed your performance data. Here's what I found:",
|
|
1209
|
+
sentiment: 'positive',
|
|
1210
|
+
});
|
|
1211
|
+
|
|
1212
|
+
// 4. Send revenue chart
|
|
1213
|
+
const chartComponent: ChartComponentData = {
|
|
1214
|
+
component: 'chart',
|
|
1215
|
+
data: {
|
|
1216
|
+
title: 'Revenue Trend (Last 6 Months)',
|
|
1217
|
+
description: '20% growth month-over-month',
|
|
1218
|
+
chartType: 'line',
|
|
1219
|
+
labels: metrics.labels,
|
|
1220
|
+
datasets: [
|
|
1221
|
+
{
|
|
1222
|
+
label: 'Revenue ($)',
|
|
1223
|
+
data: metrics.revenue,
|
|
1224
|
+
color: 'hsl(var(--chart-1))',
|
|
1225
|
+
fill: true,
|
|
1226
|
+
},
|
|
1227
|
+
],
|
|
1228
|
+
},
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
yield* agentUI.sendUI({
|
|
1232
|
+
agentId: AGENT_ID,
|
|
1233
|
+
conversationId: args.conversationId,
|
|
1234
|
+
component: chartComponent,
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// 5. Send metrics table
|
|
1238
|
+
const tableComponent: TableComponentData = {
|
|
1239
|
+
component: 'table',
|
|
1240
|
+
data: {
|
|
1241
|
+
title: 'Monthly Performance Summary',
|
|
1242
|
+
headers: ['Month', 'Revenue', 'Users', 'Revenue/User'],
|
|
1243
|
+
rows: metrics.labels.map((label, i) => [
|
|
1244
|
+
label,
|
|
1245
|
+
`$${metrics.revenue[i].toLocaleString()}`,
|
|
1246
|
+
metrics.users[i],
|
|
1247
|
+
`$${(metrics.revenue[i] / metrics.users[i]).toFixed(2)}`,
|
|
1248
|
+
]),
|
|
1249
|
+
sortable: true,
|
|
1250
|
+
filterable: true,
|
|
1251
|
+
},
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
yield* agentUI.sendUI({
|
|
1255
|
+
agentId: AGENT_ID,
|
|
1256
|
+
conversationId: args.conversationId,
|
|
1257
|
+
component: tableComponent,
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
// 6. Send action suggestions
|
|
1261
|
+
yield* agentUI.sendActions({
|
|
1262
|
+
agentId: AGENT_ID,
|
|
1263
|
+
conversationId: args.conversationId,
|
|
1264
|
+
actions: [
|
|
1265
|
+
{
|
|
1266
|
+
id: 'export_report',
|
|
1267
|
+
label: 'Export Full Report',
|
|
1268
|
+
description: 'Download PDF with detailed analysis',
|
|
1269
|
+
params: { format: 'pdf' },
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
id: 'schedule_review',
|
|
1273
|
+
label: 'Schedule Review',
|
|
1274
|
+
description: 'Set up monthly performance review',
|
|
1275
|
+
params: { frequency: 'monthly' },
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
id: 'deep_dive',
|
|
1279
|
+
label: 'Deep Dive Analysis',
|
|
1280
|
+
description: 'Get detailed insights on specific metrics',
|
|
1281
|
+
params: { metric: 'revenue' },
|
|
1282
|
+
},
|
|
1283
|
+
],
|
|
1284
|
+
});
|
|
1285
|
+
|
|
1286
|
+
return { success: true };
|
|
1287
|
+
}),
|
|
1288
|
+
};
|
|
1289
|
+
}),
|
|
1290
|
+
dependencies: [ConvexDatabase.Default, AgentUIService.Default],
|
|
1291
|
+
}
|
|
1292
|
+
) {}
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
---
|
|
1296
|
+
|
|
1297
|
+
## Part 4: Context Sharing Pattern
|
|
1298
|
+
|
|
1299
|
+
### useAgentContext Hook
|
|
1300
|
+
|
|
1301
|
+
**File:** `src/hooks/useAgentContext.ts`
|
|
1302
|
+
|
|
1303
|
+
```tsx
|
|
1304
|
+
import { useQuery, useMutation } from 'convex/react';
|
|
1305
|
+
import { api } from '@/convex/_generated/api';
|
|
1306
|
+
import type { Id } from '@/convex/_generated/dataModel';
|
|
1307
|
+
import { useState, useEffect } from 'react';
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Context sharing hook (inspired by CopilotKit's useCopilotReadable)
|
|
1311
|
+
* Allows agents to access application context
|
|
1312
|
+
*/
|
|
1313
|
+
export function useAgentContext(conversationId: Id<'entities'>) {
|
|
1314
|
+
const [context, setContext] = useState<Record<string, any>>({});
|
|
1315
|
+
const updateContext = useMutation(api.conversations.updateContext);
|
|
1316
|
+
|
|
1317
|
+
// Automatically share context with agent
|
|
1318
|
+
useEffect(() => {
|
|
1319
|
+
updateContext({
|
|
1320
|
+
conversationId,
|
|
1321
|
+
context,
|
|
1322
|
+
});
|
|
1323
|
+
}, [context, conversationId]);
|
|
1324
|
+
|
|
1325
|
+
return {
|
|
1326
|
+
// Share context with agent
|
|
1327
|
+
shareContext: (key: string, value: any) => {
|
|
1328
|
+
setContext((prev) => ({ ...prev, [key]: value }));
|
|
1329
|
+
},
|
|
1330
|
+
|
|
1331
|
+
// Remove context
|
|
1332
|
+
removeContext: (key: string) => {
|
|
1333
|
+
setContext((prev) => {
|
|
1334
|
+
const { [key]: _, ...rest } = prev;
|
|
1335
|
+
return rest;
|
|
1336
|
+
});
|
|
1337
|
+
},
|
|
1338
|
+
|
|
1339
|
+
// Get current context
|
|
1340
|
+
getContext: () => context,
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Usage example:
|
|
1346
|
+
*
|
|
1347
|
+
* function MyComponent() {
|
|
1348
|
+
* const { shareContext } = useAgentContext(conversationId);
|
|
1349
|
+
*
|
|
1350
|
+
* // Share shopping cart with agent
|
|
1351
|
+
* shareContext('cart', cart);
|
|
1352
|
+
*
|
|
1353
|
+
* // Share current page
|
|
1354
|
+
* shareContext('currentPage', location.pathname);
|
|
1355
|
+
*
|
|
1356
|
+
* // Share user preferences
|
|
1357
|
+
* shareContext('userPreferences', preferences);
|
|
1358
|
+
* }
|
|
1359
|
+
*/
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
---
|
|
1363
|
+
|
|
1364
|
+
## Part 5: Multi-Agent Orchestration
|
|
1365
|
+
|
|
1366
|
+
### AgentOrchestrator Service
|
|
1367
|
+
|
|
1368
|
+
**File:** `convex/services/agent-orchestrator.ts`
|
|
1369
|
+
|
|
1370
|
+
```typescript
|
|
1371
|
+
import { Effect } from 'effect';
|
|
1372
|
+
import { IntelligenceAgent } from './intelligence-agent';
|
|
1373
|
+
import { StrategyAgent } from './strategy-agent';
|
|
1374
|
+
import { MarketingAgent } from './marketing-agent';
|
|
1375
|
+
import { SalesAgent } from './sales-agent';
|
|
1376
|
+
import { AgentUIService } from './agent-ui';
|
|
1377
|
+
import type { Id } from '../_generated/dataModel';
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* AgentOrchestrator - Coordinate multiple agents
|
|
1381
|
+
* Inspired by CopilotKit's multi-agent patterns
|
|
1382
|
+
*/
|
|
1383
|
+
export class AgentOrchestrator extends Effect.Service<AgentOrchestrator>()(
|
|
1384
|
+
'AgentOrchestrator',
|
|
1385
|
+
{
|
|
1386
|
+
effect: Effect.gen(function* () {
|
|
1387
|
+
const intelligence = yield* IntelligenceAgent;
|
|
1388
|
+
const strategy = yield* StrategyAgent;
|
|
1389
|
+
const marketing = yield* MarketingAgent;
|
|
1390
|
+
const sales = yield* SalesAgent;
|
|
1391
|
+
const agentUI = yield* AgentUIService;
|
|
1392
|
+
|
|
1393
|
+
return {
|
|
1394
|
+
/**
|
|
1395
|
+
* Coordinate campaign creation across multiple agents
|
|
1396
|
+
*/
|
|
1397
|
+
coordinateCampaign: (args: {
|
|
1398
|
+
userId: Id<'entities'>;
|
|
1399
|
+
conversationId: Id<'entities'>;
|
|
1400
|
+
campaignGoal: string;
|
|
1401
|
+
}) =>
|
|
1402
|
+
Effect.gen(function* () {
|
|
1403
|
+
const orchestratorId = 'agent-orchestrator' as Id<'entities'>;
|
|
1404
|
+
|
|
1405
|
+
// Step 1: Intelligence agent analyzes current performance
|
|
1406
|
+
yield* agentUI.sendText({
|
|
1407
|
+
agentId: orchestratorId,
|
|
1408
|
+
conversationId: args.conversationId,
|
|
1409
|
+
text: '🎯 Step 1: Analyzing current performance...',
|
|
1410
|
+
});
|
|
1411
|
+
|
|
1412
|
+
const analysis = yield* intelligence.analyzePerformance({
|
|
1413
|
+
userId: args.userId,
|
|
1414
|
+
conversationId: args.conversationId,
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1417
|
+
// Step 2: Strategy agent creates plan
|
|
1418
|
+
yield* agentUI.sendText({
|
|
1419
|
+
agentId: orchestratorId,
|
|
1420
|
+
conversationId: args.conversationId,
|
|
1421
|
+
text: '📋 Step 2: Creating campaign strategy...',
|
|
1422
|
+
});
|
|
1423
|
+
|
|
1424
|
+
const plan = yield* strategy.createCampaignPlan({
|
|
1425
|
+
userId: args.userId,
|
|
1426
|
+
conversationId: args.conversationId,
|
|
1427
|
+
goal: args.campaignGoal,
|
|
1428
|
+
insights: analysis,
|
|
1429
|
+
});
|
|
1430
|
+
|
|
1431
|
+
// Step 3: Marketing agent creates content
|
|
1432
|
+
yield* agentUI.sendText({
|
|
1433
|
+
agentId: orchestratorId,
|
|
1434
|
+
conversationId: args.conversationId,
|
|
1435
|
+
text: '✍️ Step 3: Generating marketing content...',
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
const content = yield* marketing.createContent({
|
|
1439
|
+
userId: args.userId,
|
|
1440
|
+
conversationId: args.conversationId,
|
|
1441
|
+
plan: plan,
|
|
1442
|
+
});
|
|
1443
|
+
|
|
1444
|
+
// Step 4: Sales agent prepares follow-up
|
|
1445
|
+
yield* agentUI.sendText({
|
|
1446
|
+
agentId: orchestratorId,
|
|
1447
|
+
conversationId: args.conversationId,
|
|
1448
|
+
text: '📞 Step 4: Setting up sales follow-up...',
|
|
1449
|
+
});
|
|
1450
|
+
|
|
1451
|
+
const followUp = yield* sales.preparefollowUp({
|
|
1452
|
+
userId: args.userId,
|
|
1453
|
+
conversationId: args.conversationId,
|
|
1454
|
+
campaign: content,
|
|
1455
|
+
});
|
|
1456
|
+
|
|
1457
|
+
// Final summary
|
|
1458
|
+
yield* agentUI.sendText({
|
|
1459
|
+
agentId: orchestratorId,
|
|
1460
|
+
conversationId: args.conversationId,
|
|
1461
|
+
text: '✅ Campaign ready! All agents have contributed.',
|
|
1462
|
+
sentiment: 'positive',
|
|
1463
|
+
});
|
|
1464
|
+
|
|
1465
|
+
// Send action to approve and launch
|
|
1466
|
+
yield* agentUI.sendActions({
|
|
1467
|
+
agentId: orchestratorId,
|
|
1468
|
+
conversationId: args.conversationId,
|
|
1469
|
+
actions: [
|
|
1470
|
+
{
|
|
1471
|
+
id: 'approve_campaign',
|
|
1472
|
+
label: 'Approve & Launch Campaign',
|
|
1473
|
+
description: 'Review and launch the complete campaign',
|
|
1474
|
+
params: { planId: plan.id, contentId: content.id },
|
|
1475
|
+
confirmationRequired: true,
|
|
1476
|
+
},
|
|
1477
|
+
],
|
|
1478
|
+
});
|
|
1479
|
+
|
|
1480
|
+
return { plan, content, followUp };
|
|
1481
|
+
}),
|
|
1482
|
+
};
|
|
1483
|
+
}),
|
|
1484
|
+
dependencies: [
|
|
1485
|
+
IntelligenceAgent.Default,
|
|
1486
|
+
StrategyAgent.Default,
|
|
1487
|
+
MarketingAgent.Default,
|
|
1488
|
+
SalesAgent.Default,
|
|
1489
|
+
AgentUIService.Default,
|
|
1490
|
+
],
|
|
1491
|
+
}
|
|
1492
|
+
) {}
|
|
1493
|
+
```
|
|
1494
|
+
|
|
1495
|
+
---
|
|
1496
|
+
|
|
1497
|
+
## Summary
|
|
1498
|
+
|
|
1499
|
+
### What We Built (PromptKit + AG-UI)
|
|
1500
|
+
|
|
1501
|
+
**UI Layer (PromptKit):**
|
|
1502
|
+
- ✅ `<Message>` - Chat messages
|
|
1503
|
+
- ✅ `<PromptInput>` - User input
|
|
1504
|
+
- ✅ `<ChatContainer>` - Auto-scroll
|
|
1505
|
+
- ✅ `<Reasoning>` - Agent thinking
|
|
1506
|
+
- ✅ `<Tool>` - Function calls
|
|
1507
|
+
- ✅ All shadcn/ui based
|
|
1508
|
+
|
|
1509
|
+
**Protocol Layer (Our AG-UI Implementation):**
|
|
1510
|
+
- ✅ AgentUIMessage types (text, ui, action, context_request, reasoning, tool_call, error)
|
|
1511
|
+
- ✅ AgentUIService (Effect.ts service)
|
|
1512
|
+
- ✅ Structured component data (ChartComponentData, TableComponentData, etc.)
|
|
1513
|
+
- ✅ Type-safe protocol with Convex validators
|
|
1514
|
+
|
|
1515
|
+
**Generative UI Layer (Our Renderer):**
|
|
1516
|
+
- ✅ GenerativeUIRenderer component
|
|
1517
|
+
- ✅ DynamicChart (Recharts integration)
|
|
1518
|
+
- ✅ DynamicTable (shadcn table)
|
|
1519
|
+
- ✅ DynamicCard, DynamicForm, DynamicList, DynamicTimeline
|
|
1520
|
+
- ✅ AgentMessage component with AG-UI support
|
|
1521
|
+
|
|
1522
|
+
**Context & Orchestration:**
|
|
1523
|
+
- ✅ useAgentContext hook (bidirectional state sharing)
|
|
1524
|
+
- ✅ AgentOrchestrator service (multi-agent coordination)
|
|
1525
|
+
- ✅ Action system (human-in-the-loop approvals)
|
|
1526
|
+
|
|
1527
|
+
### Final Stack
|
|
1528
|
+
|
|
1529
|
+
| Layer | Technology | Purpose |
|
|
1530
|
+
|-------|------------|---------|
|
|
1531
|
+
| **UI Components** | PromptKit (shadcn/ui) | Chat interface, message display |
|
|
1532
|
+
| **Generative UI** | Our Renderer + Recharts | Dynamic component rendering |
|
|
1533
|
+
| **Protocol** | AG-UI (our implementation) | Agent-to-frontend communication |
|
|
1534
|
+
| **AI SDK** | Vercel AI SDK 5 | Streaming, tool calling |
|
|
1535
|
+
| **Backend** | Convex + Effect.ts | Real-time DB, agent services |
|
|
1536
|
+
| **State** | Convex reactive queries | Context sharing |
|
|
1537
|
+
|
|
1538
|
+
### Benefits
|
|
1539
|
+
|
|
1540
|
+
**No Vendor Lock-in:**
|
|
1541
|
+
- PromptKit: MIT licensed, shadcn-based (can fork/modify)
|
|
1542
|
+
- AG-UI Protocol: 100% our implementation
|
|
1543
|
+
- Effect.ts agents: Fully independent
|
|
1544
|
+
- Convex backend: No CopilotKit dependencies
|
|
1545
|
+
|
|
1546
|
+
**CopilotKit Patterns We Implemented:**
|
|
1547
|
+
- ✅ AG-UI protocol for structured UI messages
|
|
1548
|
+
- ✅ Generative UI for dynamic component rendering
|
|
1549
|
+
- ✅ Context sharing (useAgentContext hook)
|
|
1550
|
+
- ✅ Action suggestions (human-in-the-loop)
|
|
1551
|
+
- ✅ Multi-agent orchestration (AgentOrchestrator)
|
|
1552
|
+
|
|
1553
|
+
**Complete Open Source Freedom:**
|
|
1554
|
+
- Can replace any component
|
|
1555
|
+
- Can modify any pattern
|
|
1556
|
+
- Can extend infinitely
|
|
1557
|
+
- Zero external runtime dependencies
|
|
1558
|
+
|
|
1559
|
+
🎉 **Result:** Professional AI agent interfaces with generative UI, built entirely on open-source stack with PromptKit + Effect.ts + Convex.
|